OmniSciDB  29e35f4d58
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 1200 of file ParserNode.h.

Constructor & Destructor Documentation

◆ RenameDatabaseStmt()

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

Definition at line 1202 of file ParserNode.h.

1203  : database_name_(database_name), new_database_name_(new_database_name) {}
std::unique_ptr< std::string > database_name_
Definition: ParserNode.h:1210
std::unique_ptr< std::string > new_database_name_
Definition: ParserNode.h:1211

Member Function Documentation

◆ execute()

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

Implements Parser::DDLStmt.

Definition at line 2944 of file ParserNode.cpp.

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

2944  {
2946  if (!SysCatalog::instance().getMetadataForDB(*database_name_, db)) {
2947  throw std::runtime_error("Database " + *database_name_ + " does not exist.");
2948  }
2949 
2950  if (!session.get_currentUser().isSuper &&
2951  session.get_currentUser().userId != db.dbOwner) {
2952  throw std::runtime_error("Only a super user or the owner can rename the database.");
2953  }
2954 
2955  SysCatalog::instance().renameDatabase(*database_name_, *new_database_name_);
2956 }
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:93
std::unique_ptr< std::string > database_name_
Definition: ParserNode.h:1210
std::atomic< bool > isSuper
Definition: SysCatalog.h:97
std::unique_ptr< std::string > new_database_name_
Definition: ParserNode.h:1211
+ Here is the call graph for this function:

◆ getNewDatabaseName()

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

Definition at line 1206 of file ParserNode.h.

1206 { return new_database_name_; }
std::unique_ptr< std::string > new_database_name_
Definition: ParserNode.h:1211

◆ getPreviousDatabaseName()

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

Definition at line 1205 of file ParserNode.h.

1205 { return database_name_; }
std::unique_ptr< std::string > database_name_
Definition: ParserNode.h:1210

Member Data Documentation

◆ database_name_

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

Definition at line 1210 of file ParserNode.h.

◆ new_database_name_

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

Definition at line 1211 of file ParserNode.h.


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