OmniSciDB  343343d194
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Catalog_Namespace::anonymous_namespace{SysCatalog.cpp} Namespace Reference

Functions

auto get_users (std::unique_ptr< SqliteConnector > &sqliteConnector, const int32_t dbId=-1)
 

Variables

auto append_with_commas
 

Function Documentation

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

Definition at line 1191 of file SysCatalog.cpp.

References Catalog_Namespace::SysCatalog::getUserGrantee(), Grantee::hasAnyPrivilegesOnDb(), Catalog_Namespace::SysCatalog::instance(), and Catalog_Namespace::SysCatalog::name().

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

1192  {
1193  sqliteConnector->query("SELECT userid, name, issuper FROM mapd_users");
1194  int numRows = sqliteConnector->getNumRows();
1195  list<UserMetadata> user_list;
1196  const bool return_all_users = dbId == -1;
1197  auto has_any_privilege = [&return_all_users, &dbId](const std::string& name) {
1198  if (!return_all_users) {
1199  const auto grantee = SysCatalog::instance().getUserGrantee(name);
1200  return grantee ? grantee->hasAnyPrivilegesOnDb(dbId, false) : false;
1201  }
1202  return true;
1203  };
1204  auto add_user = [&user_list, &has_any_privilege](
1205  const int32_t id, const std::string& name, const bool super) {
1206  if (has_any_privilege(name)) {
1207  user_list.emplace_back(id, name, "", super, -1);
1208  };
1209  };
1210  for (int r = 0; r < numRows; ++r) {
1211  add_user(sqliteConnector->getData<int>(r, 0),
1212  sqliteConnector->getData<string>(r, 1),
1213  sqliteConnector->getData<bool>(r, 2));
1214  }
1215  return user_list;
1216 }

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

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 802 of file SysCatalog.cpp.

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