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

#include <ParserNode.h>

+ Inheritance diagram for Parser::DropDBStmt:
+ Collaboration diagram for Parser::DropDBStmt:

Public Member Functions

 DropDBStmt (const rapidjson::Value &payload)
 
 DropDBStmt (std::string *n, bool i)
 
auto constgetDatabaseName ()
 
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 > db_name_
 
bool if_exists_
 

Detailed Description

Definition at line 1955 of file ParserNode.h.

Constructor & Destructor Documentation

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

Definition at line 6028 of file ParserNode.cpp.

References CHECK, json_bool(), and json_str().

6028  {
6029  CHECK(payload.HasMember("name"));
6030  db_name_ = std::make_unique<std::string>(json_str(payload["name"]));
6031 
6032  if_exists_ = false;
6033  if (payload.HasMember("ifExists")) {
6034  if_exists_ = json_bool(payload["ifExists"]);
6035  }
6036 }
std::unique_ptr< std::string > db_name_
Definition: ParserNode.h:1964
const bool json_bool(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:49
const std::string json_str(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:44
#define CHECK(condition)
Definition: Logger.h:209

+ Here is the call graph for this function:

Parser::DropDBStmt::DropDBStmt ( std::string *  n,
bool  i 
)
inlineexplicit

Definition at line 1959 of file ParserNode.h.

1959 : db_name_(n), if_exists_(i) {}
std::unique_ptr< std::string > db_name_
Definition: ParserNode.h:1964
constexpr double n
Definition: Utm.h:40

Member Function Documentation

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

Implements Parser::DDLStmt.

Definition at line 6038 of file ParserNode.cpp.

References 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().

6038  {
6039  const auto execute_write_lock = mapd_unique_lock<mapd_shared_mutex>(
6042 
6044  if (!SysCatalog::instance().getMetadataForDB(*db_name_, db)) {
6045  if (if_exists_) {
6046  return;
6047  }
6048  throw std::runtime_error("Database " + *db_name_ + " does not exist.");
6049  }
6050 
6051  if (!session.get_currentUser().isSuper &&
6052  session.get_currentUser().userId != db.dbOwner) {
6053  throw std::runtime_error(
6054  "DROP DATABASE command can only be executed by the owner or by a super "
6055  "user.");
6056  }
6057 
6058  SysCatalog::instance().dropDatabase(db);
6059 }
std::unique_ptr< std::string > db_name_
Definition: ParserNode.h:1964
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:118

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

auto const& Parser::DropDBStmt::getDatabaseName ( )
inline

Definition at line 1960 of file ParserNode.h.

References db_name_.

1960 { return db_name_; }
std::unique_ptr< std::string > db_name_
Definition: ParserNode.h:1964

Member Data Documentation

std::unique_ptr<std::string> Parser::DropDBStmt::db_name_
private

Definition at line 1964 of file ParserNode.h.

Referenced by getDatabaseName().

bool Parser::DropDBStmt::if_exists_
private

Definition at line 1965 of file ParserNode.h.


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