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

#include <DdlCommandExecutor.h>

+ Inheritance diagram for AlterTableAlterColumnCommand:
+ Collaboration diagram for AlterTableAlterColumnCommand:

Public Types

using TypePairs = alter_column_shared::TypePairs
 

Public Member Functions

 AlterTableAlterColumnCommand (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)
 

Private Member Functions

void alterColumn ()
 
void populateAndWriteRecoveryInfo (const TableDescriptor *td, const TypePairs &src_dst_cds)
 
void cleanupRecoveryInfo (const TableDescriptor *td)
 
void alterColumnTypes (const TableDescriptor *td, const TypePairs &src_dst_cds)
 
void collectExpectedCatalogChanges (const TableDescriptor *td, const TypePairs &src_dst_cds)
 
std::list< std::list
< ColumnDescriptor > > 
prepareGeoColumns (const TableDescriptor *td, const TypePairs &src_dst_cds)
 
std::list< const
ColumnDescriptor * > 
prepareColumns (const TableDescriptor *td, const TypePairs &src_dst_cds)
 
void alterColumns (const TableDescriptor *td, const TypePairs &src_dst_cds)
 
void alterNonGeoColumnData (const TableDescriptor *td, const std::list< const ColumnDescriptor * > &cds)
 
void alterGeoColumnData (const TableDescriptor *td, const std::list< std::pair< const ColumnDescriptor *, std::list< const ColumnDescriptor * >>> &geo_src_dst_cds)
 
void clearInMemoryData (const TableDescriptor *td, const TypePairs &src_dst_cds)
 

Private Attributes

AlterTableAlterColumnCommandRecoveryMgr::RecoveryInfo recovery_info_
 
AlterTableAlterColumnCommandRecoveryMgr recovery_mgr_
 

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 114 of file DdlCommandExecutor.h.

Member Typedef Documentation

Constructor & Destructor Documentation

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

Definition at line 2754 of file DdlCommandExecutor.cpp.

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

2757  : DdlCommand(ddl_data, session_ptr)
2758  , recovery_mgr_(session_ptr->getCatalog())
2759 
2760 {
2761  auto& ddl_payload = extractPayload(ddl_data_);
2762 
2763  CHECK_EQ(std::string(ddl_payload["alterType"].GetString()), "ALTER_COLUMN");
2764 
2765  CHECK(ddl_payload.HasMember("alterData"));
2766  CHECK(ddl_payload["alterData"].IsArray());
2767 
2768  const auto elements = ddl_payload["alterData"].GetArray();
2769  for (const auto& element : elements) {
2770  CHECK(element.HasMember("type"));
2771  CHECK(element["type"].IsString());
2772  CHECK_EQ(std::string(element["type"].GetString()), "SQL_COLUMN_DECLARATION");
2773 
2774  CHECK(element.HasMember("name"));
2775  CHECK(element["name"].IsString());
2776 
2777  CHECK(element.HasMember("default"));
2778 
2779  CHECK(element.HasMember("nullable"));
2780  CHECK(element["nullable"].IsBool());
2781 
2782  CHECK(element.HasMember("encodingType"));
2783  CHECK(element.HasMember("encodingSize"));
2784 
2785  CHECK(element.HasMember("sqltype"));
2786  CHECK(element["sqltype"].IsString());
2787  }
2788 }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
const DdlCommandData & ddl_data_
const rapidjson::Value & extractPayload(const DdlCommandData &ddl_data)
AlterTableAlterColumnCommandRecoveryMgr recovery_mgr_
DdlCommand(const DdlCommandData &ddl_data, std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr)
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

Member Function Documentation

void AlterTableAlterColumnCommand::alterColumn ( )
private

Definition at line 3030 of file DdlCommandExecutor.cpp.

References alterColumnTypes(), CHECK, Parser::check_alter_table_privilege(), DdlCommand::ddl_data_, anonymous_namespace{DdlCommandExecutor.cpp}::extractPayload(), anonymous_namespace{DdlCommandExecutor.cpp}::get_alter_column_pairs_from_src_dst_cds(), anonymous_namespace{DdlCommandExecutor.cpp}::get_alter_column_src_dst_cds(), Parser::get_columns_from_json_payload(), DdlCommand::session_ptr_, ddl_utils::TABLE, table_is_temporary(), and ddl_utils::validate_table_type().

Referenced by execute().

3030  {
3031  auto& ddl_payload = extractPayload(ddl_data_);
3032  const auto tableName = std::string(ddl_payload["tableName"].GetString());
3033 
3034  auto columns = Parser::get_columns_from_json_payload("alterData", ddl_payload);
3035 
3036  auto& catalog = session_ptr_->getCatalog();
3037  const auto td_with_lock =
3039  catalog, tableName, true);
3040  const auto td = td_with_lock();
3041 
3042  if (!td) {
3043  throw std::runtime_error("Table " + tableName + " does not exist.");
3044  } else {
3045  if (td->isView) {
3046  throw std::runtime_error("Altering columns in a view is not supported.");
3047  }
3049  if (table_is_temporary(td)) {
3050  throw std::runtime_error("Altering columns in temporary tables is not supported.");
3051  }
3052  }
3053 
3055 
3056  for (const auto& coldef : columns) {
3057  const auto& column_name = *coldef.get_column_name();
3058  if (catalog.getMetadataForColumn(td->tableId, column_name) == nullptr) {
3059  throw std::runtime_error("Column " + column_name + " does not exist.");
3060  }
3061  }
3062 
3063  CHECK(td->fragmenter);
3064  if (td->sortedColumnId) {
3065  throw std::runtime_error(
3066  "Altering columns to a table is not supported when using the \"sort_column\" "
3067  "option.");
3068  }
3069 
3070  auto [src_cds, dst_cds] = get_alter_column_src_dst_cds(columns, catalog, td);
3072 }
std::pair< std::list< ColumnDescriptor >, std::list< ColumnDescriptor > > get_alter_column_src_dst_cds(const std::list< Parser::ColumnDef > &columns, Catalog_Namespace::Catalog &catalog, const TableDescriptor *td)
const DdlCommandData & ddl_data_
std::list< ColumnDef > get_columns_from_json_payload(const std::string &payload_key, const rapidjson::Value &payload)
const rapidjson::Value & extractPayload(const DdlCommandData &ddl_data)
void alterColumnTypes(const TableDescriptor *td, const TypePairs &src_dst_cds)
void check_alter_table_privilege(const Catalog_Namespace::SessionInfo &session, const TableDescriptor *td)
bool table_is_temporary(const TableDescriptor *const td)
AlterTableAlterColumnCommand::TypePairs get_alter_column_pairs_from_src_dst_cds(std::list< ColumnDescriptor > &src_cds, std::list< ColumnDescriptor > &dst_cds)
void validate_table_type(const TableDescriptor *td, const TableType expected_table_type, const std::string &command)
Definition: DdlUtils.cpp:745
#define CHECK(condition)
Definition: Logger.h:291
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:

void AlterTableAlterColumnCommand::alterColumns ( const TableDescriptor td,
const TypePairs src_dst_cds 
)
private

Definition at line 2790 of file DdlCommandExecutor.cpp.

References CHECK, ddl_utils::alter_column_utils::compare_column_descriptors(), and DdlCommand::session_ptr_.

Referenced by alterColumnTypes().

2791  {
2792  auto& catalog = session_ptr_->getCatalog();
2793 
2794  for (auto& [src_cd, dst_cd] : src_dst_cds) {
2795  if (dst_cd->columnType.is_geometry()) {
2796  continue;
2797  }
2798  auto compare_result =
2800  CHECK(!compare_result.sql_types_match || !compare_result.defaults_match);
2801 
2802  catalog.alterColumnTypeTransactional(*dst_cd);
2803  }
2804 }
CompareResult compare_column_descriptors(const ColumnDescriptor *lhs, const ColumnDescriptor *rhs)
Definition: DdlUtils.cpp:52
#define CHECK(condition)
Definition: Logger.h:291
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:

void AlterTableAlterColumnCommand::alterColumnTypes ( const TableDescriptor td,
const TypePairs src_dst_cds 
)
private

Definition at line 2980 of file DdlCommandExecutor.cpp.

References alterColumns(), alterGeoColumnData(), alterNonGeoColumnData(), AlterTableAlterColumnCommandRecoveryMgr::checkpoint(), AlterTableAlterColumnCommandRecoveryMgr::cleanup(), cleanupRecoveryInfo(), clearInMemoryData(), logger::FATAL, anonymous_namespace{DdlCommandExecutor.cpp}::get_alter_column_geo_pairs_from_src_dst_pairs_phys_cds(), LOG, populateAndWriteRecoveryInfo(), prepareColumns(), prepareGeoColumns(), recovery_info_, recovery_mgr_, AlterTableAlterColumnCommandRecoveryMgr::rollback(), DdlCommand::session_ptr_, TableDescriptor::tableId, and anonymous_namespace{DdlCommandExecutor.cpp}::vacuum_table_if_required().

Referenced by alterColumn().

2981  {
2982  auto& catalog = session_ptr_->getCatalog();
2983 
2984  auto table_epochs = catalog.getTableEpochs(catalog.getDatabaseId(), td->tableId);
2985 
2986  populateAndWriteRecoveryInfo(td, src_dst_cds);
2987 
2988  try {
2989  // Apply a vacuum operation prior to alter column when applicable
2990  vacuum_table_if_required(catalog, td);
2991 
2992  auto physical_columns = prepareGeoColumns(td, src_dst_cds);
2993  auto geo_src_dst_column_pairs =
2995  physical_columns);
2996 
2997  auto non_geo_cds = prepareColumns(td, src_dst_cds);
2998 
2999  alterGeoColumnData(td, geo_src_dst_column_pairs);
3000  alterNonGeoColumnData(td, non_geo_cds);
3001 
3002  alterColumns(td, src_dst_cds);
3003 
3004  // First checkpoint is for added/altered data, rollback is possible
3005  recovery_mgr_.checkpoint(td, src_dst_cds);
3006 
3007  } catch (std::exception& except) {
3008  catalog.setTableEpochs(catalog.getDatabaseId(), table_epochs);
3009  clearInMemoryData(td, src_dst_cds);
3011  cleanupRecoveryInfo(td);
3012  throw std::runtime_error("Alter column type: " + std::string(except.what()));
3013  }
3014 
3015  // After the last checkpoint, the following operations are non-reversible,
3016  // when recovering from a crash will be required to finish
3017  try {
3018  recovery_mgr_.cleanup(td, src_dst_cds);
3019  } catch (std::exception& except) {
3020  // Any exception encountered during the last steps is unexpected and will cause a
3021  // crash, relying on the recovery process to fix resulting issues
3022  LOG(FATAL) << "Alter column type: encountered fatal error during finalizing: "
3023  << except.what();
3024  }
3025 
3026  clearInMemoryData(td, src_dst_cds);
3027  cleanupRecoveryInfo(td);
3028 }
void alterGeoColumnData(const TableDescriptor *td, const std::list< std::pair< const ColumnDescriptor *, std::list< const ColumnDescriptor * >>> &geo_src_dst_cds)
void cleanupRecoveryInfo(const TableDescriptor *td)
void clearInMemoryData(const TableDescriptor *td, const TypePairs &src_dst_cds)
AlterTableAlterColumnCommandRecoveryMgr::RecoveryInfo recovery_info_
#define LOG(tag)
Definition: Logger.h:285
void alterColumns(const TableDescriptor *td, const TypePairs &src_dst_cds)
void alterNonGeoColumnData(const TableDescriptor *td, const std::list< const ColumnDescriptor * > &cds)
std::list< std::pair< const ColumnDescriptor *, std::list< const ColumnDescriptor * > > > get_alter_column_geo_pairs_from_src_dst_pairs_phys_cds(const AlterTableAlterColumnCommand::TypePairs &src_dst_cds, const std::list< std::list< ColumnDescriptor >> &phys_cds)
void populateAndWriteRecoveryInfo(const TableDescriptor *td, const TypePairs &src_dst_cds)
void checkpoint(const TableDescriptor *td, const TypePairs &src_dst_cds)
std::list< const ColumnDescriptor * > prepareColumns(const TableDescriptor *td, const TypePairs &src_dst_cds)
std::list< std::list< ColumnDescriptor > > prepareGeoColumns(const TableDescriptor *td, const TypePairs &src_dst_cds)
AlterTableAlterColumnCommandRecoveryMgr recovery_mgr_
void cleanup(const TableDescriptor *td, const TypePairs &src_dst_cds)
void vacuum_table_if_required(const Catalog_Namespace::Catalog &catalog, const TableDescriptor *td)
std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr_
void rollback(const TableDescriptor *td, const RecoveryInfo &param)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void AlterTableAlterColumnCommand::alterGeoColumnData ( const TableDescriptor td,
const std::list< std::pair< const ColumnDescriptor *, std::list< const ColumnDescriptor * >>> &  geo_src_dst_cds 
)
private

Definition at line 2873 of file DdlCommandExecutor.cpp.

References CHECK, and TableDescriptor::fragmenter.

Referenced by alterColumnTypes().

2876  {
2877  if (geo_src_dst_cds.empty()) {
2878  return;
2879  }
2880  auto fragmenter = td->fragmenter;
2881  CHECK(fragmenter);
2882  auto io_fragmenter =
2883  dynamic_cast<Fragmenter_Namespace::InsertOrderFragmenter*>(fragmenter.get());
2884  CHECK(io_fragmenter);
2885  io_fragmenter->alterColumnGeoType(geo_src_dst_cds);
2886 }
The InsertOrderFragmenter is a child class of AbstractFragmenter, and fragments data in insert order...
std::shared_ptr< Fragmenter_Namespace::AbstractFragmenter > fragmenter
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the caller graph for this function:

void AlterTableAlterColumnCommand::alterNonGeoColumnData ( const TableDescriptor td,
const std::list< const ColumnDescriptor * > &  cds 
)
private

Definition at line 2859 of file DdlCommandExecutor.cpp.

References CHECK, and TableDescriptor::fragmenter.

Referenced by alterColumnTypes().

2861  {
2862  if (cds.empty()) {
2863  return;
2864  }
2865  auto fragmenter = td->fragmenter;
2866  CHECK(fragmenter);
2867  auto io_fragmenter =
2868  dynamic_cast<Fragmenter_Namespace::InsertOrderFragmenter*>(fragmenter.get());
2869  CHECK(io_fragmenter);
2870  io_fragmenter->alterNonGeoColumnType(cds);
2871 }
The InsertOrderFragmenter is a child class of AbstractFragmenter, and fragments data in insert order...
std::shared_ptr< Fragmenter_Namespace::AbstractFragmenter > fragmenter
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the caller graph for this function:

void AlterTableAlterColumnCommand::cleanupRecoveryInfo ( const TableDescriptor td)
private

Definition at line 2950 of file DdlCommandExecutor.cpp.

References AlterTableAlterColumnCommandRecoveryMgr::getRecoveryFilepathInfo(), recovery_mgr_, AlterTableAlterColumnCommandRecoveryMgr::recoveryFilepath(), and TableDescriptor::tableId.

Referenced by alterColumnTypes().

2950  {
2951  auto recovery_file_info = recovery_mgr_.getRecoveryFilepathInfo(td->tableId);
2952  auto recovery_filepath = recovery_mgr_.recoveryFilepath(recovery_file_info);
2953 
2954  if (std::filesystem::exists(recovery_filepath)) {
2955  std::filesystem::remove(recovery_filepath);
2956  }
2957 }
RecoveryParamFilepathInfo getRecoveryFilepathInfo(const int32_t table_id=-1)
std::string recoveryFilepath(const RecoveryParamFilepathInfo &filepath_info)
AlterTableAlterColumnCommandRecoveryMgr recovery_mgr_

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void AlterTableAlterColumnCommand::clearInMemoryData ( const TableDescriptor td,
const TypePairs src_dst_cds 
)
private

Definition at line 2888 of file DdlCommandExecutor.cpp.

References Executor::clearExternalCaches(), Data_Namespace::CPU_LEVEL, Data_Namespace::GPU_LEVEL, DdlCommand::session_ptr_, and TableDescriptor::tableId.

Referenced by alterColumnTypes().

2889  {
2890  auto& catalog = session_ptr_->getCatalog();
2891 
2892  ChunkKey column_key{catalog.getCurrentDB().dbId, td->tableId, 0};
2893  Executor::clearExternalCaches(true, td, catalog.getDatabaseId());
2894  column_key.resize(3);
2895  for (auto& [src_cd, _] : src_dst_cds) {
2896  column_key[2] = src_cd->columnId;
2897  catalog.getDataMgr().deleteChunksWithPrefix(column_key, MemoryLevel::GPU_LEVEL);
2898  catalog.getDataMgr().deleteChunksWithPrefix(column_key, MemoryLevel::CPU_LEVEL);
2899  }
2900 
2901  catalog.removeFragmenterForTable(td->tableId);
2902 }
std::vector< int > ChunkKey
Definition: types.h:36
static void clearExternalCaches(bool for_update, const TableDescriptor *td, const int current_db_id)
Definition: Execute.h:438
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:

void AlterTableAlterColumnCommand::collectExpectedCatalogChanges ( const TableDescriptor td,
const TypePairs src_dst_cds 
)
private

Definition at line 2904 of file DdlCommandExecutor.cpp.

References AlterTableAlterColumnCommandRecoveryMgr::RecoveryInfo::added_columns, AlterTableAlterColumnCommandRecoveryMgr::RecoveryInfo::altered_columns, CHECK, ColumnDescriptor::columnId, ddl_utils::alter_column_utils::compare_column_descriptors(), recovery_info_, AlterTableAlterColumnCommandRecoveryMgr::RecoveryInfo::renamed_columns, DdlCommand::session_ptr_, ddl_utils::alter_column_utils::CompareResult::sql_types_match, ColumnDescriptor::tableId, TableDescriptor::tableId, and AlterTableAlterColumnCommandRecoveryMgr::RecoveryInfo::updated_dict_cds.

Referenced by populateAndWriteRecoveryInfo().

2906  {
2907  auto& catalog = session_ptr_->getCatalog();
2908 
2909  auto column_id_start = catalog.getNextAddedColumnId(*td);
2910  auto current_column_id = column_id_start;
2911 
2912  // Simulate operations required for geo changes
2913  for (auto& [src_cd, dst_cd] : src_dst_cds) {
2914  if (dst_cd->columnType.is_geometry()) {
2915  recovery_info_.renamed_columns.push_back(*src_cd);
2916 
2917  std::list<ColumnDescriptor> phy_geo_columns;
2918  catalog.expandGeoColumn(*dst_cd, phy_geo_columns);
2919 
2920  auto col_to_add = *dst_cd;
2921  col_to_add.tableId = td->tableId;
2922  col_to_add.columnId = current_column_id++;
2923  recovery_info_.added_columns.push_back(col_to_add);
2924 
2925  for (auto& cd : phy_geo_columns) {
2926  ColumnDescriptor phys_col_to_add = cd;
2927  phys_col_to_add.tableId = td->tableId;
2928  phys_col_to_add.columnId = current_column_id++;
2929  recovery_info_.added_columns.push_back(phys_col_to_add);
2930  }
2931  } else if (dst_cd->columnType.is_dict_encoded_type()) {
2933  .sql_types_match) {
2934  recovery_info_.updated_dict_cds.push_back(*src_cd);
2935  }
2936  }
2937  }
2938 
2939  for (auto& [src_cd, dst_cd] : src_dst_cds) {
2940  if (dst_cd->columnType.is_geometry()) {
2941  continue;
2942  }
2943  auto compare_result =
2945  CHECK(!compare_result.sql_types_match || !compare_result.defaults_match);
2946  recovery_info_.altered_columns.emplace_back(*src_cd, *dst_cd);
2947  }
2948 }
CompareResult compare_column_descriptors(const ColumnDescriptor *lhs, const ColumnDescriptor *rhs)
Definition: DdlUtils.cpp:52
AlterTableAlterColumnCommandRecoveryMgr::RecoveryInfo recovery_info_
specifies the content in-memory of a row in the column metadata table
#define CHECK(condition)
Definition: Logger.h:291
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:

ExecutionResult AlterTableAlterColumnCommand::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 3074 of file DdlCommandExecutor.cpp.

References alterColumn(), g_cluster, and legacylockmgr::getExecuteReadLock().

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

3074  {
3075  if (g_cluster) {
3076  throw std::runtime_error(
3077  "ALTER TABLE ALTER COLUMN is unsupported in distributed mode.");
3078  }
3079 
3080  // NOTE: read_only_mode is validated at a higher level in AlterTableCommand
3081 
3082  // TODO: Refactor this lock when refactoring other ALTER TABLE commands
3083  const auto execute_read_lock = legacylockmgr::getExecuteReadLock();
3084 
3085  // There are a few major cases to consider when alter column is invoked.
3086  // Below non variable length column is abbreviated as NVL and a variable
3087  // length column is abbreviated as VL.
3088  //
3089  // 1. A NVL -> NVL or VL -> VL column conversion.
3090  //
3091  // 2. A NVL -> VL or VL -> NVL column conversion.
3092  //
3093  // 3. A VL/NVL column converted to a Geo column.
3094  //
3095  // Case (1) is the simplest since chunks do not change their chunk keys.
3096  //
3097  // Case (2) requires that the chunk keys are added or removed (typically the
3098  // index chunk), and this requires special treatment.
3099  //
3100  // Case (3) requires temporarily renaming the source column, creating new Geo
3101  // columns, populating the destination Geo columns and dropping the source
3102  // column.
3103 
3104  alterColumn();
3105  return {};
3106 }
auto getExecuteReadLock()
bool g_cluster

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void AlterTableAlterColumnCommand::populateAndWriteRecoveryInfo ( const TableDescriptor td,
const TypePairs src_dst_cds 
)
private

Definition at line 2959 of file DdlCommandExecutor.cpp.

References CHECK_GT, collectExpectedCatalogChanges(), AlterTableAlterColumnCommandRecoveryMgr::getRecoveryFilepathInfo(), TableDescriptor::hasDeletedCol, AlterTableAlterColumnCommandRecoveryMgr::RecoveryInfo::is_vacuumed, recovery_info_, recovery_mgr_, AlterTableAlterColumnCommandRecoveryMgr::recoveryFilepath(), DdlCommand::session_ptr_, AlterTableAlterColumnCommandRecoveryMgr::RecoveryInfo::src_dst_cds, AlterTableAlterColumnCommandRecoveryMgr::RecoveryInfo::table_epoch, TableDescriptor::tableId, and AlterTableAlterColumnCommandRecoveryMgr::writeSerializedRecoveryInformation().

Referenced by alterColumnTypes().

