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

#include <ParserNode.h>

+ Inheritance diagram for Parser::DropUserStmt:
+ Collaboration diagram for Parser::DropUserStmt:

Public Member Functions

 DropUserStmt (const rapidjson::Value &payload)
 
 DropUserStmt (std::string *n, bool e)
 
auto const & getUserName ()
 
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 > user_name_
 
bool if_exists_
 

Detailed Description

Definition at line 2061 of file ParserNode.h.

Constructor & Destructor Documentation

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

Definition at line 6669 of file ParserNode.cpp.

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

6669  {
6670  CHECK(payload.HasMember("name"));
6671  user_name_ = std::make_unique<std::string>(json_str(payload["name"]));
6672 
6673  if_exists_ = false;
6674  if (payload.HasMember("ifExists")) {
6675  if_exists_ = json_bool(payload["ifExists"]);
6676  }
6677 }
const bool json_bool(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:49
const std::string json_str(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:44
std::unique_ptr< std::string > user_name_
Definition: ParserNode.h:2070
#define CHECK(condition)
Definition: Logger.h:222

+ Here is the call graph for this function:

Parser::DropUserStmt::DropUserStmt ( std::string *  n,
bool  e 
)
inline

Definition at line 2064 of file ParserNode.h.

2064 : user_name_(n), if_exists_(e) {}
std::unique_ptr< std::string > user_name_
Definition: ParserNode.h:2070
constexpr double n
Definition: Utm.h:38

Member Function Documentation

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

Implements Parser::DDLStmt.

Definition at line 6679 of file ParserNode.cpp.

References Catalog_Namespace::SessionInfo::get_currentUser(), if_exists_, Catalog_Namespace::UserMetadata::isSuper, and user_name_.

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

6680  {
6681  if (read_only_mode) {
6682  throw std::runtime_error("DROP USER invalid in read only mode.");
6683  }
6684  if (!session.get_currentUser().isSuper) {
6685  throw std::runtime_error("Only super user can drop users.");
6686  }
6687 
6688  // Test to see if the user does not exist *and* if_exists_ flag set
6690  if (if_exists_ && !SysCatalog::instance().getMetadataForUser(*user_name_, user))
6691  return;
6692 
6693  SysCatalog::instance().dropUser(*user_name_);
6694 }
std::unique_ptr< std::string > user_name_
Definition: ParserNode.h:2070
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:71
std::atomic< bool > isSuper
Definition: SysCatalog.h:107

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

auto const& Parser::DropUserStmt::getUserName ( )
inline

Definition at line 2065 of file ParserNode.h.

References user_name_.

2065 { return user_name_; }
std::unique_ptr< std::string > user_name_
Definition: ParserNode.h:2070

Member Data Documentation

bool Parser::DropUserStmt::if_exists_
private

Definition at line 2071 of file ParserNode.h.

Referenced by DropUserStmt(), and execute().

std::unique_ptr<std::string> Parser::DropUserStmt::user_name_
private

Definition at line 2070 of file ParserNode.h.

Referenced by DropUserStmt(), execute(), and getUserName().


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