OmniSciDB  b28c0d5765
 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 5783 of file Catalog.cpp.

References DBObject::setPrivileges().

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

5787  {
5788  DBObject db_object{object_name, object_type};
5789  db_object.setPrivileges(privileges);
5790  db_objects[user_id].emplace_back(db_object);
5791 }
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 6087 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().

6089  {
6090  auto cache = data_mgr->getPersistentStorageMgr()->getDiskCache();
6091  if (cache) {
6092  cache->clearForTablePrefix({db_id, table_id});
6093  }
6094 }
PersistentStorageMgr * getPersistentStorageMgr() const
Definition: DataMgr.cpp:634
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 5760 of file Catalog.cpp.

References DBObjectTypeToString(), and run_benchmark_import::result.

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

5763  {
5764  std::stringstream result;
5765  for (const auto& [old_owner_id, db_objects] : old_owner_db_objects) {
5766  result << "db_id: " << db_id << ", new_owner_user_id: " << new_owner_id
5767  << ", old_owner_user_id: " << old_owner_id << ", db_objects: [";
5768  bool first_object{true};
5769  for (const auto& db_object : db_objects) {
5770  if (first_object) {
5771  first_object = false;
5772  } else {
5773  result << ", ";
5774  }
5775  result << "\"object_id: " << db_object.getObjectKey().objectId
5776  << ", object_type: " << DBObjectTypeToString(db_object.getType()) << "\"";
5777  }
5778  result << "]\n";
5779  }
5780  return result.str();
5781 }
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 6096 of file Catalog.cpp.

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

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

6096  {
6097  for (const auto& table_name : table_names) {
6098  if (auto td = catalog.getMetadataForTable(table_name)) {
6099  catalog.dropTable(td);
6100  }
6101  }
6102 }

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

3735  {
3736  const auto& table_name = shared_dict_def.get_foreign_table();
3737  const auto td = cat.getMetadataForTable(table_name, false);
3738  CHECK(td);
3739  const auto& foreign_col_name = shared_dict_def.get_foreign_column();
3740  return cat.getMetadataForColumn(td->tableId, foreign_col_name);
3741 }
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 2706 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().

2706  {
2707  auto timing_type_entry =
2709  CHECK(timing_type_entry != foreign_table.options.end());
2710  if (timing_type_entry->second ==
2713  foreign_table.options);
2714  }
2716 }
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 6052 of file Catalog.cpp.

References kARRAY, and kENCODING_NONE.

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

6052  {
6053  SQLTypeInfo sql_type_info{kARRAY, 0, 0, false, kENCODING_NONE, 0, type};
6054  sql_type_info.set_size(-1);
6055  return sql_type_info;
6056 }

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

References get_var_array_type(), kENCODING_DICT, and kTEXT.

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

6058  {
6059  auto sql_type_info = get_var_array_type(kTEXT);
6060  sql_type_info.set_compression(kENCODING_DICT);
6061  sql_type_info.set_comp_param(32);
6062  return sql_type_info;
6063 }
Definition: sqltypes.h:67

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

6076  {
6077  // Each log entry should start with a timestamp.
6079  foreign_table.options[RegexFileBufferParser::LINE_START_REGEX_KEY] =
6080  "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{6}";
6082  foreign_table.options[AbstractFileStorageDataWrapper::REGEX_PATH_FILTER_KEY] =
6083  ".*heavydb\\.INFO\\..*";
6084  set_common_log_system_table_options(foreign_table);
6085 }
void set_common_log_system_table_options(foreign_storage::ForeignTable &foreign_table)
Definition: Catalog.cpp:6065

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

6065  {
6067  foreign_table.options[ForeignTable::REFRESH_TIMING_TYPE_KEY] =
6068  ForeignTable::MANUAL_REFRESH_TIMING_TYPE;
6069  foreign_table.options[ForeignTable::REFRESH_UPDATE_TYPE_KEY] =
6070  ForeignTable::APPEND_REFRESH_UPDATE_TYPE;
6072  foreign_table.options[AbstractFileStorageDataWrapper::ALLOW_FILE_ROLL_OFF_KEY] = "TRUE";
6073 }

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

References to_string().

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

3648  {
3649  std::string table_epochs_str{"["};
3650  bool first_entry{true};
3651  for (const auto& table_epoch : table_epochs) {
3652  if (first_entry) {
3653  first_entry = false;
3654  } else {
3655  table_epochs_str += ", ";
3656  }
3657  table_epochs_str += "(table_id: " + std::to_string(table_epoch.table_id) +
3658  ", epoch: " + std::to_string(table_epoch.table_epoch) + ")";
3659  }
3660  table_epochs_str += "]";
3661  return table_epochs_str;
3662 }
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 5752 of file Catalog.cpp.

References Catalog_Namespace::UserMetadata::userId.

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

5752  {
5753  UserMetadata user;
5754  if (!SysCatalog::instance().getMetadataForUser(user_name, user)) {
5755  throw std::runtime_error{"User with username \"" + user_name + "\" does not exist."};
5756  }
5757  return user.userId;
5758 }

+ Here is the caller graph for this function: