OmniSciDB  c07336695a
Parser::RenameDatabaseStmt Class Reference

#include <ParserNode.h>

+ Inheritance diagram for Parser::RenameDatabaseStmt:
+ Collaboration diagram for Parser::RenameDatabaseStmt:

Public Member Functions

 RenameDatabaseStmt (std::string *database_name, std::string *new_database_name)
 
auto const & getPreviousDatabaseName ()
 
auto const & getNewDatabaseName ()
 
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 > database_name_
 
std::unique_ptr< std::string > new_database_name_
 

Detailed Description

Definition at line 1194 of file ParserNode.h.

Constructor & Destructor Documentation

◆ RenameDatabaseStmt()

Parser::RenameDatabaseStmt::RenameDatabaseStmt ( std::string *  database_name,
std::string *  new_database_name 
)
inline

Definition at line 1196 of file ParserNode.h.

1197  : database_name_(database_name), new_database_name_(new_database_name) {}
std::unique_ptr< std::string > database_name_
Definition: ParserNode.h:1204
std::unique_ptr< std::string > new_database_name_
Definition: ParserNode.h:1205

Member Function Documentation

◆ execute()

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

Implements Parser::DDLStmt.

Definition at line 2842 of file ParserNode.cpp.

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

2842  {
2844  if (!SysCatalog::instance().getMetadataForDB(*database_name_, db)) {
2845  throw std::runtime_error("Database " + *database_name_ + " does not exist.");
2846  }
2847 
2848  if (!session.get_currentUser().isSuper &&
2849  session.get_currentUser().userId != db.dbOwner) {
2850  throw std::runtime_error("Only a super user or the owner can rename the database.");
2851  }
2852 
2853  SysCatalog::instance().renameDatabase(*database_name_, *new_database_name_);
2854 }
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:93
std::unique_ptr< std::string > database_name_
Definition: ParserNode.h:1204
std::unique_ptr< std::string > new_database_name_
Definition: ParserNode.h:1205
+ Here is the call graph for this function:

◆ getNewDatabaseName()

auto const& Parser::RenameDatabaseStmt::getNewDatabaseName ( )
inline

Definition at line 1200 of file ParserNode.h.

References session.

1200 { return new_database_name_; }
std::unique_ptr< std::string > new_database_name_
Definition: ParserNode.h:1205

◆ getPreviousDatabaseName()

auto const& Parser::RenameDatabaseStmt::getPreviousDatabaseName ( )
inline

Definition at line 1199 of file ParserNode.h.

1199 { return database_name_; }
std::unique_ptr< std::string > database_name_
Definition: ParserNode.h:1204

Member Data Documentation

◆ database_name_

std::unique_ptr<std::string> Parser::RenameDatabaseStmt::database_name_
private

Definition at line 1204 of file ParserNode.h.

◆ new_database_name_

std::unique_ptr<std::string> Parser::RenameDatabaseStmt::new_database_name_
private

Definition at line 1205 of file ParserNode.h.


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