OmniSciDB  1dac507f6e
 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 1829 of file ParserNode.h.

Constructor & Destructor Documentation

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

Definition at line 1831 of file ParserNode.h.

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

Member Function Documentation

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

Implements Parser::DDLStmt.

Definition at line 4485 of file ParserNode.cpp.

References Catalog_Namespace::DBMetadata::dbOwner, Catalog_Namespace::SessionInfo::get_currentUser(), Catalog_Namespace::UserMetadata::isSuper, and Catalog_Namespace::UserMetadata::userId.

4485  {
4486  if (!session.get_currentUser().isSuper) {
4487  throw std::runtime_error("DROP DATABASE command can only be executed by super user.");
4488  }
4490  if (!SysCatalog::instance().getMetadataForDB(*db_name, db)) {
4491  if (if_exists_) {
4492  return;
4493  }
4494  throw std::runtime_error("Database " + *db_name + " does not exist.");
4495  }
4496 
4497  if (!session.get_currentUser().isSuper &&
4498  session.get_currentUser().userId != db.dbOwner) {
4499  throw std::runtime_error("Only the super user or the owner can drop database.");
4500  }
4501 
4502  SysCatalog::instance().dropDatabase(db);
4503 }
std::unique_ptr< std::string > db_name
Definition: ParserNode.h:1837
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:93
std::atomic< bool > isSuper
Definition: SysCatalog.h:85

+ Here is the call graph for this function:

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

Definition at line 1833 of file ParserNode.h.

References db_name.

1833 { return db_name; }
std::unique_ptr< std::string > db_name
Definition: ParserNode.h:1837

Member Data Documentation

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

Definition at line 1837 of file ParserNode.h.

Referenced by getDatabaseName().

bool Parser::DropDBStmt::if_exists_
private

Definition at line 1838 of file ParserNode.h.


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