OmniSciDB  0b528656ed
Catalog_Namespace Namespace Reference

Namespaces

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

Classes

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

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 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 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 > >
 

Functions

std::ostream & operator<< (std::ostream &os, const SessionInfo &session_info)
 
void deleteObjectPrivileges (std::unique_ptr< SqliteConnector > &sqliteConnector, std::string roleName, bool userRole, DBObject &object)
 
void insertOrUpdateObjectPrivileges (std::unique_ptr< SqliteConnector > &sqliteConnector, std::string roleName, bool userRole, DBObject &object)
 
static bool parseUserMetadataFromSQLite (const std::unique_ptr< SqliteConnector > &conn, UserMetadata &user)
 

Variables

const int DEFAULT_INITIAL_VERSION = 1
 
const int MAPD_TEMP_TABLE_START_ID
 
const int MAPD_TEMP_DICT_START_ID
 

Typedef Documentation

◆ cat_read_lock

Definition at line 111 of file Catalog.cpp.

◆ cat_sqlite_lock

Definition at line 113 of file Catalog.cpp.

◆ cat_write_lock

Definition at line 112 of file Catalog.cpp.

◆ ColumnDescriptorMap

Definition at line 37 of file Types.h.

◆ ColumnDescriptorMapById

Definition at line 39 of file Types.h.

◆ ColumnIdKey

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

Definition at line 38 of file Types.h.

◆ ColumnKey

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

Definition at line 36 of file Types.h.

◆ DashboardDescriptorMap

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

Definition at line 42 of file Types.h.

◆ DBSummaryList

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

Definition at line 120 of file SysCatalog.h.

◆ DeletedColumnPerTableMap

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

Definition at line 46 of file Types.h.

◆ DictDescriptorMapById

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

Definition at line 40 of file Types.h.

◆ ForeignServerMap

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

Definition at line 48 of file Types.h.

◆ ForeignServerMapById

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

Definition at line 50 of file Types.h.

◆ LinkDescriptorMap

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

Definition at line 43 of file Types.h.

◆ LinkDescriptorMapById

Definition at line 44 of file Types.h.

◆ LogicalToPhysicalTableMapById

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

Definition at line 35 of file Types.h.

◆ sys_read_lock

Definition at line 110 of file Catalog.cpp.

◆ sys_sqlite_lock

Definition at line 81 of file SysCatalog.cpp.

◆ sys_write_lock

Definition at line 80 of file SysCatalog.cpp.

◆ TableDescriptorMap

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

Definition at line 33 of file Types.h.

◆ TableDescriptorMapById

Definition at line 34 of file Types.h.

Function Documentation

◆ deleteObjectPrivileges()

void Catalog_Namespace::deleteObjectPrivileges ( std::unique_ptr< SqliteConnector > &  sqliteConnector,
std::string  roleName,
bool  userRole,
DBObject object 
)

Definition at line 322 of file SysCatalog.cpp.

References DBObjectKey::dbId, DBObjectKey::objectId, DBObjectKey::permissionType, and to_string().

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

325  {
326  DBObjectKey key = object.getObjectKey();
327 
328  sqliteConnector->query_with_text_params(
329  "DELETE FROM mapd_object_permissions WHERE roleName = ?1 and roleType = ?2 and "
330  "objectPermissionsType = ?3 and "
331  "dbId = "
332  "?4 "
333  "and objectId = ?5",
334  std::vector<std::string>{roleName,
335  std::to_string(userRole),
337  std::to_string(key.dbId),
338  std::to_string(key.objectId)});
339 }
int32_t objectId
Definition: DBObject.h:57
std::string to_string(char const *&&v)
int32_t dbId
Definition: DBObject.h:56
int32_t permissionType
Definition: DBObject.h:55
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ insertOrUpdateObjectPrivileges()

void Catalog_Namespace::insertOrUpdateObjectPrivileges ( std::unique_ptr< SqliteConnector > &  sqliteConnector,
std::string  roleName,
bool  userRole,
DBObject object 
)

