OmniSciDB  1dac507f6e
 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 1099 of file ParserNode.h.

Constructor & Destructor Documentation

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

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

Implements Parser::DDLStmt.

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

2862  {
2863  auto& catalog = session.getCatalog();
2864 
2865  const TableDescriptor* td = catalog.getMetadataForTable(*table, false);
2866  if (td == nullptr) {
2867  if (if_exists) {
2868  return;
2869  }
2870  throw std::runtime_error("Table " + *table + " does not exist.");
2871  }
2872 
2873  // check access privileges
2874  if (!session.checkDBAccessPrivileges(
2876  throw std::runtime_error("Table " + *table +
2877  " will not be dropped. User has no proper privileges.");
2878  }
2879 
2880  if (td->isView) {
2881  throw std::runtime_error(*table + " is a view. Use DROP VIEW.");
2882  }
2883 
2884  auto chkptlLock = getTableLock<mapd_shared_mutex, mapd_unique_lock>(
2885  catalog, *table, LockType::CheckpointLock);
2886  auto table_write_lock = TableLockMgr::getWriteLockForTable(catalog, *table);
2887  catalog.dropTable(td);
2888 }
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
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 1102 of file ParserNode.h.

References table.

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

Member Data Documentation

bool Parser::DropTableStmt::if_exists
private

Definition at line 1107 of file ParserNode.h.

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

Definition at line 1106 of file ParserNode.h.

Referenced by get_table().


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