OmniSciDB  04ee39c94c
Parser::TruncateTableStmt Class Reference

#include <ParserNode.h>

+ Inheritance diagram for Parser::TruncateTableStmt:
+ Collaboration diagram for Parser::TruncateTableStmt:

Public Member Functions

 TruncateTableStmt (std::string *tab)
 
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
 

Detailed Description

Definition at line 1108 of file ParserNode.h.

Constructor & Destructor Documentation

◆ TruncateTableStmt()

Parser::TruncateTableStmt::TruncateTableStmt ( std::string *  tab)
inline

Definition at line 1110 of file ParserNode.h.

1110 : table(tab) {}
std::unique_ptr< std::string > table
Definition: ParserNode.h:1115

Member Function Documentation

◆ execute()

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

Implements Parser::DDLStmt.

Definition at line 2790 of file ParserNode.cpp.

References Catalog_Namespace::SessionInfo::get_currentUser(), Catalog_Namespace::SessionInfo::getCatalog(), TableDescriptor::isView, DBObject::loadKey(), anonymous_namespace{DBObjectPrivilegesTest.cpp}::privObjects, DBObject::setPrivileges(), TableDBObjectType, AccessPrivileges::TRUNCATE_TABLE, and Catalog_Namespace::UserMetadata::userName.

2790  {
2791  auto& catalog = session.getCatalog();
2792  const TableDescriptor* td = catalog.getMetadataForTable(*table);
2793  if (td == nullptr) {
2794  throw std::runtime_error("Table " + *table + " does not exist.");
2795  }
2796 
2797  // check access privileges
2798  std::vector<DBObject> privObjects;
2799  DBObject dbObject(*table, TableDBObjectType);
2800  dbObject.loadKey(catalog);
2801  dbObject.setPrivileges(AccessPrivileges::TRUNCATE_TABLE);
2802  privObjects.push_back(dbObject);
2803  if (!SysCatalog::instance().checkPrivileges(session.get_currentUser(), privObjects)) {
2804  throw std::runtime_error("Table " + *table + " will not be truncated. User " +
2805  session.get_currentUser().userName +
2806  " has no proper privileges.");
2807  }
2808 
2809  if (td->isView) {
2810  throw std::runtime_error(*table + " is a view. Cannot Truncate.");
2811  }
2812  catalog.truncateTable(td);
2813 }
static const AccessPrivileges TRUNCATE_TABLE
Definition: DBObject.h:157
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:93
Catalog & getCatalog() const
Definition: SessionInfo.h:90
std::unique_ptr< std::string > table
Definition: ParserNode.h:1115
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::TruncateTableStmt::get_table ( ) const
inline

Definition at line 1111 of file ParserNode.h.

References session.

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

Member Data Documentation

◆ table

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

Definition at line 1115 of file ParserNode.h.


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