OmniSciDB  ca0c39ec8f
 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

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)
 
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< 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 163 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().

165  {
166  bool is_sharded_table = (logical_table->nShards > 0);
167  logical_values.emplace_back(RelLogicalValues::RowValues{});
168  logical_values.back().emplace_back(genLiteralBigInt(logical_table->tableId));
169  logical_values.back().emplace_back(genLiteralStr(logical_table->tableName));
170  logical_values.back().emplace_back(genLiteralBigInt(logical_table->nColumns));
171  logical_values.back().emplace_back(genLiteralBoolean(is_sharded_table));
172  logical_values.back().emplace_back(genLiteralBigInt(logical_table->nShards));
173  logical_values.back().emplace_back(genLiteralBigInt(logical_table->maxRows));
174  logical_values.back().emplace_back(genLiteralBigInt(logical_table->maxFragRows));
175  logical_values.back().emplace_back(genLiteralBigInt(logical_table->maxRollbackEpochs));
176  logical_values.back().emplace_back(genLiteralBigInt(agg_storage_stats.min_epoch));
177  logical_values.back().emplace_back(genLiteralBigInt(agg_storage_stats.max_epoch));
178  logical_values.back().emplace_back(genLiteralBigInt(agg_storage_stats.min_epoch_floor));
179  logical_values.back().emplace_back(genLiteralBigInt(agg_storage_stats.max_epoch_floor));
180  logical_values.back().emplace_back(
181  genLiteralBigInt(agg_storage_stats.metadata_file_count));
182  logical_values.back().emplace_back(
183  genLiteralBigInt(agg_storage_stats.total_metadata_file_size));
184  logical_values.back().emplace_back(
185  genLiteralBigInt(agg_storage_stats.total_metadata_page_count));
186 
187  if (agg_storage_stats.total_free_metadata_page_count) {
188  logical_values.back().emplace_back(
189  genLiteralBigInt(agg_storage_stats.total_free_metadata_page_count.value()));
190  } else {
191  logical_values.back().emplace_back(genLiteralBigInt(NULL_BIGINT));
192  }
193 
194  logical_values.back().emplace_back(genLiteralBigInt(agg_storage_stats.data_file_count));
195  logical_values.back().emplace_back(
196  genLiteralBigInt(agg_storage_stats.total_data_file_size));
197  logical_values.back().emplace_back(
198  genLiteralBigInt(agg_storage_stats.total_data_page_count));
199 
200  if (agg_storage_stats.total_free_data_page_count) {
201  logical_values.back().emplace_back(
202  genLiteralBigInt(agg_storage_stats.total_free_data_page_count.value()));
203  } else {
204  logical_values.back().emplace_back(genLiteralBigInt(NULL_BIGINT));
205  }
206 }
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:7262
std::vector< std::unique_ptr< const RexScalar >> RowValues
Definition: RelAlgDag.h:2226

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 300 of file DdlCommandExecutor.cpp.

Referenced by ShowForeignServersCommand::execute().

300  {
301  const rapidjson::Value* filters = nullptr;
302  if (payload.HasMember("filters") && payload["filters"].IsArray()) {
303  filters = &payload["filters"];
304  }
305  return filters;
306 }

+ Here is the caller graph for this function:

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

Definition at line 295 of file DdlCommandExecutor.cpp.

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

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

295  {
296  const DdlCommandDataImpl* data = static_cast<const DdlCommandDataImpl*>(&ddl_data);
297  return data->payload();
298 }

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 137 of file DdlCommandExecutor.cpp.

References kBIGINT.

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

137  {
138  return std::unique_ptr<RexLiteral>(
139  new RexLiteral(val, SQLTypes::kBIGINT, SQLTypes::kBIGINT, 0, 8, 0, 8));
140 }

+ Here is the caller graph for this function:

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

Definition at line 142 of file DdlCommandExecutor.cpp.

References kBIGINT.

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

142  {
143  return std::unique_ptr<RexLiteral>(
144  // new RexLiteral(val, SQLTypes::kBOOLEAN, SQLTypes::kBOOLEAN, 0, 0, 0, 0));
145  new RexLiteral(
146  (int64_t)(val ? 1 : 0), SQLTypes::kBIGINT, SQLTypes::kBIGINT, 0, 8, 0, 8));
147 }

+ Here is the caller graph for this function:

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

Definition at line 127 of file DdlCommandExecutor.cpp.

References kTEXT.

127  {
128  return std::unique_ptr<RexLiteral>(
129  new RexLiteral(val, SQLTypes::kTEXT, SQLTypes::kTEXT, 0, 0, 0, 0));
130 }
Definition: sqltypes.h:67
std::unique_ptr<RexLiteral> anonymous_namespace{DdlCommandExecutor.cpp}::genLiteralTimestamp ( time_t  val)

