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

#include <DdlCommandExecutor.h>

+ Inheritance diagram for DropForeignTableCommand:
+ Collaboration diagram for DropForeignTableCommand:

Public Member Functions

 DropForeignTableCommand (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 106 of file DdlCommandExecutor.h.

Constructor & Destructor Documentation

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

Definition at line 1120 of file DdlCommandExecutor.cpp.

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

1123  : DdlCommand(ddl_data, session_ptr) {
1124  auto& ddl_payload = extractPayload(ddl_data_);
1125  CHECK(ddl_payload.HasMember("tableName"));
1126  CHECK(ddl_payload["tableName"].IsString());
1127  CHECK(ddl_payload.HasMember("ifExists"));
1128  CHECK(ddl_payload["ifExists"].IsBool());
1129 }
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 DropForeignTableCommand::execute ( )
overridevirtual

Executes the DDL command corresponding to provided JSON payload.

Parameters
_returnresult of DDL command execution (if applicable)

Implements DdlCommand.

Definition at line 1131 of file DdlCommandExecutor.cpp.

References CHECK, DdlCommand::ddl_data_, AccessPrivileges::DROP_TABLE, anonymous_namespace{DdlCommandExecutor.cpp}::extractPayload(), ddl_utils::FOREIGN_TABLE, lockmgr::TableLockMgrImpl< TableDataLockMgr >::getWriteLockForTable(), DdlCommand::session_ptr_, TableDBObjectType, and ddl_utils::validate_table_type().

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

1131  {
1132  auto& catalog = session_ptr_->getCatalog();
1133  auto& ddl_payload = extractPayload(ddl_data_);
1134 
1135  const std::string& table_name = ddl_payload["tableName"].GetString();
1136  const TableDescriptor* td{nullptr};
1137  std::unique_ptr<lockmgr::TableSchemaLockContainer<lockmgr::WriteLock>> td_with_lock;
1138 
1139  try {
1140  td_with_lock =
1141  std::make_unique<lockmgr::TableSchemaLockContainer<lockmgr::WriteLock>>(
1143  catalog, table_name, false));
1144  CHECK(td_with_lock);
1145  td = (*td_with_lock)();
1146  } catch (const std::runtime_error& e) {
1147  // TODO(Misiu): This should not just swallow any exception, it should only catch
1148  // exceptions that stem from the table not existing.
1149  if (ddl_payload["ifExists"].GetBool()) {
1150  return ExecutionResult();
1151  } else {
1152  throw e;
1153  }
1154  }
1155 
1156  CHECK(td);
1157 
1158  if (!session_ptr_->checkDBAccessPrivileges(
1160  throw std::runtime_error(
1161  "Foreign table \"" + table_name +
1162  "\" will not be dropped. User has no DROP TABLE privileges.");
1163  }
1164 
1166  auto table_data_write_lock =
1168  catalog.dropTable(td);
1169 
1170  return ExecutionResult();
1171 }
static WriteLock getWriteLockForTable(const Catalog_Namespace::Catalog &cat, const std::string &table_name)
Definition: LockMgrImpl.h:155
const DdlCommandData & ddl_data_
static const AccessPrivileges DROP_TABLE
Definition: DBObject.h:161
const rapidjson::Value & extractPayload(const DdlCommandData &ddl_data)
void validate_table_type(const TableDescriptor *td, const TableType expected_table_type, const std::string &command)
Definition: DdlUtils.cpp:692
#define CHECK(condition)
Definition: Logger.h:211
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: