OmniSciDB  a987f07e93
 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 1997 of file ParserNode.h.

Constructor & Destructor Documentation

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

Definition at line 6578 of file ParserNode.cpp.

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

6578  {
6579  CHECK(payload.HasMember("name"));
6580  db_name_ = std::make_unique<std::string>(json_str(payload["name"]));
6581 
6582  if_exists_ = false;
6583  if (payload.HasMember("ifExists")) {
6584  if_exists_ = json_bool(payload["ifExists"]);
6585  }
6586 }
std::unique_ptr< std::string > db_name_
Definition: ParserNode.h:2007
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:289

+ Here is the call graph for this function:

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

Definition at line 2001 of file ParserNode.h.

2001 : db_name_(n), if_exists_(i) {}
std::unique_ptr< std::string > db_name_
Definition: ParserNode.h:2007
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 6588 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().

6589  {
6590  if (read_only_mode) {
6591  throw std::runtime_error("DROP DATABASE invalid in read only mode.");
6592  }
6593  const auto execute_write_lock =
6597 
6599  if (!SysCatalog::instance().getMetadataForDB(*db_name_, db)) {
6600  if (if_exists_) {
6601  return;
6602  }
6603  throw std::runtime_error("Database " + *db_name_ + " does not exist.");
6604  }
6605 
6606  if (!session.get_currentUser().isSuper &&
6607  session.get_currentUser().userId != db.dbOwner) {
6608  throw std::runtime_error(
6609  "DROP DATABASE command can only be executed by the owner or by a super "
6610  "user.");
6611  }
6612 
6613  SysCatalog::instance().dropDatabase(db);
6614 }
static std::shared_ptr< WrapperType< MutexType > > getMutex(const LockType lockType, const KeyType &key)
std::unique_ptr< std::string > db_name_
Definition: ParserNode.h:2007
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 2002 of file ParserNode.h.

References db_name_.

2002 { return db_name_; }
std::unique_ptr< std::string > db_name_
Definition: ParserNode.h:2007

Member Data Documentation

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

Definition at line 2007 of file ParserNode.h.

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

bool Parser::DropDBStmt::if_exists_
private

Definition at line 2008 of file ParserNode.h.

Referenced by DropDBStmt(), and execute().


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