OmniSciDB  4201147b46
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Parser::DropTableStmt Class Reference

#include <ParserNode.h>

+ Inheritance diagram for Parser::DropTableStmt:
+ Collaboration diagram for Parser::DropTableStmt:

Public Member Functions

 DropTableStmt (std::string *tab, bool i)
 
 DropTableStmt (const rapidjson::Value &payload)
 
const std::string * get_table () const
 
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 > table_
 
bool if_exists_
 

Detailed Description

Definition at line 1222 of file ParserNode.h.

Constructor & Destructor Documentation

Parser::DropTableStmt::DropTableStmt ( std::string *  tab,
bool  i 
)
inline

Definition at line 1224 of file ParserNode.h.

1224 : table_(tab), if_exists_(i) {}
std::unique_ptr< std::string > table_
Definition: ParserNode.h:1232
Parser::DropTableStmt::DropTableStmt ( const rapidjson::Value &  payload)

Definition at line 4349 of file ParserNode.cpp.

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

4349  {
4350  CHECK(payload.HasMember("tableName"));
4351  table_ = std::make_unique<std::string>(json_str(payload["tableName"]));
4352 
4353  if_exists_ = false;
4354  if (payload.HasMember("ifExists")) {
4355  if_exists_ = json_bool(payload["ifExists"]);
4356  }
4357 }
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
std::unique_ptr< std::string > table_
Definition: ParserNode.h:1232
#define CHECK(condition)
Definition: Logger.h:222

+ Here is the call graph for this function:

Member Function Documentation

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

Implements Parser::DDLStmt.

Definition at line 4359 of file ParserNode.cpp.

References CHECK, Catalog_Namespace::SessionInfo::checkDBAccessPrivileges(), Executor::clearExternalCaches(), AccessPrivileges::DROP_TABLE, legacylockmgr::ExecutorOuterLock, Catalog_Namespace::SessionInfo::getCatalog(), legacylockmgr::LockMgr< MutexType, KeyType >::getMutex(), lockmgr::TableLockMgrImpl< TableDataLockMgr >::getReadLockForTable(), lockmgr::TableLockMgrImpl< TableDataLockMgr >::getWriteLockForTable(), if_exists_, ddl_utils::TABLE, table_, TableDBObjectType, and ddl_utils::validate_table_type().

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

4360  {
4361  if (read_only_mode) {
4362  throw std::runtime_error("DROP TABLE invalid in read only mode.");
4363  }
4364  const auto execute_read_lock = heavyai::shared_lock<heavyai::shared_mutex>(
4367  auto& catalog = session.getCatalog();
4368  const TableDescriptor* td{nullptr};
4369  std::unique_ptr<lockmgr::TableSchemaLockContainer<lockmgr::WriteLock>> td_with_lock;
4370  try {
4371  td_with_lock =
4372  std::make_unique<lockmgr::TableSchemaLockContainer<lockmgr::WriteLock>>(
4374  catalog, *table_, false));
4375  td = (*td_with_lock)();
4376  } catch (const std::runtime_error& e) {
4377  if (if_exists_) {
4378  return;
4379  } else {
4380  throw e;
4381  }
4382  }
4383 
4384  CHECK(td);
4385  CHECK(td_with_lock);
4386 
4387  // check access privileges
4388  if (!session.checkDBAccessPrivileges(
4390  throw std::runtime_error("Table " + *table_ +
4391  " will not be dropped. User has no proper privileges.");
4392  }
4393 
4395 
4396  {
4397  auto table_data_read_lock =
4399  Executor::clearExternalCaches(false, td, catalog.getCurrentDB().dbId);
4400  }
4401 
4402  auto table_data_write_lock =
4404  catalog.dropTable(td);
4405 }
static ReadLock getReadLockForTable(const Catalog_Namespace::Catalog &cat, const std::string &table_name)
Definition: LockMgrImpl.h:164
static WriteLock getWriteLockForTable(const Catalog_Namespace::Catalog &cat, const std::string &table_name)
Definition: LockMgrImpl.h:155
std::shared_lock< T > shared_lock
static const AccessPrivileges DROP_TABLE
Definition: DBObject.h:159
std::unique_ptr< std::string > table_
Definition: ParserNode.h:1232
Catalog & getCatalog() const
Definition: SessionInfo.h:65
static std::shared_ptr< MutexType > getMutex(const LockType lockType, const KeyType &key)
Definition: LegacyLockMgr.h:51
void validate_table_type(const TableDescriptor *td, const TableType expected_table_type, const std::string &command)
Definition: DdlUtils.cpp:693
#define CHECK(condition)
Definition: Logger.h:222
static void clearExternalCaches(bool for_update, const TableDescriptor *td, const int current_db_id)
Definition: Execute.h:391
bool checkDBAccessPrivileges(const DBObjectType &permissionType, const AccessPrivileges &privs, const std::string &objectName="") const
Definition: SessionInfo.cpp:24

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const std::string* Parser::DropTableStmt::get_table ( ) const
inline

Definition at line 1227 of file ParserNode.h.

References table_.

1227 { return table_.get(); }
std::unique_ptr< std::string > table_
Definition: ParserNode.h:1232

Member Data Documentation

bool Parser::DropTableStmt::if_exists_
private

Definition at line 1233 of file ParserNode.h.

Referenced by DropTableStmt(), and execute().

std::unique_ptr<std::string> Parser::DropTableStmt::table_
private

Definition at line 1232 of file ParserNode.h.

Referenced by DropTableStmt(), execute(), and get_table().


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