OmniSciDB  0fdbebe030
 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 1238 of file ParserNode.h.

Constructor & Destructor Documentation

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

Definition at line 1240 of file ParserNode.h.

1241  : database_name_(database_name), new_database_name_(new_database_name) {}
std::unique_ptr< std::string > database_name_
Definition: ParserNode.h:1248
std::unique_ptr< std::string > new_database_name_
Definition: ParserNode.h:1249

Member Function Documentation

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

Implements Parser::DDLStmt.

Definition at line 3032 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.

3032  {
3034 
3035  // TODO: use database lock instead
3036  const auto execute_write_lock = mapd_unique_lock<mapd_shared_mutex>(
3039 
3040  if (!SysCatalog::instance().getMetadataForDB(*database_name_, db)) {
3041  throw std::runtime_error("Database " + *database_name_ + " does not exist.");
3042  }
3043 
3044  if (!session.get_currentUser().isSuper &&
3045  session.get_currentUser().userId != db.dbOwner) {
3046  throw std::runtime_error("Only a super user or the owner can rename the database.");
3047  }
3048 
3049  SysCatalog::instance().renameDatabase(*database_name_, *new_database_name_);
3050 }
std::unique_ptr< std::string > database_name_
Definition: ParserNode.h:1248
static std::shared_ptr< MutexType > getMutex(const LockType lockType, const KeyType &key)
Definition: LegacyLockMgr.h:51
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:79
std::atomic< bool > isSuper
Definition: SysCatalog.h:96
std::unique_ptr< std::string > new_database_name_
Definition: ParserNode.h:1249

+ Here is the call graph for this function:

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

Definition at line 1244 of file ParserNode.h.

References new_database_name_.

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

Definition at line 1243 of file ParserNode.h.

References database_name_.

1243 { return database_name_; }
std::unique_ptr< std::string > database_name_
Definition: ParserNode.h:1248

Member Data Documentation

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

Definition at line 1248 of file ParserNode.h.

Referenced by getPreviousDatabaseName().

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

Definition at line 1249 of file ParserNode.h.

Referenced by getNewDatabaseName().


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