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

Functions

auto table_json_filepath (const std::string &base_path, const std::string &db_name)
 
std::map< int32_t, std::string > get_user_id_to_user_name_map ()
 
std::string get_user_name_from_id (int32_t id, const std::map< int32_t, std::string > &user_name_by_user_id)
 
void set_dict_key (ColumnDescriptor &cd)
 
int64_t get_next_refresh_time (const foreign_storage::ForeignTable &foreign_table)
 
std::string table_epochs_to_string (const std::vector< TableEpochInfo > &table_epochs)
 
const ColumnDescriptorget_foreign_col (const Catalog &cat, const Parser::SharedDictionaryDef &shared_dict_def)
 
void replace_cached_table_name (std::map< std::string, int > &cachedTableMap, const std::string &curTableName, const std::string &newTableName, int tableId)
 
int32_t validate_and_get_user_id (const std::string &user_name)
 
std::string convert_object_owners_map_to_string (int32_t db_id, int32_t new_owner_id, const std::map< int32_t, std::vector< DBObject >> &old_owner_db_objects)
 
void add_db_object (const std::string &object_name, DBObjectType object_type, int32_t user_id, const AccessPrivileges &privileges, std::map< int32_t, std::vector< DBObject >> &db_objects)
 
SQLTypeInfo get_encoded_text_type ()
 
SQLTypeInfo get_var_array_type (SQLTypes type)
 
SQLTypeInfo get_var_encoded_text_array_type ()
 
void set_common_log_system_table_options (foreign_storage::ForeignTable &foreign_table)
 
void set_common_db_log_system_table_options (foreign_storage::ForeignTable &foreign_table)
 
void clear_cached_table_data (const Data_Namespace::DataMgr *data_mgr, int32_t db_id, int32_t table_id)
 
void drop_tables (Catalog &catalog, const std::vector< std::string > &table_names)
 
std::string get_checked_table_name (const Catalog *catalog, const ColumnDescriptor *cd)
 

Function Documentation

void Catalog_Namespace::anonymous_namespace{Catalog.cpp}::add_db_object ( const std::string &  object_name,
DBObjectType  object_type,
int32_t  user_id,
const AccessPrivileges privileges,
std::map< int32_t, std::vector< DBObject >> &  db_objects 
)

Definition at line 6150 of file Catalog.cpp.

References DBObject::setPrivileges().

Referenced by Catalog_Namespace::Catalog::reassignOwners().

6154  {
6155  DBObject db_object{object_name, object_type};
6156  db_object.setPrivileges(privileges);
6157  db_objects[user_id].emplace_back(db_object);
6158 }
void setPrivileges(const AccessPrivileges &privs)
Definition: DBObject.h:227

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Catalog_Namespace::anonymous_namespace{Catalog.cpp}::clear_cached_table_data ( const Data_Namespace::DataMgr data_mgr,
int32_t  db_id,
int32_t  table_id 
)

Definition at line 6458 of file Catalog.cpp.

References foreign_storage::ForeignStorageCache::clearForTablePrefix(), PersistentStorageMgr::getDiskCache(), and Data_Namespace::DataMgr::getPersistentStorageMgr().

Referenced by Catalog_Namespace::Catalog::initializeRequestLogsSystemTables(), Catalog_Namespace::Catalog::initializeServerLogsSystemTables(), Catalog_Namespace::Catalog::initializeWebServerAccessLogsSystemTables(), and Catalog_Namespace::Catalog::initializeWebServerLogsSystemTables().

6460  {
6461  auto cache = data_mgr->getPersistentStorageMgr()->getDiskCache();
6462  if (cache) {
6463  cache->clearForTablePrefix({db_id, table_id});
6464  }
6465 }
PersistentStorageMgr * getPersistentStorageMgr() const
Definition: DataMgr.cpp:677
foreign_storage::ForeignStorageCache * getDiskCache() const

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string Catalog_Namespace::anonymous_namespace{Catalog.cpp}::convert_object_owners_map_to_string ( int32_t  db_id,
int32_t  new_owner_id,
const std::map< int32_t, std::vector< DBObject >> &  old_owner_db_objects 
)

Definition at line 6127 of file Catalog.cpp.

References DBObjectTypeToString(), and run_benchmark_import::result.

Referenced by Catalog_Namespace::Catalog::restoreOldOwners().

