OmniSciDB  dfae7c3b14
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

◆ ShowCreateTableStmt()

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

◆ execute()

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

Implements Parser::DDLStmt.

Definition at line 4312 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, TableDescriptor::isView, DBObject::loadKey(), TableDBObjectType, TableDescriptor::tableName, and ViewDBObjectType.

Referenced by omnisci.cursor.Cursor::executemany().

4312  {
4313  using namespace Catalog_Namespace;
4314 
4315  const auto execute_read_lock = mapd_shared_lock<mapd_shared_mutex>(
4318 
4319  auto& catalog = session.getCatalog();
4320  const TableDescriptor* td = catalog.getMetadataForTable(*table_, false);
4321  if (!td) {
4322  throw std::runtime_error("Table/View " + *table_ + " does not exist.");
4323  }
4324 
4326  dbObject.loadKey(catalog);
4327  std::vector<DBObject> privObjects = {dbObject};
4328 
4329  if (!SysCatalog::instance().hasAnyPrivileges(session.get_currentUser(), privObjects)) {
4330  throw std::runtime_error("Table/View " + *table_ + " does not exist.");
4331  }
4332  if (td->isView && !session.get_currentUser().isSuper) {
4333  // TODO: we need to run a validate query to ensure the user has access to the
4334  // underlying table, but we do not have any of the machinery in here. Disable for now,
4335  // unless the current user is a super user.
4336  throw std::runtime_error("SHOW CREATE TABLE not yet supported for views");
4337  }
4338 
4339  create_stmt_ = catalog.dumpCreateTable(td);
4340 }
std::string tableName
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:68
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
std::atomic< bool > isSuper
Definition: SysCatalog.h:94
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCreateStmt()

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

Definition at line 1794 of file ParserNode.h.

1794 { return create_stmt_; }

Member Data Documentation

◆ create_stmt_

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

Definition at line 1799 of file ParserNode.h.

◆ table_

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: