OmniSciDB  cecceef8da
 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)
 
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 1135 of file ParserNode.h.

Constructor & Destructor Documentation

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

Definition at line 1137 of file ParserNode.h.

1137 : table(tab), if_exists(i) {}
std::unique_ptr< std::string > table
Definition: ParserNode.h:1142

Member Function Documentation

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

Implements Parser::DDLStmt.

Definition at line 2921 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(), ddl_utils::TABLE, TableDBObjectType, and ddl_utils::validate_drop_table_type().

2921  {
2922  auto& catalog = session.getCatalog();
2923 
2924  // TODO(adb): the catalog should be handling this locking.
2925  const auto execute_write_lock = mapd_unique_lock<mapd_shared_mutex>(
2928 
2929  const TableDescriptor* td{nullptr};
2930  std::unique_ptr<lockmgr::TableSchemaLockContainer<lockmgr::WriteLock>> td_with_lock;
2931 
2932  try {
2933  td_with_lock =
2934  std::make_unique<lockmgr::TableSchemaLockContainer<lockmgr::WriteLock>>(
2936  catalog, *table, false));
2937  td = (*td_with_lock)();
2938  } catch (const std::runtime_error& e) {
2939  if (if_exists) {
2940  return;
2941  } else {
2942  throw e;
2943  }
2944  }
2945 
2946  CHECK(td);
2947  CHECK(td_with_lock);
2948 
2949  // check access privileges
2950  if (!session.checkDBAccessPrivileges(
2952  throw std::runtime_error("Table " + *table +
2953  " will not be dropped. User has no proper privileges.");
2954  }
2955 
2957 
2958  auto table_data_write_lock =
2960  catalog.dropTable(td);
2961 }
static WriteLock getWriteLockForTable(const Catalog_Namespace::Catalog &cat, const std::string &table_name)
Definition: LockMgrImpl.h:88
std::unique_ptr< std::string > table
Definition: ParserNode.h:1142
CHECK(cgen_state)
static const AccessPrivileges DROP_TABLE
Definition: DBObject.h:159
void validate_drop_table_type(const TableDescriptor *td, const TableType expected_table_type)
Definition: DdlUtils.cpp:548
Catalog & getCatalog() const
Definition: SessionInfo.h:76
static std::shared_ptr< MutexType > getMutex(const LockType lockType, const KeyType &key)
Definition: LegacyLockMgr.h:51
specifies the content in-memory of a row in the table metadata table
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:

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

Definition at line 1138 of file ParserNode.h.

References table.

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

Member Data Documentation

bool Parser::DropTableStmt::if_exists
private

Definition at line 1143 of file ParserNode.h.

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

Definition at line 1142 of file ParserNode.h.

Referenced by get_table().


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