OmniSciDB  95562058bd
 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 3109 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().

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

3109  {
3110  auto& catalog = session.getCatalog();
3111 
3112  // TODO(adb): the catalog should be handling this locking.
3113  const auto execute_write_lock = mapd_unique_lock<mapd_shared_mutex>(
3116 
3117  const TableDescriptor* td{nullptr};
3118  std::unique_ptr<lockmgr::TableSchemaLockContainer<lockmgr::WriteLock>> td_with_lock;
3119 
3120  try {
3121  td_with_lock =
3122  std::make_unique<lockmgr::TableSchemaLockContainer<lockmgr::WriteLock>>(
3124  catalog, *table, false));
3125  td = (*td_with_lock)();
3126  } catch (const std::runtime_error& e) {
3127  if (if_exists) {
3128  return;
3129  } else {
3130  throw e;
3131  }
3132  }
3133 
3134  CHECK(td);
3135  CHECK(td_with_lock);
3136 
3137  // check access privileges
3138  if (!session.checkDBAccessPrivileges(
3140  throw std::runtime_error("Table " + *table +
3141  " will not be dropped. User has no proper privileges.");
3142  }
3143 
3145 
3146  auto table_data_write_lock =
3148  catalog.dropTable(td);
3149 
3150  // invalidate cached hashtable
3152 }
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()
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
#define CHECK(condition)
Definition: Logger.h:197
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:

+ Here is the caller 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: