OmniSciDB  ba1bac9284
 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 1845 of file ParserNode.h.

Constructor & Destructor Documentation

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

Definition at line 1847 of file ParserNode.h.

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

Member Function Documentation

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

Implements Parser::DDLStmt.

Definition at line 5239 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().

5239  {
5240  using namespace Catalog_Namespace;
5241 
5242  const auto execute_read_lock = mapd_shared_lock<mapd_shared_mutex>(
5245 
5246  auto& catalog = session.getCatalog();
5247  const TableDescriptor* td = catalog.getMetadataForTable(*table_, false);
5248  if (!td) {
5249  throw std::runtime_error("Table/View " + *table_ + " does not exist.");
5250  }
5251 
5252  DBObject dbObject(td->tableName, td->isView ? ViewDBObjectType : TableDBObjectType);
5253  dbObject.loadKey(catalog);
5254  std::vector<DBObject> privObjects = {dbObject};
5255 
5256  if (!SysCatalog::instance().hasAnyPrivileges(session.get_currentUser(), privObjects)) {
5257  throw std::runtime_error("Table/View " + *table_ + " does not exist.");
5258  }
5259  if (td->isView && !session.get_currentUser().isSuper) {
5260  // TODO: we need to run a validate query to ensure the user has access to the
5261  // underlying table, but we do not have any of the machinery in here. Disable for
5262  // now, unless the current user is a super user.
5263  throw std::runtime_error("SHOW CREATE TABLE not yet supported for views");
5264  }
5265 
5266  create_stmt_ = catalog.dumpCreateTable(td);
5267 }
Catalog & getCatalog() const
Definition: SessionInfo.h:67
std::unique_ptr< std::string > table_
Definition: ParserNode.h:1852
static std::shared_ptr< MutexType > getMutex(const LockType lockType, const KeyType &key)
Definition: LegacyLockMgr.h:51
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:73
std::atomic< bool > isSuper
Definition: SysCatalog.h:99

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 1848 of file ParserNode.h.

References create_stmt_.

Referenced by DBHandler::sql_execute_impl().

1848 { return create_stmt_; }

+ Here is the caller graph for this function:

Member Data Documentation

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

Definition at line 1853 of file ParserNode.h.

Referenced by getCreateStmt().

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

Definition at line 1852 of file ParserNode.h.


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