2961  {
2962  auto& catalog = session_ptr_->getCatalog();
2963 
2964  auto table_epochs = catalog.getTableEpochs(catalog.getDatabaseId(), td->tableId);
2965  CHECK_GT(table_epochs.size(), 0UL);
2966  recovery_info_.table_epoch = table_epochs[0].table_epoch;
2968 
2969  collectExpectedCatalogChanges(td, src_dst_cds);
2970 
2971  for (const auto& [src_cd, dst_cd] : src_dst_cds) {
2972  recovery_info_.src_dst_cds.emplace_back(*src_cd, *dst_cd);
2973  }
2974 
2975  auto recovery_file_info = recovery_mgr_.getRecoveryFilepathInfo(td->tableId);
2976  auto recovery_filepath = recovery_mgr_.recoveryFilepath(recovery_file_info);
2978 }
AlterTableAlterColumnCommandRecoveryMgr::RecoveryInfo recovery_info_
RecoveryParamFilepathInfo getRecoveryFilepathInfo(const int32_t table_id=-1)
#define CHECK_GT(x, y)
Definition: Logger.h:305
std::list< std::pair< ColumnDescriptor, ColumnDescriptor > > src_dst_cds
std::string recoveryFilepath(const RecoveryParamFilepathInfo &filepath_info)
void collectExpectedCatalogChanges(const TableDescriptor *td, const TypePairs &src_dst_cds)
AlterTableAlterColumnCommandRecoveryMgr recovery_mgr_
std::shared_ptr< Catalog_Namespace::SessionInfo const > session_ptr_
void writeSerializedRecoveryInformation(const RecoveryInfo &param, const RecoveryParamFilepathInfo &filepath_info)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::list< const ColumnDescriptor * > AlterTableAlterColumnCommand::prepareColumns ( const TableDescriptor td,
const TypePairs src_dst_cds 
)
private

Definition at line 2806 of file DdlCommandExecutor.cpp.

References ddl_utils::alter_column_utils::compare_column_descriptors(), and DdlCommand::session_ptr_.

Referenced by alterColumnTypes().

2808  {
2809  auto& catalog = session_ptr_->getCatalog();
2810 
2811  std::list<const ColumnDescriptor*> non_geo_cds;
2812  for (auto& [src_cd, dst_cd] : src_dst_cds) {
2813  if (dst_cd->columnType.is_geometry()) {
2814  continue;
2815  }
2816  non_geo_cds.emplace_back(dst_cd);
2817 
2818  auto compare_result =
2820  if (compare_result.sql_types_match) {
2821  continue;
2822  }
2823 
2824  if (dst_cd->columnType.is_dict_encoded_type()) {
2825  catalog.addDictionaryTransactional(*dst_cd);
2826  }
2827  }
2828 
2829  return non_geo_cds;
2830 }
CompareResult compare_column_descriptors(const ColumnDescriptor *lhs, const ColumnDescriptor *rhs)
Definition: DdlUtils.cpp:52
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:

std::list< std::list< ColumnDescriptor > > AlterTableAlterColumnCommand::prepareGeoColumns ( const TableDescriptor td,
const TypePairs src_dst_cds 
)
private

Definition at line 2832 of file DdlCommandExecutor.cpp.

References DdlCommand::session_ptr_, and to_string().

Referenced by alterColumnTypes().

2834  {
2835  auto& catalog = session_ptr_->getCatalog();
2836  std::list<std::list<ColumnDescriptor>> physical_geo_columns;
2837 
2838  for (auto& [src_cd, dst_cd] : src_dst_cds) {
2839  if (dst_cd->columnType.is_geometry()) {
2840  std::string col_name = src_cd->columnName;
2841  auto uuid = boost::uuids::random_generator()();
2842  catalog.renameColumn(td, src_cd, col_name + "_" + boost::uuids::to_string(uuid));
2843 
2844  physical_geo_columns.emplace_back();
2845  std::list<ColumnDescriptor>& phy_geo_columns = physical_geo_columns.back();
2846  catalog.expandGeoColumn(*dst_cd, phy_geo_columns);
2847 
2848  catalog.addColumnTransactional(*td, *dst_cd);
2849 
2850  for (auto& cd : phy_geo_columns) {
2851  catalog.addColumnTransactional(*td, cd);
2852  }
2853  }
2854  }
2855 
2856  return physical_geo_columns;
2857 }
std::string to_string(char const *&&v)
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:

Member Data Documentation

AlterTableAlterColumnCommandRecoveryMgr::RecoveryInfo AlterTableAlterColumnCommand::recovery_info_
private
AlterTableAlterColumnCommandRecoveryMgr AlterTableAlterColumnCommand::recovery_mgr_
private

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