OmniSciDB  a667adc9c8
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 (const 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)
 

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

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

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

Referenced by ShowForeignServersCommand::execute().

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

+ Here is the caller graph for this function:

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

Definition at line 297 of file DdlCommandExecutor.cpp.

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

Referenced by AlterForeignServerCommand::AlterForeignServerCommand(), AlterForeignTableCommand::AlterForeignTableCommand(), AlterForeignTableCommand::alterOptions(), AlterForeignServerCommand::changeForeignServerOwner(), CreateForeignServerCommand::CreateForeignServerCommand(), CreateForeignTableCommand::CreateForeignTableCommand(), DropForeignServerCommand::DropForeignServerCommand(), DropForeignTableCommand::DropForeignTableCommand(), CreateForeignServerCommand::execute(), AlterForeignServerCommand::execute(), DropForeignServerCommand::execute(), CreateForeignTableCommand::execute(), DropForeignTableCommand::execute(), AlterForeignTableCommand::execute(), ShowForeignServersCommand::execute(), RefreshForeignTablesCommand::execute(), DdlCommandExecutor::execute(), ShowTableDetailsCommand::getFilteredTableNames(), ShowDiskCacheUsageCommand::getFilteredTableNames(), DdlCommandExecutor::getTargetQuerySessionToKill(), AlterForeignServerCommand::hasAlterServerPrivileges(), RefreshForeignTablesCommand::RefreshForeignTablesCommand(), AlterForeignTableCommand::renameColumn(), AlterForeignServerCommand::renameForeignServer(), AlterForeignTableCommand::renameTable(), CreateForeignTableCommand::setColumnDetails(), AlterForeignServerCommand::setForeignServerDataWrapper(), AlterForeignServerCommand::setForeignServerOptions(), CreateForeignTableCommand::setTableDetails(), ShowDiskCacheUsageCommand::ShowDiskCacheUsageCommand(), ShowForeignServersCommand::ShowForeignServersCommand(), and ShowTableDetailsCommand::ShowTableDetailsCommand().

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

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

References kBIGINT.

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

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

+ Here is the caller graph for this function:

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

Definition at line 144 of file DdlCommandExecutor.cpp.

References kBIGINT.

Referenced by add_table_details().

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

+ Here is the caller graph for this function:

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

Definition at line 129 of file DdlCommandExecutor.cpp.

References kTEXT.

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

Definition at line 134 of file DdlCommandExecutor.cpp.

References kTIMESTAMP.

Referenced by ShowForeignServersCommand::execute().

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

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

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

+ 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 ( const Catalog_Namespace::Catalog cat,
const std::string &  table_name,
const bool  populate_fragmenter 
)

Definition at line 47 of file DdlCommandExecutor.cpp.

References CHECK.

49  {
50  const TableDescriptor* td{nullptr};
51  std::unique_ptr<lockmgr::TableSchemaLockContainer<LockType>> td_with_lock =
52  std::make_unique<lockmgr::TableSchemaLockContainer<LockType>>(
54  cat, table_name, populate_fragmenter));
55  CHECK(td_with_lock);
56  td = (*td_with_lock)();
57  CHECK(td);
58  return std::make_tuple(td, std::move(td_with_lock));
59 }
#define CHECK(condition)
Definition: Logger.h:197
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 151 of file DdlCommandExecutor.cpp.

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

Referenced by ShowTableDetailsCommand::execute().

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function: