#include <DdlCommandExecutor.h>
Definition at line 166 of file DdlCommandExecutor.h.
Definition at line 3230 of file DdlCommandExecutor.cpp.
References CHECK, DdlCommand::ddl_data_, anonymous_namespace{DdlCommandExecutor.cpp}::extractPayload(), g_enable_fsi, and UNREACHABLE.
3235 throw std::runtime_error(
"Unsupported command: ALTER FOREIGN TABLE");
3238 CHECK(ddl_payload.HasMember(
"tableName"));
3239 CHECK(ddl_payload[
"tableName"].IsString());
3240 CHECK(ddl_payload.HasMember(
"alterType"));
3241 CHECK(ddl_payload[
"alterType"].IsString());
3242 if (ddl_payload[
"alterType"] ==
"RENAME_TABLE") {
3243 CHECK(ddl_payload.HasMember(
"newTableName"));
3244 CHECK(ddl_payload[
"newTableName"].IsString());
3245 }
else if (ddl_payload[
"alterType"] ==
"RENAME_COLUMN") {
3246 CHECK(ddl_payload.HasMember(
"oldColumnName"));
3247 CHECK(ddl_payload[
"oldColumnName"].IsString());
3248 CHECK(ddl_payload.HasMember(
"newColumnName"));
3249 CHECK(ddl_payload[
"newColumnName"].IsString());
3250 }
else if (ddl_payload[
"alterType"] ==
"ALTER_OPTIONS") {
3251 CHECK(ddl_payload.HasMember(
"options"));
3252 CHECK(ddl_payload[
"options"].IsObject());
3254 UNREACHABLE() <<
"Not a valid alter foreign table command: "
3255 << ddl_payload[
"alterType"].GetString();
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)
Executes the DDL command corresponding to provided JSON payload.
- Parameters
-
_return | result of DDL command execution (if applicable) |
Implements DdlCommand.
Definition at line 3259 of file DdlCommandExecutor.cpp.
References AccessPrivileges::ALTER_TABLE, alterOptions(), CHECK, DdlCommand::ddl_data_, anonymous_namespace{DdlCommandExecutor.cpp}::extractPayload(), ddl_utils::FOREIGN_TABLE, legacylockmgr::getExecuteReadLock(), legacylockmgr::getExecuteWriteLock(), lockmgr::TableLockMgrImpl< TableDataLockMgr >::getWriteLockForTable(), renameColumn(), renameTable(), DdlCommand::session_ptr_, TableDBObjectType, and ddl_utils::validate_table_type().
Referenced by heavydb.cursor.Cursor::executemany().
3260 if (read_only_mode) {
3261 throw std::runtime_error(
"ALTER FOREIGN TABLE invalid in read only mode.");
3265 std::string alter_type = ddl_payload[
"alterType"].GetString();
3271 if (alter_type ==
"RENAME_TABLE") {
3278 const std::string& table_name = ddl_payload[
"tableName"].GetString();
3279 auto [td, td_with_lock] =
3280 get_table_descriptor_with_lock<lockmgr::WriteLock>(catalog, table_name,
false);
3286 throw std::runtime_error(
3287 "Current user does not have the privilege to alter foreign table: " + table_name);
3290 auto table_data_write_lock =
3293 CHECK(foreign_table);
3296 if (alter_type ==
"RENAME_TABLE") {
3298 }
else if (alter_type ==
"RENAME_COLUMN") {
3300 }
else if (alter_type ==
"ALTER_OPTIONS") {
void alterOptions(const foreign_storage::ForeignTable &foreign_table)
static const AccessPrivileges ALTER_TABLE
auto getExecuteReadLock()
std::unique_lock< WrapperType< std::shared_mutex >> ExecutorWriteLock
const DdlCommandData & ddl_data_
std::shared_lock< WrapperType< std::shared_mutex >> ExecutorReadLock
const rapidjson::Value & extractPayload(const DdlCommandData &ddl_data)
static WriteLock getWriteLockForTable(const Catalog_Namespace::Catalog &cat, const std::string &table_name)
void validate_table_type(const TableDescriptor *td, const TableType expected_table_type, const std::string &command)
void renameTable(const foreign_storage::ForeignTable *foreign_table)
auto getExecuteWriteLock()
std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr_
void renameColumn(const foreign_storage::ForeignTable *foreign_table)
Definition at line 3322 of file DdlCommandExecutor.cpp.
References cat(), DdlCommand::ddl_data_, anonymous_namespace{DdlCommandExecutor.cpp}::extractPayload(), DdlCommand::session_ptr_, and TableDescriptor::tableId.
Referenced by execute().
3326 const std::string& old_column_name = ddl_payload[
"oldColumnName"].GetString();
3327 const std::string& new_column_name = ddl_payload[
"newColumnName"].GetString();
3328 auto column =
cat.getMetadataForColumn(foreign_table->
tableId, old_column_name);
3330 throw std::runtime_error(
"Column with name \"" + old_column_name +
3331 "\" can not be renamed to \"" + new_column_name +
"\". " +
3332 "Column with name \"" + old_column_name +
3333 "\" does not exist.");
3335 if (
cat.getMetadataForColumn(foreign_table->
tableId, new_column_name)) {
3336 throw std::runtime_error(
"Column with name \"" + old_column_name +
3337 "\" can not be renamed to \"" + new_column_name +
"\". " +
3338 "A column with name \"" + new_column_name +
3339 "\" already exists.");
3341 cat.renameColumn(foreign_table, column, new_column_name);
const DdlCommandData & ddl_data_
const rapidjson::Value & extractPayload(const DdlCommandData &ddl_data)
std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr_
Definition at line 3307 of file DdlCommandExecutor.cpp.
References cat(), DdlCommand::ddl_data_, anonymous_namespace{DdlCommandExecutor.cpp}::extractPayload(), and DdlCommand::session_ptr_.
Referenced by execute().
3311 const std::string& table_name = ddl_payload[
"tableName"].GetString();
3312 const std::string& new_table_name = ddl_payload[
"newTableName"].GetString();
3313 if (
cat.getForeignTable(new_table_name)) {
3314 throw std::runtime_error(
"Foreign table with name \"" + table_name +
3315 "\" can not be renamed to \"" + new_table_name +
"\". " +
3316 "A different table with name \"" + new_table_name +
3317 "\" already exists.");
3319 cat.renameTable(foreign_table, new_table_name);
const DdlCommandData & ddl_data_
const rapidjson::Value & extractPayload(const DdlCommandData &ddl_data)
std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr_
The documentation for this class was generated from the following files: