OmniSciDB  29e35f4d58
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 1099 of file ParserNode.h.

Constructor & Destructor Documentation

◆ DropTableStmt()

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

Definition at line 1101 of file ParserNode.h.

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

Member Function Documentation

◆ execute()

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

Implements Parser::DDLStmt.

Definition at line 2861 of file ParserNode.cpp.

References Catalog_Namespace::SessionInfo::checkDBAccessPrivileges(), Lock_Namespace::CheckpointLock, AccessPrivileges::DROP_TABLE, Catalog_Namespace::SessionInfo::getCatalog(), Lock_Namespace::TableLockMgrImpl< TableLockMgr >::getWriteLockForTable(), TableDescriptor::isView, and TableDBObjectType.

2861  {
2862  auto& catalog = session.getCatalog();
2863 
2864  const TableDescriptor* td = catalog.getMetadataForTable(*table, false);
2865  if (td == nullptr) {
2866  if (if_exists) {
2867  return;
2868  }
2869  throw std::runtime_error("Table " + *table + " does not exist.");
2870  }
2871 
2872  // check access privileges
2873  if (!session.checkDBAccessPrivileges(
2875  throw std::runtime_error("Table " + *table +
2876  " will not be dropped. User has no proper privileges.");
2877  }
2878 
2879  if (td->isView) {
2880  throw std::runtime_error(*table + " is a view. Use DROP VIEW.");
2881  }
2882 
2883  auto chkptlLock = getTableLock<mapd_shared_mutex, mapd_unique_lock>(
2884  catalog, *table, LockType::CheckpointLock);
2885  auto table_write_lock = TableLockMgr::getWriteLockForTable(catalog, *table);
2886  catalog.dropTable(td);
2887 }
std::unique_ptr< std::string > table
Definition: ParserNode.h:1106
static const AccessPrivileges DROP_TABLE
Definition: DBObject.h:152
Catalog & getCatalog() const
Definition: SessionInfo.h:90
bool checkDBAccessPrivileges(const DBObjectType &permissionType, const AccessPrivileges &privs, const std::string &objectName="") const
Definition: SessionInfo.cpp:24
specifies the content in-memory of a row in the table metadata table
+ Here is the call graph for this function:

◆ get_table()

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

Definition at line 1102 of file ParserNode.h.

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

Member Data Documentation

◆ if_exists

bool Parser::DropTableStmt::if_exists
private

Definition at line 1107 of file ParserNode.h.

◆ table

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

Definition at line 1106 of file ParserNode.h.


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