6130  {
6131  std::stringstream result;
6132  for (const auto& [old_owner_id, db_objects] : old_owner_db_objects) {
6133  result << "db_id: " << db_id << ", new_owner_user_id: " << new_owner_id
6134  << ", old_owner_user_id: " << old_owner_id << ", db_objects: [";
6135  bool first_object{true};
6136  for (const auto& db_object : db_objects) {
6137  if (first_object) {
6138  first_object = false;
6139  } else {
6140  result << ", ";
6141  }
6142  result << "\"object_id: " << db_object.getObjectKey().objectId
6143  << ", object_type: " << DBObjectTypeToString(db_object.getType()) << "\"";
6144  }
6145  result << "]\n";
6146  }
6147  return result.str();
6148 }
std::string DBObjectTypeToString(DBObjectType type)
Definition: DBObject.cpp:92

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Catalog_Namespace::anonymous_namespace{Catalog.cpp}::drop_tables ( Catalog &  catalog,
const std::vector< std::string > &  table_names 
)

Definition at line 6467 of file Catalog.cpp.

References Catalog_Namespace::Catalog::dropTable(), and Catalog_Namespace::Catalog::getMetadataForTable().

Referenced by Catalog_Namespace::Catalog::initializeSystemTables().

6467  {
6468  for (const auto& table_name : table_names) {
6469  if (auto td = catalog.getMetadataForTable(table_name)) {
6470  catalog.dropTable(td);
6471  }
6472  }
6473 }

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string Catalog_Namespace::anonymous_namespace{Catalog.cpp}::get_checked_table_name ( const Catalog *  catalog,
const ColumnDescriptor cd 
)

Definition at line 6953 of file Catalog.cpp.

References CHECK, Catalog_Namespace::Catalog::getTableName(), and ColumnDescriptor::tableId.

Referenced by Catalog_Namespace::Catalog::updateInColumnMap().

6953  {
6954  auto table_name_opt = catalog->getTableName(cd->tableId);
6955  CHECK(table_name_opt.has_value());
6956  return table_name_opt.value();
6957 }
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

SQLTypeInfo Catalog_Namespace::anonymous_namespace{Catalog.cpp}::get_encoded_text_type ( )
inline
const ColumnDescriptor* Catalog_Namespace::anonymous_namespace{Catalog.cpp}::get_foreign_col ( const Catalog &  cat,
const Parser::SharedDictionaryDef shared_dict_def 
)

Definition at line 3953 of file Catalog.cpp.

References CHECK, Parser::SharedDictionaryDef::get_foreign_column(), Parser::SharedDictionaryDef::get_foreign_table(), Catalog_Namespace::Catalog::getMetadataForColumn(), and Catalog_Namespace::Catalog::getMetadataForTable().

Referenced by Catalog_Namespace::Catalog::addReferenceToForeignDict().

3955  {
3956  const auto& table_name = shared_dict_def.get_foreign_table();
3957  const auto td = cat.getMetadataForTable(table_name, false);
3958  CHECK(td);
3959  const auto& foreign_col_name = shared_dict_def.get_foreign_column();
3960  return cat.getMetadataForColumn(td->tableId, foreign_col_name);
3961 }
std::string cat(Ts &&...args)
const std::string & get_foreign_table() const
Definition: ParserNode.h:933
const std::string & get_foreign_column() const
Definition: ParserNode.h:935
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int64_t Catalog_Namespace::anonymous_namespace{Catalog.cpp}::get_next_refresh_time ( const foreign_storage::ForeignTable foreign_table)

Definition at line 2922 of file Catalog.cpp.

References CHECK, foreign_storage::RefreshTimeCalculator::getNextRefreshTime(), foreign_storage::ForeignTable::NULL_REFRESH_TIME, foreign_storage::OptionsContainer::options, foreign_storage::ForeignTable::REFRESH_TIMING_TYPE_KEY, and foreign_storage::ForeignTable::SCHEDULE_REFRESH_TIMING_TYPE.

Referenced by Catalog_Namespace::Catalog::createTable(), and Catalog_Namespace::Catalog::updateForeignTableRefreshTimes().

2922  {
2923  auto timing_type_entry =
2925  CHECK(timing_type_entry != foreign_table.options.end());
2926  if (timing_type_entry->second ==
2929  foreign_table.options);
2930  }
2932 }
static int64_t getNextRefreshTime(const std::map< std::string, std::string, std::less<>> &foreign_table_options)
static constexpr const char * REFRESH_TIMING_TYPE_KEY
Definition: ForeignTable.h:43
#define CHECK(condition)
Definition: Logger.h:291
static constexpr int NULL_REFRESH_TIME
Definition: ForeignTable.h:55
static constexpr const char * SCHEDULE_REFRESH_TIMING_TYPE
Definition: ForeignTable.h:53

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::map< int32_t, std::string > Catalog_Namespace::anonymous_namespace{Catalog.cpp}::get_user_id_to_user_name_map ( )

Definition at line 1042 of file Catalog.cpp.

References Catalog_Namespace::SysCatalog::getAllUserMetadata(), and Catalog_Namespace::SysCatalog::instance().

Referenced by Catalog_Namespace::Catalog::buildMaps(), and Catalog_Namespace::Catalog::reloadCatalogMetadata().

1042  {
1043  auto users = SysCatalog::instance().getAllUserMetadata();
1044  std::map<int32_t, std::string> user_name_by_user_id;
1045  for (const auto& user : users) {
1046  user_name_by_user_id[user.userId] = user.userName;
1047  }
1048  return user_name_by_user_id;
1049 }

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string Catalog_Namespace::anonymous_namespace{Catalog.cpp}::get_user_name_from_id ( int32_t  id,
const std::map< int32_t, std::string > &  user_name_by_user_id 
)

Definition at line 1051 of file Catalog.cpp.

Referenced by Catalog_Namespace::Catalog::buildDashboardsMapUnlocked().

1053  {
1054  auto entry = user_name_by_user_id.find(id);
1055  if (entry != user_name_by_user_id.end()) {
1056  return entry->second;
1057  }
1058  // a user could be deleted and a dashboard still exist?
1059  return "Unknown";
1060 }

+ Here is the caller graph for this function:

SQLTypeInfo Catalog_Namespace::anonymous_namespace{Catalog.cpp}::get_var_array_type ( SQLTypes  type)
inline

Definition at line 6423 of file Catalog.cpp.

References kARRAY, and kENCODING_NONE.

Referenced by get_var_encoded_text_array_type(), and Catalog_Namespace::Catalog::initializeMemoryDetailsSystemTable().

6423  {
6424  SQLTypeInfo sql_type_info{kARRAY, 0, 0, false, kENCODING_NONE, 0, type};
6425  sql_type_info.set_size(-1);
6426  return sql_type_info;
6427 }

+ Here is the caller graph for this function:

SQLTypeInfo Catalog_Namespace::anonymous_namespace{Catalog.cpp}::get_var_encoded_text_array_type ( )
inline

Definition at line 6429 of file Catalog.cpp.

References get_var_array_type(), kENCODING_DICT, and kTEXT.

Referenced by Catalog_Namespace::Catalog::initializeDashboardsSystemTable(), Catalog_Namespace::Catalog::initializeMLModelMetadataSystemTable(), and Catalog_Namespace::Catalog::initializePermissionsSystemTable().

6429  {
6430  auto sql_type_info = get_var_array_type(kTEXT);
6431  sql_type_info.set_compression(kENCODING_DICT);
6432  sql_type_info.set_comp_param(32);
6433  return sql_type_info;
6434 }
Definition: sqltypes.h:79

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Catalog_Namespace::anonymous_namespace{Catalog.cpp}::replace_cached_table_name ( std::map< std::string, int > &  cachedTableMap,
const std::string &  curTableName,
const std::string &  newTableName,
int  tableId 
)

Definition at line 4491 of file Catalog.cpp.

Referenced by Catalog_Namespace::Catalog::renameTables().

4494  {
4495  // mark old/cur name as deleted
4496  cachedTableMap[curTableName] = -1;
4497 
4498  // insert the 'new' name
4499  cachedTableMap[newTableName] = tableId;
4500 }

+ Here is the caller graph for this function:

void Catalog_Namespace::anonymous_namespace{Catalog.cpp}::set_common_db_log_system_table_options ( foreign_storage::ForeignTable foreign_table)

Definition at line 6446 of file Catalog.cpp.

References foreign_storage::OptionsContainer::options, and set_common_log_system_table_options().

Referenced by Catalog_Namespace::Catalog::initializeRequestLogsSystemTables(), and Catalog_Namespace::Catalog::initializeServerLogsSystemTables().

6447  {
6448  // Each log entry should start with a timestamp.
6450  foreign_table.options[RegexFileBufferParser::LINE_START_REGEX_KEY] =
6451  "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{6}";
6453  foreign_table.options[AbstractFileStorageDataWrapper::REGEX_PATH_FILTER_KEY] =
6454  ".*heavydb\\.INFO\\..*";
6455  set_common_log_system_table_options(foreign_table);
6456 }
void set_common_log_system_table_options(foreign_storage::ForeignTable &foreign_table)
Definition: Catalog.cpp:6436

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Catalog_Namespace::anonymous_namespace{Catalog.cpp}::set_common_log_system_table_options ( foreign_storage::ForeignTable foreign_table)

Definition at line 6436 of file Catalog.cpp.

References foreign_storage::OptionsContainer::options.

Referenced by Catalog_Namespace::Catalog::initializeWebServerAccessLogsSystemTables(), Catalog_Namespace::Catalog::initializeWebServerLogsSystemTables(), and set_common_db_log_system_table_options().

6436  {
6438  foreign_table.options[ForeignTable::REFRESH_TIMING_TYPE_KEY] =
6439  ForeignTable::MANUAL_REFRESH_TIMING_TYPE;
6440  foreign_table.options[ForeignTable::REFRESH_UPDATE_TYPE_KEY] =
6441  ForeignTable::APPEND_REFRESH_UPDATE_TYPE;
6443  foreign_table.options[AbstractFileStorageDataWrapper::ALLOW_FILE_ROLL_OFF_KEY] = "TRUE";
6444 }

+ Here is the caller graph for this function:

void Catalog_Namespace::anonymous_namespace{Catalog.cpp}::set_dict_key ( ColumnDescriptor cd)

Definition at line 1062 of file Catalog.cpp.

References CHECK_GT, ColumnDescriptor::columnType, ColumnDescriptor::db_id, and SQLTypeInfo::setStringDictKey().

Referenced by Catalog_Namespace::Catalog::buildColumnsMapUnlocked(), Catalog_Namespace::Catalog::createTable(), Catalog_Namespace::Catalog::setColumnDictionary(), and Catalog_Namespace::Catalog::sqliteGetColumnsForTableUnlocked().

1062  {
1063  CHECK_GT(cd.db_id, 0);
1064  auto& column_type = cd.columnType;
1065  if (column_type.is_dict_encoded_string() ||
1066  column_type.is_subtype_dict_encoded_string()) {
1067  column_type.setStringDictKey({cd.db_id, column_type.get_comp_param()});
1068  }
1069 }
#define CHECK_GT(x, y)
Definition: Logger.h:305
void setStringDictKey(const shared::StringDictKey &dict_key)
Definition: sqltypes.h:1061
SQLTypeInfo columnType

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string Catalog_Namespace::anonymous_namespace{Catalog.cpp}::table_epochs_to_string ( const std::vector< TableEpochInfo > &  table_epochs)

Definition at line 3868 of file Catalog.cpp.

References to_string().

Referenced by Catalog_Namespace::Catalog::setTableEpochsLogExceptions().

3868  {
3869  std::string table_epochs_str{"["};
3870  bool first_entry{true};
3871  for (const auto& table_epoch : table_epochs) {
3872  if (first_entry) {
3873  first_entry = false;
3874  } else {
3875  table_epochs_str += ", ";
3876  }
3877  table_epochs_str += "(table_id: " + std::to_string(table_epoch.table_id) +
3878  ", epoch: " + std::to_string(table_epoch.table_epoch) + ")";
3879  }
3880  table_epochs_str += "]";
3881  return table_epochs_str;
3882 }
std::string to_string(char const *&&v)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

auto Catalog_Namespace::anonymous_namespace{Catalog.cpp}::table_json_filepath ( const std::string &  base_path,
const std::string &  db_name 
)
inline

Definition at line 162 of file Catalog.cpp.

References shared::kCatalogDirectoryName.

Referenced by Catalog_Namespace::Catalog::dropTableFromJsonUnlocked(), Catalog_Namespace::Catalog::serializeTableJsonUnlocked(), Catalog_Namespace::thread_holding_write_lock(), and Catalog_Namespace::Catalog::~Catalog().

163  {
164  return boost::filesystem::path(base_path + "/" + shared::kCatalogDirectoryName + "/" +
165  db_name + "_temp_tables.json");
166 }
const std::string kCatalogDirectoryName

+ Here is the caller graph for this function:

int32_t Catalog_Namespace::anonymous_namespace{Catalog.cpp}::validate_and_get_user_id ( const std::string &  user_name)

Definition at line 6119 of file Catalog.cpp.

References Catalog_Namespace::UserMetadata::userId.

Referenced by Catalog_Namespace::Catalog::reassignOwners().

6119  {
6120  UserMetadata user;
6121  if (!SysCatalog::instance().getMetadataForUser(user_name, user)) {
6122  throw std::runtime_error{"User with username \"" + user_name + "\" does not exist."};
6123  }
6124  return user.userId;
6125 }

+ Here is the caller graph for this function: