OmniSciDB  a5dc49c757
 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 6160 of file Catalog.cpp.

References DBObject::setPrivileges().

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

6164  {
6165  DBObject db_object{object_name, object_type};
6166  db_object.setPrivileges(privileges);
6167  db_objects[user_id].emplace_back(db_object);
6168 }
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 6479 of file Catalog.cpp.

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

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

6481  {
6482  auto cache = data_mgr->getPersistentStorageMgr()->getDiskCache();
6483  if (cache) {
6484  cache->clearForTablePrefix({db_id, table_id});
6485  }
6486 }
PersistentStorageMgr * getPersistentStorageMgr() const
Definition: DataMgr.cpp:729
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 6137 of file Catalog.cpp.

References DBObjectTypeToString(), and run_benchmark_import::result.

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

6140  {
6141  std::stringstream result;
6142  for (const auto& [old_owner_id, db_objects] : old_owner_db_objects) {
6143  result << "db_id: " << db_id << ", new_owner_user_id: " << new_owner_id
6144  << ", old_owner_user_id: " << old_owner_id << ", db_objects: [";
6145  bool first_object{true};
6146  for (const auto& db_object : db_objects) {
6147  if (first_object) {
6148  first_object = false;
6149  } else {
6150  result << ", ";
6151  }
6152  result << "\"object_id: " << db_object.getObjectKey().objectId
6153  << ", object_type: " << DBObjectTypeToString(db_object.getType()) << "\"";
6154  }
6155  result << "]\n";
6156  }
6157  return result.str();
6158 }
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 6488 of file Catalog.cpp.

References clear_cached_table_data(), Catalog_Namespace::Catalog::dropTable(), Catalog_Namespace::Catalog::getDatabaseId(), Catalog_Namespace::Catalog::getDataMgr(), and Catalog_Namespace::Catalog::getMetadataForTable().

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

6488  {
6489  for (const auto& table_name : table_names) {
6490  if (auto td = catalog.getMetadataForTable(table_name)) {
6492  &catalog.getDataMgr(), catalog.getDatabaseId(), td->tableId);
6493  catalog.dropTable(td);
6494  }
6495  }
6496 }
void clear_cached_table_data(const Data_Namespace::DataMgr *data_mgr, int32_t db_id, int32_t table_id)
Definition: Catalog.cpp:6479

+ 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 6976 of file Catalog.cpp.

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

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

6976  {
6977  auto table_name_opt = catalog->getTableName(cd->tableId);
6978  CHECK(table_name_opt.has_value());
6979  return table_name_opt.value();
6980 }
#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 3963 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().

3965  {
3966  const auto& table_name = shared_dict_def.get_foreign_table();
3967  const auto td = cat.getMetadataForTable(table_name, false);
3968  CHECK(td);
3969  const auto& foreign_col_name = shared_dict_def.get_foreign_column();
3970  return cat.getMetadataForColumn(td->tableId, foreign_col_name);
3971 }
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 2932 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().

2932  {
2933  auto timing_type_entry =
2935  CHECK(timing_type_entry != foreign_table.options.end());
2936  if (timing_type_entry->second ==
2939  foreign_table.options);
2940  }
2942 }
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 1045 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().

1045  {
1046  auto users = SysCatalog::instance().getAllUserMetadata();
1047  std::map<int32_t, std::string> user_name_by_user_id;
1048  for (const auto& user : users) {
1049  user_name_by_user_id[user.userId] = user.userName;
1050  }
1051  return user_name_by_user_id;
1052 }
T & instance()
Definition: LockMgr.cpp:101

+ 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 1054 of file Catalog.cpp.

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

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

+ 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 6433 of file Catalog.cpp.

References kARRAY, and kENCODING_NONE.

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

6433  {
6434  SQLTypeInfo sql_type_info{kARRAY, 0, 0, false, kENCODING_NONE, 0, type};
6435  sql_type_info.set_size(-1);
6436  return sql_type_info;
6437 }

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

6439  {
6440  auto sql_type_info = get_var_array_type(kTEXT);
6441  sql_type_info.set_compression(kENCODING_DICT);
6442  sql_type_info.set_comp_param(32);
6443  return sql_type_info;
6444 }
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 4501 of file Catalog.cpp.

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

4504  {
4505  // mark old/cur name as deleted
4506  cachedTableMap[curTableName] = -1;
4507 
4508  // insert the 'new' name
4509  cachedTableMap[newTableName] = tableId;
4510 }

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

6468  {
6469  // Each log entry should start with a timestamp.
6471  foreign_table.options[RegexFileBufferParser::LINE_START_REGEX_KEY] =
6472  "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{6}";
6474  foreign_table.options[AbstractFileStorageDataWrapper::REGEX_PATH_FILTER_KEY] =
6475  ".*heavydb\\.INFO\\..*";
6476  set_common_log_system_table_options(foreign_table);
6477 }
void set_common_log_system_table_options(foreign_storage::ForeignTable &foreign_table)
Definition: Catalog.cpp:6446

+ 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 6446 of file Catalog.cpp.

References shared::convert_temporal_to_iso_format(), g_enable_logs_system_tables_auto_refresh, g_logs_system_tables_refresh_interval, foreign_storage::RefreshTimeCalculator::getCurrentTime(), kTIMESTAMP, and foreign_storage::OptionsContainer::options.

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

6446  {
6449  foreign_table.options[ForeignTable::REFRESH_TIMING_TYPE_KEY] =
6450  ForeignTable::SCHEDULE_REFRESH_TIMING_TYPE;
6451  // Set start date time to 1 minute from now.
6453  foreign_table.options[ForeignTable::REFRESH_START_DATE_TIME_KEY] =
6455  foreign_table.options[ForeignTable::REFRESH_INTERVAL_KEY] =
6457  } else {
6458  foreign_table.options[ForeignTable::REFRESH_TIMING_TYPE_KEY] =
6459  ForeignTable::MANUAL_REFRESH_TIMING_TYPE;
6460  }
6461  foreign_table.options[ForeignTable::REFRESH_UPDATE_TYPE_KEY] =
6462  ForeignTable::APPEND_REFRESH_UPDATE_TYPE;
6464  foreign_table.options[AbstractFileStorageDataWrapper::ALLOW_FILE_ROLL_OFF_KEY] = "TRUE";
6465 }
std::string convert_temporal_to_iso_format(const SQLTypeInfo &type_info, int64_t unix_time)
Definition: misc.cpp:111
bool g_enable_logs_system_tables_auto_refresh
Definition: Catalog.cpp:101
std::string g_logs_system_tables_refresh_interval
Definition: Catalog.cpp:103

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Definition at line 1065 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().

1065  {
1066  CHECK_GT(cd.db_id, 0);
1067  auto& column_type = cd.columnType;
1068  if (column_type.is_dict_encoded_string() ||
1069  column_type.is_subtype_dict_encoded_string()) {
1070  column_type.setStringDictKey({cd.db_id, column_type.get_comp_param()});
1071  }
1072 }
#define CHECK_GT(x, y)
Definition: Logger.h:305
void setStringDictKey(const shared::StringDictKey &dict_key)
Definition: sqltypes.h:1063
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 3878 of file Catalog.cpp.

References to_string().

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

3878  {
3879  std::string table_epochs_str{"["};
3880  bool first_entry{true};
3881  for (const auto& table_epoch : table_epochs) {
3882  if (first_entry) {
3883  first_entry = false;
3884  } else {
3885  table_epochs_str += ", ";
3886  }
3887  table_epochs_str += "(table_id: " + std::to_string(table_epoch.table_id) +
3888  ", epoch: " + std::to_string(table_epoch.table_epoch) + ")";
3889  }
3890  table_epochs_str += "]";
3891  return table_epochs_str;
3892 }
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 165 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().

166  {
167  return boost::filesystem::path(base_path + "/" + shared::kCatalogDirectoryName + "/" +
168  db_name + "_temp_tables.json");
169 }
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 6129 of file Catalog.cpp.

References lockmgr::instance(), and Catalog_Namespace::UserMetadata::userId.

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

6129  {
6130  UserMetadata user;
6131  if (!SysCatalog::instance().getMetadataForUser(user_name, user)) {
6132  throw std::runtime_error{"User with username \"" + user_name + "\" does not exist."};
6133  }
6134  return user.userId;
6135 }
T & instance()
Definition: LockMgr.cpp:101

+ Here is the call graph for this function:

+ Here is the caller graph for this function: