OmniSciDB  c1a53651b2
 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)
 
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 5813 of file Catalog.cpp.

References DBObject::setPrivileges().

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

5817  {
5818  DBObject db_object{object_name, object_type};
5819  db_object.setPrivileges(privileges);
5820  db_objects[user_id].emplace_back(db_object);
5821 }
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 6117 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().

6119  {
6120  auto cache = data_mgr->getPersistentStorageMgr()->getDiskCache();
6121  if (cache) {
6122  cache->clearForTablePrefix({db_id, table_id});
6123  }
6124 }
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 5790 of file Catalog.cpp.

References DBObjectTypeToString(), and run_benchmark_import::result.

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

5793  {
5794  std::stringstream result;
5795  for (const auto& [old_owner_id, db_objects] : old_owner_db_objects) {
5796  result << "db_id: " << db_id << ", new_owner_user_id: " << new_owner_id
5797  << ", old_owner_user_id: " << old_owner_id << ", db_objects: [";
5798  bool first_object{true};
5799  for (const auto& db_object : db_objects) {
5800  if (first_object) {
5801  first_object = false;
5802  } else {
5803  result << ", ";
5804  }
5805  result << "\"object_id: " << db_object.getObjectKey().objectId
5806  << ", object_type: " << DBObjectTypeToString(db_object.getType()) << "\"";
5807  }
5808  result << "]\n";
5809  }
5810  return result.str();
5811 }
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 6126 of file Catalog.cpp.

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

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

6126  {
6127  for (const auto& table_name : table_names) {
6128  if (auto td = catalog.getMetadataForTable(table_name)) {
6129  catalog.dropTable(td);
6130  }
6131  }
6132 }

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

3764  {
3765  const auto& table_name = shared_dict_def.get_foreign_table();
3766  const auto td = cat.getMetadataForTable(table_name, false);
3767  CHECK(td);
3768  const auto& foreign_col_name = shared_dict_def.get_foreign_column();
3769  return cat.getMetadataForColumn(td->tableId, foreign_col_name);
3770 }
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: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 2730 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().

2730  {
2731  auto timing_type_entry =
2733  CHECK(timing_type_entry != foreign_table.options.end());
2734  if (timing_type_entry->second ==
2737  foreign_table.options);
2738  }
2740 }
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: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 1037 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().

1037  {
1038  auto users = SysCatalog::instance().getAllUserMetadata();
1039  std::map<int32_t, std::string> user_name_by_user_id;
1040  for (const auto& user : users) {
1041  user_name_by_user_id[user.userId] = user.userName;
1042  }
1043  return user_name_by_user_id;
1044 }

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

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

1048  {
1049  auto entry = user_name_by_user_id.find(id);
1050  if (entry != user_name_by_user_id.end()) {
1051  return entry->second;
1052  }
1053  // a user could be deleted and a dashboard still exist?
1054  return "Unknown";
1055 }

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

References kARRAY, and kENCODING_NONE.

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

6082  {
6083  SQLTypeInfo sql_type_info{kARRAY, 0, 0, false, kENCODING_NONE, 0, type};
6084  sql_type_info.set_size(-1);
6085  return sql_type_info;
6086 }

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

References get_var_array_type(), kENCODING_DICT, and kTEXT.

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

6088  {
6089  auto sql_type_info = get_var_array_type(kTEXT);
6090  sql_type_info.set_compression(kENCODING_DICT);
6091  sql_type_info.set_comp_param(32);
6092  return sql_type_info;
6093 }
Definition: sqltypes.h:69

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

6106  {
6107  // Each log entry should start with a timestamp.
6109  foreign_table.options[RegexFileBufferParser::LINE_START_REGEX_KEY] =
6110  "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{6}";
6112  foreign_table.options[AbstractFileStorageDataWrapper::REGEX_PATH_FILTER_KEY] =
6113  ".*heavydb\\.INFO\\..*";
6114  set_common_log_system_table_options(foreign_table);
6115 }
void set_common_log_system_table_options(foreign_storage::ForeignTable &foreign_table)
Definition: Catalog.cpp:6095

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

6095  {
6097  foreign_table.options[ForeignTable::REFRESH_TIMING_TYPE_KEY] =
6098  ForeignTable::MANUAL_REFRESH_TIMING_TYPE;
6099  foreign_table.options[ForeignTable::REFRESH_UPDATE_TYPE_KEY] =
6100  ForeignTable::APPEND_REFRESH_UPDATE_TYPE;
6102  foreign_table.options[AbstractFileStorageDataWrapper::ALLOW_FILE_ROLL_OFF_KEY] = "TRUE";
6103 }

+ Here is the caller graph for this function:

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

Definition at line 1057 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(), and Catalog_Namespace::Catalog::setColumnDictionary().

1057  {
1058  CHECK_GT(cd.db_id, 0);
1059  auto& column_type = cd.columnType;
1060  if (column_type.is_dict_encoded_string() ||
1061  column_type.is_subtype_dict_encoded_string()) {
1062  column_type.setStringDictKey({cd.db_id, column_type.get_comp_param()});
1063  }
1064 }
#define CHECK_GT(x, y)
Definition: Logger.h:305
void setStringDictKey(const shared::StringDictKey &dict_key)
Definition: sqltypes.h:1027
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 3677 of file Catalog.cpp.

References to_string().

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

3677  {
3678  std::string table_epochs_str{"["};
3679  bool first_entry{true};
3680  for (const auto& table_epoch : table_epochs) {
3681  if (first_entry) {
3682  first_entry = false;
3683  } else {
3684  table_epochs_str += ", ";
3685  }
3686  table_epochs_str += "(table_id: " + std::to_string(table_epoch.table_id) +
3687  ", epoch: " + std::to_string(table_epoch.table_epoch) + ")";
3688  }
3689  table_epochs_str += "]";
3690  return table_epochs_str;
3691 }
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 5782 of file Catalog.cpp.

References Catalog_Namespace::UserMetadata::userId.

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

5782  {
5783  UserMetadata user;
5784  if (!SysCatalog::instance().getMetadataForUser(user_name, user)) {
5785  throw std::runtime_error{"User with username \"" + user_name + "\" does not exist."};
5786  }
5787  return user.userId;
5788 }

+ Here is the caller graph for this function: