OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Catalog_Namespace::SessionInfo Class Reference

#include <SessionInfo.h>

+ Collaboration diagram for Catalog_Namespace::SessionInfo:

Public Member Functions

 SessionInfo (std::shared_ptr< Catalog > cat, const UserMetadata &user, const ExecutorDeviceType t, const std::string &sid)
 
 SessionInfo (const SessionInfo &s)
 
CataloggetCatalog () const
 
std::shared_ptr< Catalogget_catalog_ptr () const
 
void set_catalog_ptr (std::shared_ptr< Catalog > c)
 
const UserMetadataget_currentUser () const
 
const ExecutorDeviceType get_executor_device_type () const
 
void set_executor_device_type (ExecutorDeviceType t)
 
std::string get_session_id () const
 
time_t get_last_used_time () const
 
void update_last_used_time ()
 
bool checkDBAccessPrivileges (const DBObjectType &permissionType, const AccessPrivileges &privs, const std::string &objectName="") const
 
time_t get_start_time () const
 
std::string const & get_public_session_id () const
 
 operator std::string () const
 
std::string const & get_connection_info () const
 
void set_connection_info (const std::string &connection)
 
heavyai::shared_mutexgetLock ()
 

Private Member Functions

std::string public_session_id () const
 

Private Attributes

std::shared_ptr< Catalogcatalog_
 
UserMetadata currentUser_
 
std::atomic< ExecutorDeviceTypeexecutor_device_type_
 
const std::string session_id_
 
std::atomic< time_t > last_used_time_
 
std::atomic< time_t > start_time_
 
const std::string public_session_id_
 
std::string connection_info_
 
heavyai::shared_mutex mtx_
 

Detailed Description

Definition at line 47 of file SessionInfo.h.

Constructor & Destructor Documentation

Catalog_Namespace::SessionInfo::SessionInfo ( std::shared_ptr< Catalog cat,
const UserMetadata user,
const ExecutorDeviceType  t,
const std::string &  sid 
)
inline

Definition at line 49 of file SessionInfo.h.

53  : catalog_(cat)
54  , currentUser_(user)
56  , session_id_(sid)
57  , last_used_time_(time(0))
58  , start_time_(time(0))
std::shared_ptr< Catalog > catalog_
Definition: SessionInfo.h:111
const std::string session_id_
Definition: SessionInfo.h:114
std::string cat(Ts &&...args)
const std::string public_session_id_
Definition: SessionInfo.h:117
std::atomic< time_t > last_used_time_
Definition: SessionInfo.h:115
std::string public_session_id() const
Definition: SessionInfo.cpp:43
std::atomic< time_t > start_time_
Definition: SessionInfo.h:116
std::atomic< ExecutorDeviceType > executor_device_type_
Definition: SessionInfo.h:113
Catalog_Namespace::SessionInfo::SessionInfo ( const SessionInfo s)
inline

Definition at line 60 of file SessionInfo.h.

61  : catalog_(s.catalog_)
62  , currentUser_(s.currentUser_)
63  , executor_device_type_(static_cast<ExecutorDeviceType>(s.executor_device_type_))
64  , session_id_(s.session_id_)
65  , public_session_id_(s.public_session_id_) {}
std::shared_ptr< Catalog > catalog_
Definition: SessionInfo.h:111
const std::string session_id_
Definition: SessionInfo.h:114
const std::string public_session_id_
Definition: SessionInfo.h:117
std::atomic< ExecutorDeviceType > executor_device_type_
Definition: SessionInfo.h:113

Member Function Documentation

bool Catalog_Namespace::SessionInfo::checkDBAccessPrivileges ( const DBObjectType permissionType,
const AccessPrivileges privs,
const std::string &  objectName = "" 
) const

Definition at line 24 of file SessionInfo.cpp.

References cat(), Catalog_Namespace::SysCatalog::checkPrivileges(), DatabaseDBObjectType, get_currentUser(), getCatalog(), and Catalog_Namespace::SysCatalog::instance().

Referenced by Parser::CreateTableStmt::execute(), Parser::CreateDataframeStmt::execute(), Parser::CreateTableAsSelectStmt::execute(), Parser::DropTableStmt::execute(), Parser::DumpTableStmt::execute(), Parser::RestoreTableStmt::execute(), Parser::CreateViewStmt::execute(), Parser::DropViewStmt::execute(), and Parser::InsertValuesStmt::execute().

26  {
27  auto& cat = getCatalog();
28  // run flow with DB object level access permission checks
29  DBObject object(objectName, permissionType);
30  if (permissionType == DBObjectType::DatabaseDBObjectType) {
31  object.setName(cat.getCurrentDB().dbName);
32  }
33  object.loadKey(cat);
34  object.setPrivileges(privs);
35  std::vector<DBObject> privObjects;
36  privObjects.push_back(object);
37  return SysCatalog::instance().checkPrivileges(get_currentUser(), privObjects);
38 }
std::string cat(Ts &&...args)
bool checkPrivileges(const UserMetadata &user, const std::vector< DBObject > &privObjects) const
static SysCatalog & instance()
Definition: SysCatalog.h:343
Catalog & getCatalog() const
Definition: SessionInfo.h:75
const UserMetadata & get_currentUser() const
Definition: SessionInfo.h:88

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::shared_ptr<Catalog> Catalog_Namespace::SessionInfo::get_catalog_ptr ( ) const
inline

Definition at line 80 of file SessionInfo.h.

References catalog_, and mtx_.

80  {
82  return catalog_;
83  }
std::shared_ptr< Catalog > catalog_
Definition: SessionInfo.h:111
std::shared_lock< T > shared_lock
heavyai::shared_mutex mtx_
Definition: SessionInfo.h:121
std::string const& Catalog_Namespace::SessionInfo::get_connection_info ( ) const
inline

Definition at line 103 of file SessionInfo.h.

References connection_info_.

103 { return connection_info_; }
const UserMetadata& Catalog_Namespace::SessionInfo::get_currentUser ( ) const
inline

Definition at line 88 of file SessionInfo.h.

References currentUser_.

Referenced by Parser::check_alter_table_privilege(), anonymous_namespace{Calcite.cpp}::check_db_access(), DBHandler::check_table_load_privileges(), checkDBAccessPrivileges(), anonymous_namespace{Calcite.cpp}::checkPermissionForTables(), Parser::CreateTableStmt::execute(), Parser::CreateDataframeStmt::execute(), Parser::CreateTableAsSelectStmt::execute(), Parser::TruncateTableStmt::execute(), Parser::RenameDBStmt::execute(), Parser::RenameUserStmt::execute(), Parser::CopyTableStmt::execute(), Parser::CreateRoleStmt::execute(), Parser::DropRoleStmt::execute(), Parser::GrantPrivilegesStmt::execute(), Parser::RevokePrivilegesStmt::execute(), Parser::ShowPrivilegesStmt::execute(), Parser::GrantRoleStmt::execute(), Parser::RevokeRoleStmt::execute(), Parser::CreateViewStmt::execute(), Parser::CreateDBStmt::execute(), Parser::DropDBStmt::execute(), Parser::CreateUserStmt::execute(), Parser::AlterUserStmt::execute(), Parser::DropUserStmt::execute(), DBHandler::get_tables_impl(), Calcite::getCompletionHints(), DBHandler::hasTableAccessPrivileges(), import_export::ForeignDataImporter::importGeneral(), DBHandler::interruptQuery(), is_allowed_on_dashboard(), query_state::operator<<(), DBHandler::set_execution_mode_nolock(), DBHandler::user_can_access_table(), Parser::anonymous_namespace{ParserNode.cpp}::user_can_access_table(), and DBHandler::validateDashboardIdsForSharing().

88 { return currentUser_; }

+ Here is the caller graph for this function:

const ExecutorDeviceType Catalog_Namespace::SessionInfo::get_executor_device_type ( ) const
inline

Definition at line 89 of file SessionInfo.h.

References executor_device_type_.

89  {
90  return executor_device_type_;
91  }
std::atomic< ExecutorDeviceType > executor_device_type_
Definition: SessionInfo.h:113
time_t Catalog_Namespace::SessionInfo::get_last_used_time ( ) const
inline

Definition at line 94 of file SessionInfo.h.

References last_used_time_.

94 { return last_used_time_; }
std::atomic< time_t > last_used_time_
Definition: SessionInfo.h:115
std::string const& Catalog_Namespace::SessionInfo::get_public_session_id ( ) const
inline

Definition at line 101 of file SessionInfo.h.

References public_session_id_.

Referenced by Catalog_Namespace::operator<<(), and query_state::operator<<().

101 { return public_session_id_; }
const std::string public_session_id_
Definition: SessionInfo.h:117

+ Here is the caller graph for this function:

std::string Catalog_Namespace::SessionInfo::get_session_id ( ) const
inline
time_t Catalog_Namespace::SessionInfo::get_start_time ( ) const
inline

Definition at line 100 of file SessionInfo.h.

References start_time_.

Referenced by public_session_id().

100 { return start_time_; }
std::atomic< time_t > start_time_
Definition: SessionInfo.h:116

+ Here is the caller graph for this function:

Catalog& Catalog_Namespace::SessionInfo::getCatalog ( ) const
inline

Definition at line 75 of file SessionInfo.h.

References catalog_, CHECK, and mtx_.

Referenced by Parser::check_alter_table_privilege(), Parser::AddColumnStmt::check_executable(), DBHandler::check_table_load_privileges(), checkDBAccessPrivileges(), Fragmenter_Namespace::LocalInsertConnector::checkpoint(), Parser::create_stmt_for_query(), Parser::CreateTableStmt::execute(), Parser::CreateDataframeStmt::execute(), Parser::CreateTableAsSelectStmt::execute(), Parser::DropTableStmt::execute(), Parser::TruncateTableStmt::execute(), Parser::OptimizeTableStmt::execute(), Parser::RenameTableStmt::execute(), Parser::RenameColumnStmt::execute(), Parser::AddColumnStmt::execute(), Parser::DropColumnStmt::execute(), Parser::AlterTableParamStmt::execute(), Parser::DumpTableStmt::execute(), Parser::RestoreTableStmt::execute(), Parser::CopyTableStmt::execute(), Parser::GrantPrivilegesStmt::execute(), Parser::RevokePrivilegesStmt::execute(), Parser::ShowPrivilegesStmt::execute(), Parser::CreateViewStmt::execute(), Parser::DropViewStmt::execute(), Parser::InsertValuesStmt::execute(), Parser::CreateTableStmt::executeDryRun(), RelAlgExecutor::executeSimpleInsert(), import_export::ForeignDataImporter::finalize(), import_export::anonymous_namespace{ForeignDataImporter.cpp}::get_proxy_foreign_table_fragment_size(), DBHandler::get_tables_impl(), DBHandler::get_tables_meta_impl(), Calcite::getCompletionHints(), DBHandler::hasTableAccessPrivileges(), import_export::ForeignDataImporter::importGeneral(), Fragmenter_Namespace::InsertDataLoader::insertChunks(), Fragmenter_Namespace::LocalInsertConnector::insertChunksToLeaf(), Fragmenter_Namespace::InsertDataLoader::insertData(), Fragmenter_Namespace::LocalInsertConnector::insertDataToLeaf(), DBHandler::interruptQuery(), is_allowed_on_dashboard(), query_state::operator<<(), DBHandler::prepare_loader_generic(), Fragmenter_Namespace::LocalInsertConnector::rollback(), DBHandler::user_can_access_table(), Parser::anonymous_namespace{ParserNode.cpp}::user_can_access_table(), and DBHandler::validateDashboardIdsForSharing().

75  {
77  CHECK(catalog_);
78  return *catalog_;
79  }
std::shared_ptr< Catalog > catalog_
Definition: SessionInfo.h:111
std::shared_lock< T > shared_lock
heavyai::shared_mutex mtx_
Definition: SessionInfo.h:121
#define CHECK(condition)
Definition: Logger.h:291

+ Here is the caller graph for this function:

heavyai::shared_mutex& Catalog_Namespace::SessionInfo::getLock ( )
inline

Definition at line 107 of file SessionInfo.h.

References mtx_.

107 { return mtx_; }
heavyai::shared_mutex mtx_
Definition: SessionInfo.h:121
Catalog_Namespace::SessionInfo::operator std::string ( ) const
inline

Definition at line 102 of file SessionInfo.h.

References public_session_id_.

102 { return public_session_id_; }
const std::string public_session_id_
Definition: SessionInfo.h:117
std::string Catalog_Namespace::SessionInfo::public_session_id ( ) const
private

Definition at line 43 of file SessionInfo.cpp.

References get_start_time(), session_id_, and run_benchmark_import::start_time.

43  {
44  const time_t start_time = get_start_time();
45  struct tm st;
46 #ifdef __linux__
47  localtime_r(&start_time, &st);
48 #else
49  localtime_s(&st, &start_time);
50 #endif
51  std::ostringstream ss;
52  ss << (st.tm_min % 10) << std::setfill('0') << std::setw(2) << st.tm_sec << '-'
53  << session_id_.substr(0, 4);
54  return ss.str();
55 }
const std::string session_id_
Definition: SessionInfo.h:114
time_t get_start_time() const
Definition: SessionInfo.h:100

+ Here is the call graph for this function:

void Catalog_Namespace::SessionInfo::set_catalog_ptr ( std::shared_ptr< Catalog c)
inline

Definition at line 84 of file SessionInfo.h.

References catalog_, and mtx_.

84  {
86  catalog_ = c;
87  }
std::lock_guard< T > lock_guard
std::shared_ptr< Catalog > catalog_
Definition: SessionInfo.h:111
heavyai::shared_mutex mtx_
Definition: SessionInfo.h:121
void Catalog_Namespace::SessionInfo::set_connection_info ( const std::string &  connection)
inline

Definition at line 104 of file SessionInfo.h.

References connection_info_.

104  {
105  connection_info_ = connection;
106  }
void Catalog_Namespace::SessionInfo::set_executor_device_type ( ExecutorDeviceType  t)
inline

Definition at line 92 of file SessionInfo.h.

References executor_device_type_.

Referenced by DBHandler::set_execution_mode_nolock().

92 { executor_device_type_ = t; }
std::atomic< ExecutorDeviceType > executor_device_type_
Definition: SessionInfo.h:113

+ Here is the caller graph for this function:

void Catalog_Namespace::SessionInfo::update_last_used_time ( )
inline

Definition at line 95 of file SessionInfo.h.

References last_used_time_.

95 { last_used_time_ = time(0); }
std::atomic< time_t > last_used_time_
Definition: SessionInfo.h:115

Member Data Documentation

std::shared_ptr<Catalog> Catalog_Namespace::SessionInfo::catalog_
private

Definition at line 111 of file SessionInfo.h.

Referenced by get_catalog_ptr(), getCatalog(), and set_catalog_ptr().

std::string Catalog_Namespace::SessionInfo::connection_info_
private

Definition at line 119 of file SessionInfo.h.

Referenced by get_connection_info(), and set_connection_info().

UserMetadata Catalog_Namespace::SessionInfo::currentUser_
private

Definition at line 112 of file SessionInfo.h.

Referenced by get_currentUser().

std::atomic<ExecutorDeviceType> Catalog_Namespace::SessionInfo::executor_device_type_
private

Definition at line 113 of file SessionInfo.h.

Referenced by get_executor_device_type(), and set_executor_device_type().

std::atomic<time_t> Catalog_Namespace::SessionInfo::last_used_time_
private

Definition at line 115 of file SessionInfo.h.

Referenced by get_last_used_time(), and update_last_used_time().

heavyai::shared_mutex Catalog_Namespace::SessionInfo::mtx_
mutableprivate

Definition at line 121 of file SessionInfo.h.

Referenced by get_catalog_ptr(), getCatalog(), getLock(), and set_catalog_ptr().

const std::string Catalog_Namespace::SessionInfo::public_session_id_
private

Definition at line 117 of file SessionInfo.h.

Referenced by get_public_session_id(), and operator std::string().

const std::string Catalog_Namespace::SessionInfo::session_id_
private

Definition at line 114 of file SessionInfo.h.

Referenced by get_session_id(), and public_session_id().

std::atomic<time_t> Catalog_Namespace::SessionInfo::start_time_
private

Definition at line 116 of file SessionInfo.h.

Referenced by get_start_time().


The documentation for this class was generated from the following files: