OmniSciDB  c0231cc57d
 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 (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)
 

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 81 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 958 of file DdlCommandExecutor.cpp.

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

961  : DdlCommand(ddl_data, session_ptr) {
962  if (!g_enable_fsi) {
963  throw std::runtime_error("Unsupported command: DROP FOREIGN SERVER");
964  }
965  auto& ddl_payload = extractPayload(ddl_data_);
966  CHECK(ddl_payload.HasMember("serverName"));
967  CHECK(ddl_payload["serverName"].IsString());
968  CHECK(ddl_payload.HasMember("ifExists"));
969  CHECK(ddl_payload["ifExists"].IsBool());
970 }
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 DropForeignServerCommand::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 972 of file DdlCommandExecutor.cpp.

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

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

972  {
973  if (read_only_mode) {
974  throw std::runtime_error("DROP FOREIGN SERVER invalid in read only mode.");
975  }
976  auto& ddl_payload = extractPayload(ddl_data_);
977  std::string server_name = ddl_payload["serverName"].GetString();
978  if (is_default_server(server_name)) {
979  throw std::runtime_error{"Default servers cannot be dropped."};
980  }
981  bool if_exists = ddl_payload["ifExists"].GetBool();
982  if (!session_ptr_->getCatalog().getForeignServer(server_name)) {
983  if (if_exists) {
984  return ExecutionResult();
985  } else {
986  throw std::runtime_error{"Foreign server with name \"" + server_name +
987  "\" can not be dropped. Server does not exist."};
988  }
989  }
990  // check access privileges
991  if (!session_ptr_->checkDBAccessPrivileges(
993  throw std::runtime_error("Server " + server_name +
994  " will not be dropped. User has no DROP SERVER privileges.");
995  }
997  DBObject(server_name, ServerDBObjectType), session_ptr_->get_catalog_ptr().get());
998  session_ptr_->getCatalog().dropForeignServer(ddl_payload["serverName"].GetString());
999 
1000  return ExecutionResult();
1001 }
static const AccessPrivileges DROP_SERVER
Definition: DBObject.h:189
void revokeDBObjectPrivilegesFromAll(DBObject object, Catalog *catalog)
const DdlCommandData & ddl_data_
bool is_default_server(const std::string &server_name)
static SysCatalog & instance()
Definition: SysCatalog.h:341
const rapidjson::Value & extractPayload(const DdlCommandData &ddl_data)
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: