OmniSciDB  a5dc49c757
 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 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 1174 of file DdlCommandExecutor.cpp.

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

1177  : DdlCommand(ddl_data, session_ptr) {
1178  if (!g_enable_fsi) {
1179  throw std::runtime_error("Unsupported command: DROP FOREIGN SERVER");
1180  }
1181  auto& ddl_payload = extractPayload(ddl_data_);
1182  CHECK(ddl_payload.HasMember("serverName"));
1183  CHECK(ddl_payload["serverName"].IsString());
1184  CHECK(ddl_payload.HasMember("ifExists"));
1185  CHECK(ddl_payload["ifExists"].IsBool());
1186 }
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:291
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 1188 of file DdlCommandExecutor.cpp.

References DdlCommand::ddl_data_, AccessPrivileges::DROP_SERVER, anonymous_namespace{DdlCommandExecutor.cpp}::extractPayload(), legacylockmgr::getExecuteWriteLock(), 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().

1188  {
1189  auto execute_write_lock = legacylockmgr::getExecuteWriteLock();
1190 
1191  if (read_only_mode) {
1192  throw std::runtime_error("DROP FOREIGN SERVER invalid in read only mode.");
1193  }
1194 
1195  auto& ddl_payload = extractPayload(ddl_data_);
1196  std::string server_name = ddl_payload["serverName"].GetString();
1197  if (is_default_server(server_name)) {
1198  throw std::runtime_error{"Default servers cannot be dropped."};
1199  }
1200  bool if_exists = ddl_payload["ifExists"].GetBool();
1201  if (!session_ptr_->getCatalog().getForeignServer(server_name)) {
1202  if (if_exists) {
1203  return ExecutionResult();
1204  } else {
1205  throw std::runtime_error{"Foreign server with name \"" + server_name +
1206  "\" can not be dropped. Server does not exist."};
1207  }
1208  }
1209  // check access privileges
1210  if (!session_ptr_->checkDBAccessPrivileges(
1212  throw std::runtime_error("Server " + server_name +
1213  " will not be dropped. User has no DROP SERVER privileges.");
1214  }
1216  DBObject(server_name, ServerDBObjectType), session_ptr_->get_catalog_ptr().get());
1217  session_ptr_->getCatalog().dropForeignServer(ddl_payload["serverName"].GetString());
1218 
1219  return ExecutionResult();
1220 }
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:343
const rapidjson::Value & extractPayload(const DdlCommandData &ddl_data)
auto getExecuteWriteLock()
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: