OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Parser::DropRoleStmt Class Reference

#include <ParserNode.h>

+ Inheritance diagram for Parser::DropRoleStmt:
+ Collaboration diagram for Parser::DropRoleStmt:

Public Member Functions

 DropRoleStmt (std::string *r, bool e)
 
 DropRoleStmt (const rapidjson::Value &payload)
 
const std::string & get_role () 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::unique_ptr< std::string > role_
 
bool if_exists_
 

Detailed Description

Definition at line 1528 of file ParserNode.h.

Constructor & Destructor Documentation

Parser::DropRoleStmt::DropRoleStmt ( std::string *  r,
bool  e 
)
inline

Definition at line 1530 of file ParserNode.h.

1530 : role_(r), if_exists_(e) {}
std::unique_ptr< std::string > role_
Definition: ParserNode.h:1537
Parser::DropRoleStmt::DropRoleStmt ( const rapidjson::Value &  payload)

Definition at line 5941 of file ParserNode.cpp.

References CHECK, if_exists_, json_bool(), json_str(), and role_.

5941  {
5942  CHECK(payload.HasMember("role"));
5943  role_ = std::make_unique<std::string>(json_str(payload["role"]));
5944 
5945  if_exists_ = false;
5946  if (payload.HasMember("ifExists")) {
5947  if_exists_ = json_bool(payload["ifExists"]);
5948  }
5949 }
const bool json_bool(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:51
const std::string json_str(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:46
std::unique_ptr< std::string > role_
Definition: ParserNode.h:1537
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

Member Function Documentation

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

Implements Parser::DDLStmt.

Definition at line 5951 of file ParserNode.cpp.

References Catalog_Namespace::SessionInfo::get_currentUser(), get_role(), if_exists_, and lockmgr::instance().

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

5952  {
5953  if (read_only_mode) {
5954  throw std::runtime_error("DROP ROLE invalid in read only mode.");
5955  }
5956  const auto& currentUser = session.get_currentUser();
5957  if (!currentUser.isSuper) {
5958  throw std::runtime_error("DROP ROLE " + get_role() +
5959  " failed. It can only be executed by super user.");
5960  }
5961  auto* rl = SysCatalog::instance().getRoleGrantee(get_role());
5962  if (rl) {
5963  SysCatalog::instance().dropRole(get_role(), /*is_temporary=*/false);
5964  } else if (!if_exists_) {
5965  throw std::runtime_error("DROP ROLE " + get_role() +
5966  " failed because role with this name does not exist.");
5967  }
5968 }
const std::string & get_role() const
Definition: ParserNode.h:1532
T & instance()
Definition: LockMgr.cpp:101
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::string& Parser::DropRoleStmt::get_role ( ) const
inline

Definition at line 1532 of file ParserNode.h.

References role_.

Referenced by execute().

1532 { return *role_; }
std::unique_ptr< std::string > role_
Definition: ParserNode.h:1537

+ Here is the caller graph for this function:

Member Data Documentation

bool Parser::DropRoleStmt::if_exists_
private

Definition at line 1538 of file ParserNode.h.

Referenced by DropRoleStmt(), and execute().

std::unique_ptr<std::string> Parser::DropRoleStmt::role_
private

Definition at line 1537 of file ParserNode.h.

Referenced by DropRoleStmt(), and get_role().


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