OmniSciDB  1dac507f6e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 1490 of file ParserNode.h.

Constructor & Destructor Documentation

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

Definition at line 1492 of file ParserNode.h.

References grantees, Parser::parser_slistval_to_vector(), and privs.

1496  : object_type(t), object(o) {
1499  }
std::vector< std::string > grantees
Definition: ParserNode.h:1511
void parser_slistval_to_vector(std::list< std::string * > *l, std::vector< std::string > &v)
Definition: ParserNode.h:1448
std::unique_ptr< std::string > object_type
Definition: ParserNode.h:1509
std::vector< std::string > privs
Definition: ParserNode.h:1508
std::unique_ptr< std::string > object
Definition: ParserNode.h:1510

+ Here is the call graph for this function:

Member Function Documentation

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

Implements Parser::DDLStmt.

Definition at line 3987 of file ParserNode.cpp.

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

3987  {
3988  auto& catalog = session.getCatalog();
3989  const auto& currentUser = session.get_currentUser();
3990  const auto parserObjectType = boost::to_upper_copy<std::string>(get_object_type());
3991  const auto objectName =
3992  extractObjectNameFromHierName(get_object(), parserObjectType, catalog);
3993  auto objectType = DBObjectTypeFromString(parserObjectType);
3994  DBObject dbObject = createObject(objectName, objectType);
3995  /* verify object ownership if not suser */
3996  if (!currentUser.isSuper) {
3997  if (!SysCatalog::instance().verifyDBObjectOwnership(currentUser, dbObject, catalog)) {
3998  throw std::runtime_error(
3999  "REVOKE failed. It can only be executed by super user or owner of the object.");
4000  }
4001  }
4002  /* set proper values of privileges & grant them to the object */
4003  std::vector<DBObject> objects(get_privs().size(), dbObject);
4004  for (size_t i = 0; i < get_privs().size(); ++i) {
4005  std::pair<AccessPrivileges, DBObjectType> priv = parseStringPrivs(
4006  boost::to_upper_copy<std::string>(get_privs()[i]), objectType, get_object());
4007  objects[i].setPrivileges(priv.first);
4008  objects[i].setPermissionType(priv.second);
4009  }
4010  SysCatalog::instance().revokeDBObjectPrivilegesBatch(grantees, objects, catalog);
4011 }
std::vector< std::string > grantees
Definition: ParserNode.h:1511
std::string extractObjectNameFromHierName(const std::string &objectHierName, const std::string &objectType, const Catalog_Namespace::Catalog &cat)
DBObjectType DBObjectTypeFromString(const std::string &type)
Definition: DBObject.cpp:88
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)
const std::vector< std::string > & get_privs() const
Definition: ParserNode.h:1501
static DBObject createObject(const std::string &objectName, DBObjectType objectType)
const std::string & get_object() const
Definition: ParserNode.h:1503
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:93
const std::string & get_object_type() const
Definition: ParserNode.h:1502

+ Here is the call graph for this function:

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

Definition at line 1504 of file ParserNode.h.

References grantees.

1504 { return grantees; }
std::vector< std::string > grantees
Definition: ParserNode.h:1511
const std::string& Parser::RevokePrivilegesStmt::get_object ( ) const
inline

Definition at line 1503 of file ParserNode.h.

References object.

1503 { return *object; }
std::unique_ptr< std::string > object
Definition: ParserNode.h:1510
const std::string& Parser::RevokePrivilegesStmt::get_object_type ( ) const
inline

Definition at line 1502 of file ParserNode.h.

References object_type.

1502 { return *object_type; }
std::unique_ptr< std::string > object_type
Definition: ParserNode.h:1509
const std::vector<std::string>& Parser::RevokePrivilegesStmt::get_privs ( ) const
inline

Definition at line 1501 of file ParserNode.h.

References privs.

1501 { return privs; }
std::vector< std::string > privs
Definition: ParserNode.h:1508

Member Data Documentation

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

Definition at line 1511 of file ParserNode.h.

Referenced by get_grantees(), and RevokePrivilegesStmt().

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

Definition at line 1510 of file ParserNode.h.

Referenced by get_object().

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

Definition at line 1509 of file ParserNode.h.

Referenced by get_object_type().

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

Definition at line 1508 of file ParserNode.h.

Referenced by get_privs(), and RevokePrivilegesStmt().


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