OmniSciDB  04ee39c94c
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 1093 of file ParserNode.h.

Constructor & Destructor Documentation

◆ DropTableStmt()

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

Definition at line 1095 of file ParserNode.h.

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

Member Function Documentation

◆ execute()

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

Implements Parser::DDLStmt.

Definition at line 2762 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.

2762  {
2763  auto& catalog = session.getCatalog();
2764 
2765  const TableDescriptor* td = catalog.getMetadataForTable(*table, false);
2766  if (td == nullptr) {
2767  if (if_exists) {
2768  return;
2769  }
2770  throw std::runtime_error("Table " + *table + " does not exist.");
2771  }
2772 
2773  // check access privileges
2774  if (!session.checkDBAccessPrivileges(
2776  throw std::runtime_error("Table " + *table +
2777  " will not be dropped. User has no proper privileges.");
2778  }
2779 
2780  if (td->isView) {
2781  throw std::runtime_error(*table + " is a view. Use DROP VIEW.");
2782  }
2783 
2784  auto chkptlLock = getTableLock<mapd_shared_mutex, mapd_unique_lock>(
2785  catalog, *table, LockType::CheckpointLock);
2786  auto table_write_lock = TableLockMgr::getWriteLockForTable(catalog, *table);
2787  catalog.dropTable(td);
2788 }
std::unique_ptr< std::string > table
Definition: ParserNode.h:1100
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 1096 of file ParserNode.h.

References session.

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

Member Data Documentation

◆ if_exists

bool Parser::DropTableStmt::if_exists
private

Definition at line 1101 of file ParserNode.h.

◆ table

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

Definition at line 1100 of file ParserNode.h.


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