OmniSciDB  a5dc49c757
 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 1292 of file ParserNode.h.

Constructor & Destructor Documentation

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

Definition at line 5138 of file ParserNode.cpp.

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

5138  {
5139  CHECK(payload.HasMember("name"));
5140  database_name_ = std::make_unique<std::string>(json_str(payload["name"]));
5141  CHECK(payload.HasMember("newName"));
5142  new_database_name_ = std::make_unique<std::string>(json_str(payload["newName"]));
5143 }
std::unique_ptr< std::string > new_database_name_
Definition: ParserNode.h:1306
const std::string json_str(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:46
std::unique_ptr< std::string > database_name_
Definition: ParserNode.h:1305
#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 1296 of file ParserNode.h.

1297  : database_name_(database_name), new_database_name_(new_database_name) {}
std::unique_ptr< std::string > new_database_name_
Definition: ParserNode.h:1306
std::unique_ptr< std::string > database_name_
Definition: ParserNode.h:1305

Member Function Documentation

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

Implements Parser::DDLStmt.

Definition at line 5145 of file ParserNode.cpp.

References database_name_, Catalog_Namespace::DBMetadata::dbOwner, Catalog_Namespace::SessionInfo::get_currentUser(), legacylockmgr::getExecuteWriteLock(), lockmgr::instance(), Catalog_Namespace::UserMetadata::isSuper, new_database_name_, and Catalog_Namespace::UserMetadata::userId.

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

5146  {
5147  if (read_only_mode) {
5148  throw std::runtime_error("RENAME DATABASE invalid in read only mode.");
5149  }
5151 
5152  // TODO: use database lock instead
5153  const auto execute_write_lock = legacylockmgr::getExecuteWriteLock();
5154 
5155  if (!SysCatalog::instance().getMetadataForDB(*database_name_, db)) {
5156  throw std::runtime_error("Database " + *database_name_ + " does not exist.");
5157  }
5158 
5159  if (!session.get_currentUser().isSuper &&
5160  session.get_currentUser().userId != db.dbOwner) {
5161  throw std::runtime_error("Only a super user or the owner can rename the database.");
5162  }
5163 
5165 }
std::unique_ptr< std::string > new_database_name_
Definition: ParserNode.h:1306
std::unique_ptr< std::string > database_name_
Definition: ParserNode.h:1305
T & instance()
Definition: LockMgr.cpp:101
auto getExecuteWriteLock()
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 1300 of file ParserNode.h.

References new_database_name_.

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

Definition at line 1299 of file ParserNode.h.

References database_name_.

1299 { return database_name_; }
std::unique_ptr< std::string > database_name_
Definition: ParserNode.h:1305

Member Data Documentation

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

Definition at line 1305 of file ParserNode.h.

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

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

Definition at line 1306 of file ParserNode.h.

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


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