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

Constructor & Destructor Documentation

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

Definition at line 1524 of file ParserNode.h.

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

1528  : object_type(t), object(o) {
1531  }
std::unique_ptr< std::string > object
Definition: ParserNode.h:1542
void parser_slistval_to_vector(std::list< std::string * > *l, std::vector< std::string > &v)
Definition: ParserNode.h:1508
std::vector< std::string > grantees
Definition: ParserNode.h:1543
std::vector< std::string > privs
Definition: ParserNode.h:1540
std::unique_ptr< std::string > object_type
Definition: ParserNode.h:1541

+ Here is the call graph for this function:

Member Function Documentation

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

Implements Parser::DDLStmt.

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

Referenced by omnisci.cursor.Cursor::executemany().

4131  {
4132  auto& catalog = session.getCatalog();
4133  const auto& currentUser = session.get_currentUser();
4134  const auto parserObjectType = boost::to_upper_copy<std::string>(get_object_type());
4135  const auto objectName =
4136  extractObjectNameFromHierName(get_object(), parserObjectType, catalog);
4137  auto objectType = DBObjectTypeFromString(parserObjectType);
4138  if (objectType == ServerDBObjectType && !g_enable_fsi) {
4139  throw std::runtime_error("GRANT failed. SERVER object unrecognized.");
4140  }
4141  DBObject dbObject = createObject(objectName, objectType);
4142  /* verify object ownership if not suser */
4143  if (!currentUser.isSuper) {
4144  if (!SysCatalog::instance().verifyDBObjectOwnership(currentUser, dbObject, catalog)) {
4145  throw std::runtime_error(
4146  "GRANT failed. It can only be executed by super user or owner of the "
4147  "object.");
4148  }
4149  }
4150  /* set proper values of privileges & grant them to the object */
4151  std::vector<DBObject> objects(get_privs().size(), dbObject);
4152  for (size_t i = 0; i < get_privs().size(); ++i) {
4153  std::pair<AccessPrivileges, DBObjectType> priv = parseStringPrivs(
4154  boost::to_upper_copy<std::string>(get_privs()[i]), objectType, get_object());
4155  objects[i].setPrivileges(priv.first);
4156  objects[i].setPermissionType(priv.second);
4157  if (priv.second == ServerDBObjectType && !g_enable_fsi) {
4158  throw std::runtime_error("GRANT failed. SERVER object unrecognized.");
4159  }
4160  }
4161  SysCatalog::instance().grantDBObjectPrivilegesBatch(grantees, objects, catalog);
4162 }
std::string extractObjectNameFromHierName(const std::string &objectHierName, const std::string &objectType, const Catalog_Namespace::Catalog &cat)
const std::string & get_object_type() const
Definition: ParserNode.h:1534
DBObjectType DBObjectTypeFromString(const std::string &type)
Definition: DBObject.cpp:99
std::vector< std::string > grantees
Definition: ParserNode.h:1543
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:1533
static DBObject createObject(const std::string &objectName, DBObjectType objectType)
bool g_enable_fsi
Definition: Catalog.cpp:91
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:68
const std::string & get_object() const
Definition: ParserNode.h:1535

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 1536 of file ParserNode.h.

References grantees.

1536 { return grantees; }
std::vector< std::string > grantees
Definition: ParserNode.h:1543
const std::string& Parser::GrantPrivilegesStmt::get_object ( ) const
inline

Definition at line 1535 of file ParserNode.h.

References object.

1535 { return *object; }
std::unique_ptr< std::string > object
Definition: ParserNode.h:1542
const std::string& Parser::GrantPrivilegesStmt::get_object_type ( ) const
inline

Definition at line 1534 of file ParserNode.h.

References object_type.

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

Definition at line 1533 of file ParserNode.h.

References privs.

1533 { return privs; }
std::vector< std::string > privs
Definition: ParserNode.h:1540

Member Data Documentation

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

Definition at line 1543 of file ParserNode.h.

Referenced by get_grantees(), and GrantPrivilegesStmt().

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

Definition at line 1542 of file ParserNode.h.

Referenced by get_object().

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

Definition at line 1541 of file ParserNode.h.

Referenced by get_object_type().

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

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