OmniSciDB  b24e664e58
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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

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

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

Implements Parser::DDLStmt.

Definition at line 2945 of file ParserNode.cpp.

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

2945  {
2947  if (!SysCatalog::instance().getMetadataForDB(*database_name_, db)) {
2948  throw std::runtime_error("Database " + *database_name_ + " does not exist.");
2949  }
2950 
2951  if (!session.get_currentUser().isSuper &&
2952  session.get_currentUser().userId != db.dbOwner) {
2953  throw std::runtime_error("Only a super user or the owner can rename the database.");
2954  }
2955 
2956  SysCatalog::instance().renameDatabase(*database_name_, *new_database_name_);
2957 }
std::unique_ptr< std::string > database_name_
Definition: ParserNode.h:1210
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:93
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:

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

Definition at line 1206 of file ParserNode.h.

References new_database_name_.

1206 { return new_database_name_; }
std::unique_ptr< std::string > new_database_name_
Definition: ParserNode.h:1211
auto const& Parser::RenameDatabaseStmt::getPreviousDatabaseName ( )
inline

Definition at line 1205 of file ParserNode.h.

References database_name_.

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

Member Data Documentation

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

Definition at line 1210 of file ParserNode.h.

Referenced by getPreviousDatabaseName().

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

Definition at line 1211 of file ParserNode.h.

Referenced by getNewDatabaseName().


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