OmniSciDB  ba1bac9284
 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 constgetPreviousDatabaseName ()
 
auto constgetNewDatabaseName ()
 
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 1278 of file ParserNode.h.

Constructor & Destructor Documentation

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

Definition at line 1280 of file ParserNode.h.

1281  : database_name_(database_name), new_database_name_(new_database_name) {}
std::unique_ptr< std::string > database_name_
Definition: ParserNode.h:1288
std::unique_ptr< std::string > new_database_name_
Definition: ParserNode.h:1289

Member Function Documentation

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

Implements Parser::DDLStmt.

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

Referenced by omnisci.cursor.Cursor::executemany().

3896  {
3898 
3899  // TODO: use database lock instead
3900  const auto execute_write_lock = mapd_unique_lock<mapd_shared_mutex>(
3903 
3904  if (!SysCatalog::instance().getMetadataForDB(*database_name_, db)) {
3905  throw std::runtime_error("Database " + *database_name_ + " does not exist.");
3906  }
3907 
3908  if (!session.get_currentUser().isSuper &&
3909  session.get_currentUser().userId != db.dbOwner) {
3910  throw std::runtime_error("Only a super user or the owner can rename the database.");
3911  }
3912 
3913  SysCatalog::instance().renameDatabase(*database_name_, *new_database_name_);
3914 }
std::unique_ptr< std::string > database_name_
Definition: ParserNode.h:1288
static std::shared_ptr< MutexType > getMutex(const LockType lockType, const KeyType &key)
Definition: LegacyLockMgr.h:51
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:73
std::atomic< bool > isSuper
Definition: SysCatalog.h:99
std::unique_ptr< std::string > new_database_name_
Definition: ParserNode.h:1289

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 1284 of file ParserNode.h.

References new_database_name_.

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

Definition at line 1283 of file ParserNode.h.

References database_name_.

1283 { return database_name_; }
std::unique_ptr< std::string > database_name_
Definition: ParserNode.h:1288

Member Data Documentation

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

Definition at line 1288 of file ParserNode.h.

Referenced by getPreviousDatabaseName().

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

Definition at line 1289 of file ParserNode.h.

Referenced by getNewDatabaseName().


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