OmniSciDB  95562058bd
 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 4725 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.

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

4725  {
4726  if (!session.get_currentUser().isSuper) {
4727  throw std::runtime_error("DROP DATABASE command can only be executed by super user.");
4728  }
4729 
4730  const auto execute_write_lock = mapd_unique_lock<mapd_shared_mutex>(
4733 
4735  if (!SysCatalog::instance().getMetadataForDB(*db_name, db)) {
4736  if (if_exists_) {
4737  return;
4738  }
4739  throw std::runtime_error("Database " + *db_name + " does not exist.");
4740  }
4741 
4742  if (!session.get_currentUser().isSuper &&
4743  session.get_currentUser().userId != db.dbOwner) {
4744  throw std::runtime_error("Only the super user or the owner can drop database.");
4745  }
4746 
4747  SysCatalog::instance().dropDatabase(db);
4748 }
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:94

+ 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 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
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: