OmniSciDB  2e3a973ef4
DropForeignTableCommand Class Reference

#include <DdlCommandExecutor.h>

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

Public Member Functions

 DropForeignTableCommand (const rapidjson::Value &ddl_payload, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
 
void execute (TQueryResult &_return) override
 
- Public Member Functions inherited from DdlCommand
 DdlCommand (const rapidjson::Value &ddl_payload, 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 rapidjson::Value & ddl_payload_
 
std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr_
 

Detailed Description

Definition at line 129 of file DdlCommandExecutor.h.

Constructor & Destructor Documentation

◆ DropForeignTableCommand()

DropForeignTableCommand::DropForeignTableCommand ( const rapidjson::Value &  ddl_payload,
std::shared_ptr< Catalog_Namespace::SessionInfo const >  session_ptr 
)

Definition at line 660 of file DdlCommandExecutor.cpp.

References CHECK.

663  : DdlCommand(ddl_payload, session_ptr) {
664  CHECK(ddl_payload.HasMember("tableName"));
665  CHECK(ddl_payload["tableName"].IsString());
666  CHECK(ddl_payload.HasMember("ifExists"));
667  CHECK(ddl_payload["ifExists"].IsBool());
668 }
DdlCommand(const rapidjson::Value &ddl_payload, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
#define CHECK(condition)
Definition: Logger.h:197

Member Function Documentation

◆ execute()

void DropForeignTableCommand::execute ( TQueryResult &  _return)
overridevirtual

Executes the DDL command corresponding to provided JSON payload.

Parameters
_returnresult of DDL command execution (if applicable)

Implements DdlCommand.

Definition at line 670 of file DdlCommandExecutor.cpp.

References CHECK, DdlCommand::ddl_payload_, AccessPrivileges::DROP_TABLE, ddl_utils::FOREIGN_TABLE, lockmgr::TableLockMgrImpl< TableDataLockMgr >::getWriteLockForTable(), DdlCommand::session_ptr_, TableDBObjectType, and ddl_utils::validate_drop_table_type().

670  {
671  auto& catalog = session_ptr_->getCatalog();
672  const std::string& table_name = ddl_payload_["tableName"].GetString();
673  const TableDescriptor* td{nullptr};
674  std::unique_ptr<lockmgr::TableSchemaLockContainer<lockmgr::WriteLock>> td_with_lock;
675 
676  try {
677  td_with_lock =
678  std::make_unique<lockmgr::TableSchemaLockContainer<lockmgr::WriteLock>>(
680  catalog, table_name, false));
681  td = (*td_with_lock)();
682  } catch (const std::runtime_error& e) {
683  if (ddl_payload_["ifExists"].GetBool()) {
684  return;
685  } else {
686  throw e;
687  }
688  }
689 
690  CHECK(td);
691  CHECK(td_with_lock);
692 
693  if (!session_ptr_->checkDBAccessPrivileges(
695  throw std::runtime_error(
696  "Foreign table \"" + table_name +
697  "\" will not be dropped. User has no DROP TABLE privileges.");
698  }
699 
701  auto table_data_write_lock =
703  catalog.dropTable(td);
704 }
static WriteLock getWriteLockForTable(const Catalog_Namespace::Catalog &cat, const std::string &table_name)
Definition: LockMgrImpl.h:155
static const AccessPrivileges DROP_TABLE
Definition: DBObject.h:160
void validate_drop_table_type(const TableDescriptor *td, const TableType expected_table_type)
Definition: DdlUtils.cpp:537
#define CHECK(condition)
Definition: Logger.h:197
const rapidjson::Value & ddl_payload_
std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr_
specifies the content in-memory of a row in the table metadata table
+ Here is the call graph for this function:

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