OmniSciDB  72c90bc290
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
anonymous_namespace{DdlCommandExecutor.cpp} Namespace Reference

Classes

struct  AggregratedStorageStats
 
class  JsonColumnSqlType
 declare this class scoped local to avoid exposing rapidjson in the header file More...
 
class  JsonColumnEncoding
 
class  DdlCommandDataImpl
 

Functions

void vacuum_table_if_required (const Catalog_Namespace::Catalog &catalog, const TableDescriptor *td)
 
void validate_alter_type_allowed (const std::string &colname, const SQLTypeInfo &src, const SQLTypeInfo &dst)
 
void validate_alter_type_metadata (const Catalog_Namespace::Catalog &catalog, const TableDescriptor *td, const ColumnDescriptor &cd)
 
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)
 
AlterTableAlterColumnCommand::TypePairs get_alter_column_pairs_from_src_dst_cds (std::list< ColumnDescriptor > &src_cds, std::list< ColumnDescriptor > &dst_cds)
 
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)
 
template<class LockType >
std::tuple< const
TableDescriptor
*, std::unique_ptr
< lockmgr::TableSchemaLockContainer
< LockType > > > 
get_table_descriptor_with_lock (Catalog_Namespace::Catalog &cat, const std::string &table_name, const bool populate_fragmenter)
 
template<class Func >
void exec_for_tables_which_exist (const std::vector< std::string > &table_names, Catalog_Namespace::Catalog *cat_ptr, Func func)
 
AggregratedStorageStats get_agg_storage_stats (const TableDescriptor *td, const Catalog_Namespace::Catalog *catalog)
 
std::unique_ptr< RexLiteralgenLiteralStr (std::string val)
 
std::unique_ptr< RexLiteralgenLiteralTimestamp (time_t val)
 
std::unique_ptr< RexLiteralgenLiteralBigInt (int64_t val)
 
std::unique_ptr< RexLiteralgenLiteralDouble (double val)
 
std::unique_ptr< RexLiteralgenLiteralBoolean (bool val)
 
void set_headers_with_type (std::vector< TargetMetaInfo > &label_infos, const std::vector< std::tuple< std::string, SQLTypes, bool >> &headers)
 
void add_table_details (std::vector< RelLogicalValues::RowValues > &logical_values, const TableDescriptor *logical_table, const AggregratedStorageStats &agg_storage_stats)
 
const rapidjson::Value & extractPayload (const DdlCommandData &ddl_data)
 
const rapidjson::Value * extractFilters (const rapidjson::Value &payload)
 
bool is_default_server (const std::string &server_name)
 
void throw_reserved_server_prefix_exception ()
 

Variables

const std::array< std::string, 3 > kReservedServerPrefixes {"default", "system", "internal"}
 

Function Documentation

void anonymous_namespace{DdlCommandExecutor.cpp}::add_table_details ( std::vector< RelLogicalValues::RowValues > &  logical_values,
const TableDescriptor logical_table,
const AggregratedStorageStats &  agg_storage_stats 
)

Definition at line 356 of file DdlCommandExecutor.cpp.

References File_Namespace::StorageStats::data_file_count, genLiteralBigInt(), genLiteralBoolean(), genLiteralStr(), anonymous_namespace{DdlCommandExecutor.cpp}::AggregratedStorageStats::max_epoch, anonymous_namespace{DdlCommandExecutor.cpp}::AggregratedStorageStats::max_epoch_floor, TableDescriptor::maxFragRows, TableDescriptor::maxRollbackEpochs, TableDescriptor::maxRows, File_Namespace::StorageStats::metadata_file_count, anonymous_namespace{DdlCommandExecutor.cpp}::AggregratedStorageStats::min_epoch, anonymous_namespace{DdlCommandExecutor.cpp}::AggregratedStorageStats::min_epoch_floor, TableDescriptor::nColumns, TableDescriptor::nShards, NULL_BIGINT, TableDescriptor::tableId, TableDescriptor::tableName, File_Namespace::StorageStats::total_data_file_size, File_Namespace::StorageStats::total_data_page_count, File_Namespace::StorageStats::total_free_data_page_count, File_Namespace::StorageStats::total_free_metadata_page_count, File_Namespace::StorageStats::total_metadata_file_size, and File_Namespace::StorageStats::total_metadata_page_count.

Referenced by ShowTableDetailsCommand::execute().

358  {
359  bool is_sharded_table = (logical_table->nShards > 0);
360  logical_values.emplace_back(RelLogicalValues::RowValues{});
361  logical_values.back().emplace_back(genLiteralBigInt(logical_table->tableId));
362  logical_values.back().emplace_back(genLiteralStr(logical_table->tableName));
363  logical_values.back().emplace_back(genLiteralBigInt(logical_table->nColumns));
364  logical_values.back().emplace_back(genLiteralBoolean(is_sharded_table));
365  logical_values.back().emplace_back(genLiteralBigInt(logical_table->nShards));
366  logical_values.back().emplace_back(genLiteralBigInt(logical_table->maxRows));
367  logical_values.back().emplace_back(genLiteralBigInt(logical_table->maxFragRows));
368  logical_values.back().emplace_back(genLiteralBigInt(logical_table->maxRollbackEpochs));
369  logical_values.back().emplace_back(genLiteralBigInt(agg_storage_stats.min_epoch));
370  logical_values.back().emplace_back(genLiteralBigInt(agg_storage_stats.max_epoch));
371  logical_values.back().emplace_back(genLiteralBigInt(agg_storage_stats.min_epoch_floor));
372  logical_values.back().emplace_back(genLiteralBigInt(agg_storage_stats.max_epoch_floor));
373  logical_values.back().emplace_back(
374  genLiteralBigInt(agg_storage_stats.metadata_file_count));
375  logical_values.back().emplace_back(
376  genLiteralBigInt(agg_storage_stats.total_metadata_file_size));
377  logical_values.back().emplace_back(
378  genLiteralBigInt(agg_storage_stats.total_metadata_page_count));
379 
380  if (agg_storage_stats.total_free_metadata_page_count) {
381  logical_values.back().emplace_back(
382  genLiteralBigInt(agg_storage_stats.total_free_metadata_page_count.value()));
383  } else {
384  logical_values.back().emplace_back(genLiteralBigInt(NULL_BIGINT));
385  }
386 
387  logical_values.back().emplace_back(genLiteralBigInt(agg_storage_stats.data_file_count));
388  logical_values.back().emplace_back(
389  genLiteralBigInt(agg_storage_stats.total_data_file_size));
390  logical_values.back().emplace_back(
391  genLiteralBigInt(agg_storage_stats.total_data_page_count));
392 
393  if (agg_storage_stats.total_free_data_page_count) {
394  logical_values.back().emplace_back(
395  genLiteralBigInt(agg_storage_stats.total_free_data_page_count.value()));
396  } else {
397  logical_values.back().emplace_back(genLiteralBigInt(NULL_BIGINT));
398  }
399 }
int32_t maxRollbackEpochs
std::string tableName
#define NULL_BIGINT
std::unique_ptr< RexLiteral > genLiteralBigInt(int64_t val)
std::unique_ptr< RexLiteral > genLiteralBoolean(bool val)
static std::unique_ptr< RexLiteral > genLiteralStr(std::string val)
Definition: DBHandler.cpp:7752
std::vector< std::unique_ptr< const RexScalar >> RowValues
Definition: RelAlgDag.h:2656

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class Func >
void anonymous_namespace{DdlCommandExecutor.cpp}::exec_for_tables_which_exist ( const std::vector< std::string > &  table_names,
Catalog_Namespace::Catalog cat_ptr,
Func  func 
)

Definition at line 235 of file DdlCommandExecutor.cpp.

Referenced by ShowTableDetailsCommand::execute(), ShowDiskCacheUsageCommand::execute(), and ShowTableDetailsCommand::getFilteredTableNames().

237  {
238  for (const auto& table_name : table_names) {
239  try {
240  auto [td, td_with_lock] =
241  get_table_descriptor_with_lock<lockmgr::ReadLock>(*cat_ptr, table_name, false);
242  func(td, table_name);
243  } catch (const Catalog_Namespace::TableNotFoundException& e) {
244  continue;
245  }
246  }
247 }

+ Here is the caller graph for this function:

const rapidjson::Value* anonymous_namespace{DdlCommandExecutor.cpp}::extractFilters ( const rapidjson::Value &  payload)

Definition at line 493 of file DdlCommandExecutor.cpp.

