OmniSciDB  cde582ebc3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Parser::RenameDBStmt Class Reference

#include <ParserNode.h>

+ Inheritance diagram for Parser::RenameDBStmt:
+ Collaboration diagram for Parser::RenameDBStmt:

Public Member Functions

 RenameDBStmt (const rapidjson::Value &payload)
 
 RenameDBStmt (std::string *database_name, std::string *new_database_name)
 
auto const & getPreviousDatabaseName ()
 
auto const & getNewDatabaseName ()
 
void execute (const Catalog_Namespace::SessionInfo &session, bool read_only_mode) 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 1305 of file ParserNode.h.

Constructor & Destructor Documentation

Parser::RenameDBStmt::RenameDBStmt ( const rapidjson::Value &  payload)

Definition at line 4717 of file ParserNode.cpp.

References CHECK, database_name_, json_str(), and new_database_name_.

4717  {
4718  CHECK(payload.HasMember("name"));
4719  database_name_ = std::make_unique<std::string>(json_str(payload["name"]));
4720  CHECK(payload.HasMember("newName"));
4721  new_database_name_ = std::make_unique<std::string>(json_str(payload["newName"]));
4722 }
std::unique_ptr< std::string > new_database_name_
Definition: ParserNode.h:1319
const std::string json_str(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:44
std::unique_ptr< std::string > database_name_
Definition: ParserNode.h:1318
#define CHECK(condition)
Definition: Logger.h:222

+ Here is the call graph for this function:

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

Definition at line 1309 of file ParserNode.h.

1310  : database_name_(database_name), new_database_name_(new_database_name) {}
std::unique_ptr< std::string > new_database_name_
Definition: ParserNode.h:1319
std::unique_ptr< std::string > database_name_
Definition: ParserNode.h:1318

Member Function Documentation

void Parser::RenameDBStmt::execute ( const Catalog_Namespace::SessionInfo session,
bool  read_only_mode 
)
overridevirtual

Implements Parser::DDLStmt.

Definition at line 4724 of file ParserNode.cpp.

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

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

4725  {
4726  if (read_only_mode) {
4727  throw std::runtime_error("RENAME DATABASE invalid in read only mode.");
4728  }
4730 
4731  // TODO: use database lock instead
4732  const auto execute_write_lock =
4736 
4737  if (!SysCatalog::instance().getMetadataForDB(*database_name_, db)) {
4738  throw std::runtime_error("Database " + *database_name_ + " does not exist.");
4739  }
4740 
4741  if (!session.get_currentUser().isSuper &&
4742  session.get_currentUser().userId != db.dbOwner) {
4743  throw std::runtime_error("Only a super user or the owner can rename the database.");
4744  }
4745 
4746  SysCatalog::instance().renameDatabase(*database_name_, *new_database_name_);
4747 }
static std::shared_ptr< WrapperType< MutexType > > getMutex(const LockType lockType, const KeyType &key)
std::unique_ptr< std::string > new_database_name_
Definition: ParserNode.h:1319
std::unique_ptr< std::string > database_name_
Definition: ParserNode.h:1318
std::unique_lock< T > unique_lock
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:71
std::atomic< bool > isSuper
Definition: SysCatalog.h:107

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 1313 of file ParserNode.h.

References new_database_name_.

1313 { return new_database_name_; }
std::unique_ptr< std::string > new_database_name_
Definition: ParserNode.h:1319
auto const& Parser::RenameDBStmt::getPreviousDatabaseName ( )
inline

Definition at line 1312 of file ParserNode.h.

References database_name_.

1312 { return database_name_; }
std::unique_ptr< std::string > database_name_
Definition: ParserNode.h:1318

Member Data Documentation

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

Definition at line 1318 of file ParserNode.h.

Referenced by execute(), getPreviousDatabaseName(), and RenameDBStmt().

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

Definition at line 1319 of file ParserNode.h.

Referenced by execute(), getNewDatabaseName(), and RenameDBStmt().


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