OmniSciDB  06b3bd477c
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Parser::ShowCreateTableStmt Class Reference

#include <ParserNode.h>

+ Inheritance diagram for Parser::ShowCreateTableStmt:
+ Collaboration diagram for Parser::ShowCreateTableStmt:

Public Member Functions

 ShowCreateTableStmt (std::string *tab)
 
std::string getCreateStmt ()
 
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_
 
std::string create_stmt_
 

Detailed Description

Definition at line 1791 of file ParserNode.h.

Constructor & Destructor Documentation

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

Definition at line 1793 of file ParserNode.h.

1793 : table_(tab) {}
std::unique_ptr< std::string > table_
Definition: ParserNode.h:1798

Member Function Documentation

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

Implements Parser::DDLStmt.

Definition at line 4320 of file ParserNode.cpp.

References legacylockmgr::ExecutorOuterLock, Catalog_Namespace::SessionInfo::get_currentUser(), Catalog_Namespace::SessionInfo::getCatalog(), legacylockmgr::LockMgr< MutexType, KeyType >::getMutex(), Catalog_Namespace::UserMetadata::isSuper, DBObject::loadKey(), TableDBObjectType, and ViewDBObjectType.

4320  {
4321  using namespace Catalog_Namespace;
4322 
4323  const auto execute_read_lock = mapd_shared_lock<mapd_shared_mutex>(
4326 
4327  auto& catalog = session.getCatalog();
4328  const TableDescriptor* td = catalog.getMetadataForTable(*table_);
4329  if (!td) {
4330  throw std::runtime_error("Table/View " + *table_ + " does not exist.");
4331  }
4332 
4333  DBObject dbObject(td->tableName, td->isView ? ViewDBObjectType : TableDBObjectType);
4334  dbObject.loadKey(catalog);
4335  std::vector<DBObject> privObjects = {dbObject};
4336 
4337  if (!SysCatalog::instance().hasAnyPrivileges(session.get_currentUser(), privObjects)) {
4338  throw std::runtime_error("Table/View " + *table_ + " does not exist.");
4339  }
4340  if (td->isView && !session.get_currentUser().isSuper) {
4341  // TODO: we need to run a validate query to ensure the user has access to the
4342  // underlying table, but we do not have any of the machinery in here. Disable for now,
4343  // unless the current user is a super user.
4344  throw std::runtime_error("SHOW CREATE TABLE not yet supported for views");
4345  }
4346 
4347  create_stmt_ = catalog.dumpCreateTable(td);
4348 }
Catalog & getCatalog() const
Definition: SessionInfo.h:65
std::unique_ptr< std::string > table_
Definition: ParserNode.h:1798
static std::shared_ptr< MutexType > getMutex(const LockType lockType, const KeyType &key)
Definition: LegacyLockMgr.h:51
specifies the content in-memory of a row in the table metadata table
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:68
std::atomic< bool > isSuper
Definition: SysCatalog.h:96

+ Here is the call graph for this function:

std::string Parser::ShowCreateTableStmt::getCreateStmt ( )
inline

Definition at line 1794 of file ParserNode.h.

References create_stmt_.

1794 { return create_stmt_; }

Member Data Documentation

std::string Parser::ShowCreateTableStmt::create_stmt_
private

Definition at line 1799 of file ParserNode.h.

Referenced by getCreateStmt().

std::unique_ptr<std::string> Parser::ShowCreateTableStmt::table_
private

Definition at line 1798 of file ParserNode.h.


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