OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ShowCreateServerCommand Class Reference

#include <DdlCommandExecutor.h>

+ Inheritance diagram for ShowCreateServerCommand:
+ Collaboration diagram for ShowCreateServerCommand:

Public Member Functions

 ShowCreateServerCommand (const DdlCommandData &ddl_data, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
 
ExecutionResult execute (bool read_only_mode) override
 
- Public Member Functions inherited from DdlCommand
 DdlCommand (const DdlCommandData &ddl_data, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
 

Private Attributes

std::string server_
 

Additional Inherited Members

- Protected Attributes inherited from DdlCommand
const DdlCommandDataddl_data_
 
std::shared_ptr
< Catalog_Namespace::SessionInfo
const > 
session_ptr_
 

Detailed Description

Definition at line 188 of file DdlCommandExecutor.h.

Constructor & Destructor Documentation

ShowCreateServerCommand::ShowCreateServerCommand ( const DdlCommandData ddl_data,
std::shared_ptr< Catalog_Namespace::SessionInfo const >  session_ptr 
)

Definition at line 2612 of file DdlCommandExecutor.cpp.

References CHECK, DdlCommand::ddl_data_, anonymous_namespace{DdlCommandExecutor.cpp}::extractPayload(), g_enable_fsi, and server_.

2615  : DdlCommand(ddl_data, session_ptr) {
2616  if (!g_enable_fsi) {
2617  throw std::runtime_error("Unsupported command: SHOW CREATE SERVER");
2618  }
2619  // Verify that members are valid
2620  auto& payload = extractPayload(ddl_data_);
2621  CHECK(payload.HasMember("serverName"));
2622  CHECK(payload["serverName"].IsString());
2623  server_ = (payload["serverName"].GetString());
2624 }
const DdlCommandData & ddl_data_
const rapidjson::Value & extractPayload(const DdlCommandData &ddl_data)
DdlCommand(const DdlCommandData &ddl_data, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
#define CHECK(condition)
Definition: Logger.h:291
bool g_enable_fsi
Definition: Catalog.cpp:96

+ Here is the call graph for this function:

Member Function Documentation

ExecutionResult ShowCreateServerCommand::execute ( bool  read_only_mode)
overridevirtual

Executes the DDL command corresponding to provided JSON payload.

Parameters
_returnresult of DDL command execution (if applicable)

Implements DdlCommand.

Definition at line 2626 of file DdlCommandExecutor.cpp.

References ResultSetLogicalValuesBuilder::create(), genLiteralStr(), legacylockmgr::getExecuteReadLock(), lockmgr::instance(), kTEXT, DBObject::loadKey(), server_, ServerDBObjectType, and DdlCommand::session_ptr_.

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

2626  {
2627  auto execute_read_lock = legacylockmgr::getExecuteReadLock();
2628  // valid in read_only_mode
2629 
2630  using namespace Catalog_Namespace;
2631  auto& catalog = session_ptr_->getCatalog();
2632  const auto server = catalog.getForeignServer(server_);
2633  if (!server) {
2634  throw std::runtime_error("Foreign server " + server_ + " does not exist.");
2635  }
2636  DBObject dbObject(server_, ServerDBObjectType);
2637  dbObject.loadKey(catalog);
2638  std::vector<DBObject> privObjects = {dbObject};
2639  if (!SysCatalog::instance().hasAnyPrivileges(session_ptr_->get_currentUser(),
2640  privObjects)) {
2641  throw std::runtime_error("Foreign server " + server_ + " does not exist.");
2642  }
2643  auto create_stmt = catalog.dumpCreateServer(server_);
2644 
2645  std::vector<std::string> labels{"create_server_sql"};
2646  std::vector<TargetMetaInfo> label_infos;
2647  label_infos.emplace_back(labels[0], SQLTypeInfo(kTEXT, true));
2648 
2649  std::vector<RelLogicalValues::RowValues> logical_values;
2650  logical_values.emplace_back(RelLogicalValues::RowValues{});
2651  logical_values.back().emplace_back(genLiteralStr(create_stmt));
2652 
2653  std::shared_ptr<ResultSet> rSet = std::shared_ptr<ResultSet>(
2654  ResultSetLogicalValuesBuilder::create(label_infos, logical_values));
2655 
2656  return ExecutionResult(rSet, label_infos);
2657 }
auto getExecuteReadLock()
static ResultSet * create(std::vector< TargetMetaInfo > &label_infos, std::vector< RelLogicalValues::RowValues > &logical_values)
Definition: sqltypes.h:79
T & instance()
Definition: LockMgr.cpp:101
static std::unique_ptr< RexLiteral > genLiteralStr(std::string val)
Definition: DBHandler.cpp:7770
std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr_
std::vector< std::unique_ptr< const RexScalar >> RowValues
Definition: RelAlgDag.h:2656

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

std::string ShowCreateServerCommand::server_
private

Definition at line 197 of file DdlCommandExecutor.h.

Referenced by execute(), and ShowCreateServerCommand().


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