OmniSciDB  06b3bd477c
 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 1550 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 1552 of file ParserNode.h.

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

1556  : object_type(t), object(o) {
1559  }
std::vector< std::string > grantees
Definition: ParserNode.h:1571
void parser_slistval_to_vector(std::list< std::string * > *l, std::vector< std::string > &v)
Definition: ParserNode.h:1508
std::unique_ptr< std::string > object_type
Definition: ParserNode.h:1569
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

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

Implements Parser::DDLStmt.

Definition at line 4162 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.

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

+ Here is the call graph for this function:

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

Definition at line 1564 of file ParserNode.h.

References grantees.

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

Definition at line 1563 of file ParserNode.h.

References object.

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

Definition at line 1562 of file ParserNode.h.

References object_type.

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

Definition at line 1561 of file ParserNode.h.

References privs.

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

Member Data Documentation

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

Definition at line 1571 of file ParserNode.h.

Referenced by get_grantees(), and RevokePrivilegesStmt().

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

Definition at line 1570 of file ParserNode.h.

Referenced by get_object().

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

Definition at line 1569 of file ParserNode.h.

Referenced by get_object_type().

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

Definition at line 1568 of file ParserNode.h.

Referenced by get_privs(), and RevokePrivilegesStmt().


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