OmniSciDB  c0231cc57d
 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 135 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 1876 of file DdlCommandExecutor.cpp.

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

1879  : DdlCommand(ddl_data, session_ptr) {
1880  if (!g_enable_fsi) {
1881  throw std::runtime_error("Unsupported command: SHOW CREATE SERVER");
1882  }
1883  // Verify that members are valid
1884  auto& payload = extractPayload(ddl_data_);
1885  CHECK(payload.HasMember("serverName"));
1886  CHECK(payload["serverName"].IsString());
1887  server_ = (payload["serverName"].GetString());
1888 }
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:222
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 1890 of file DdlCommandExecutor.cpp.

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

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

1890  {
1891  // valid in read_only_mode
1892 
1893  using namespace Catalog_Namespace;
1894  auto& catalog = session_ptr_->getCatalog();
1895  const auto server = catalog.getForeignServer(server_);
1896  if (!server) {
1897  throw std::runtime_error("Foreign server " + server_ + " does not exist.");
1898  }
1899  DBObject dbObject(server_, ServerDBObjectType);
1900  dbObject.loadKey(catalog);
1901  std::vector<DBObject> privObjects = {dbObject};
1902  if (!SysCatalog::instance().hasAnyPrivileges(session_ptr_->get_currentUser(),
1903  privObjects)) {
1904  throw std::runtime_error("Foreign server " + server_ + " does not exist.");
1905  }
1906  auto create_stmt = catalog.dumpCreateServer(server_);
1907 
1908  std::vector<std::string> labels{"create_server_sql"};
1909  std::vector<TargetMetaInfo> label_infos;
1910  label_infos.emplace_back(labels[0], SQLTypeInfo(kTEXT, true));
1911 
1912  std::vector<RelLogicalValues::RowValues> logical_values;
1913  logical_values.emplace_back(RelLogicalValues::RowValues{});
1914  logical_values.back().emplace_back(genLiteralStr(create_stmt));
1915 
1916  std::shared_ptr<ResultSet> rSet = std::shared_ptr<ResultSet>(
1917  ResultSetLogicalValuesBuilder::create(label_infos, logical_values));
1918 
1919  return ExecutionResult(rSet, label_infos);
1920 }
static ResultSet * create(std::vector< TargetMetaInfo > &label_infos, std::vector< RelLogicalValues::RowValues > &logical_values)
Definition: sqltypes.h:66
static std::unique_ptr< RexLiteral > genLiteralStr(std::string val)
Definition: DBHandler.cpp:7263
std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr_
std::vector< std::unique_ptr< const RexScalar >> RowValues
Definition: RelAlgDag.h:2226

+ 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 144 of file DdlCommandExecutor.h.

Referenced by execute(), and ShowCreateServerCommand().


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