OmniSciDB  cde582ebc3
 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)
 
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)
 
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)
 

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

References DBObject::setPrivileges().

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

5718  {
5719  DBObject db_object{object_name, object_type};
5720  db_object.setPrivileges(privileges);
5721  db_objects[user_id].emplace_back(db_object);
5722 }
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 6024 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().

6026  {
6027  auto cache = data_mgr->getPersistentStorageMgr()->getDiskCache();
6028  if (cache) {
6029  cache->clearForTablePrefix({db_id, table_id});
6030  }
6031 }
PersistentStorageMgr * getPersistentStorageMgr() const
Definition: DataMgr.cpp:637
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 5691 of file Catalog.cpp.

References DBObjectTypeToString(), and run_benchmark_import::result.

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

5694  {
5695  std::stringstream result;
5696  for (const auto& [old_owner_id, db_objects] : old_owner_db_objects) {
5697  result << "db_id: " << db_id << ", new_owner_user_id: " << new_owner_id
5698  << ", old_owner_user_id: " << old_owner_id << ", db_objects: [";
5699  bool first_object{true};
5700  for (const auto& db_object : db_objects) {
5701  if (first_object) {
5702  first_object = false;
5703  } else {
5704  result << ", ";
5705  }
5706  result << "\"object_id: " << db_object.getObjectKey().objectId
5707  << ", object_type: " << DBObjectTypeToString(db_object.getType()) << "\"";
5708  }
5709  result << "]\n";
5710  }
5711  return result.str();
5712 }
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 6033 of file Catalog.cpp.

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

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

6033  {
6034  for (const auto& table_name : table_names) {
6035  if (auto td = catalog.getMetadataForTable(table_name)) {
6036  catalog.dropTable(td);
6037  }
6038  }
6039 }

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

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

3690  {
3691  const auto& table_name = shared_dict_def.get_foreign_table();
3692  const auto td = cat.getMetadataForTable(table_name, false);
3693  CHECK(td);
3694  const auto& foreign_col_name = shared_dict_def.get_foreign_column();
3695  return cat.getMetadataForColumn(td->tableId, foreign_col_name);
3696 }
std::string cat(Ts &&...args)
const std::string & get_foreign_table() const
Definition: ParserNode.h:932
const std::string & get_foreign_column() const
Definition: ParserNode.h:934
#define CHECK(condition)
Definition: Logger.h:222

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

2661  {
2662  auto timing_type_entry =
2664  CHECK(timing_type_entry != foreign_table.options.end());
2665  if (timing_type_entry->second ==
2668  foreign_table.options);
2669  }
2671 }
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:222
static constexpr int NULL_REFRESH_TIME
Definition: ForeignTable.h:54
static constexpr const char * SCHEDULE_REFRESH_TIMING_TYPE
Definition: ForeignTable.h:52

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

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

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

1027  {
1028  auto users = SysCatalog::instance().getAllUserMetadata();
1029  std::map<int32_t, std::string> user_name_by_user_id;
1030  for (const auto& user : users) {
1031  user_name_by_user_id[user.userId] = user.userName;
1032  }
1033  return user_name_by_user_id;
1034 }

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

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

1038  {
1039  auto entry = user_name_by_user_id.find(id);
1040  if (entry != user_name_by_user_id.end()) {
1041  return entry->second;
1042  }
1043  // a user could be deleted and a dashboard still exist?
1044  return "Unknown";
1045 }

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

References kARRAY, and kENCODING_NONE.

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

5983  {
5984  SQLTypeInfo sql_type_info{kARRAY, 0, 0, false, kENCODING_NONE, 0, type};
5985  sql_type_info.set_size(-1);
5986  return sql_type_info;
5987 }

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

References get_var_array_type(), kENCODING_DICT, and kTEXT.

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

5989  {
5990  auto sql_type_info = get_var_array_type(kTEXT);
5991  sql_type_info.set_compression(kENCODING_DICT);
5992  sql_type_info.set_comp_param(32);
5993  return sql_type_info;
5994 }
Definition: sqltypes.h:52

+ 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_db_log_system_table_options ( foreign_storage::ForeignTable foreign_table)

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

6013  {
6014  // Each log entry should start with a timestamp.
6016  foreign_table.options[RegexFileBufferParser::LINE_START_REGEX_KEY] =
6017  "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{6}";
6019  foreign_table.options[AbstractFileStorageDataWrapper::REGEX_PATH_FILTER_KEY] =
6020  ".*heavydb\\.INFO\\..*";
6021  set_common_log_system_table_options(foreign_table);
6022 }
void set_common_log_system_table_options(foreign_storage::ForeignTable &foreign_table)
Definition: Catalog.cpp:5996

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

References shared::convert_temporal_to_iso_format(), 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().

5996  {
5998  foreign_table.options[ForeignTable::REFRESH_TIMING_TYPE_KEY] =
5999  ForeignTable::SCHEDULE_REFRESH_TIMING_TYPE;
6000  // Set start date time to 1 minute from now.
6002  foreign_table.options[ForeignTable::REFRESH_START_DATE_TIME_KEY] =
6004  foreign_table.options[ForeignTable::REFRESH_INTERVAL_KEY] =
6006  foreign_table.options[ForeignTable::REFRESH_UPDATE_TYPE_KEY] =
6007  ForeignTable::APPEND_REFRESH_UPDATE_TYPE;
6009  foreign_table.options[AbstractFileStorageDataWrapper::ALLOW_FILE_ROLL_OFF_KEY] = "TRUE";
6010 }
std::string convert_temporal_to_iso_format(const SQLTypeInfo &type_info, int64_t unix_time)
Definition: misc.cpp:109
std::string g_logs_system_tables_refresh_interval
Definition: Catalog.cpp:102

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

References to_string().

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

3603  {
3604  std::string table_epochs_str{"["};
3605  bool first_entry{true};
3606  for (const auto& table_epoch : table_epochs) {
3607  if (first_entry) {
3608  first_entry = false;
3609  } else {
3610  table_epochs_str += ", ";
3611  }
3612  table_epochs_str += "(table_id: " + std::to_string(table_epoch.table_id) +
3613  ", epoch: " + std::to_string(table_epoch.table_epoch) + ")";
3614  }
3615  table_epochs_str += "]";
3616  return table_epochs_str;
3617 }
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 164 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().

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

References Catalog_Namespace::UserMetadata::userId.

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

5683  {
5684  UserMetadata user;
5685  if (!SysCatalog::instance().getMetadataForUser(user_name, user)) {
5686  throw std::runtime_error{"User with username \"" + user_name + "\" does not exist."};
5687  }
5688  return user.userId;
5689 }

+ Here is the caller graph for this function: