OmniSciDB  a5dc49c757
 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 6908 of file ParserNode.cpp.

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

6908  {
6909  CHECK(payload.HasMember("name"));
6910  db_name_ = std::make_unique<std::string>(json_str(payload["name"]));
6911 
6912  if_exists_ = false;
6913  if (payload.HasMember("ifExists")) {
6914  if_exists_ = json_bool(payload["ifExists"]);
6915  }
6916 }
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 6918 of file ParserNode.cpp.

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

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

6919  {
6920  if (read_only_mode) {
6921  throw std::runtime_error("DROP DATABASE invalid in read only mode.");
6922  }
6923  const auto execute_write_lock = legacylockmgr::getExecuteWriteLock();
6924 
6926  if (!SysCatalog::instance().getMetadataForDB(*db_name_, db)) {
6927  if (if_exists_) {
6928  return;
6929  }
6930  throw std::runtime_error("Database " + *db_name_ + " does not exist.");
6931  }
6932 
6933  if (!session.get_currentUser().isSuper &&
6934  session.get_currentUser().userId != db.dbOwner) {
6935  throw std::runtime_error(
6936  "DROP DATABASE command can only be executed by the owner or by a super "
6937  "user.");
6938  }
6939 
6940  SysCatalog::instance().dropDatabase(db);
6941 }
std::unique_ptr< std::string > db_name_
Definition: ParserNode.h:1950
T & instance()
Definition: LockMgr.cpp:101
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: