OmniSciDB  7bf56492aa
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Parser::DropDBStmt Class Reference

#include <ParserNode.h>

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

Public Member Functions

 DropDBStmt (std::string *n, bool if_exists)
 
auto const & getDatabaseName ()
 
void execute (const Catalog_Namespace::SessionInfo &session) 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 1886 of file ParserNode.h.

Constructor & Destructor Documentation

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

Definition at line 1888 of file ParserNode.h.

1889  : db_name(n), if_exists_(if_exists) {}
std::unique_ptr< std::string > db_name
Definition: ParserNode.h:1894

Member Function Documentation

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

Implements Parser::DDLStmt.

Definition at line 4517 of file ParserNode.cpp.

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

4517  {
4518  if (!session.get_currentUser().isSuper) {
4519  throw std::runtime_error("DROP DATABASE command can only be executed by super user.");
4520  }
4521 
4522  const auto execute_write_lock = mapd_unique_lock<mapd_shared_mutex>(
4525 
4527  if (!SysCatalog::instance().getMetadataForDB(*db_name, db)) {
4528  if (if_exists_) {
4529  return;
4530  }
4531  throw std::runtime_error("Database " + *db_name + " does not exist.");
4532  }
4533 
4534  if (!session.get_currentUser().isSuper &&
4535  session.get_currentUser().userId != db.dbOwner) {
4536  throw std::runtime_error("Only the super user or the owner can drop database.");
4537  }
4538 
4539  SysCatalog::instance().dropDatabase(db);
4540 }
static std::shared_ptr< MutexType > getMutex(const LockType lockType, const KeyType &key)
Definition: LegacyLockMgr.h:51
std::unique_ptr< std::string > db_name
Definition: ParserNode.h:1894
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:79
std::atomic< bool > isSuper
Definition: SysCatalog.h:96

+ Here is the call graph for this function:

auto const& Parser::DropDBStmt::getDatabaseName ( )
inline

Definition at line 1890 of file ParserNode.h.

References db_name.

1890 { return db_name; }
std::unique_ptr< std::string > db_name
Definition: ParserNode.h:1894

Member Data Documentation

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

Definition at line 1894 of file ParserNode.h.

Referenced by getDatabaseName().

bool Parser::DropDBStmt::if_exists_
private

Definition at line 1895 of file ParserNode.h.


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