OmniSciDB  dfae7c3b14
Parser::GrantRoleStmt Class Reference

#include <ParserNode.h>

+ Inheritance diagram for Parser::GrantRoleStmt:
+ Collaboration diagram for Parser::GrantRoleStmt:

Public Member Functions

 GrantRoleStmt (std::list< std::string *> *r, std::list< std::string *> *g)
 
const std::vector< std::string > & get_roles () 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 > roles
 
std::vector< std::string > grantees
 

Detailed Description

Definition at line 1597 of file ParserNode.h.

Constructor & Destructor Documentation

◆ GrantRoleStmt()

Parser::GrantRoleStmt::GrantRoleStmt ( std::list< std::string *> *  r,
std::list< std::string *> *  g 
)
inline

Definition at line 1599 of file ParserNode.h.

References Parser::parser_slistval_to_vector().

1599  {
1602  }
std::vector< std::string > roles
Definition: ParserNode.h:1608
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:1609
+ Here is the call graph for this function:

Member Function Documentation

◆ execute()

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

Implements Parser::DDLStmt.

Definition at line 4281 of file ParserNode.cpp.

References parse_ast::end, Catalog_Namespace::SessionInfo::get_currentUser(), and OMNISCI_ROOT_USER.

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

4281  {
4282  const auto& currentUser = session.get_currentUser();
4283  if (!currentUser.isSuper) {
4284  throw std::runtime_error(
4285  "GRANT failed, because it can only be executed by super user.");
4286  }
4287  if (std::find(get_grantees().begin(), get_grantees().end(), OMNISCI_ROOT_USER) !=
4288  get_grantees().end()) {
4289  throw std::runtime_error(
4290  "Request to grant role failed because mapd root user has all privileges by "
4291  "default.");
4292  }
4293  SysCatalog::instance().grantRoleBatch(get_roles(), get_grantees());
4294 }
const std::vector< std::string > & get_grantees() const
Definition: ParserNode.h:1604
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:68
const std::vector< std::string > & get_roles() const
Definition: ParserNode.h:1603
const std::string OMNISCI_ROOT_USER
Definition: SysCatalog.h:57
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get_grantees()

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

Definition at line 1604 of file ParserNode.h.

1604 { return grantees; }
std::vector< std::string > grantees
Definition: ParserNode.h:1609

◆ get_roles()

const std::vector<std::string>& Parser::GrantRoleStmt::get_roles ( ) const
inline

Definition at line 1603 of file ParserNode.h.

1603 { return roles; }
std::vector< std::string > roles
Definition: ParserNode.h:1608

Member Data Documentation

◆ grantees

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

Definition at line 1609 of file ParserNode.h.

◆ roles

std::vector<std::string> Parser::GrantRoleStmt::roles
private

Definition at line 1608 of file ParserNode.h.


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