OmniSciDB  06b3bd477c
 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 1899 of file ParserNode.h.

Constructor & Destructor Documentation

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

Definition at line 1901 of file ParserNode.h.

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

Member Function Documentation

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

Implements Parser::DDLStmt.

Definition at line 4722 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.

4722  {
4723  if (!session.get_currentUser().isSuper) {
4724  throw std::runtime_error("DROP DATABASE command can only be executed by super user.");
4725  }
4726 
4727  const auto execute_write_lock = mapd_unique_lock<mapd_shared_mutex>(
4730 
4732  if (!SysCatalog::instance().getMetadataForDB(*db_name, db)) {
4733  if (if_exists_) {
4734  return;
4735  }
4736  throw std::runtime_error("Database " + *db_name + " does not exist.");
4737  }
4738 
4739  if (!session.get_currentUser().isSuper &&
4740  session.get_currentUser().userId != db.dbOwner) {
4741  throw std::runtime_error("Only the super user or the owner can drop database.");
4742  }
4743 
4744  SysCatalog::instance().dropDatabase(db);
4745 }
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:1907
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:68
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 1903 of file ParserNode.h.

References db_name.

1903 { return db_name; }
std::unique_ptr< std::string > db_name
Definition: ParserNode.h:1907

Member Data Documentation

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

Definition at line 1907 of file ParserNode.h.

Referenced by getDatabaseName().

bool Parser::DropDBStmt::if_exists_
private

Definition at line 1908 of file ParserNode.h.


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