OmniSciDB  ba1bac9284
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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) 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 1175 of file ParserNode.h.

Constructor & Destructor Documentation

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

Definition at line 1177 of file ParserNode.h.

1177 : table(tab), if_exists(i) {}
std::unique_ptr< std::string > table
Definition: ParserNode.h:1184
Parser::DropTableStmt::DropTableStmt ( const rapidjson::Value &  payload)

Definition at line 3585 of file ParserNode.cpp.

References CHECK, json_bool(), json_str(), and test_readcsv::table.

3585  {
3586  CHECK(payload.HasMember("tableName"));
3587  table = std::make_unique<std::string>(json_str(payload["tableName"]));
3588 
3589  if_exists = false;
3590  if (payload.HasMember("ifExists")) {
3591  if_exists = json_bool(payload["ifExists"]);
3592  }
3593 }
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:1184
#define CHECK(condition)
Definition: Logger.h:206

+ Here is the call graph for this function:

Member Function Documentation

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

Implements Parser::DDLStmt.

Definition at line 3595 of file ParserNode.cpp.

References CHECK, Catalog_Namespace::SessionInfo::checkDBAccessPrivileges(), AccessPrivileges::DROP_TABLE, legacylockmgr::ExecutorOuterLock, Catalog_Namespace::SessionInfo::getCatalog(), legacylockmgr::LockMgr< MutexType, KeyType >::getMutex(), lockmgr::TableLockMgrImpl< TableDataLockMgr >::getWriteLockForTable(), CacheInvalidator< CACHE_HOLDING_TYPES >::invalidateCaches(), test_readcsv::table, ddl_utils::TABLE, TableDBObjectType, and ddl_utils::validate_table_type().

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

3595  {
3596  auto& catalog = session.getCatalog();
3597 
3598  // TODO(adb): the catalog should be handling this locking.
3599  const auto execute_write_lock = mapd_unique_lock<mapd_shared_mutex>(
3602 
3603  const TableDescriptor* td{nullptr};
3604  std::unique_ptr<lockmgr::TableSchemaLockContainer<lockmgr::WriteLock>> td_with_lock;
3605 
3606  try {
3607  td_with_lock =
3608  std::make_unique<lockmgr::TableSchemaLockContainer<lockmgr::WriteLock>>(
3610  catalog, *table, false));
3611  td = (*td_with_lock)();
3612  } catch (const std::runtime_error& e) {
3613  if (if_exists) {
3614  return;
3615  } else {
3616  throw e;
3617  }
3618  }
3619 
3620  CHECK(td);
3621  CHECK(td_with_lock);
3622 
3623  // check access privileges
3624  if (!session.checkDBAccessPrivileges(
3626  throw std::runtime_error("Table " + *table +
3627  " will not be dropped. User has no proper privileges.");
3628  }
3629 
3631 
3632  auto table_data_write_lock =
3634  catalog.dropTable(td);
3635 
3636  // invalidate cached hashtable
3638 }
static WriteLock getWriteLockForTable(const Catalog_Namespace::Catalog &cat, const std::string &table_name)
Definition: LockMgrImpl.h:155
std::unique_ptr< std::string > table
Definition: ParserNode.h:1184
static void invalidateCaches()
static const AccessPrivileges DROP_TABLE
Definition: DBObject.h:161
Catalog & getCatalog() const
Definition: SessionInfo.h:67
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:554
#define CHECK(condition)
Definition: Logger.h:206
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 1180 of file ParserNode.h.

References table.

1180 { return table.get(); }
std::unique_ptr< std::string > table
Definition: ParserNode.h:1184

Member Data Documentation

bool Parser::DropTableStmt::if_exists
private

Definition at line 1185 of file ParserNode.h.

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

Definition at line 1184 of file ParserNode.h.

Referenced by get_table().


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