OmniSciDB  c07336695a
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 1728 of file ParserNode.h.

Constructor & Destructor Documentation

◆ DropDBStmt()

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

Definition at line 1730 of file ParserNode.h.

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

Member Function Documentation

◆ execute()

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

Implements Parser::DDLStmt.

Definition at line 4417 of file ParserNode.cpp.

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

4417  {
4418  if (!session.get_currentUser().isSuper) {
4419  throw std::runtime_error("DROP DATABASE command can only be executed by super user.");
4420  }
4422  if (!SysCatalog::instance().getMetadataForDB(*db_name, db)) {
4423  if (if_exists_) {
4424  return;
4425  }
4426  throw std::runtime_error("Database " + *db_name + " does not exist.");
4427  }
4428 
4429  if (!session.get_currentUser().isSuper &&
4430  session.get_currentUser().userId != db.dbOwner) {
4431  throw std::runtime_error("Only the super user or the owner can drop database.");
4432  }
4433 
4434  SysCatalog::instance().dropDatabase(db);
4435 }
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:93
std::unique_ptr< std::string > db_name
Definition: ParserNode.h:1736
+ Here is the call graph for this function:

◆ getDatabaseName()

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

Definition at line 1732 of file ParserNode.h.

References session.

1732 { return db_name; }
std::unique_ptr< std::string > db_name
Definition: ParserNode.h:1736

Member Data Documentation

◆ db_name

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

Definition at line 1736 of file ParserNode.h.

◆ if_exists_

bool Parser::DropDBStmt::if_exists_
private

Definition at line 1737 of file ParserNode.h.


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