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

#include <DdlCommandExecutor.h>

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

Public Member Functions

 DropForeignServerCommand (const DdlCommandData &ddl_data, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
 
ExecutionResult execute () override
 
- Public Member Functions inherited from DdlCommand
 DdlCommand (const DdlCommandData &ddl_data, 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 DdlCommandDataddl_data_
 
std::shared_ptr
< Catalog_Namespace::SessionInfo
const
session_ptr_
 

Detailed Description

Definition at line 82 of file DdlCommandExecutor.h.

Constructor & Destructor Documentation

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

Definition at line 802 of file DdlCommandExecutor.cpp.

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

805  : DdlCommand(ddl_data, session_ptr) {
806  auto& ddl_payload = extractPayload(ddl_data_);
807  CHECK(ddl_payload.HasMember("serverName"));
808  CHECK(ddl_payload["serverName"].IsString());
809  CHECK(ddl_payload.HasMember("ifExists"));
810  CHECK(ddl_payload["ifExists"].IsBool());
811 }
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:211

+ Here is the call graph for this function:

Member Function Documentation

ExecutionResult DropForeignServerCommand::execute ( )
overridevirtual

Executes the DDL command corresponding to provided JSON payload.

Parameters
_returnresult of DDL command execution (if applicable)

Implements DdlCommand.

Definition at line 813 of file DdlCommandExecutor.cpp.

References DdlCommand::ddl_data_, AccessPrivileges::DROP_SERVER, anonymous_namespace{DdlCommandExecutor.cpp}::extractPayload(), Catalog_Namespace::SysCatalog::instance(), DdlCommand::isDefaultServer(), Catalog_Namespace::SysCatalog::revokeDBObjectPrivilegesFromAll(), ServerDBObjectType, and DdlCommand::session_ptr_.

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

813  {
814  auto& ddl_payload = extractPayload(ddl_data_);
815  std::string server_name = ddl_payload["serverName"].GetString();
816  if (isDefaultServer(server_name)) {
817  throw std::runtime_error{"OmniSci default servers cannot be dropped."};
818  }
819  bool if_exists = ddl_payload["ifExists"].GetBool();
820  if (!session_ptr_->getCatalog().getForeignServer(server_name)) {
821  if (if_exists) {
822  return ExecutionResult();
823  } else {
824  throw std::runtime_error{"Foreign server with name \"" + server_name +
825  "\" can not be dropped. Server does not exist."};
826  }
827  }
828  // check access privileges
829  if (!session_ptr_->checkDBAccessPrivileges(
831  throw std::runtime_error("Server " + server_name +
832  " will not be dropped. User has no DROP SERVER privileges.");
833  }
835  DBObject(server_name, ServerDBObjectType), session_ptr_->get_catalog_ptr().get());
836  session_ptr_->getCatalog().dropForeignServer(ddl_payload["serverName"].GetString());
837 
838  return ExecutionResult();
839 }
static const AccessPrivileges DROP_SERVER
Definition: DBObject.h:191
void revokeDBObjectPrivilegesFromAll(DBObject object, Catalog *catalog)
const DdlCommandData & ddl_data_
static SysCatalog & instance()
Definition: SysCatalog.h:326
const rapidjson::Value & extractPayload(const DdlCommandData &ddl_data)
bool isDefaultServer(const std::string &server_name)
std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr_

+ Here is the call graph for this function:

+ Here is the caller graph for this function:


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