OmniSciDB  dfae7c3b14
Catalog_Namespace::anonymous_namespace{SysCatalog.cpp} Namespace Reference

Functions

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)
 
auto get_users (std::unique_ptr< SqliteConnector > &sqliteConnector, const int32_t dbId=-1)
 

Variables

auto append_with_commas
 

Function Documentation

◆ deleteObjectPrivileges()

void Catalog_Namespace::anonymous_namespace{SysCatalog.cpp}::deleteObjectPrivileges ( std::unique_ptr< SqliteConnector > &  sqliteConnector,
std::string  roleName,
bool  userRole,
DBObject object 
)

Definition at line 323 of file SysCatalog.cpp.

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

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

326  {
327  DBObjectKey key = object.getObjectKey();
328 
329  sqliteConnector->query_with_text_params(
330  "DELETE FROM mapd_object_permissions WHERE roleName = ?1 and roleType = ?2 and "
331  "objectPermissionsType = ?3 and "
332  "dbId = "
333  "?4 "
334  "and objectId = ?5",
335  std::vector<std::string>{roleName,
336  std::to_string(userRole),
338  std::to_string(key.dbId),
339  std::to_string(key.objectId)});
340 }
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:

◆ get_users()

auto Catalog_Namespace::anonymous_namespace{SysCatalog.cpp}::get_users ( std::unique_ptr< SqliteConnector > &  sqliteConnector,
const int32_t  dbId = -1 
)

Definition at line 1287 of file SysCatalog.cpp.

References setup::name.

Referenced by Catalog_Namespace::SysCatalog::getAllUserMetadata(), and DBHandler::max_bytes_for_thrift().

1288  {
1289  sqliteConnector->query("SELECT userid, name, issuper, can_login FROM mapd_users");
1290  int numRows = sqliteConnector->getNumRows();
1291  list<UserMetadata> user_list;
1292  const bool return_all_users = dbId == -1;
1293  auto has_any_privilege = [&return_all_users, &dbId](const std::string& name) {
1294  if (!return_all_users) {
1295  const auto grantee = SysCatalog::instance().getUserGrantee(name);
1296  return grantee ? grantee->hasAnyPrivilegesOnDb(dbId, false) : false;
1297  }
1298  return true;
1299  };
1300  auto add_user = [&user_list, &has_any_privilege](const int32_t id,
1301  const std::string& name,
1302  const bool super,
1303  const bool can_login) {
1304  if (has_any_privilege(name)) {
1305  user_list.emplace_back(id, name, "", super, -1, can_login);
1306  };
1307  };
1308  for (int r = 0; r < numRows; ++r) {
1309  add_user(sqliteConnector->getData<int>(r, 0),
1310  sqliteConnector->getData<string>(r, 1),
1311  sqliteConnector->getData<bool>(r, 2),
1312  sqliteConnector->getData<bool>(r, 3));
1313  }
1314  return user_list;
1315 }
name
Definition: setup.py:35
+ Here is the caller graph for this function:

◆ insertOrUpdateObjectPrivileges()

void Catalog_Namespace::anonymous_namespace{SysCatalog.cpp}::insertOrUpdateObjectPrivileges ( std::unique_ptr< SqliteConnector > &  sqliteConnector,
std::string  roleName,
bool  userRole,
DBObject object 
)

Definition at line 342 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().

345  {
346  DBObjectKey key = object.getObjectKey();
347 
348  sqliteConnector->query_with_text_params(
349  "INSERT OR REPLACE INTO mapd_object_permissions("
350  "roleName, "
351  "roleType, "
352  "objectPermissionsType, "
353  "dbId, "
354  "objectId, "
355  "objectPermissions, "
356  "objectOwnerId,"
357  "objectName) "
358  "VALUES (?1, ?2, ?3, "
359  "?4, ?5, ?6, ?7, ?8)",
360  std::vector<std::string>{
361  roleName, // roleName
362  userRole ? "1" : "0", // roleType
363  std::to_string(key.permissionType), // permissionType
364  std::to_string(key.dbId), // dbId
365  std::to_string(key.objectId), // objectId
366  std::to_string(object.getPrivileges().privileges), // objectPrivileges
367  std::to_string(object.getOwner()), // objectOwnerId
368  object.getName() // name
369  });
370 }
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:

Variable Documentation

◆ append_with_commas

auto Catalog_Namespace::anonymous_namespace{SysCatalog.cpp}::append_with_commas
Initial value:
= [](string& s, const string& t) {
if (!s.empty()) {
s += ", ";
}
s += t;
}

Definition at line 886 of file SysCatalog.cpp.

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