OmniSciDB  04ee39c94c
Parser::GrantPrivilegesStmt Class Reference

#include <ParserNode.h>

+ Inheritance diagram for Parser::GrantPrivilegesStmt:
+ Collaboration diagram for Parser::GrantPrivilegesStmt:

Public Member Functions

 GrantPrivilegesStmt (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 1361 of file ParserNode.h.

Constructor & Destructor Documentation

◆ GrantPrivilegesStmt()

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

Definition at line 1363 of file ParserNode.h.

References Parser::parser_slistval_to_vector().

1367  : object_type(t), object(o) {
1370  }
T g(const TargetValue &r)
Definition: TestHelpers.h:118
std::unique_ptr< std::string > object
Definition: ParserNode.h:1381
void parser_slistval_to_vector(std::list< std::string *> *l, std::vector< std::string > &v)
Definition: ParserNode.h:1347
std::vector< std::string > grantees
Definition: ParserNode.h:1382
std::vector< std::string > privs
Definition: ParserNode.h:1379
std::unique_ptr< std::string > object_type
Definition: ParserNode.h:1380
+ Here is the call graph for this function:

Member Function Documentation

◆ execute()

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

Implements Parser::DDLStmt.

Definition at line 3881 of file ParserNode.cpp.

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

3881  {
3882  auto& catalog = session.getCatalog();
3883  const auto& currentUser = session.get_currentUser();
3884  const auto parserObjectType = boost::to_upper_copy<std::string>(get_object_type());
3885  const auto objectName =
3886  extractObjectNameFromHierName(get_object(), parserObjectType, catalog);
3887  auto objectType = DBObjectTypeFromString(parserObjectType);
3888  DBObject dbObject = createObject(objectName, objectType);
3889  /* verify object ownership if not suser */
3890  if (!currentUser.isSuper) {
3891  if (!SysCatalog::instance().verifyDBObjectOwnership(currentUser, dbObject, catalog)) {
3892  throw std::runtime_error(
3893  "GRANT failed. It can only be executed by super user or owner of the object.");
3894  }
3895  }
3896  /* set proper values of privileges & grant them to the object */
3897  std::vector<DBObject> objects(get_privs().size(), dbObject);
3898  for (size_t i = 0; i < get_privs().size(); ++i) {
3899  std::pair<AccessPrivileges, DBObjectType> priv = parseStringPrivs(
3900  boost::to_upper_copy<std::string>(get_privs()[i]), objectType, get_object());
3901  objects[i].setPrivileges(priv.first);
3902  objects[i].setPermissionType(priv.second);
3903  }
3904  SysCatalog::instance().grantDBObjectPrivilegesBatch(grantees, objects, catalog);
3905 }
const std::vector< std::string > & get_privs() const
Definition: ParserNode.h:1372
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)
DBObjectType DBObjectTypeFromString(const std::string &type)
Definition: DBObject.cpp:88
std::vector< std::string > grantees
Definition: ParserNode.h:1382
Catalog & getCatalog() const
Definition: SessionInfo.h:90
const std::string & get_object() const
Definition: ParserNode.h:1374
const std::string & get_object_type() const
Definition: ParserNode.h:1373
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::GrantPrivilegesStmt::get_grantees ( ) const
inline

Definition at line 1375 of file ParserNode.h.

References session.

1375 { return grantees; }
std::vector< std::string > grantees
Definition: ParserNode.h:1382

◆ get_object()

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

Definition at line 1374 of file ParserNode.h.

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

◆ get_object_type()

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

Definition at line 1373 of file ParserNode.h.

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

◆ get_privs()

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

Definition at line 1372 of file ParserNode.h.

1372 { return privs; }
std::vector< std::string > privs
Definition: ParserNode.h:1379

Member Data Documentation

◆ grantees

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

Definition at line 1382 of file ParserNode.h.

◆ object

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

Definition at line 1381 of file ParserNode.h.

◆ object_type

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

Definition at line 1380 of file ParserNode.h.

◆ privs

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

Definition at line 1379 of file ParserNode.h.


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