OmniSciDB  eb3a3d0a03
 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) 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 1203 of file ParserNode.h.

Constructor & Destructor Documentation

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

Definition at line 1205 of file ParserNode.h.

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

Definition at line 3705 of file ParserNode.cpp.

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

3705  {
3706  CHECK(payload.HasMember("tableName"));
3707  table_ = std::make_unique<std::string>(json_str(payload["tableName"]));
3708 
3709  if_exists_ = false;
3710  if (payload.HasMember("ifExists")) {
3711  if_exists_ = json_bool(payload["ifExists"]);
3712  }
3713 }
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:1212
#define CHECK(condition)
Definition: Logger.h:209

+ 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 3715 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(), if_exists_, CacheInvalidator< CACHE_HOLDING_TYPES >::invalidateCaches(), ddl_utils::TABLE, table_, TableDBObjectType, and ddl_utils::validate_table_type().

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

3715  {
3716  auto& catalog = session.getCatalog();
3717 
3718  // TODO(adb): the catalog should be handling this locking.
3719  const auto execute_write_lock = mapd_unique_lock<mapd_shared_mutex>(
3722 
3723  const TableDescriptor* td{nullptr};
3724  std::unique_ptr<lockmgr::TableSchemaLockContainer<lockmgr::WriteLock>> td_with_lock;
3725 
3726  try {
3727  td_with_lock =
3728  std::make_unique<lockmgr::TableSchemaLockContainer<lockmgr::WriteLock>>(
3730  catalog, *table_, false));
3731  td = (*td_with_lock)();
3732  } catch (const std::runtime_error& e) {
3733  if (if_exists_) {
3734  return;
3735  } else {
3736  throw e;
3737  }
3738  }
3739 
3740  CHECK(td);
3741  CHECK(td_with_lock);
3742 
3743  // check access privileges
3744  if (!session.checkDBAccessPrivileges(
3746  throw std::runtime_error("Table " + *table_ +
3747  " will not be dropped. User has no proper privileges.");
3748  }
3749 
3751 
3752  auto table_data_write_lock =
3754  catalog.dropTable(td);
3755 
3756  // invalidate cached hashtable
3758 }
static WriteLock getWriteLockForTable(const Catalog_Namespace::Catalog &cat, const std::string &table_name)
Definition: LockMgrImpl.h:155
static void invalidateCaches()
static const AccessPrivileges DROP_TABLE
Definition: DBObject.h:161
std::unique_ptr< std::string > table_
Definition: ParserNode.h:1212
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:650
#define CHECK(condition)
Definition: Logger.h:209
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 1208 of file ParserNode.h.

References table_.

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

Member Data Documentation

bool Parser::DropTableStmt::if_exists_
private

Definition at line 1213 of file ParserNode.h.

Referenced by DropTableStmt(), and execute().

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

Definition at line 1212 of file ParserNode.h.

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


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