OmniSciDB  c1a53651b2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Catalog_Namespace Namespace Reference

Namespaces

 anonymous_namespace{Catalog.cpp}
 
 anonymous_namespace{SysCatalog.cpp}
 

Classes

struct  TableEpochInfo
 
class  Catalog
 class for a per-database catalog. also includes metadata for the current database and the current user. More...
 
struct  CustomExpression
 
class  read_lock
 
class  sqlite_lock
 
class  write_lock
 
class  SessionInfo
 
class  SessionsStore
 
struct  UserMetadata
 
struct  UserAlterations
 
struct  DBMetadata
 
struct  DBSummary
 
class  CommonFileOperations
 
class  SysCatalog
 

Typedefs

using sys_read_lock = read_lock< SysCatalog >
 
using cat_read_lock = read_lock< Catalog >
 
using cat_write_lock = write_lock< Catalog >
 
using cat_sqlite_lock = sqlite_lock< Catalog >
 
using SessionInfoPtr = std::shared_ptr< SessionInfo >
 
using DisconnectCallback = std::function< void(SessionInfoPtr &session)>
 
using sys_write_lock = write_lock< SysCatalog >
 
using sys_sqlite_lock = sqlite_lock< SysCatalog >
 
using DBSummaryList = std::list< DBSummary >
 
using TableDescriptorMap = std::map< std::string, TableDescriptor * >
 
using TableDescriptorMapById = std::map< int, TableDescriptor * >
 
using LogicalToPhysicalTableMapById = std::map< int32_t, std::vector< int32_t >>
 
using ColumnKey = std::tuple< int, std::string >
 
using ColumnDescriptorMap = std::map< ColumnKey, ColumnDescriptor * >
 
using ColumnIdKey = std::tuple< int, int >
 
using ColumnDescriptorMapById = std::map< ColumnIdKey, ColumnDescriptor * >
 
using TableDictColumnsMap = std::map< int32_t, std::set< const ColumnDescriptor * >>
 
using DictDescriptorMapById = std::map< DictRef, std::unique_ptr< DictDescriptor >>
 
using DashboardDescriptorMap = std::map< std::string, std::shared_ptr< DashboardDescriptor >>
 
using LinkDescriptorMap = std::map< std::string, LinkDescriptor * >
 
using LinkDescriptorMapById = std::map< int, LinkDescriptor * >
 
using DeletedColumnPerTableMap = std::unordered_map< const TableDescriptor *, const ColumnDescriptor * >
 
using ForeignServerMap = std::map< std::string, std::shared_ptr< foreign_storage::ForeignServer >>
 
using ForeignServerMapById = std::map< int, std::shared_ptr< foreign_storage::ForeignServer >>
 
using CustomExpressionMapById = std::map< int, std::unique_ptr< CustomExpression >>
 

Enumerations

enum  DataSourceType { DataSourceType::TABLE = 0 }
 

Functions

 dsqliteMutex_ (std::make_unique< heavyai::DistributedSharedMutex >(std::filesystem::path(basePath_)/shared::kLockfilesDirectoryName/shared::kCatalogDirectoryName/(currentDB_.dbName+".sqlite.lockfile")))
 
 sqliteMutex_ ()
 
 sharedMutex_ ()
 
 thread_holding_sqlite_lock ()
 
 thread_holding_write_lock ()
 
const TableDescriptorlookupTableDescriptor (Catalog *cat, std::map< std::string, int > &cachedTableMap, std::string &curTableName)
 
void replaceTableName (std::map< std::string, int > &cachedTableMap, std::string &curTableName, std::string &newTableName, int tableId)
 
bool contains_spaces (std::string_view str)
 returns true if the string contains one or more spaces More...
 
bool contains_sql_reserved_chars (std::string_view str, std::string_view chars="`~!@#$%^&*()-=+[{]}\\|;:'\",<.>/?")
 returns true if the string contains one or more OmniSci SQL reserved characters More...
 
bool is_reserved_sql_keyword (std::string_view str)
 returns true if the string equals an OmniSci SQL reserved keyword More...
 
std::ostream & operator<< (std::ostream &os, const SessionInfo &session_info)
 
static bool parseUserMetadataFromSQLite (const std::unique_ptr< SqliteConnector > &conn, UserMetadata &user, int row)
 
const TableDescriptorget_metadata_for_table (const ::shared::TableKey &table_key, bool populate_fragmenter)
 
const ColumnDescriptorget_metadata_for_column (const ::shared::ColumnKey &column_key)
 

Variables

const int DEFAULT_INITIAL_VERSION = 1
 
const int MAPD_TEMP_TABLE_START_ID
 
const int MAPD_TEMP_DICT_START_ID
 
static constexpr const char * USERS_SYS_TABLE_NAME {"users"}
 
static constexpr const char * TABLES_SYS_TABLE_NAME {"tables"}
 
static constexpr const char * DASHBOARDS_SYS_TABLE_NAME {"dashboards"}
 
static constexpr const char * DATABASES_SYS_TABLE_NAME {"databases"}
 
static constexpr const char * PERMISSIONS_SYS_TABLE_NAME {"permissions"}
 
static constexpr const char * ROLES_SYS_TABLE_NAME {"roles"}
 
static constexpr const char * ROLE_ASSIGNMENTS_SYS_TABLE_NAME {"role_assignments"}
 
static constexpr const char * MEMORY_SUMMARY_SYS_TABLE_NAME {"memory_summary"}
 
static constexpr const char * MEMORY_DETAILS_SYS_TABLE_NAME {"memory_details"}
 
static constexpr const char * STORAGE_DETAILS_SYS_TABLE_NAME {"storage_details"}
 
static constexpr const char * SERVER_LOGS_SYS_TABLE_NAME {"server_logs"}
 
static constexpr const char * REQUEST_LOGS_SYS_TABLE_NAME {"request_logs"}
 
static constexpr const char * WS_SERVER_LOGS_SYS_TABLE_NAME {"web_server_logs"}
 
static constexpr const char * WS_SERVER_ACCESS_LOGS_SYS_TABLE_NAME
 
static const std::array
< std::string, 4 > 
kAggregatorOnlySystemTables
 
const size_t CALCITE_SESSION_ID_LENGTH = 64
 
const size_t SESSION_ID_LENGTH = 32
 
bool g_log_user_id {false}
 

Typedef Documentation

Definition at line 121 of file Catalog.cpp.

Definition at line 123 of file Catalog.cpp.

Definition at line 122 of file Catalog.cpp.

Definition at line 38 of file Types.h.

Definition at line 40 of file Types.h.

using Catalog_Namespace::ColumnIdKey = typedef std::tuple<int, int>

Definition at line 39 of file Types.h.

using Catalog_Namespace::ColumnKey = typedef std::tuple<int, std::string>

Definition at line 37 of file Types.h.

using Catalog_Namespace::CustomExpressionMapById = typedef std::map<int, std::unique_ptr<CustomExpression>>

Definition at line 53 of file Types.h.

using Catalog_Namespace::DashboardDescriptorMap = typedef std::map<std::string, std::shared_ptr<DashboardDescriptor>>

Definition at line 44 of file Types.h.

using Catalog_Namespace::DBSummaryList = typedef std::list<DBSummary>

Definition at line 145 of file SysCatalog.h.

using Catalog_Namespace::DeletedColumnPerTableMap = typedef std::unordered_map<const TableDescriptor*, const ColumnDescriptor*>

Definition at line 48 of file Types.h.

using Catalog_Namespace::DictDescriptorMapById = typedef std::map<DictRef, std::unique_ptr<DictDescriptor>>

Definition at line 42 of file Types.h.

using Catalog_Namespace::DisconnectCallback = typedef std::function<void(SessionInfoPtr& session)>

Definition at line 29 of file SessionsStore.h.

using Catalog_Namespace::ForeignServerMap = typedef std::map<std::string, std::shared_ptr<foreign_storage::ForeignServer>>

Definition at line 50 of file Types.h.

using Catalog_Namespace::ForeignServerMapById = typedef std::map<int, std::shared_ptr<foreign_storage::ForeignServer>>

Definition at line 52 of file Types.h.

using Catalog_Namespace::LinkDescriptorMap = typedef std::map<std::string, LinkDescriptor*>

Definition at line 45 of file Types.h.

Definition at line 46 of file Types.h.

using Catalog_Namespace::LogicalToPhysicalTableMapById = typedef std::map<int32_t, std::vector<int32_t>>

Definition at line 36 of file Types.h.

using Catalog_Namespace::SessionInfoPtr = typedef std::shared_ptr<SessionInfo>

Definition at line 27 of file SessionsStore.h.

Definition at line 120 of file Catalog.cpp.

Definition at line 154 of file SysCatalog.cpp.

Definition at line 153 of file SysCatalog.cpp.

using Catalog_Namespace::TableDescriptorMap = typedef std::map<std::string, TableDescriptor*>

Definition at line 34 of file Types.h.

Definition at line 35 of file Types.h.

using Catalog_Namespace::TableDictColumnsMap = typedef std::map<int32_t, std::set<const ColumnDescriptor*>>

Definition at line 41 of file Types.h.

Enumeration Type Documentation

Enumerator
TABLE 

Definition at line 22 of file CustomExpression.h.

Function Documentation

bool Catalog_Namespace::contains_spaces ( std::string_view  str)
inline

returns true if the string contains one or more spaces

Definition at line 5211 of file Catalog.cpp.

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

5211  {
5212  return std::find_if(str.begin(), str.end(), [](const unsigned char& ch) {
5213  return std::isspace(ch);
5214  }) != str.end();
5215 }

+ Here is the caller graph for this function:

bool Catalog_Namespace::contains_sql_reserved_chars ( std::string_view  str,
std::string_view  chars = "`~!@#$%^&*()-=+[{]}\\|;:'\",<.>/?" 
)
inline

returns true if the string contains one or more OmniSci SQL reserved characters

Definition at line 5218 of file Catalog.cpp.

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

5220  {]}\\|;:'\",<.>/?") {
5221  return str.find_first_of(chars) != std::string_view::npos;
5222 }

+ Here is the caller graph for this function:

Catalog_Namespace::dsqliteMutex_ ( std::make_unique< heavyai::DistributedSharedMutex std::filesystem::path(basePath_)/shared::kLockfilesDirectoryName/shared::kCatalogDirectoryName/(currentDB_.dbName+".sqlite.lockfile"))

Referenced by Catalog_Namespace::SysCatalog::init().

+ Here is the caller graph for this function:

const ColumnDescriptor * Catalog_Namespace::get_metadata_for_column ( const ::shared::ColumnKey column_key)

Definition at line 3196 of file SysCatalog.cpp.

References CHECK, Catalog_Namespace::SysCatalog::getCatalog(), and Catalog_Namespace::SysCatalog::instance().

Referenced by RangeJoinHashTable::codegenKey(), OverlapsJoinHashTable::codegenKey(), OverlapsJoinHashTable::codegenManyKey(), CodeGenerator::codegenOverlaps(), Executor::computeColRangesCache(), get_column_descriptor(), RangeJoinHashTable::getInstance(), and Executor::getNumBytesForFetchedRow().

3196  {
3197  const auto catalog = SysCatalog::instance().getCatalog(column_key.db_id);
3198  CHECK(catalog);
3199  return catalog->getMetadataForColumn(column_key.table_id, column_key.column_id);
3200 }
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const TableDescriptor * Catalog_Namespace::get_metadata_for_table ( const ::shared::TableKey table_key,
bool  populate_fragmenter 
)

Definition at line 3189 of file SysCatalog.cpp.

References CHECK, Catalog_Namespace::SysCatalog::getCatalog(), and Catalog_Namespace::SysCatalog::instance().

Referenced by QueryFragmentDescriptor::buildFragmentPerKernelMapForUnion(), HashJoin::checkHashJoinReplicationConstraint(), anonymous_namespace{RelAlgExecutor.cpp}::do_table_reordering(), RelAlgExecutor::executeWorkUnit(), anonymous_namespace{FromTableReordering.cpp}::get_join_qual_cost(), get_shard_count(), anonymous_namespace{Execute.cpp}::get_table_name(), getSyntheticInputTableInfo(), rewrite_overlaps_conjunction(), and GroupByAndAggregate::shard_count_for_top_groups().

3190  {
3191  const auto catalog = SysCatalog::instance().getCatalog(table_key.db_id);
3192  CHECK(catalog);
3193  return catalog->getMetadataForTable(table_key.table_id, populate_fragmenter);
3194 }
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Catalog_Namespace::is_reserved_sql_keyword ( std::string_view  str)
inline

returns true if the string equals an OmniSci SQL reserved keyword

Definition at line 5225 of file Catalog.cpp.

References reserved_keywords, and to_upper().

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

5225  {
5226  return reserved_keywords.find(to_upper(std::string(str))) != reserved_keywords.end();
5227 }
static std::set< std::string > reserved_keywords
std::string to_upper(const std::string &str)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

const TableDescriptor* Catalog_Namespace::lookupTableDescriptor ( Catalog *  cat,
std::map< std::string, int > &  cachedTableMap,
std::string &  curTableName 
)

Definition at line 4291 of file Catalog.cpp.

References Catalog_Namespace::Catalog::getMetadataForTable().

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

4293  {
4294  auto iter = cachedTableMap.find(curTableName);
4295  if ((iter != cachedTableMap.end())) {
4296  // get the cached tableId
4297  // and use that to lookup the TableDescriptor
4298  int tableId = (*iter).second;
4299  if (tableId == -1) {
4300  return NULL;
4301  } else {
4302  return cat->getMetadataForTable(tableId);
4303  }
4304  }
4305 
4306  // else ... lookup in standard location
4307  return cat->getMetadataForTable(curTableName);
4308 }
std::string cat(Ts &&...args)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::ostream & Catalog_Namespace::operator<< ( std::ostream &  os,
const SessionInfo &  session_info 
)

Definition at line 57 of file SessionInfo.cpp.

References Catalog_Namespace::SessionInfo::get_public_session_id().

57  {
58  os << session_info.get_public_session_id();
59  return os;
60 }

+ Here is the call graph for this function:

static bool Catalog_Namespace::parseUserMetadataFromSQLite ( const std::unique_ptr< SqliteConnector > &  conn,
UserMetadata &  user,
int  row 
)
static

Definition at line 1659 of file SysCatalog.cpp.

References Catalog_Namespace::UserMetadata::can_login, Catalog_Namespace::UserMetadata::defaultDbId, g_log_user_id, Catalog_Namespace::UserMetadata::isSuper, LOG, Catalog_Namespace::UserMetadata::passwd_hash, Catalog_Namespace::UserMetadata::userId, Catalog_Namespace::UserMetadata::userLoggable(), Catalog_Namespace::UserMetadata::userName, and logger::WARNING.

Referenced by Catalog_Namespace::anonymous_namespace{SysCatalog.cpp}::get_users(), Catalog_Namespace::SysCatalog::getMetadataForUser(), and Catalog_Namespace::SysCatalog::getMetadataForUserById().

1661  {
1662  int numRows = conn->getNumRows();
1663  if (numRows == 0) {
1664  return false;
1665  }
1666  user.userId = conn->getData<int>(row, 0);
1667  user.userName = conn->getData<string>(row, 1);
1668  user.passwd_hash = conn->getData<string>(row, 2);
1669  user.isSuper = conn->getData<bool>(row, 3);
1670  user.defaultDbId = conn->isNull(row, 4) ? -1 : conn->getData<int>(row, 4);
1671  if (conn->isNull(row, 5)) {
1672  LOG(WARNING)
1673  << "User property 'can_login' not set for user " << user.userLoggable()
1674  << ". Disabling login ability. Set the users login ability with \"ALTER USER "
1675  << (g_log_user_id ? std::string("[username]") : user.userName)
1676  << " (can_login='true');\".";
1677  }
1678  user.can_login = conn->isNull(row, 5) ? false : conn->getData<bool>(row, 5);
1679  return true;
1680 }
#define LOG(tag)
Definition: Logger.h:285

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Catalog_Namespace::replaceTableName ( std::map< std::string, int > &  cachedTableMap,
std::string &  curTableName,
std::string &  newTableName,
int  tableId 
)

Definition at line 4310 of file Catalog.cpp.

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

4313  {
4314  // mark old/cur name as deleted
4315  cachedTableMap[curTableName] = -1;
4316 
4317  // insert the 'new' name
4318  cachedTableMap[newTableName] = tableId;
4319 }

+ Here is the caller graph for this function:

Catalog_Namespace::sharedMutex_ ( )
Catalog_Namespace::sqliteMutex_ ( )
Catalog_Namespace::thread_holding_sqlite_lock ( )
Catalog_Namespace::thread_holding_write_lock ( )

Definition at line 205 of file Catalog.cpp.

References CHECK, g_enable_fsi, g_enable_s3_fsi, g_enable_system_tables, g_multi_instance, g_serialize_temp_tables, and Catalog_Namespace::anonymous_namespace{Catalog.cpp}::table_json_filepath().

205  {
206  if (!g_enable_fsi) {
207  CHECK(!g_enable_system_tables) << "System tables require FSI to be enabled";
208  CHECK(!g_enable_s3_fsi) << "S3 FSI requires FSI to be enabled";
209  }
210 
211  if (!is_new_db && !g_multi_instance) {
212  CheckAndExecuteMigrations();
213  }
214 
215  buildMaps();
216 
217  if (g_enable_fsi) {
218  createDefaultServersIfNotExists();
219  }
220  if (!is_new_db) {
221  CheckAndExecuteMigrationsPostBuildMaps();
222  }
224  boost::filesystem::remove(table_json_filepath(basePath_, currentDB_.dbName));
225  }
226  conditionallyInitializeSystemObjects();
227  // once all initialized use real object
228  initialized_ = true;
229 }
bool g_multi_instance
Definition: heavyai_locks.h:21
auto table_json_filepath(const std::string &base_path, const std::string &db_name)
Definition: Catalog.cpp:162
bool g_enable_s3_fsi
Definition: Catalog.cpp:97
bool g_enable_system_tables
Definition: SysCatalog.cpp:64
bool g_serialize_temp_tables
Definition: Catalog.cpp:106
#define CHECK(condition)
Definition: Logger.h:291
bool g_enable_fsi
Definition: Catalog.cpp:96

+ Here is the call graph for this function:

Variable Documentation

const size_t Catalog_Namespace::CALCITE_SESSION_ID_LENGTH = 64
const int Catalog_Namespace::DEFAULT_INITIAL_VERSION = 1
const std::array<std::string, 4> Catalog_Namespace::kAggregatorOnlySystemTables
static
Initial value:
{
static constexpr const char * WS_SERVER_ACCESS_LOGS_SYS_TABLE_NAME
Definition: Catalog.h:117
static constexpr const char * DASHBOARDS_SYS_TABLE_NAME
Definition: Catalog.h:106
static constexpr const char * REQUEST_LOGS_SYS_TABLE_NAME
Definition: Catalog.h:115
static constexpr const char * WS_SERVER_LOGS_SYS_TABLE_NAME
Definition: Catalog.h:116

Definition at line 120 of file Catalog.h.

Referenced by foreign_storage::refresh_foreign_table().

const int Catalog_Namespace::MAPD_TEMP_DICT_START_ID
Initial value:
=
1073741824

Definition at line 113 of file Catalog.cpp.

const int Catalog_Namespace::MAPD_TEMP_TABLE_START_ID
Initial value:
=
1073741824

Definition at line 111 of file Catalog.cpp.

constexpr const char* Catalog_Namespace::REQUEST_LOGS_SYS_TABLE_NAME {"request_logs"}
static
constexpr const char* Catalog_Namespace::ROLE_ASSIGNMENTS_SYS_TABLE_NAME {"role_assignments"}
static
constexpr const char* Catalog_Namespace::SERVER_LOGS_SYS_TABLE_NAME {"server_logs"}
static
const size_t Catalog_Namespace::SESSION_ID_LENGTH = 32

Definition at line 127 of file SessionInfo.h.

Referenced by CachedSessionStore::add().

constexpr const char* Catalog_Namespace::WS_SERVER_ACCESS_LOGS_SYS_TABLE_NAME
static
constexpr const char* Catalog_Namespace::WS_SERVER_LOGS_SYS_TABLE_NAME {"web_server_logs"}
static