Definition at line 132 of file DdlCommandExecutor.cpp.

References kTIMESTAMP.

Referenced by ShowForeignServersCommand::execute().

132  {
133  return std::unique_ptr<RexLiteral>(new RexLiteral(
134  (int64_t)val, SQLTypes::kTIMESTAMP, SQLTypes::kTIMESTAMP, 0, 8, 0, 8));
135 }

+ 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 102 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().

103  {
104  const auto global_file_mgr = catalog->getDataMgr().getGlobalFileMgr();
105  std::optional<AggregratedStorageStats> agg_storage_stats;
106  if (td->nShards > 0) {
107  const auto physical_tables = catalog->getPhysicalTablesDescriptors(td, false);
108  CHECK_EQ(static_cast<size_t>(td->nShards), physical_tables.size());
109 
110  for (const auto physical_table : physical_tables) {
111  auto storage_stats = global_file_mgr->getStorageStats(catalog->getDatabaseId(),
112  physical_table->tableId);
113  if (agg_storage_stats) {
114  agg_storage_stats.value().aggregate(storage_stats);
115  } else {
116  agg_storage_stats = storage_stats;
117  }
118  }
119  } else {
120  agg_storage_stats =
121  global_file_mgr->getStorageStats(catalog->getDatabaseId(), td->tableId);
122  }
123  CHECK(agg_storage_stats.has_value());
124  return agg_storage_stats.value();
125 }
#define CHECK_EQ(x, y)
Definition: Logger.h:230
Data_Namespace::DataMgr & getDataMgr() const
Definition: Catalog.h:243
int getDatabaseId() const
Definition: Catalog.h:298
std::vector< const TableDescriptor * > getPhysicalTablesDescriptors(const TableDescriptor *logical_table_desc, bool populate_fragmenter=true) const
Definition: Catalog.cpp:4630
File_Namespace::GlobalFileMgr * getGlobalFileMgr() const
Definition: DataMgr.cpp:606
#define CHECK(condition)
Definition: Logger.h:222

+ 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 45 of file DdlCommandExecutor.cpp.

References CHECK.

47  {
48  const TableDescriptor* td{nullptr};
49  std::unique_ptr<lockmgr::TableSchemaLockContainer<LockType>> td_with_lock =
50  std::make_unique<lockmgr::TableSchemaLockContainer<LockType>>(
52  cat, table_name, populate_fragmenter));
53  CHECK(td_with_lock);
54  td = (*td_with_lock)();
55  CHECK(td);
56  return std::make_tuple(td, std::move(td_with_lock));
57 }
#define CHECK(condition)
Definition: Logger.h:222
bool anonymous_namespace{DdlCommandExecutor.cpp}::is_default_server ( const std::string &  server_name)

Definition at line 636 of file DdlCommandExecutor.cpp.

References kReservedServerPrefixes.

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

636  {
637  return std::any_of(kReservedServerPrefixes.begin(),
639  [&server_name](const std::string& reserved_prefix) {
640  return boost::istarts_with(server_name, reserved_prefix);
641  });
642 }
const std::array< std::string, 3 > kReservedServerPrefixes

+ 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 149 of file DdlCommandExecutor.cpp.

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

Referenced by ShowTableDetailsCommand::execute().

151  {
152  for (const auto& header : headers) {
153  auto [_val, _type, _notnull] = header;
154  if (_type == kBIGINT || _type == kTEXT || _type == kTIMESTAMP || _type == kBOOLEAN) {
155  label_infos.emplace_back(_val, SQLTypeInfo(_type, _notnull));
156  } else {
157  UNREACHABLE() << "Unsupported type provided for header. SQL type: "
158  << to_string(_type);
159  }
160  }
161 }
#define UNREACHABLE()
Definition: Logger.h:266
std::string to_string(char const *&&v)
Definition: sqltypes.h:67

+ 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 644 of file DdlCommandExecutor.cpp.

References kReservedServerPrefixes.

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

644  {
645  std::string error_message{"Foreign server names cannot start with "};
646  for (size_t i = 0; i < kReservedServerPrefixes.size(); i++) {
647  if (i > 0) {
648  error_message += ", ";
649  }
650  if (i == kReservedServerPrefixes.size() - 1) {
651  error_message += "or ";
652  }
653  error_message += "\"" + kReservedServerPrefixes[i] + "\"";
654  }
655  error_message += ".";
656  throw std::runtime_error{error_message};
657 }
const std::array< std::string, 3 > kReservedServerPrefixes

+ Here is the caller graph for this function:

Variable Documentation

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