OmniSciDB  c1a53651b2
 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 1953 of file ParserNode.h.

Constructor & Destructor Documentation

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

Definition at line 6597 of file ParserNode.cpp.

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

6597  {
6598  CHECK(payload.HasMember("name"));
6599  db_name_ = std::make_unique<std::string>(json_str(payload["name"]));
6600 
6601  if_exists_ = false;
6602  if (payload.HasMember("ifExists")) {
6603  if_exists_ = json_bool(payload["ifExists"]);
6604  }
6605 }
std::unique_ptr< std::string > db_name_
Definition: ParserNode.h:1963
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
#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 1957 of file ParserNode.h.

1957 : db_name_(n), if_exists_(i) {}
std::unique_ptr< std::string > db_name_
Definition: ParserNode.h:1963
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 6607 of file ParserNode.cpp.

References db_name_, legacylockmgr::ExecutorOuterLock, Catalog_Namespace::SessionInfo::get_currentUser(), legacylockmgr::LockMgr< MutexType, KeyType >::getMutex(), if_exists_, Catalog_Namespace::UserMetadata::isSuper, and Catalog_Namespace::UserMetadata::userId.

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

6608  {
6609  if (read_only_mode) {
6610  throw std::runtime_error("DROP DATABASE invalid in read only mode.");
6611  }
6612  const auto execute_write_lock =
6616 
6618  if (!SysCatalog::instance().getMetadataForDB(*db_name_, db)) {
6619  if (if_exists_) {
6620  return;
6621  }
6622  throw std::runtime_error("Database " + *db_name_ + " does not exist.");
6623  }
6624 
6625  if (!session.get_currentUser().isSuper &&
6626  session.get_currentUser().userId != db.dbOwner) {
6627  throw std::runtime_error(
6628  "DROP DATABASE command can only be executed by the owner or by a super "
6629  "user.");
6630  }
6631 
6632  SysCatalog::instance().dropDatabase(db);
6633 }
static std::shared_ptr< WrapperType< MutexType > > getMutex(const LockType lockType, const KeyType &key)
std::unique_ptr< std::string > db_name_
Definition: ParserNode.h:1963
std::unique_lock< T > unique_lock
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 1958 of file ParserNode.h.

References db_name_.

1958 { return db_name_; }
std::unique_ptr< std::string > db_name_
Definition: ParserNode.h:1963

Member Data Documentation

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

Definition at line 1963 of file ParserNode.h.

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

bool Parser::DropDBStmt::if_exists_
private

Definition at line 1964 of file ParserNode.h.

Referenced by DropDBStmt(), and execute().


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