OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Parser::DropDBStmt Class Reference

#include <ParserNode.h>

+ Inheritance diagram for Parser::DropDBStmt:
+ Collaboration diagram for Parser::DropDBStmt:

Public Member Functions

 DropDBStmt (const rapidjson::Value &payload)
 
 DropDBStmt (std::string *n, bool i)
 
auto const & getDatabaseName ()
 
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 > db_name_
 
bool if_exists_
 

Detailed Description

Definition at line 1940 of file ParserNode.h.

Constructor & Destructor Documentation

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

Definition at line 6887 of file ParserNode.cpp.

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

6887  {
6888  CHECK(payload.HasMember("name"));
6889  db_name_ = std::make_unique<std::string>(json_str(payload["name"]));
6890 
6891  if_exists_ = false;
6892  if (payload.HasMember("ifExists")) {
6893  if_exists_ = json_bool(payload["ifExists"]);
6894  }
6895 }
std::unique_ptr< std::string > db_name_
Definition: ParserNode.h:1950
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
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

Parser::DropDBStmt::DropDBStmt ( std::string *  n,
bool  i 
)
inlineexplicit

Definition at line 1944 of file ParserNode.h.

1944 : db_name_(n), if_exists_(i) {}
std::unique_ptr< std::string > db_name_
Definition: ParserNode.h:1950
constexpr double n
Definition: Utm.h:38

Member Function Documentation

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

Implements Parser::DDLStmt.

Definition at line 6897 of file ParserNode.cpp.

References db_name_, Catalog_Namespace::DBMetadata::dbOwner, Catalog_Namespace::SessionInfo::get_currentUser(), legacylockmgr::getExecuteWriteLock(), if_exists_, Catalog_Namespace::UserMetadata::isSuper, and Catalog_Namespace::UserMetadata::userId.

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

6898  {
6899  if (read_only_mode) {
6900  throw std::runtime_error("DROP DATABASE invalid in read only mode.");
6901  }
6902  const auto execute_write_lock = legacylockmgr::getExecuteWriteLock();
6903 
6905  if (!SysCatalog::instance().getMetadataForDB(*db_name_, db)) {
6906  if (if_exists_) {
6907  return;
6908  }
6909  throw std::runtime_error("Database " + *db_name_ + " does not exist.");
6910  }
6911 
6912  if (!session.get_currentUser().isSuper &&
6913  session.get_currentUser().userId != db.dbOwner) {
6914  throw std::runtime_error(
6915  "DROP DATABASE command can only be executed by the owner or by a super "
6916  "user.");
6917  }
6918 
6919  SysCatalog::instance().dropDatabase(db);
6920 }
std::unique_ptr< std::string > db_name_
Definition: ParserNode.h:1950
auto getExecuteWriteLock()
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:88
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::DropDBStmt::getDatabaseName ( )
inline

Definition at line 1945 of file ParserNode.h.

References db_name_.

1945 { return db_name_; }
std::unique_ptr< std::string > db_name_
Definition: ParserNode.h:1950

Member Data Documentation

std::unique_ptr<std::string> Parser::DropDBStmt::db_name_
private

Definition at line 1950 of file ParserNode.h.

Referenced by DropDBStmt(), execute(), and getDatabaseName().

bool Parser::DropDBStmt::if_exists_
private

Definition at line 1951 of file ParserNode.h.

Referenced by DropDBStmt(), and execute().


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