Definition at line 341 of file SysCatalog.cpp.

References DBObjectKey::dbId, DBObjectKey::objectId, DBObjectKey::permissionType, and to_string().

Referenced by Catalog_Namespace::SysCatalog::createRole_unsafe(), Catalog_Namespace::SysCatalog::grantDBObjectPrivileges_unsafe(), Catalog_Namespace::SysCatalog::migrateDBAccessPrivileges(), Catalog_Namespace::SysCatalog::migratePrivileges(), Catalog_Namespace::SysCatalog::populateRoleDbObjects(), and Catalog_Namespace::SysCatalog::revokeDBObjectPrivileges_unsafe().

344  {
345  DBObjectKey key = object.getObjectKey();
346 
347  sqliteConnector->query_with_text_params(
348  "INSERT OR REPLACE INTO mapd_object_permissions("
349  "roleName, "
350  "roleType, "
351  "objectPermissionsType, "
352  "dbId, "
353  "objectId, "
354  "objectPermissions, "
355  "objectOwnerId,"
356  "objectName) "
357  "VALUES (?1, ?2, ?3, "
358  "?4, ?5, ?6, ?7, ?8)",
359  std::vector<std::string>{
360  roleName, // roleName
361  userRole ? "1" : "0", // roleType
362  std::to_string(key.permissionType), // permissionType
363  std::to_string(key.dbId), // dbId
364  std::to_string(key.objectId), // objectId
365  std::to_string(object.getPrivileges().privileges), // objectPrivileges
366  std::to_string(object.getOwner()), // objectOwnerId
367  object.getName() // name
368  });
369 }
int32_t objectId
Definition: DBObject.h:57
std::string to_string(char const *&&v)
int32_t dbId
Definition: DBObject.h:56
int32_t permissionType
Definition: DBObject.h:55
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator<<()

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

Definition at line 53 of file SessionInfo.cpp.

References Catalog_Namespace::SessionInfo::get_public_session_id().

53  {
54  os << session_info.get_public_session_id();
55  return os;
56 }
+ Here is the call graph for this function:

◆ parseUserMetadataFromSQLite()

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

Definition at line 1197 of file SysCatalog.cpp.

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

Referenced by Catalog_Namespace::SysCatalog::getMetadataForUser(), and Catalog_Namespace::SysCatalog::getMetadataForUserById().

1198  {
1199  int numRows = conn->getNumRows();
1200  if (numRows == 0) {
1201  return false;
1202  }
1203  user.userId = conn->getData<int>(0, 0);
1204  user.userName = conn->getData<string>(0, 1);
1205  user.passwd_hash = conn->getData<string>(0, 2);
1206  user.isSuper = conn->getData<bool>(0, 3);
1207  user.defaultDbId = conn->isNull(0, 4) ? -1 : conn->getData<int>(0, 4);
1208  if (conn->isNull(0, 5)) {
1209  LOG(WARNING)
1210  << "User property 'can_login' not set for user " << user.userName
1211  << ". Disabling login ability. Set the users login ability with \"ALTER USER "
1212  << user.userName << " (can_login='true');\".";
1213  }
1214  user.can_login = conn->isNull(0, 5) ? false : conn->getData<bool>(0, 5);
1215  return true;
1216 }
#define LOG(tag)
Definition: Logger.h:188
+ Here is the caller graph for this function:

Variable Documentation

◆ DEFAULT_INITIAL_VERSION

const int Catalog_Namespace::DEFAULT_INITIAL_VERSION = 1

Definition at line 99 of file Catalog.cpp.

◆ MAPD_TEMP_DICT_START_ID

const int Catalog_Namespace::MAPD_TEMP_DICT_START_ID
Initial value:
=
1073741824

Definition at line 102 of file Catalog.cpp.

◆ MAPD_TEMP_TABLE_START_ID

const int Catalog_Namespace::MAPD_TEMP_TABLE_START_ID
Initial value:
=
1073741824

Definition at line 100 of file Catalog.cpp.