OmniSciDB  1dac507f6e
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 1114 of file ParserNode.h.

Constructor & Destructor Documentation

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

Definition at line 1116 of file ParserNode.h.

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

Member Function Documentation

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

Implements Parser::DDLStmt.

Definition at line 2890 of file ParserNode.cpp.

References Catalog_Namespace::SessionInfo::get_currentUser(), Catalog_Namespace::SessionInfo::getCatalog(), TableDescriptor::isView, DBObject::loadKey(), DBObject::setPrivileges(), TableDBObjectType, AccessPrivileges::TRUNCATE_TABLE, and Catalog_Namespace::UserMetadata::userName.

2890  {
2891  auto& catalog = session.getCatalog();
2892  const TableDescriptor* td = catalog.getMetadataForTable(*table);
2893  if (td == nullptr) {
2894  throw std::runtime_error("Table " + *table + " does not exist.");
2895  }
2896 
2897  // check access privileges
2898  std::vector<DBObject> privObjects;
2899  DBObject dbObject(*table, TableDBObjectType);
2900  dbObject.loadKey(catalog);
2901  dbObject.setPrivileges(AccessPrivileges::TRUNCATE_TABLE);
2902  privObjects.push_back(dbObject);
2903  if (!SysCatalog::instance().checkPrivileges(session.get_currentUser(), privObjects)) {
2904  throw std::runtime_error("Table " + *table + " will not be truncated. User " +
2905  session.get_currentUser().userName +
2906  " has no proper privileges.");
2907  }
2908 
2909  if (td->isView) {
2910  throw std::runtime_error(*table + " is a view. Cannot Truncate.");
2911  }
2912  catalog.truncateTable(td);
2913 }
static const AccessPrivileges TRUNCATE_TABLE
Definition: DBObject.h:157
Catalog & getCatalog() const
Definition: SessionInfo.h:90
std::unique_ptr< std::string > table
Definition: ParserNode.h:1121
specifies the content in-memory of a row in the table metadata table
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:93

+ Here is the call graph for this function:

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

Definition at line 1117 of file ParserNode.h.

References table.

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

Member Data Documentation

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

Definition at line 1121 of file ParserNode.h.

Referenced by get_table().


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