OmniSciDB  ba1bac9284
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 674 of file DdlCommandExecutor.cpp.

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

677  : DdlCommand(ddl_data, session_ptr) {
678  auto& ddl_payload = extractPayload(ddl_data_);
679  CHECK(ddl_payload.HasMember("serverName"));
680  CHECK(ddl_payload["serverName"].IsString());
681  CHECK(ddl_payload.HasMember("ifExists"));
682  CHECK(ddl_payload["ifExists"].IsBool());
683 }
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:206

+ 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 685 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().

685  {
686  auto& ddl_payload = extractPayload(ddl_data_);
687  std::string server_name = ddl_payload["serverName"].GetString();
688  if (isDefaultServer(server_name)) {
689  throw std::runtime_error{"OmniSci default servers cannot be dropped."};
690  }
691  bool if_exists = ddl_payload["ifExists"].GetBool();
692  if (!session_ptr_->getCatalog().getForeignServer(server_name)) {
693  if (if_exists) {
694  return ExecutionResult();
695  } else {
696  throw std::runtime_error{"Foreign server with name \"" + server_name +
697  "\" can not be dropped. Server does not exist."};
698  }
699  }
700  // check access privileges
701  if (!session_ptr_->checkDBAccessPrivileges(
703  throw std::runtime_error("Server " + server_name +
704  " will not be dropped. User has no DROP SERVER privileges.");
705  }
707  DBObject(server_name, ServerDBObjectType), session_ptr_->get_catalog_ptr().get());
708  session_ptr_->getCatalog().dropForeignServer(ddl_payload["serverName"].GetString());
709 
710  return ExecutionResult();
711 }
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:292
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: