OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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)
 
 GrantRoleStmt (const rapidjson::Value &payload)
 
const std::vector< std::string > & get_roles () const
 
const std::vector< std::string > & get_grantees () const
 
void execute (const Catalog_Namespace::SessionInfo &session, bool read_only_mode) 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 1635 of file ParserNode.h.

Constructor & Destructor Documentation

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

Definition at line 1637 of file ParserNode.h.

References grantees_, Parser::parser_slistval_to_vector(), and roles_.

1637  {
1640  }
void parser_slistval_to_vector(std::list< std::string * > *l, std::vector< std::string > &v)
Definition: ParserNode.h:1541
std::vector< std::string > roles_
Definition: ParserNode.h:1649
std::vector< std::string > grantees_
Definition: ParserNode.h:1650

+ Here is the call graph for this function:

Parser::GrantRoleStmt::GrantRoleStmt ( const rapidjson::Value &  payload)

Definition at line 6388 of file ParserNode.cpp.

References CHECK, grantees_, json_str(), and roles_.

6388  {
6389  if (payload.HasMember("roles")) {
6390  CHECK(payload["roles"].IsArray());
6391  for (auto& role : payload["roles"].GetArray()) {
6392  std::string r = json_str(role);
6393  roles_.emplace_back(r);
6394  }
6395  }
6396  if (payload.HasMember("grantees")) {
6397  CHECK(payload["grantees"].IsArray());
6398  for (auto& grantee : payload["grantees"].GetArray()) {
6399  std::string g = json_str(grantee);
6400  grantees_.emplace_back(g);
6401  }
6402  }
6403 }
const std::string json_str(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:46
std::vector< std::string > roles_
Definition: ParserNode.h:1649
std::vector< std::string > grantees_
Definition: ParserNode.h:1650
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

Member Function Documentation

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

Implements Parser::DDLStmt.

Definition at line 6405 of file ParserNode.cpp.

References Catalog_Namespace::SessionInfo::get_currentUser(), get_grantees(), get_roles(), lockmgr::instance(), and shared::kRootUsername.

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

6406  {
6407  if (read_only_mode) {
6408  throw std::runtime_error("GRANT ROLE invalid in read only mode.");
6409  }
6410  const auto& currentUser = session.get_currentUser();
6411  if (!currentUser.isSuper) {
6412  throw std::runtime_error(
6413  "GRANT failed, because it can only be executed by super user.");
6414  }
6415  if (std::find(get_grantees().begin(), get_grantees().end(), shared::kRootUsername) !=
6416  get_grantees().end()) {
6417  throw std::runtime_error(
6418  "Request to grant role failed because mapd root user has all privileges by "
6419  "default.");
6420  }
6421  SysCatalog::instance().grantRoleBatch(get_roles(), get_grantees());
6422 }
const std::vector< std::string > & get_roles() const
Definition: ParserNode.h:1643
const std::string kRootUsername
T & instance()
Definition: LockMgr.cpp:101
const std::vector< std::string > & get_grantees() const
Definition: ParserNode.h:1644
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:88

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 1644 of file ParserNode.h.

References grantees_.

Referenced by execute().

1644 { return grantees_; }
std::vector< std::string > grantees_
Definition: ParserNode.h:1650

+ Here is the caller graph for this function:

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

Definition at line 1643 of file ParserNode.h.

References roles_.

Referenced by execute().

1643 { return roles_; }
std::vector< std::string > roles_
Definition: ParserNode.h:1649

+ Here is the caller graph for this function:

Member Data Documentation

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

Definition at line 1650 of file ParserNode.h.

Referenced by get_grantees(), and GrantRoleStmt().

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

Definition at line 1649 of file ParserNode.h.

Referenced by get_roles(), and GrantRoleStmt().


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