Referenced by ShowForeignServersCommand::execute().

493  {
494  const rapidjson::Value* filters = nullptr;
495  if (payload.HasMember("filters") && payload["filters"].IsArray()) {
496  filters = &payload["filters"];
497  }
498  return filters;
499 }

+ Here is the caller graph for this function:

const rapidjson::Value& anonymous_namespace{DdlCommandExecutor.cpp}::extractPayload ( const DdlCommandData ddl_data)

Definition at line 488 of file DdlCommandExecutor.cpp.

References anonymous_namespace{DdlCommandExecutor.cpp}::DdlCommandDataImpl::payload().

Referenced by AlterTableAlterColumnCommand::alterColumn(), AlterDatabaseCommand::AlterDatabaseCommand(), AlterForeignServerCommand::AlterForeignServerCommand(), AlterForeignTableCommand::AlterForeignTableCommand(), AlterForeignTableCommand::alterOptions(), AlterTableAlterColumnCommand::AlterTableAlterColumnCommand(), AlterTableCommand::AlterTableCommand(), AlterForeignServerCommand::changeForeignServerOwner(), AlterDatabaseCommand::changeOwner(), CreateForeignServerCommand::CreateForeignServerCommand(), CreateForeignTableCommand::CreateForeignTableCommand(), DropForeignServerCommand::DropForeignServerCommand(), DropForeignTableCommand::DropForeignTableCommand(), CreateForeignServerCommand::execute(), AlterForeignServerCommand::execute(), DropForeignServerCommand::execute(), CreateForeignTableCommand::execute(), DropForeignTableCommand::execute(), AlterTableCommand::execute(), AlterForeignTableCommand::execute(), ShowForeignServersCommand::execute(), ShowCreateTableCommand::execute(), ShowFunctionsCommand::execute(), ShowTableFunctionsCommand::execute(), ShowModelFeatureDetailsCommand::execute(), EvaluateModelCommand::execute(), ShowUserDetailsCommand::execute(), ShowRolesCommand::execute(), RefreshForeignTablesCommand::execute(), AlterDatabaseCommand::execute(), DdlCommandExecutor::execute(), DdlCommandExecutor::getDistributedExecutionDetails(), ShowModelDetailsCommand::getFilteredModelNames(), ShowTableDetailsCommand::getFilteredTableNames(), ShowDiskCacheUsageCommand::getFilteredTableNames(), DdlCommandExecutor::getSessionParameter(), DdlCommandExecutor::getTargetQuerySessionToKill(), AlterForeignServerCommand::hasAlterServerPrivileges(), ReassignOwnedCommand::ReassignOwnedCommand(), RefreshForeignTablesCommand::RefreshForeignTablesCommand(), AlterDatabaseCommand::rename(), AlterForeignTableCommand::renameColumn(), AlterForeignServerCommand::renameForeignServer(), AlterForeignTableCommand::renameTable(), DdlCommandExecutor::returnCacheType(), DdlCommandExecutor::returnQueueAction(), CreateForeignTableCommand::setColumnDetails(), AlterForeignServerCommand::setForeignServerDataWrapper(), AlterForeignServerCommand::setForeignServerOptions(), CreateForeignTableCommand::setTableDetails(), ShowCreateServerCommand::ShowCreateServerCommand(), ShowDiskCacheUsageCommand::ShowDiskCacheUsageCommand(), ShowForeignServersCommand::ShowForeignServersCommand(), ShowRolesCommand::ShowRolesCommand(), ShowTableDetailsCommand::ShowTableDetailsCommand(), and ShowUserDetailsCommand::ShowUserDetailsCommand().

488  {
489  const DdlCommandDataImpl* data = static_cast<const DdlCommandDataImpl*>(&ddl_data);
490  return data->payload();
491 }

+ Here is the call graph for this function:

std::unique_ptr<RexLiteral> anonymous_namespace{DdlCommandExecutor.cpp}::genLiteralBigInt ( int64_t  val)

Definition at line 327 of file DdlCommandExecutor.cpp.

References kBIGINT.

Referenced by add_table_details(), ShowModelDetailsCommand::execute(), ShowDiskCacheUsageCommand::execute(), ShowUserDetailsCommand::execute(), and ShowModelFeatureDetailsCommand::prepareLogicalValues().

327  {
328  return std::unique_ptr<RexLiteral>(
329  new RexLiteral(val, SQLTypes::kBIGINT, SQLTypes::kBIGINT, 0, 8, 0, 8));
330 }

+ Here is the caller graph for this function:

std::unique_ptr<RexLiteral> anonymous_namespace{DdlCommandExecutor.cpp}::genLiteralBoolean ( bool  val)

Definition at line 337 of file DdlCommandExecutor.cpp.

References kBIGINT.

Referenced by add_table_details(), ShowFunctionsCommand::execute(), ShowTableFunctionsCommand::execute(), and ShowUserDetailsCommand::execute().

337  {
338  return std::unique_ptr<RexLiteral>(new RexLiteral(
339  (int64_t)(val ? 1 : 0), SQLTypes::kBIGINT, SQLTypes::kBIGINT, 0, 8, 0, 8));
340 }

+ Here is the caller graph for this function:

std::unique_ptr<RexLiteral> anonymous_namespace{DdlCommandExecutor.cpp}::genLiteralDouble ( double  val)

Definition at line 332 of file DdlCommandExecutor.cpp.

References kDOUBLE.

Referenced by ShowModelDetailsCommand::execute(), EvaluateModelCommand::execute(), and ShowModelFeatureDetailsCommand::prepareLogicalValues().

332  {
333  return std::unique_ptr<RexLiteral>(
334  new RexLiteral(val, SQLTypes::kDOUBLE, SQLTypes::kDOUBLE, 0, 8, 0, 8));
335 }

+ Here is the caller graph for this function:

std::unique_ptr<RexLiteral> anonymous_namespace{DdlCommandExecutor.cpp}::genLiteralStr ( std::string  val)

Definition at line 317 of file DdlCommandExecutor.cpp.

References kTEXT.

317  {
318  return std::unique_ptr<RexLiteral>(
319  new RexLiteral(val, SQLTypes::kTEXT, SQLTypes::kTEXT, 0, 0, 0, 0));
320 }
Definition: sqltypes.h:79
std::unique_ptr<RexLiteral> anonymous_namespace{DdlCommandExecutor.cpp}::genLiteralTimestamp ( time_t  val)

Definition at line 322 of file DdlCommandExecutor.cpp.

References kTIMESTAMP.

Referenced by ShowForeignServersCommand::execute().

322  {
323  return std::unique_ptr<RexLiteral>(new RexLiteral(
324  (int64_t)val, SQLTypes::kTIMESTAMP, SQLTypes::kTIMESTAMP, 0, 8, 0, 8));
325 }

+ Here is the caller graph for this function:

AggregratedStorageStats anonymous_namespace{DdlCommandExecutor.cpp}::get_agg_storage_stats ( const TableDescriptor td,
const Catalog_Namespace::Catalog catalog 
)

Definition at line 292 of file DdlCommandExecutor.cpp.

References CHECK, CHECK_EQ, Catalog_Namespace::Catalog::getDatabaseId(), Catalog_Namespace::Catalog::getDataMgr(), Data_Namespace::DataMgr::getGlobalFileMgr(), Catalog_Namespace::Catalog::getPhysicalTablesDescriptors(), TableDescriptor::nShards, and TableDescriptor::tableId.

Referenced by ShowTableDetailsCommand::execute().

293  {
294  const auto global_file_mgr = catalog->getDataMgr().getGlobalFileMgr();
295  std::optional<AggregratedStorageStats> agg_storage_stats;
296  if (td->nShards > 0) {
297  const auto physical_tables = catalog->getPhysicalTablesDescriptors(td, false);
298  CHECK_EQ(static_cast<size_t>(td->nShards), physical_tables.size());
299 
300  for (const auto physical_table : physical_tables) {
301  auto storage_stats = global_file_mgr->getStorageStats(catalog->getDatabaseId(),
302  physical_table->tableId);
303  if (agg_storage_stats) {
304  agg_storage_stats.value().aggregate(storage_stats);
305  } else {
306  agg_storage_stats = storage_stats;
307  }
308  }
309  } else {
310  agg_storage_stats =
311  global_file_mgr->getStorageStats(catalog->getDatabaseId(), td->tableId);
312  }
313  CHECK(agg_storage_stats.has_value());
314  return agg_storage_stats.value();
315 }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
Data_Namespace::DataMgr & getDataMgr() const
Definition: Catalog.h:266
int getDatabaseId() const
Definition: Catalog.h:326
std::vector< const TableDescriptor * > getPhysicalTablesDescriptors(const TableDescriptor *logical_table_desc, bool populate_fragmenter=true) const
Definition: Catalog.cpp:4869
File_Namespace::GlobalFileMgr * getGlobalFileMgr() const
Definition: DataMgr.cpp:649
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::list<std::pair<const ColumnDescriptor*, std::list<const ColumnDescriptor*> > > anonymous_namespace{DdlCommandExecutor.cpp}::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 
)

Definition at line 101 of file DdlCommandExecutor.cpp.

References CHECK.

Referenced by AlterTableAlterColumnCommand::alterColumnTypes().

103  {
104  std::list<std::pair<const ColumnDescriptor*, std::list<const ColumnDescriptor*>>>
105  geo_src_dst_column_pairs;
106 
107  auto phys_cds_it = phys_cds.begin();
108  for (auto& [src_cd, dst_cd] : src_dst_cds) {
109  if (dst_cd->columnType.is_geometry()) {
110  geo_src_dst_column_pairs.emplace_back();
111  auto& pair = geo_src_dst_column_pairs.back();
112  pair.first = src_cd;
113 
114  std::list<const ColumnDescriptor*> geo_dst_cds;
115  CHECK(phys_cds_it != phys_cds.end());
116  auto& phy_geo_columns = *phys_cds_it;
117  geo_dst_cds.push_back(dst_cd);
118  for (const auto& cd : phy_geo_columns) {
119  geo_dst_cds.push_back(&cd);
120  }
121  pair.second = geo_dst_cds;
122 
123  phys_cds_it++;
124  }
125  }
126 
127  return geo_src_dst_column_pairs;
128 }
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the caller graph for this function:

AlterTableAlterColumnCommand::TypePairs anonymous_namespace{DdlCommandExecutor.cpp}::get_alter_column_pairs_from_src_dst_cds ( std::list< ColumnDescriptor > &  src_cds,
std::list< ColumnDescriptor > &  dst_cds 
)

Definition at line 130 of file DdlCommandExecutor.cpp.

References CHECK_EQ.

Referenced by AlterTableAlterColumnCommand::alterColumn().

132  {
133  CHECK_EQ(src_cds.size(), dst_cds.size());
134  AlterTableAlterColumnCommand::TypePairs src_dst_column_pairs;
135  auto src_cd_it = src_cds.begin();
136  auto dst_cd_it = dst_cds.begin();
137  for (; src_cd_it != src_cds.end(); ++src_cd_it, ++dst_cd_it) {
138  src_dst_column_pairs.emplace_back(&(*src_cd_it), &(*dst_cd_it));
139  }
140  return src_dst_column_pairs;
141 }
#define CHECK_EQ(x, y)
Definition: Logger.h:301
alter_column_shared::TypePairs TypePairs

+ Here is the caller graph for this function:

std::pair<std::list<ColumnDescriptor>, std::list<ColumnDescriptor> > anonymous_namespace{DdlCommandExecutor.cpp}::get_alter_column_src_dst_cds ( const std::list< Parser::ColumnDef > &  columns,
Catalog_Namespace::Catalog catalog,
const TableDescriptor td 
)

Definition at line 144 of file DdlCommandExecutor.cpp.

References CHECK, ColumnDescriptor::chunks, ColumnDescriptor::columnId, ColumnDescriptor::columnName, ColumnDescriptor::columnType, ddl_utils::alter_column_utils::compare_column_descriptors(), ColumnDescriptor::db_id, ddl_utils::alter_column_utils::CompareResult::exact_match, SQLTypeInfo::get_comp_param(), Catalog_Namespace::Catalog::getMetadataForColumn(), SQLTypeInfo::is_dict_encoded_string(), SQLTypeInfo::is_dict_encoded_type(), Parser::set_column_descriptor(), SQLTypeInfo::set_comp_param(), SQLTypeInfo::set_size(), SQLTypeInfo::setStringDictKey(), ColumnDescriptor::sourceName, ddl_utils::alter_column_utils::CompareResult::sql_types_match, ColumnDescriptor::tableId, TableDescriptor::tableId, UNREACHABLE, validate_alter_type_allowed(), and validate_alter_type_metadata().

Referenced by AlterTableAlterColumnCommand::alterColumn().

146  {
147  std::list<ColumnDescriptor> src_cds;
148  std::list<ColumnDescriptor> dst_cds;
149  for (const auto& coldef : columns) {
150  dst_cds.emplace_back();
151  ColumnDescriptor& dst_cd = dst_cds.back();
152  set_column_descriptor(dst_cd, &coldef);
153 
154  // update kENCODING_DICT column descriptors to reflect correct sizing based on comp
155  // param
156  if (dst_cd.columnType.is_dict_encoded_string()) {
157  switch (dst_cd.columnType.get_comp_param()) {
158  case 8:
159  dst_cd.columnType.set_size(1);
160  break;
161  case 16:
162  dst_cd.columnType.set_size(2);
163  break;
164  case 32:
165  dst_cd.columnType.set_size(4);
166  break;
167  default:
168  UNREACHABLE();
169  }
170  }
171 
172  auto catalog_cd = catalog.getMetadataForColumn(td->tableId, dst_cd.columnName);
173  CHECK(catalog_cd);
174 
176  dst_cd.columnName, catalog_cd->columnType, dst_cd.columnType);
177 
178  // Set remaining values in column descriptor that must be obtained from catalog
179  dst_cd.columnId = catalog_cd->columnId;
180  dst_cd.tableId = catalog_cd->tableId;
181  dst_cd.sourceName = catalog_cd->sourceName;
182  dst_cd.chunks = catalog_cd->chunks;
183  dst_cd.db_id = catalog_cd->db_id;
184 
185  // This branch handles the special case where a string dictionary column
186  // type is not changed, but altering is required (for example default
187  // changes)
188  if (catalog_cd->columnType.is_dict_encoded_type() &&
189  dst_cd.columnType.is_dict_encoded_type() &&
191  .sql_types_match) {
192  dst_cd.columnType.set_comp_param(catalog_cd->columnType.get_comp_param());
193  dst_cd.columnType.setStringDictKey(catalog_cd->columnType.getStringDictKey());
194  }
195 
197  .exact_match) {
198  throw std::runtime_error("Altering column " + dst_cd.columnName +
199  " results in no change to column, please review command.");
200  }
201 
202  validate_alter_type_metadata(catalog, td, dst_cd);
203 
204  // A copy of the catalog column descriptor is stored for the source because
205  // the catalog may delete its version of the source descriptor in progress
206  // of the alter column command
207  src_cds.emplace_back();
208  src_cds.back() = *catalog_cd;
209  }
210  return {src_cds, dst_cds};
211 }
void set_size(int s)
Definition: sqltypes.h:476
void validate_alter_type_allowed(const std::string &colname, const SQLTypeInfo &src, const SQLTypeInfo &dst)
CompareResult compare_column_descriptors(const ColumnDescriptor *lhs, const ColumnDescriptor *rhs)
Definition: DdlUtils.cpp:52
void set_column_descriptor(ColumnDescriptor &cd, const ColumnDef *coldef)
#define UNREACHABLE()
Definition: Logger.h:338
std::string sourceName
std::string chunks
const ColumnDescriptor * getMetadataForColumn(int tableId, const std::string &colName) const
bool is_dict_encoded_type() const
Definition: sqltypes.h:653
specifies the content in-memory of a row in the column metadata table
void set_comp_param(int p)
Definition: sqltypes.h:480
void setStringDictKey(const shared::StringDictKey &dict_key)
Definition: sqltypes.h:1061
void validate_alter_type_metadata(const Catalog_Namespace::Catalog &catalog, const TableDescriptor *td, const ColumnDescriptor &cd)
HOST DEVICE int get_comp_param() const
Definition: sqltypes.h:402
#define CHECK(condition)
Definition: Logger.h:291
bool is_dict_encoded_string() const
Definition: sqltypes.h:641
SQLTypeInfo columnType
std::string columnName

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class LockType >
std::tuple<const TableDescriptor*, std::unique_ptr<lockmgr::TableSchemaLockContainer<LockType> > > anonymous_namespace{DdlCommandExecutor.cpp}::get_table_descriptor_with_lock ( Catalog_Namespace::Catalog cat,
const std::string &  table_name,
const bool  populate_fragmenter 
)

