OmniSciDB  467d548b97
 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 1240 of file ParserNode.h.

Constructor & Destructor Documentation

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

Definition at line 1242 of file ParserNode.h.

1243  : database_name_(database_name), new_database_name_(new_database_name) {}
std::unique_ptr< std::string > database_name_
Definition: ParserNode.h:1250
std::unique_ptr< std::string > new_database_name_
Definition: ParserNode.h:1251

Member Function Documentation

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

Implements Parser::DDLStmt.

Definition at line 3224 of file ParserNode.cpp.

References Catalog_Namespace::DBMetadata::dbOwner, legacylockmgr::ExecutorOuterLock, Catalog_Namespace::SessionInfo::get_currentUser(), legacylockmgr::LockMgr< MutexType, KeyType >::getMutex(), Catalog_Namespace::UserMetadata::isSuper, and Catalog_Namespace::UserMetadata::userId.

3224  {
3226 
3227  // TODO: use database lock instead
3228  const auto execute_write_lock = mapd_unique_lock<mapd_shared_mutex>(
3231 
3232  if (!SysCatalog::instance().getMetadataForDB(*database_name_, db)) {
3233  throw std::runtime_error("Database " + *database_name_ + " does not exist.");
3234  }
3235 
3236  if (!session.get_currentUser().isSuper &&
3237  session.get_currentUser().userId != db.dbOwner) {
3238  throw std::runtime_error("Only a super user or the owner can rename the database.");
3239  }
3240 
3241  SysCatalog::instance().renameDatabase(*database_name_, *new_database_name_);
3242 }
std::unique_ptr< std::string > database_name_
Definition: ParserNode.h:1250
static std::shared_ptr< MutexType > getMutex(const LockType lockType, const KeyType &key)
Definition: LegacyLockMgr.h:51
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:68
std::atomic< bool > isSuper
Definition: SysCatalog.h:94
std::unique_ptr< std::string > new_database_name_
Definition: ParserNode.h:1251

+ Here is the call graph for this function:

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

Definition at line 1246 of file ParserNode.h.

References new_database_name_.

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

Definition at line 1245 of file ParserNode.h.

References database_name_.

1245 { return database_name_; }
std::unique_ptr< std::string > database_name_
Definition: ParserNode.h:1250

Member Data Documentation

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

Definition at line 1250 of file ParserNode.h.

Referenced by getPreviousDatabaseName().

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

Definition at line 1251 of file ParserNode.h.

Referenced by getNewDatabaseName().


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