OmniSciDB  06b3bd477c
 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 1139 of file ParserNode.h.

Constructor & Destructor Documentation

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

Definition at line 1141 of file ParserNode.h.

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

Member Function Documentation

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

Implements Parser::DDLStmt.

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

3110  {
3111  auto& catalog = session.getCatalog();
3112 
3113  // TODO(adb): the catalog should be handling this locking.
3114  const auto execute_write_lock = mapd_unique_lock<mapd_shared_mutex>(
3117 
3118  const TableDescriptor* td{nullptr};
3119  std::unique_ptr<lockmgr::TableSchemaLockContainer<lockmgr::WriteLock>> td_with_lock;
3120 
3121  try {
3122  td_with_lock =
3123  std::make_unique<lockmgr::TableSchemaLockContainer<lockmgr::WriteLock>>(
3125  catalog, *table, false));
3126  td = (*td_with_lock)();
3127  } catch (const std::runtime_error& e) {
3128  if (if_exists) {
3129  return;
3130  } else {
3131  throw e;
3132  }
3133  }
3134 
3135  CHECK(td);
3136  CHECK(td_with_lock);
3137 
3138  // check access privileges
3139  if (!session.checkDBAccessPrivileges(
3141  throw std::runtime_error("Table " + *table +
3142  " will not be dropped. User has no proper privileges.");
3143  }
3144 
3146 
3147  auto table_data_write_lock =
3149  catalog.dropTable(td);
3150 
3151  // invalidate cached hashtable
3153 }
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:1146
static void invalidateCaches()
CHECK(cgen_state)
static const AccessPrivileges DROP_TABLE
Definition: DBObject.h:160
void validate_drop_table_type(const TableDescriptor *td, const TableType expected_table_type)
Definition: DdlUtils.cpp:537
Catalog & getCatalog() const
Definition: SessionInfo.h:65
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 1142 of file ParserNode.h.

References table.

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

Member Data Documentation

bool Parser::DropTableStmt::if_exists
private

Definition at line 1147 of file ParserNode.h.

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

Definition at line 1146 of file ParserNode.h.

Referenced by get_table().


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