Definition at line 216 of file DdlCommandExecutor.cpp.

References CHECK.

218  {
219  const TableDescriptor* td{nullptr};
220  std::unique_ptr<lockmgr::TableSchemaLockContainer<LockType>> td_with_lock =
221  std::make_unique<lockmgr::TableSchemaLockContainer<LockType>>(
223  cat, table_name, populate_fragmenter));
224  CHECK(td_with_lock);
225  td = (*td_with_lock)();
226  CHECK(td);
227  return std::make_tuple(td, std::move(td_with_lock));
228 }
#define CHECK(condition)
Definition: Logger.h:291
bool anonymous_namespace{DdlCommandExecutor.cpp}::is_default_server ( const std::string &  server_name)

Definition at line 845 of file DdlCommandExecutor.cpp.

References anonymous_namespace{QueryMemoryDescriptor.cpp}::any_of(), and kReservedServerPrefixes.

Referenced by CreateForeignServerCommand::execute(), AlterForeignServerCommand::execute(), DropForeignServerCommand::execute(), AlterForeignServerCommand::renameForeignServer(), and CreateForeignTableCommand::setTableDetails().

845  {
846  return std::any_of(kReservedServerPrefixes.begin(),
848  [&server_name](const std::string& reserved_prefix) {
849  return boost::istarts_with(server_name, reserved_prefix);
850  });
851 }
bool any_of(std::vector< Analyzer::Expr * > const &target_exprs)
const std::array< std::string, 3 > kReservedServerPrefixes

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void anonymous_namespace{DdlCommandExecutor.cpp}::set_headers_with_type ( std::vector< TargetMetaInfo > &  label_infos,
const std::vector< std::tuple< std::string, SQLTypes, bool >> &  headers 
)

Definition at line 342 of file DdlCommandExecutor.cpp.

References report::header, kBIGINT, kBOOLEAN, kTEXT, kTIMESTAMP, to_string(), and UNREACHABLE.

Referenced by ShowTableDetailsCommand::execute().

344  {
345  for (const auto& header : headers) {
346  auto [_val, _type, _notnull] = header;
347  if (_type == kBIGINT || _type == kTEXT || _type == kTIMESTAMP || _type == kBOOLEAN) {
348  label_infos.emplace_back(_val, SQLTypeInfo(_type, _notnull));
349  } else {
350  UNREACHABLE() << "Unsupported type provided for header. SQL type: "
351  << to_string(_type);
352  }
353  }
354 }
#define UNREACHABLE()
Definition: Logger.h:338
std::string to_string(char const *&&v)
Definition: sqltypes.h:79
list header
Definition: report.py:113

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void anonymous_namespace{DdlCommandExecutor.cpp}::throw_reserved_server_prefix_exception ( )

Definition at line 853 of file DdlCommandExecutor.cpp.

References kReservedServerPrefixes.

Referenced by CreateForeignServerCommand::execute(), and AlterForeignServerCommand::renameForeignServer().

853  {
854  std::string error_message{"Foreign server names cannot start with "};
855  for (size_t i = 0; i < kReservedServerPrefixes.size(); i++) {
856  if (i > 0) {
857  error_message += ", ";
858  }
859  if (i == kReservedServerPrefixes.size() - 1) {
860  error_message += "or ";
861  }
862  error_message += "\"" + kReservedServerPrefixes[i] + "\"";
863  }
864  error_message += ".";
865  throw std::runtime_error{error_message};
866 }
const std::array< std::string, 3 > kReservedServerPrefixes

+ Here is the caller graph for this function:

void anonymous_namespace{DdlCommandExecutor.cpp}::vacuum_table_if_required ( const Catalog_Namespace::Catalog catalog,
const TableDescriptor td 
)

Definition at line 51 of file DdlCommandExecutor.cpp.

References DEBUG_TIMER, measure< TimeT >::execution(), Executor::getExecutor(), Catalog_Namespace::Catalog::getMetadataForTable(), TableDescriptor::hasDeletedCol, logger::INFO, LOG, TableDescriptor::tableName, Executor::UNITARY_EXECUTOR_ID, and TableOptimizer::vacuumDeletedRows().

Referenced by AlterTableAlterColumnCommand::alterColumnTypes().

52  {
53  if (!td->hasDeletedCol) {
54  return;
55  }
56 
57  DEBUG_TIMER(__func__);
58 
60  const TableOptimizer optimizer(td, executor, catalog);
61  auto total_time_ms = measure<>::execution([&]() { optimizer.vacuumDeletedRows(); });
62  LOG(INFO) << "Vacuum time (alter column data type): " << total_time_ms << "ms";
63 
64  // Reload fragmenter
65  catalog.getMetadataForTable(td->tableName, true);
66 }
std::string tableName
static TimeT::rep execution(F func, Args &&...args)
Definition: sample.cpp:29
#define LOG(tag)
Definition: Logger.h:285
Driver for running cleanup processes on a table. TableOptimizer provides functions for various cleanu...
static std::shared_ptr< Executor > getExecutor(const ExecutorId id, const std::string &debug_dir="", const std::string &debug_file="", const SystemParameters &system_parameters=SystemParameters())
Definition: Execute.cpp:509
#define DEBUG_TIMER(name)
Definition: Logger.h:412
const TableDescriptor * getMetadataForTable(const std::string &tableName, const bool populateFragmenter=true) const
Returns a pointer to a const TableDescriptor struct matching the provided tableName.
static constexpr ExecutorId UNITARY_EXECUTOR_ID
Definition: Execute.h:423

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void anonymous_namespace{DdlCommandExecutor.cpp}::validate_alter_type_allowed ( const std::string &  colname,
const SQLTypeInfo src,
const SQLTypeInfo dst 
)

Definition at line 68 of file DdlCommandExecutor.cpp.

References SQLTypeInfo::is_string().

Referenced by get_alter_column_src_dst_cds().

70  {
71  if (!src.is_string()) {
72  throw std::runtime_error("Altering column " + colname +
73  " type not allowed. Column type must be TEXT.");
74  }
75 }
bool is_string() const
Definition: sqltypes.h:559

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void anonymous_namespace{DdlCommandExecutor.cpp}::validate_alter_type_metadata ( const Catalog_Namespace::Catalog catalog,
const TableDescriptor td,
const ColumnDescriptor cd 
)

Definition at line 77 of file DdlCommandExecutor.cpp.

References ColumnDescriptor::columnId, ColumnDescriptor::columnName, ColumnDescriptor::columnType, SQLTypeInfo::get_notnull(), Data_Namespace::DataMgr::getChunkMetadataVecForKeyPrefix(), Catalog_Namespace::Catalog::getDatabaseId(), Catalog_Namespace::Catalog::getDataMgr(), TableDescriptor::nShards, and TableDescriptor::tableId.

Referenced by get_alter_column_src_dst_cds().

79  {
80  ChunkMetadataVector column_metadata;
82  column_metadata, {catalog.getDatabaseId(), td->tableId, cd.columnId});
83 
84  const bool is_not_null = cd.columnType.get_notnull();
85  // check for non nulls
86  for (const auto& [key, metadata] : column_metadata) {
87  if (is_not_null && metadata->chunkStats.has_nulls) {
88  throw std::runtime_error("Alter column type: Column " + cd.columnName +
89  ": NULL value not allowed in NOT NULL column");
90  }
91  }
92 
93  if (td->nShards > 0) {
94  throw std::runtime_error("Alter column type: Column " + cd.columnName +
95  ": altering a sharded table is unsupported");
96  }
97  // further checks on metadata can be done to prevent late exceptions
98 }
Data_Namespace::DataMgr & getDataMgr() const
Definition: Catalog.h:266
void getChunkMetadataVecForKeyPrefix(ChunkMetadataVector &chunkMetadataVec, const ChunkKey &keyPrefix)
Definition: DataMgr.cpp:496
std::vector< std::pair< ChunkKey, std::shared_ptr< ChunkMetadata >>> ChunkMetadataVector
int getDatabaseId() const
Definition: Catalog.h:326
SQLTypeInfo columnType
HOST DEVICE bool get_notnull() const
Definition: sqltypes.h:398
std::string columnName

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

const std::array<std::string, 3> anonymous_namespace{DdlCommandExecutor.cpp}::kReservedServerPrefixes {"default", "system", "internal"}