OmniSciDB  c0231cc57d
 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 4768 of file ParserNode.cpp.

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

4768  {
4769  CHECK(payload.HasMember("name"));
4770  database_name_ = std::make_unique<std::string>(json_str(payload["name"]));
4771  CHECK(payload.HasMember("newName"));
4772  new_database_name_ = std::make_unique<std::string>(json_str(payload["newName"]));
4773 }
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 4775 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().

4776  {
4777  if (read_only_mode) {
4778  throw std::runtime_error("RENAME DATABASE invalid in read only mode.");
4779  }
4781 
4782  // TODO: use database lock instead
4783  const auto execute_write_lock =
4787 
4788  if (!SysCatalog::instance().getMetadataForDB(*database_name_, db)) {
4789  throw std::runtime_error("Database " + *database_name_ + " does not exist.");
4790  }
4791 
4792  if (!session.get_currentUser().isSuper &&
4793  session.get_currentUser().userId != db.dbOwner) {
4794  throw std::runtime_error("Only a super user or the owner can rename the database.");
4795  }
4796 
4797  SysCatalog::instance().renameDatabase(*database_name_, *new_database_name_);
4798 }
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: