OmniSciDB  471d68cefb
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
foreign_storage::anonymous_namespace{InternalCatalogDataWrapper.cpp} Namespace Reference

Functions

void populate_import_buffers_for_catalog_users (const std::list< Catalog_Namespace::UserMetadata > &all_users, std::map< std::string, import_export::TypedImportBuffer * > &import_buffers)
 
void populate_import_buffers_for_catalog_tables (const std::map< int32_t, std::vector< TableDescriptor >> &tables_by_database, std::map< std::string, import_export::TypedImportBuffer * > &import_buffers)
 
void populate_import_buffers_for_catalog_dashboards (const std::map< int32_t, std::vector< DashboardDescriptor >> &dashboards_by_database, std::map< std::string, import_export::TypedImportBuffer * > &import_buffers)
 
std::vector< std::string > get_permissions (const AccessPrivileges privileges, int32_t object_type, int32_t object_id)
 
std::string get_object_type_str (int32_t object_type)
 
void populate_import_buffers_for_catalog_permissions (const std::vector< ObjectRoleDescriptor > &object_permissions, std::map< std::string, import_export::TypedImportBuffer * > &import_buffers)
 
void populate_import_buffers_for_catalog_databases (const std::list< Catalog_Namespace::DBMetadata > &databases, std::map< std::string, import_export::TypedImportBuffer * > &import_buffers)
 
void populate_import_buffers_for_catalog_roles (const std::set< std::string > &roles, std::map< std::string, import_export::TypedImportBuffer * > &import_buffers)
 
void populate_import_buffers_for_catalog_role_assignments (const std::map< std::string, std::vector< std::string >> &user_names_by_role_, std::map< std::string, import_export::TypedImportBuffer * > &import_buffers)
 
std::map< int32_t, std::vector
< TableDescriptor > > 
get_all_tables ()
 
std::map< int32_t, std::vector
< DashboardDescriptor > > 
get_all_dashboards ()
 
std::map< std::string,
std::vector< std::string > > 
get_all_role_assignments ()
 

Function Documentation

std::map<int32_t, std::vector<DashboardDescriptor> > foreign_storage::anonymous_namespace{InternalCatalogDataWrapper.cpp}::get_all_dashboards ( )

Definition at line 349 of file InternalCatalogDataWrapper.cpp.

References Catalog_Namespace::SysCatalog::instance().

Referenced by foreign_storage::InternalCatalogDataWrapper::initializeObjectsForTable().

349  {
350  std::map<int32_t, std::vector<DashboardDescriptor>> dashboards_by_database;
351  auto& sys_catalog = Catalog_Namespace::SysCatalog::instance();
352  for (const auto& catalog : sys_catalog.getCatalogsForAllDbs()) {
353  for (const auto& dashboard : catalog->getAllDashboardsMetadataCopy()) {
354  dashboards_by_database[catalog->getDatabaseId()].emplace_back(dashboard);
355  }
356  }
357  return dashboards_by_database;
358 }
static SysCatalog & instance()
Definition: SysCatalog.h:325

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::map<std::string, std::vector<std::string> > foreign_storage::anonymous_namespace{InternalCatalogDataWrapper.cpp}::get_all_role_assignments ( )

Definition at line 360 of file InternalCatalogDataWrapper.cpp.

References Catalog_Namespace::SysCatalog::instance().

Referenced by foreign_storage::InternalCatalogDataWrapper::initializeObjectsForTable().

360  {
361  auto& sys_catalog = Catalog_Namespace::SysCatalog::instance();
362  const auto& users = sys_catalog.getAllUserMetadata();
363  std::map<std::string, std::vector<std::string>> user_names_by_role;
364  for (const auto& user : users) {
365  for (const auto& role :
366  sys_catalog.getRoles(false, user.isSuper, user.userName, true)) {
367  user_names_by_role[role].emplace_back(user.userName);
368  }
369  }
370  return user_names_by_role;
371 }
static SysCatalog & instance()
Definition: SysCatalog.h:325

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::map<int32_t, std::vector<TableDescriptor> > foreign_storage::anonymous_namespace{InternalCatalogDataWrapper.cpp}::get_all_tables ( )

Definition at line 336 of file InternalCatalogDataWrapper.cpp.

References INFORMATION_SCHEMA_DB, and Catalog_Namespace::SysCatalog::instance().

Referenced by foreign_storage::InternalCatalogDataWrapper::initializeObjectsForTable().

336  {
337  std::map<int32_t, std::vector<TableDescriptor>> tables_by_database;
338  auto& sys_catalog = Catalog_Namespace::SysCatalog::instance();
339  for (const auto& catalog : sys_catalog.getCatalogsForAllDbs()) {
340  if (catalog->name() != INFORMATION_SCHEMA_DB) {
341  for (const auto& td : catalog->getAllTableMetadataCopy()) {
342  tables_by_database[catalog->getDatabaseId()].emplace_back(td);
343  }
344  }
345  }
346  return tables_by_database;
347 }
static SysCatalog & instance()
Definition: SysCatalog.h:325
const std::string INFORMATION_SCHEMA_DB
Definition: SysCatalog.h:65

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string foreign_storage::anonymous_namespace{InternalCatalogDataWrapper.cpp}::get_object_type_str ( int32_t  object_type)

Definition at line 243 of file InternalCatalogDataWrapper.cpp.

References DashboardDBObjectType, DatabaseDBObjectType, ServerDBObjectType, TableDBObjectType, run_benchmark_import::type, UNREACHABLE, and ViewDBObjectType.

Referenced by populate_import_buffers_for_catalog_permissions().

243  {
244  std::string object_type_str;
245  auto type = static_cast<DBObjectType>(object_type);
247  object_type_str = "database";
248  } else if (type == DBObjectType::TableDBObjectType) {
249  object_type_str = "table";
251  object_type_str = "dashboard";
252  } else if (type == DBObjectType::ViewDBObjectType) {
253  object_type_str = "view";
254  } else if (type == DBObjectType::ServerDBObjectType) {
255  object_type_str = "server";
256  } else {
257  UNREACHABLE() << "Unexpected object type: " << object_type;
258  }
259  return object_type_str;
260 }
DBObjectType
Definition: DBObject.h:42
#define UNREACHABLE()
Definition: Logger.h:253

+ Here is the caller graph for this function:

std::vector<std::string> foreign_storage::anonymous_namespace{InternalCatalogDataWrapper.cpp}::get_permissions ( const AccessPrivileges  privileges,
int32_t  object_type,
int32_t  object_id 
)

Definition at line 128 of file InternalCatalogDataWrapper.cpp.

References AccessPrivileges::ACCESS, AccessPrivileges::ALL_DASHBOARD, AccessPrivileges::ALL_DATABASE, AccessPrivileges::ALL_SERVER, AccessPrivileges::ALL_TABLE, AccessPrivileges::ALL_VIEW, AccessPrivileges::ALTER_SERVER, AccessPrivileges::ALTER_TABLE, AccessPrivileges::CREATE_DASHBOARD, AccessPrivileges::CREATE_SERVER, AccessPrivileges::CREATE_TABLE, AccessPrivileges::CREATE_VIEW, DashboardDBObjectType, DatabaseDBObjectType, AccessPrivileges::DELETE_DASHBOARD, AccessPrivileges::DELETE_FROM_TABLE, AccessPrivileges::DROP_SERVER, AccessPrivileges::DROP_TABLE, AccessPrivileges::DROP_VIEW, AccessPrivileges::EDIT_DASHBOARD, AccessPrivileges::hasPermission(), AccessPrivileges::INSERT_INTO_TABLE, AccessPrivileges::privileges, AccessPrivileges::SELECT_FROM_TABLE, AccessPrivileges::SELECT_FROM_VIEW, AccessPrivileges::SERVER_USAGE, ServerDBObjectType, spatial_type::suffix(), TableDBObjectType, AccessPrivileges::TRUNCATE_TABLE, run_benchmark_import::type, UNREACHABLE, AccessPrivileges::UPDATE_IN_TABLE, AccessPrivileges::VIEW_DASHBOARD, AccessPrivileges::VIEW_SQL_EDITOR, and ViewDBObjectType.

Referenced by populate_import_buffers_for_catalog_permissions().

130  {
131  std::vector<std::string> permissions;
132  auto type = static_cast<DBObjectType>(object_type);
135  permissions.emplace_back("all");
136  } else {
138  permissions.emplace_back("view_sql_editor");
139  }
141  permissions.emplace_back("access");
142  }
143  }
144  } else if (type == DBObjectType::TableDBObjectType) {
146  permissions.emplace_back("all");
147  } else {
148  std::string suffix;
149  if (object_id == -1) {
150  suffix = " table";
151  }
153  permissions.emplace_back("select" + suffix);
154  }
156  permissions.emplace_back("insert" + suffix);
157  }
159  permissions.emplace_back("update" + suffix);
160  }
162  permissions.emplace_back("delete" + suffix);
163  }
165  permissions.emplace_back("truncate" + suffix);
166  }
168  permissions.emplace_back("alter" + suffix);
169  }
171  permissions.emplace_back("drop" + suffix);
172  }
174  permissions.emplace_back("create table");
175  }
176  }
179  permissions.emplace_back("all");
180  } else {
181  std::string suffix;
182  if (object_id == -1) {
183  suffix = " dashboard";
184  }
186  permissions.emplace_back("view" + suffix);
187  }
189  permissions.emplace_back("edit" + suffix);
190  }
192  permissions.emplace_back("delete" + suffix);
193  }
195  permissions.emplace_back("create dashboard");
196  }
197  }
198  } else if (type == DBObjectType::ViewDBObjectType) {
200  permissions.emplace_back("all");
201  } else {
202  std::string suffix;
203  if (object_id == -1) {
204  suffix = " view";
205  }
207  permissions.emplace_back("select" + suffix);
208  }
210  permissions.emplace_back("drop" + suffix);
211  }
213  permissions.emplace_back("create view");
214  }
215  }
216  } else if (type == DBObjectType::ServerDBObjectType) {
218  permissions.emplace_back("all");
219  } else {
220  std::string suffix;
221  if (object_id == -1) {
222  suffix = " server";
223  }
225  permissions.emplace_back("alter" + suffix);
226  }
228  permissions.emplace_back("usage" + suffix);
229  }
231  permissions.emplace_back("drop" + suffix);
232  }
234  permissions.emplace_back("create server");
235  }
236  }
237  } else {
238  UNREACHABLE() << "Unexpected object type: " << object_type;
239  }
240  return permissions;
241 }
static const AccessPrivileges VIEW_SQL_EDITOR
Definition: DBObject.h:154
static const AccessPrivileges VIEW_DASHBOARD
Definition: DBObject.h:173
static const AccessPrivileges DROP_SERVER
Definition: DBObject.h:191
static const AccessPrivileges ALL_DATABASE
Definition: DBObject.h:153
static const AccessPrivileges ALTER_TABLE
Definition: DBObject.h:167
DBObjectType
Definition: DBObject.h:42
static const AccessPrivileges TRUNCATE_TABLE
Definition: DBObject.h:166
static const AccessPrivileges INSERT_INTO_TABLE
Definition: DBObject.h:163
static const AccessPrivileges CREATE_DASHBOARD
Definition: DBObject.h:172
static const AccessPrivileges SERVER_USAGE
Definition: DBObject.h:193
#define UNREACHABLE()
Definition: Logger.h:253
static const AccessPrivileges SELECT_FROM_TABLE
Definition: DBObject.h:162
std::string suffix(SQLTypes type)
Definition: Codegen.cpp:68
static const AccessPrivileges ALL_VIEW
Definition: DBObject.h:179
static const AccessPrivileges ALTER_SERVER
Definition: DBObject.h:192
static const AccessPrivileges DROP_TABLE
Definition: DBObject.h:161
static const AccessPrivileges ALL_SERVER
Definition: DBObject.h:189
static const AccessPrivileges CREATE_SERVER
Definition: DBObject.h:190
static const AccessPrivileges DELETE_FROM_TABLE
Definition: DBObject.h:165
static const AccessPrivileges CREATE_TABLE
Definition: DBObject.h:160
static const AccessPrivileges SELECT_FROM_VIEW
Definition: DBObject.h:182
static const AccessPrivileges ALL_DASHBOARD
Definition: DBObject.h:171
static const AccessPrivileges ACCESS
Definition: DBObject.h:155
static const AccessPrivileges ALL_TABLE
Definition: DBObject.h:159
static const AccessPrivileges DROP_VIEW
Definition: DBObject.h:181
static const AccessPrivileges CREATE_VIEW
Definition: DBObject.h:180
static const AccessPrivileges DELETE_DASHBOARD
Definition: DBObject.h:175
int64_t privileges
Definition: DBObject.h:135
static const AccessPrivileges EDIT_DASHBOARD
Definition: DBObject.h:174
static const AccessPrivileges UPDATE_IN_TABLE
Definition: DBObject.h:164
bool hasPermission(int permission) const
Definition: DBObject.h:143

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void foreign_storage::anonymous_namespace{InternalCatalogDataWrapper.cpp}::populate_import_buffers_for_catalog_dashboards ( const std::map< int32_t, std::vector< DashboardDescriptor >> &  dashboards_by_database,
std::map< std::string, import_export::TypedImportBuffer * > &  import_buffers 
)

Definition at line 102 of file InternalCatalogDataWrapper.cpp.

Referenced by foreign_storage::InternalCatalogDataWrapper::populateChunkBuffersForTable().

104  {
105  for (const auto& [db_id, dashboards] : dashboards_by_database) {
106  for (const auto& dashboard : dashboards) {
107  if (import_buffers.find("database_id") != import_buffers.end()) {
108  import_buffers["database_id"]->addInt(db_id);
109  }
110  if (import_buffers.find("dashboard_id") != import_buffers.end()) {
111  import_buffers["dashboard_id"]->addInt(dashboard.dashboardId);
112  }
113  if (import_buffers.find("dashboard_name") != import_buffers.end()) {
114  import_buffers["dashboard_name"]->addString(dashboard.dashboardName);
115  }
116  if (import_buffers.find("owner_id") != import_buffers.end()) {
117  import_buffers["owner_id"]->addInt(dashboard.userId);
118  }
119  if (import_buffers.find("last_updated_at") != import_buffers.end()) {
120  auto& buffer = import_buffers["last_updated_at"];
121  import_buffers["last_updated_at"]->add_value(
122  buffer->getColumnDesc(), dashboard.updateTime, false, {});
123  }
124  }
125  }
126 }

+ Here is the caller graph for this function:

void foreign_storage::anonymous_namespace{InternalCatalogDataWrapper.cpp}::populate_import_buffers_for_catalog_databases ( const std::list< Catalog_Namespace::DBMetadata > &  databases,
std::map< std::string, import_export::TypedImportBuffer * > &  import_buffers 
)

Definition at line 296 of file InternalCatalogDataWrapper.cpp.

Referenced by foreign_storage::InternalCatalogDataWrapper::populateChunkBuffersForTable().

298  {
299  for (const auto& db : databases) {
300  if (import_buffers.find("database_id") != import_buffers.end()) {
301  import_buffers["database_id"]->addInt(db.dbId);
302  }
303  if (import_buffers.find("database_name") != import_buffers.end()) {
304  import_buffers["database_name"]->addString(db.dbName);
305  }
306  if (import_buffers.find("owner_id") != import_buffers.end()) {
307  import_buffers["owner_id"]->addInt(db.dbOwner);
308  }
309  }
310 }

+ Here is the caller graph for this function:

void foreign_storage::anonymous_namespace{InternalCatalogDataWrapper.cpp}::populate_import_buffers_for_catalog_permissions ( const std::vector< ObjectRoleDescriptor > &  object_permissions,
std::map< std::string, import_export::TypedImportBuffer * > &  import_buffers 
)

Definition at line 262 of file InternalCatalogDataWrapper.cpp.

References get_object_type_str(), and get_permissions().

Referenced by foreign_storage::InternalCatalogDataWrapper::populateChunkBuffersForTable().

264  {
265  for (const auto& permission : object_permissions) {
266  if (import_buffers.find("role_name") != import_buffers.end()) {
267  import_buffers["role_name"]->addString(permission.roleName);
268  }
269  if (import_buffers.find("is_user_role") != import_buffers.end()) {
270  import_buffers["is_user_role"]->addBoolean(permission.roleType);
271  }
272  if (import_buffers.find("database_id") != import_buffers.end()) {
273  import_buffers["database_id"]->addInt(permission.dbId);
274  }
275  if (import_buffers.find("object_name") != import_buffers.end()) {
276  import_buffers["object_name"]->addString(permission.objectName);
277  }
278  if (import_buffers.find("object_id") != import_buffers.end()) {
279  import_buffers["object_id"]->addInt(permission.objectId);
280  }
281  if (import_buffers.find("object_owner_id") != import_buffers.end()) {
282  import_buffers["object_owner_id"]->addInt(permission.objectOwnerId);
283  }
284  if (import_buffers.find("object_permission_type") != import_buffers.end()) {
285  import_buffers["object_permission_type"]->addString(
286  get_object_type_str(permission.objectType));
287  }
288  if (import_buffers.find("object_permissions") != import_buffers.end()) {
289  auto permissions =
290  get_permissions(permission.privs, permission.objectType, permission.objectId);
291  import_buffers["object_permissions"]->addStringArray(permissions);
292  }
293  }
294 }
std::vector< std::string > get_permissions(const AccessPrivileges privileges, int32_t object_type, int32_t object_id)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void foreign_storage::anonymous_namespace{InternalCatalogDataWrapper.cpp}::populate_import_buffers_for_catalog_role_assignments ( const std::map< std::string, std::vector< std::string >> &  user_names_by_role_,
std::map< std::string, import_export::TypedImportBuffer * > &  import_buffers 
)

Definition at line 321 of file InternalCatalogDataWrapper.cpp.

Referenced by foreign_storage::InternalCatalogDataWrapper::populateChunkBuffersForTable().

323  {
324  for (const auto& [role, user_names] : user_names_by_role_) {
325  for (const auto& user_name : user_names) {
326  if (import_buffers.find("role_name") != import_buffers.end()) {
327  import_buffers["role_name"]->addString(role);
328  }
329  if (import_buffers.find("user_name") != import_buffers.end()) {
330  import_buffers["user_name"]->addString(user_name);
331  }
332  }
333  }
334 }

+ Here is the caller graph for this function:

void foreign_storage::anonymous_namespace{InternalCatalogDataWrapper.cpp}::populate_import_buffers_for_catalog_roles ( const std::set< std::string > &  roles,
std::map< std::string, import_export::TypedImportBuffer * > &  import_buffers 
)

Definition at line 312 of file InternalCatalogDataWrapper.cpp.

References CHECK.

Referenced by foreign_storage::InternalCatalogDataWrapper::populateChunkBuffersForTable().

314  {
315  for (const auto& role : roles) {
316  CHECK(import_buffers.find("role_name") != import_buffers.end());
317  import_buffers["role_name"]->addString(role);
318  }
319 }
#define CHECK(condition)
Definition: Logger.h:209

+ Here is the caller graph for this function:

void foreign_storage::anonymous_namespace{InternalCatalogDataWrapper.cpp}::populate_import_buffers_for_catalog_tables ( const std::map< int32_t, std::vector< TableDescriptor >> &  tables_by_database,
std::map< std::string, import_export::TypedImportBuffer * > &  import_buffers 
)

Definition at line 54 of file InternalCatalogDataWrapper.cpp.

References run_benchmark_import::tables.

Referenced by foreign_storage::InternalCatalogDataWrapper::populateChunkBuffersForTable().

56  {
57  for (const auto& [db_id, tables] : tables_by_database) {
58  for (const auto& table : tables) {
59  if (import_buffers.find("database_id") != import_buffers.end()) {
60  import_buffers["database_id"]->addInt(db_id);
61  }
62  if (import_buffers.find("table_id") != import_buffers.end()) {
63  import_buffers["table_id"]->addInt(table.tableId);
64  }
65  if (import_buffers.find("table_name") != import_buffers.end()) {
66  import_buffers["table_name"]->addString(table.tableName);
67  }
68  if (import_buffers.find("owner_id") != import_buffers.end()) {
69  import_buffers["owner_id"]->addInt(table.userId);
70  }
71  if (import_buffers.find("column_count") != import_buffers.end()) {
72  import_buffers["column_count"]->addInt(table.nColumns);
73  }
74  if (import_buffers.find("is_view") != import_buffers.end()) {
75  import_buffers["is_view"]->addBoolean(table.isView);
76  }
77  if (import_buffers.find("view_sql") != import_buffers.end()) {
78  import_buffers["view_sql"]->addString(table.viewSQL);
79  }
80  if (import_buffers.find("max_fragment_size") != import_buffers.end()) {
81  import_buffers["max_fragment_size"]->addInt(table.maxFragRows);
82  }
83  if (import_buffers.find("max_chunk_size") != import_buffers.end()) {
84  import_buffers["max_chunk_size"]->addBigint(table.maxChunkSize);
85  }
86  if (import_buffers.find("fragment_page_size") != import_buffers.end()) {
87  import_buffers["fragment_page_size"]->addInt(table.fragPageSize);
88  }
89  if (import_buffers.find("max_rows") != import_buffers.end()) {
90  import_buffers["max_rows"]->addBigint(table.maxRows);
91  }
92  if (import_buffers.find("max_rollback_epochs") != import_buffers.end()) {
93  import_buffers["max_rollback_epochs"]->addInt(table.maxRollbackEpochs);
94  }
95  if (import_buffers.find("shard_count") != import_buffers.end()) {
96  import_buffers["shard_count"]->addInt(table.nShards);
97  }
98  }
99  }
100 }

+ Here is the caller graph for this function:

void foreign_storage::anonymous_namespace{InternalCatalogDataWrapper.cpp}::populate_import_buffers_for_catalog_users ( const std::list< Catalog_Namespace::UserMetadata > &  all_users,
std::map< std::string, import_export::TypedImportBuffer * > &  import_buffers 
)

Definition at line 32 of file InternalCatalogDataWrapper.cpp.

Referenced by foreign_storage::InternalCatalogDataWrapper::populateChunkBuffersForTable().

34  {
35  for (const auto& user : all_users) {
36  if (import_buffers.find("user_id") != import_buffers.end()) {
37  import_buffers["user_id"]->addInt(user.userId);
38  }
39  if (import_buffers.find("user_name") != import_buffers.end()) {
40  import_buffers["user_name"]->addString(user.userName);
41  }
42  if (import_buffers.find("is_super_user") != import_buffers.end()) {
43  import_buffers["is_super_user"]->addBoolean(user.isSuper);
44  }
45  if (import_buffers.find("default_db_id") != import_buffers.end()) {
46  import_buffers["default_db_id"]->addInt(user.defaultDbId);
47  }
48  if (import_buffers.find("can_login") != import_buffers.end()) {
49  import_buffers["can_login"]->addBoolean(user.can_login);
50  }
51  }
52 }

+ Here is the caller graph for this function: