OmniSciDB  eb3a3d0a03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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)
 
 ShowCreateTableStmt (const rapidjson::Value &payload)
 
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 1837 of file ParserNode.h.

Constructor & Destructor Documentation

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

Definition at line 1839 of file ParserNode.h.

1839 : table_(tab) {}
std::unique_ptr< std::string > table_
Definition: ParserNode.h:1846
Parser::ShowCreateTableStmt::ShowCreateTableStmt ( const rapidjson::Value &  payload)

Definition at line 5564 of file ParserNode.cpp.

References CHECK, json_str(), and table_.

5564  {
5565  CHECK(payload.HasMember("tableName"));
5566  table_ = std::make_unique<std::string>(json_str(payload["tableName"]));
5567 }
const std::string json_str(const rapidjson::Value &obj) noexcept
Definition: JsonAccessors.h:44
std::unique_ptr< std::string > table_
Definition: ParserNode.h:1846
#define CHECK(condition)
Definition: Logger.h:209

+ Here is the call graph for this function:

Member Function Documentation

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

Implements Parser::DDLStmt.

Definition at line 5569 of file ParserNode.cpp.

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

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

5569  {
5570  using namespace Catalog_Namespace;
5571 
5572  const auto execute_read_lock = mapd_shared_lock<mapd_shared_mutex>(
5575 
5576  auto& catalog = session.getCatalog();
5577  const TableDescriptor* td = catalog.getMetadataForTable(*table_, false);
5578  if (!td) {
5579  throw std::runtime_error("Table/View " + *table_ + " does not exist.");
5580  }
5581 
5582  DBObject dbObject(td->tableName, td->isView ? ViewDBObjectType : TableDBObjectType);
5583  dbObject.loadKey(catalog);
5584  std::vector<DBObject> privObjects = {dbObject};
5585 
5586  if (!SysCatalog::instance().hasAnyPrivileges(session.get_currentUser(), privObjects)) {
5587  throw std::runtime_error("Table/View " + *table_ + " does not exist.");
5588  }
5589  if (td->isView && !session.get_currentUser().isSuper) {
5590  // TODO: we need to run a validate query to ensure the user has access to the
5591  // underlying table, but we do not have any of the machinery in here. Disable
5592  // for now, unless the current user is a super user.
5593  throw std::runtime_error("SHOW CREATE TABLE not yet supported for views");
5594  }
5595 
5596  create_stmt_ = catalog.dumpCreateTable(td);
5597 }
Catalog & getCatalog() const
Definition: SessionInfo.h:67
std::unique_ptr< std::string > table_
Definition: ParserNode.h:1846
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:118

+ 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 1842 of file ParserNode.h.

References create_stmt_.

Referenced by DBHandler::sql_execute_impl().

1842 { return create_stmt_; }

+ Here is the caller graph for this function:

Member Data Documentation

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

Definition at line 1847 of file ParserNode.h.

Referenced by execute(), and getCreateStmt().

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

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