OmniSciDB  c1a53651b2
 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 4795 of file ParserNode.cpp.

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

4795  {
4796  CHECK(payload.HasMember("name"));
4797  database_name_ = std::make_unique<std::string>(json_str(payload["name"]));
4798  CHECK(payload.HasMember("newName"));
4799  new_database_name_ = std::make_unique<std::string>(json_str(payload["newName"]));
4800 }
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:291

+ 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 4802 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().

4803  {
4804  if (read_only_mode) {
4805  throw std::runtime_error("RENAME DATABASE invalid in read only mode.");
4806  }
4808 
4809  // TODO: use database lock instead
4810  const auto execute_write_lock =
4814 
4815  if (!SysCatalog::instance().getMetadataForDB(*database_name_, db)) {
4816  throw std::runtime_error("Database " + *database_name_ + " does not exist.");
4817  }
4818 
4819  if (!session.get_currentUser().isSuper &&
4820  session.get_currentUser().userId != db.dbOwner) {
4821  throw std::runtime_error("Only a super user or the owner can rename the database.");
4822  }
4823 
4824  SysCatalog::instance().renameDatabase(*database_name_, *new_database_name_);
4825 }
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:88
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: