OmniSciDB  2e3a973ef4
DropForeignServerCommand Class Reference

#include <DdlCommandExecutor.h>

+ Inheritance diagram for DropForeignServerCommand:
+ Collaboration diagram for DropForeignServerCommand:

Public Member Functions

 DropForeignServerCommand (const rapidjson::Value &ddl_payload, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
 
void execute (TQueryResult &_return) override
 
- Public Member Functions inherited from DdlCommand
 DdlCommand (const rapidjson::Value &ddl_payload, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
 

Additional Inherited Members

- Protected Member Functions inherited from DdlCommand
bool isDefaultServer (const std::string &server_name)
 
- Protected Attributes inherited from DdlCommand
const rapidjson::Value & ddl_payload_
 
std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr_
 

Detailed Description

Definition at line 76 of file DdlCommandExecutor.h.

Constructor & Destructor Documentation

◆ DropForeignServerCommand()

DropForeignServerCommand::DropForeignServerCommand ( const rapidjson::Value &  ddl_payload,
std::shared_ptr< Catalog_Namespace::SessionInfo const >  session_ptr 
)

Definition at line 336 of file DdlCommandExecutor.cpp.

References CHECK.

339  : DdlCommand(ddl_payload, session_ptr) {
340  CHECK(ddl_payload.HasMember("serverName"));
341  CHECK(ddl_payload["serverName"].IsString());
342  CHECK(ddl_payload.HasMember("ifExists"));
343  CHECK(ddl_payload["ifExists"].IsBool());
344 }
DdlCommand(const rapidjson::Value &ddl_payload, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
#define CHECK(condition)
Definition: Logger.h:197

Member Function Documentation

◆ execute()

void DropForeignServerCommand::execute ( TQueryResult &  _return)
overridevirtual

Executes the DDL command corresponding to provided JSON payload.

Parameters
_returnresult of DDL command execution (if applicable)

Implements DdlCommand.

Definition at line 346 of file DdlCommandExecutor.cpp.

References DdlCommand::ddl_payload_, AccessPrivileges::DROP_SERVER, Catalog_Namespace::SysCatalog::instance(), DdlCommand::isDefaultServer(), Catalog_Namespace::SysCatalog::revokeDBObjectPrivilegesFromAll(), ServerDBObjectType, and DdlCommand::session_ptr_.

346  {
347  std::string server_name = ddl_payload_["serverName"].GetString();
348  if (isDefaultServer(server_name)) {
349  throw std::runtime_error{"OmniSci default servers cannot be dropped."};
350  }
351  bool if_exists = ddl_payload_["ifExists"].GetBool();
352  if (!session_ptr_->getCatalog().getForeignServer(server_name)) {
353  if (if_exists) {
354  return;
355  } else {
356  throw std::runtime_error{"Foreign server with name \"" + server_name +
357  "\" does not exist."};
358  }
359  }
360  // check access privileges
361  if (!session_ptr_->checkDBAccessPrivileges(
363  throw std::runtime_error("Server " + server_name +
364  " will not be dropped. User has no DROP SERVER privileges.");
365  }
367  DBObject(server_name, ServerDBObjectType), session_ptr_->get_catalog_ptr().get());
368  session_ptr_->getCatalog().dropForeignServer(ddl_payload_["serverName"].GetString());
369 }
static const AccessPrivileges DROP_SERVER
Definition: DBObject.h:190
void revokeDBObjectPrivilegesFromAll(DBObject object, Catalog *catalog)
static SysCatalog & instance()
Definition: SysCatalog.h:286
bool isDefaultServer(const std::string &server_name)
const rapidjson::Value & ddl_payload_
std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr_
+ Here is the call graph for this function:

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