OmniSciDB  ba1bac9284
 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 1604 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 1606 of file ParserNode.h.

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

1610  : object_type(t), object(o) {
1613  }
std::vector< std::string > grantees
Definition: ParserNode.h:1625
void parser_slistval_to_vector(std::list< std::string * > *l, std::vector< std::string > &v)
Definition: ParserNode.h:1562
std::unique_ptr< std::string > object_type
Definition: ParserNode.h:1623
std::vector< std::string > privs
Definition: ParserNode.h:1622
std::unique_ptr< std::string > object
Definition: ParserNode.h:1624
char * t

+ 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 5080 of file ParserNode.cpp.

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

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

5080  {
5081  auto& catalog = session.getCatalog();
5082  const auto& currentUser = session.get_currentUser();
5083  const auto parserObjectType = boost::to_upper_copy<std::string>(get_object_type());
5084  const auto objectName =
5085  extractObjectNameFromHierName(get_object(), parserObjectType, catalog);
5086  auto objectType = DBObjectTypeFromString(parserObjectType);
5087  if (objectType == ServerDBObjectType && !g_enable_fsi) {
5088  throw std::runtime_error("REVOKE failed. SERVER object unrecognized.");
5089  }
5090  DBObject dbObject = createObject(objectName, objectType);
5091  /* verify object ownership if not suser */
5092  if (!currentUser.isSuper) {
5093  if (!SysCatalog::instance().verifyDBObjectOwnership(currentUser, dbObject, catalog)) {
5094  throw std::runtime_error(
5095  "REVOKE failed. It can only be executed by super user or owner of the "
5096  "object.");
5097  }
5098  }
5099  /* set proper values of privileges & grant them to the object */
5100  std::vector<DBObject> objects(get_privs().size(), dbObject);
5101  for (size_t i = 0; i < get_privs().size(); ++i) {
5102  std::pair<AccessPrivileges, DBObjectType> priv = parseStringPrivs(
5103  boost::to_upper_copy<std::string>(get_privs()[i]), objectType, get_object());
5104  objects[i].setPrivileges(priv.first);
5105  objects[i].setPermissionType(priv.second);
5106  if (priv.second == ServerDBObjectType && !g_enable_fsi) {
5107  throw std::runtime_error("REVOKE failed. SERVER object unrecognized.");
5108  }
5109  }
5110  SysCatalog::instance().revokeDBObjectPrivilegesBatch(grantees, objects, catalog);
5111 }
std::vector< std::string > grantees
Definition: ParserNode.h:1625
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:101
Catalog & getCatalog() const
Definition: SessionInfo.h:67
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:1615
static DBObject createObject(const std::string &objectName, DBObjectType objectType)
const std::string & get_object() const
Definition: ParserNode.h:1617
bool g_enable_fsi
Definition: Catalog.cpp:92
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:73
const std::string & get_object_type() const
Definition: ParserNode.h:1616

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 1618 of file ParserNode.h.

References grantees.

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

Definition at line 1617 of file ParserNode.h.

References object.

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

Definition at line 1616 of file ParserNode.h.

References object_type.

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

Definition at line 1615 of file ParserNode.h.

References privs.

1615 { return privs; }
std::vector< std::string > privs
Definition: ParserNode.h:1622

Member Data Documentation

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

Definition at line 1625 of file ParserNode.h.

Referenced by get_grantees(), and RevokePrivilegesStmt().

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

Definition at line 1624 of file ParserNode.h.

Referenced by get_object().

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

Definition at line 1623 of file ParserNode.h.

Referenced by get_object_type().

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

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