OmniSciDB  c07336695a
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 1389 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 1391 of file ParserNode.h.

References Parser::parser_slistval_to_vector().

1395  : object_type(t), object(o) {
1398  }
T g(const TargetValue &r)
Definition: TestHelpers.h:118
std::vector< std::string > grantees
Definition: ParserNode.h:1410
std::unique_ptr< std::string > object_type
Definition: ParserNode.h:1408
void parser_slistval_to_vector(std::list< std::string *> *l, std::vector< std::string > &v)
Definition: ParserNode.h:1347
std::vector< std::string > privs
Definition: ParserNode.h:1407
std::unique_ptr< std::string > object
Definition: ParserNode.h:1409
+ 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 3905 of file ParserNode.cpp.

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

3905  {
3906  auto& catalog = session.getCatalog();
3907  const auto& currentUser = session.get_currentUser();
3908  const auto parserObjectType = boost::to_upper_copy<std::string>(get_object_type());
3909  const auto objectName =
3910  extractObjectNameFromHierName(get_object(), parserObjectType, catalog);
3911  auto objectType = DBObjectTypeFromString(parserObjectType);
3912  DBObject dbObject = createObject(objectName, objectType);
3913  /* verify object ownership if not suser */
3914  if (!currentUser.isSuper) {
3915  if (!SysCatalog::instance().verifyDBObjectOwnership(currentUser, dbObject, catalog)) {
3916  throw std::runtime_error(
3917  "REVOKE failed. It can only be executed by super user or owner of the object.");
3918  }
3919  }
3920  /* set proper values of privileges & grant them to the object */
3921  std::vector<DBObject> objects(get_privs().size(), dbObject);
3922  for (size_t i = 0; i < get_privs().size(); ++i) {
3923  std::pair<AccessPrivileges, DBObjectType> priv = parseStringPrivs(
3924  boost::to_upper_copy<std::string>(get_privs()[i]), objectType, get_object());
3925  objects[i].setPrivileges(priv.first);
3926  objects[i].setPermissionType(priv.second);
3927  }
3928  SysCatalog::instance().revokeDBObjectPrivilegesBatch(grantees, objects, catalog);
3929 }
std::vector< std::string > grantees
Definition: ParserNode.h:1410
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:93
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:1402
const std::string & get_object_type() const
Definition: ParserNode.h:1401
DBObjectType DBObjectTypeFromString(const std::string &type)
Definition: DBObject.cpp:88
const std::vector< std::string > & get_privs() const
Definition: ParserNode.h:1400
Catalog & getCatalog() const
Definition: SessionInfo.h:90
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 1403 of file ParserNode.h.

References session.

1403 { return grantees; }
std::vector< std::string > grantees
Definition: ParserNode.h:1410

◆ get_object()

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

Definition at line 1402 of file ParserNode.h.

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

◆ get_object_type()

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

Definition at line 1401 of file ParserNode.h.

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

◆ get_privs()

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

Definition at line 1400 of file ParserNode.h.

1400 { return privs; }
std::vector< std::string > privs
Definition: ParserNode.h:1407

Member Data Documentation

◆ grantees

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

Definition at line 1410 of file ParserNode.h.

◆ object

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

Definition at line 1409 of file ParserNode.h.

◆ object_type

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

Definition at line 1408 of file ParserNode.h.

◆ privs

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

Definition at line 1407 of file ParserNode.h.


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