OmniSciDB  f632821e96
Parser::RevokePrivilegesStmt Class Reference

#include <ParserNode.h>

+ Inheritance diagram for Parser::RevokePrivilegesStmt:
+ Collaboration diagram for Parser::RevokePrivilegesStmt:

Public Member Functions

 RevokePrivilegesStmt (std::list< std::string *> *p, std::string *t, std::string *o, std::list< std::string *> *g)
 
const std::vector< std::string > & get_privs () const
 
const std::string & get_object_type () const
 
const std::string & get_object () const
 
const std::vector< std::string > & get_grantees () const
 
void execute (const Catalog_Namespace::SessionInfo &session) override
 
- Public Member Functions inherited from Parser::DDLStmt
void setColumnDescriptor (ColumnDescriptor &cd, const ColumnDef *coldef)
 
- Public Member Functions inherited from Parser::Node
virtual ~Node ()
 

Private Attributes

std::vector< std::string > privs
 
std::unique_ptr< std::string > object_type
 
std::unique_ptr< std::string > object
 
std::vector< std::string > grantees
 

Detailed Description

Definition at line 1550 of file ParserNode.h.

Constructor & Destructor Documentation

◆ RevokePrivilegesStmt()

Parser::RevokePrivilegesStmt::RevokePrivilegesStmt ( std::list< std::string *> *  p,
std::string *  t,
std::string *  o,
std::list< std::string *> *  g 
)
inline

Definition at line 1552 of file ParserNode.h.

References Parser::parser_slistval_to_vector().

1556  : object_type(t), object(o) {
1559  }
std::vector< std::string > grantees
Definition: ParserNode.h:1571
std::unique_ptr< std::string > object_type
Definition: ParserNode.h:1569
void parser_slistval_to_vector(std::list< std::string *> *l, std::vector< std::string > &v)
Definition: ParserNode.h:1508
std::vector< std::string > privs
Definition: ParserNode.h:1568
std::unique_ptr< std::string > object
Definition: ParserNode.h:1570
+ Here is the call graph for this function:

Member Function Documentation

◆ execute()

void Parser::RevokePrivilegesStmt::execute ( const Catalog_Namespace::SessionInfo session)
overridevirtual

Implements Parser::DDLStmt.

Definition at line 4165 of file ParserNode.cpp.

References Parser::createObject(), DBObjectTypeFromString(), Parser::extractObjectNameFromHierName(), g_enable_fsi, Catalog_Namespace::SessionInfo::get_currentUser(), Catalog_Namespace::SessionInfo::getCatalog(), Parser::parseStringPrivs(), and ServerDBObjectType.

4165  {
4166  auto& catalog = session.getCatalog();
4167  const auto& currentUser = session.get_currentUser();
4168  const auto parserObjectType = boost::to_upper_copy<std::string>(get_object_type());
4169  const auto objectName =
4170  extractObjectNameFromHierName(get_object(), parserObjectType, catalog);
4171  auto objectType = DBObjectTypeFromString(parserObjectType);
4172  if (objectType == ServerDBObjectType && !g_enable_fsi) {
4173  throw std::runtime_error("REVOKE failed. SERVER object unrecognized.");
4174  }
4175  DBObject dbObject = createObject(objectName, objectType);
4176  /* verify object ownership if not suser */
4177  if (!currentUser.isSuper) {
4178  if (!SysCatalog::instance().verifyDBObjectOwnership(currentUser, dbObject, catalog)) {
4179  throw std::runtime_error(
4180  "REVOKE failed. It can only be executed by super user or owner of the "
4181  "object.");
4182  }
4183  }
4184  /* set proper values of privileges & grant them to the object */
4185  std::vector<DBObject> objects(get_privs().size(), dbObject);
4186  for (size_t i = 0; i < get_privs().size(); ++i) {
4187  std::pair<AccessPrivileges, DBObjectType> priv = parseStringPrivs(
4188  boost::to_upper_copy<std::string>(get_privs()[i]), objectType, get_object());
4189  objects[i].setPrivileges(priv.first);
4190  objects[i].setPermissionType(priv.second);
4191  if (priv.second == ServerDBObjectType && !g_enable_fsi) {
4192  throw std::runtime_error("REVOKE failed. SERVER object unrecognized.");
4193  }
4194  }
4195  SysCatalog::instance().revokeDBObjectPrivilegesBatch(grantees, objects, catalog);
4196 }
std::vector< std::string > grantees
Definition: ParserNode.h:1571
bool g_enable_fsi
Definition: Catalog.cpp:91
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:68
std::string extractObjectNameFromHierName(const std::string &objectHierName, const std::string &objectType, const Catalog_Namespace::Catalog &cat)
const std::string & get_object() const
Definition: ParserNode.h:1563
const std::string & get_object_type() const
Definition: ParserNode.h:1562
DBObjectType DBObjectTypeFromString(const std::string &type)
Definition: DBObject.cpp:99
const std::vector< std::string > & get_privs() const
Definition: ParserNode.h:1561
Catalog & getCatalog() const
Definition: SessionInfo.h:65
static std::pair< AccessPrivileges, DBObjectType > parseStringPrivs(const std::string &privs, const DBObjectType &objectType, const std::string &object_name)
static DBObject createObject(const std::string &objectName, DBObjectType objectType)
+ Here is the call graph for this function:

◆ get_grantees()

const std::vector<std::string>& Parser::RevokePrivilegesStmt::get_grantees ( ) const
inline

Definition at line 1564 of file ParserNode.h.

1564 { return grantees; }
std::vector< std::string > grantees
Definition: ParserNode.h:1571

◆ get_object()

const std::string& Parser::RevokePrivilegesStmt::get_object ( ) const
inline

Definition at line 1563 of file ParserNode.h.

1563 { return *object; }
std::unique_ptr< std::string > object
Definition: ParserNode.h:1570

◆ get_object_type()

const std::string& Parser::RevokePrivilegesStmt::get_object_type ( ) const
inline

Definition at line 1562 of file ParserNode.h.

1562 { return *object_type; }
std::unique_ptr< std::string > object_type
Definition: ParserNode.h:1569

◆ get_privs()

const std::vector<std::string>& Parser::RevokePrivilegesStmt::get_privs ( ) const
inline

Definition at line 1561 of file ParserNode.h.

1561 { return privs; }
std::vector< std::string > privs
Definition: ParserNode.h:1568

Member Data Documentation

◆ grantees

std::vector<std::string> Parser::RevokePrivilegesStmt::grantees
private

Definition at line 1571 of file ParserNode.h.

◆ object

std::unique_ptr<std::string> Parser::RevokePrivilegesStmt::object
private

Definition at line 1570 of file ParserNode.h.

◆ object_type

std::unique_ptr<std::string> Parser::RevokePrivilegesStmt::object_type
private

Definition at line 1569 of file ParserNode.h.

◆ privs

std::vector<std::string> Parser::RevokePrivilegesStmt::privs
private

Definition at line 1568 of file ParserNode.h.


The documentation for this class was generated from the following files: