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

Functions

void set_null (import_export::TypedImportBuffer *import_buffer)
 
void populate_import_buffers_for_catalog_users (const std::list< Catalog_Namespace::UserMetadata > &all_users, std::map< std::string, import_export::TypedImportBuffer * > &import_buffers)
 
std::string get_user_name (int32_t user_id)
 
std::string get_table_type (const TableDescriptor &td)
 
std::string get_table_ddl (int32_t db_id, const TableDescriptor &td)
 
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)
 
std::vector< std::string > get_data_sources (const std::string &dashboard_metadata)
 
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 452 of file InternalCatalogDataWrapper.cpp.

References Catalog_Namespace::SysCatalog::instance(), and shared::kInfoSchemaDbName.

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

452  {
453  std::map<int32_t, std::vector<DashboardDescriptor>> dashboards_by_database;
454  auto& sys_catalog = Catalog_Namespace::SysCatalog::instance();
455  for (const auto& catalog : sys_catalog.getCatalogsForAllDbs()) {
456  if (catalog->name() != shared::kInfoSchemaDbName) {
457  for (const auto& dashboard : catalog->getAllDashboardsMetadataCopy()) {
458  dashboards_by_database[catalog->getDatabaseId()].emplace_back(dashboard);
459  }
460  }
461  }
462  return dashboards_by_database;
463 }
const std::string kInfoSchemaDbName
static SysCatalog & instance()
Definition: SysCatalog.h:337

+ 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 465 of file InternalCatalogDataWrapper.cpp.

References Catalog_Namespace::SysCatalog::instance().

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

465  {
466  auto& sys_catalog = Catalog_Namespace::SysCatalog::instance();
467  const auto& users = sys_catalog.getAllUserMetadata();
468  std::map<std::string, std::vector<std::string>> user_names_by_role;
469  for (const auto& user : users) {
470  for (const auto& role :
471  sys_catalog.getRoles(false, user.isSuper, user.userName, true)) {
472  user_names_by_role[role].emplace_back(user.userName);
473  }
474  }
475  return user_names_by_role;
476 }
static SysCatalog & instance()
Definition: SysCatalog.h:337

+ 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 439 of file InternalCatalogDataWrapper.cpp.

References Catalog_Namespace::SysCatalog::instance(), and shared::kInfoSchemaDbName.

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

439  {
440  std::map<int32_t, std::vector<TableDescriptor>> tables_by_database;
441  auto& sys_catalog = Catalog_Namespace::SysCatalog::instance();
442  for (const auto& catalog : sys_catalog.getCatalogsForAllDbs()) {
443  if (catalog->name() != shared::kInfoSchemaDbName) {
444  for (const auto& td : catalog->getAllTableMetadataCopy()) {
445  tables_by_database[catalog->getDatabaseId()].emplace_back(td);
446  }
447  }
448  }
449  return tables_by_database;
450 }
const std::string kInfoSchemaDbName
static SysCatalog & instance()
Definition: SysCatalog.h:337

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::vector<std::string> foreign_storage::anonymous_namespace{InternalCatalogDataWrapper.cpp}::get_data_sources ( const std::string &  dashboard_metadata)

Definition at line 163 of file InternalCatalogDataWrapper.cpp.

References foreign_storage::json_utils::get_value_from_object(), split(), and strip().

Referenced by populate_import_buffers_for_catalog_dashboards().

163  {
164  rapidjson::Document document;
165  document.Parse(dashboard_metadata);
166  if (!document.IsObject()) {
167  return {};
168  }
169  std::string data_sources_str;
170  json_utils::get_value_from_object(document, data_sources_str, "table");
171  auto data_sources = split(data_sources_str, ",");
172  for (auto it = data_sources.begin(); it != data_sources.end();) {
173  *it = strip(*it);
174  static std::regex parameter_regex{"\\$\\{.+\\}"};
175  if (std::regex_match(*it, parameter_regex)) {
176  // Remove custom SQL sources.
177  it = data_sources.erase(it);
178  } else {
179  it++;
180  }
181  }
182  return data_sources;
183 }
std::string strip(std::string_view str)
trim any whitespace from the left and right ends of a string
std::vector< std::string > split(std::string_view str, std::string_view delim, std::optional< size_t > maxsplit)
split apart a string into a vector of substrings
void get_value_from_object(const rapidjson::Value &object, T &value, const std::string &name)
Definition: FsiJsonUtils.h:164

+ 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 336 of file InternalCatalogDataWrapper.cpp.

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

Referenced by populate_import_buffers_for_catalog_permissions().

336  {
337  std::string object_type_str;
338  auto type = static_cast<DBObjectType>(object_type);
340  object_type_str = "database";
341  } else if (type == DBObjectType::TableDBObjectType) {
342  object_type_str = "table";
344  object_type_str = "dashboard";
345  } else if (type == DBObjectType::ViewDBObjectType) {
346  object_type_str = "view";
347  } else if (type == DBObjectType::ServerDBObjectType) {
348  object_type_str = "server";
349  } else {
350  UNREACHABLE() << "Unexpected object type: " << object_type;
351  }
352  return object_type_str;
353 }
DBObjectType
Definition: DBObject.h:42
#define UNREACHABLE()
Definition: Logger.h:267

+ 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 221 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().

223  {
224  std::vector<std::string> permissions;
225  auto type = static_cast<DBObjectType>(object_type);
228  permissions.emplace_back("all");
229  } else {
231  permissions.emplace_back("view_sql_editor");
232  }
234  permissions.emplace_back("access");
235  }
236  }
237  } else if (type == DBObjectType::TableDBObjectType) {
239  permissions.emplace_back("all");
240  } else {
241  std::string suffix;
242  if (object_id == -1) {
243  suffix = " table";
244  }
246  permissions.emplace_back("select" + suffix);
247  }
249  permissions.emplace_back("insert" + suffix);
250  }
252  permissions.emplace_back("update" + suffix);
253  }
255  permissions.emplace_back("delete" + suffix);
256  }
258  permissions.emplace_back("truncate" + suffix);
259  }
261  permissions.emplace_back("alter" + suffix);
262  }
264  permissions.emplace_back("drop" + suffix);
265  }
267  permissions.emplace_back("create table");
268  }
269  }
272  permissions.emplace_back("all");
273  } else {
274  std::string suffix;
275  if (object_id == -1) {
276  suffix = " dashboard";
277  }
279  permissions.emplace_back("view" + suffix);
280  }
282  permissions.emplace_back("edit" + suffix);
283  }
285  permissions.emplace_back("delete" + suffix);
286  }
288  permissions.emplace_back("create dashboard");
289  }
290  }
291  } else if (type == DBObjectType::ViewDBObjectType) {
293  permissions.emplace_back("all");
294  } else {
295  std::string suffix;
296  if (object_id == -1) {
297  suffix = " view";
298  }
300  permissions.emplace_back("select" + suffix);
301  }
303  permissions.emplace_back("drop" + suffix);
304  }
306  permissions.emplace_back("create view");
307  }
308  }
309  } else if (type == DBObjectType::ServerDBObjectType) {
311  permissions.emplace_back("all");
312  } else {
313  std::string suffix;
314  if (object_id == -1) {
315  suffix = " server";
316  }
318  permissions.emplace_back("alter" + suffix);
319  }
321  permissions.emplace_back("usage" + suffix);
322  }
324  permissions.emplace_back("drop" + suffix);
325  }
327  permissions.emplace_back("create server");
328  }
329  }
330  } else {
331  UNREACHABLE() << "Unexpected object type: " << object_type;
332  }
333  return permissions;
334 }
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:267
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:

std::string foreign_storage::anonymous_namespace{InternalCatalogDataWrapper.cpp}::get_table_ddl ( int32_t  db_id,
const TableDescriptor td 
)

Definition at line 94 of file InternalCatalogDataWrapper.cpp.

References CHECK, Catalog_Namespace::SysCatalog::getCatalog(), Catalog_Namespace::SysCatalog::instance(), foreign_storage::kDeletedValueIndicator, and TableDescriptor::tableId.

Referenced by populate_import_buffers_for_catalog_tables().

94  {
96  CHECK(catalog);
97  auto ddl = catalog->dumpCreateTable(td.tableId);
98  if (!ddl.has_value()) {
99  // It is possible for the table to be concurrently deleted while querying the system
100  // table.
101  return kDeletedValueIndicator;
102  }
103  return ddl.value();
104 }
constexpr const char * kDeletedValueIndicator
static SysCatalog & instance()
Definition: SysCatalog.h:337
std::shared_ptr< Catalog > getCatalog(const std::string &dbName)
#define CHECK(condition)
Definition: Logger.h:223

+ 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_table_type ( const TableDescriptor td)

Definition at line 82 of file InternalCatalogDataWrapper.cpp.

References TableDescriptor::isForeignTable(), TableDescriptor::isTemporaryTable(), and TableDescriptor::isView.

Referenced by populate_import_buffers_for_catalog_tables().

82  {
83  std::string table_type{"DEFAULT"};
84  if (td.isView) {
85  table_type = "VIEW";
86  } else if (td.isTemporaryTable()) {
87  table_type = "TEMPORARY";
88  } else if (td.isForeignTable()) {
89  table_type = "FOREIGN";
90  }
91  return table_type;
92 }
bool isForeignTable() const
bool isTemporaryTable() const

+ 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_user_name ( int32_t  user_id)

Definition at line 71 of file InternalCatalogDataWrapper.cpp.

References Catalog_Namespace::SysCatalog::instance(), foreign_storage::kDeletedValueIndicator, and Catalog_Namespace::UserMetadata::userName.

Referenced by populate_import_buffers_for_catalog_dashboards(), populate_import_buffers_for_catalog_databases(), populate_import_buffers_for_catalog_permissions(), and populate_import_buffers_for_catalog_tables().

71  {
72  Catalog_Namespace::UserMetadata user_metadata;
73  auto& sys_catalog = Catalog_Namespace::SysCatalog::instance();
74  if (sys_catalog.getMetadataForUserById(user_id, user_metadata)) {
75  return user_metadata.userName;
76  } else {
77  // User has been deleted.
79  }
80 }
constexpr const char * kDeletedValueIndicator
static SysCatalog & instance()
Definition: SysCatalog.h:337

+ 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 185 of file InternalCatalogDataWrapper.cpp.

References get_data_sources(), foreign_storage::get_db_name(), and get_user_name().

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

187  {
188  for (const auto& [db_id, dashboards] : dashboards_by_database) {
189  for (const auto& dashboard : dashboards) {
190  if (import_buffers.find("database_id") != import_buffers.end()) {
191  import_buffers["database_id"]->addInt(db_id);
192  }
193  if (import_buffers.find("database_name") != import_buffers.end()) {
194  import_buffers["database_name"]->addString(get_db_name(db_id));
195  }
196  if (import_buffers.find("dashboard_id") != import_buffers.end()) {
197  import_buffers["dashboard_id"]->addInt(dashboard.dashboardId);
198  }
199  if (import_buffers.find("dashboard_name") != import_buffers.end()) {
200  import_buffers["dashboard_name"]->addString(dashboard.dashboardName);
201  }
202  if (import_buffers.find("owner_id") != import_buffers.end()) {
203  import_buffers["owner_id"]->addInt(dashboard.userId);
204  }
205  if (import_buffers.find("owner_user_name") != import_buffers.end()) {
206  import_buffers["owner_user_name"]->addString(get_user_name(dashboard.userId));
207  }
208  if (import_buffers.find("last_updated_at") != import_buffers.end()) {
209  auto& buffer = import_buffers["last_updated_at"];
210  import_buffers["last_updated_at"]->add_value(
211  buffer->getColumnDesc(), dashboard.updateTime, false, {});
212  }
213  if (import_buffers.find("data_sources") != import_buffers.end()) {
214  import_buffers["data_sources"]->addStringArray(
215  get_data_sources(dashboard.dashboardMetadata));
216  }
217  }
218  }
219 }
std::vector< std::string > get_data_sources(const std::string &dashboard_metadata)
std::string get_db_name(int32_t db_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_databases ( const std::list< Catalog_Namespace::DBMetadata > &  databases,
std::map< std::string, import_export::TypedImportBuffer * > &  import_buffers 
)

Definition at line 396 of file InternalCatalogDataWrapper.cpp.

References get_user_name().

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

398  {
399  for (const auto& db : databases) {
400  if (import_buffers.find("database_id") != import_buffers.end()) {
401  import_buffers["database_id"]->addInt(db.dbId);
402  }
403  if (import_buffers.find("database_name") != import_buffers.end()) {
404  import_buffers["database_name"]->addString(db.dbName);
405  }
406  if (import_buffers.find("owner_id") != import_buffers.end()) {
407  import_buffers["owner_id"]->addInt(db.dbOwner);
408  }
409  if (import_buffers.find("owner_user_name") != import_buffers.end()) {
410  import_buffers["owner_user_name"]->addString(get_user_name(db.dbOwner));
411  }
412  }
413 }

+ 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_permissions ( const std::vector< ObjectRoleDescriptor > &  object_permissions,
std::map< std::string, import_export::TypedImportBuffer * > &  import_buffers 
)

Definition at line 355 of file InternalCatalogDataWrapper.cpp.

References foreign_storage::get_db_name(), get_object_type_str(), get_permissions(), and get_user_name().

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

357  {
358  for (const auto& permission : object_permissions) {
359  if (import_buffers.find("role_name") != import_buffers.end()) {
360  import_buffers["role_name"]->addString(permission.roleName);
361  }
362  if (import_buffers.find("is_user_role") != import_buffers.end()) {
363  import_buffers["is_user_role"]->addBoolean(permission.roleType);
364  }
365  if (import_buffers.find("database_id") != import_buffers.end()) {
366  import_buffers["database_id"]->addInt(permission.dbId);
367  }
368  if (import_buffers.find("database_name") != import_buffers.end()) {
369  import_buffers["database_name"]->addString(get_db_name(permission.dbId));
370  }
371  if (import_buffers.find("object_name") != import_buffers.end()) {
372  import_buffers["object_name"]->addString(permission.objectName);
373  }
374  if (import_buffers.find("object_id") != import_buffers.end()) {
375  import_buffers["object_id"]->addInt(permission.objectId);
376  }
377  if (import_buffers.find("object_owner_id") != import_buffers.end()) {
378  import_buffers["object_owner_id"]->addInt(permission.objectOwnerId);
379  }
380  if (import_buffers.find("object_owner_user_name") != import_buffers.end()) {
381  import_buffers["object_owner_user_name"]->addString(
382  get_user_name(permission.objectOwnerId));
383  }
384  if (import_buffers.find("object_permission_type") != import_buffers.end()) {
385  import_buffers["object_permission_type"]->addString(
386  get_object_type_str(permission.objectType));
387  }
388  if (import_buffers.find("object_permissions") != import_buffers.end()) {
389  auto permissions =
390  get_permissions(permission.privs, permission.objectType, permission.objectId);
391  import_buffers["object_permissions"]->addStringArray(permissions);
392  }
393  }
394 }
std::vector< std::string > get_permissions(const AccessPrivileges privileges, int32_t object_type, int32_t object_id)
std::string get_db_name(int32_t db_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 424 of file InternalCatalogDataWrapper.cpp.

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

426  {
427  for (const auto& [role, user_names] : user_names_by_role_) {
428  for (const auto& user_name : user_names) {
429  if (import_buffers.find("role_name") != import_buffers.end()) {
430  import_buffers["role_name"]->addString(role);
431  }
432  if (import_buffers.find("user_name") != import_buffers.end()) {
433  import_buffers["user_name"]->addString(user_name);
434  }
435  }
436  }
437 }

+ 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 415 of file InternalCatalogDataWrapper.cpp.

References CHECK.

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

417  {
418  for (const auto& role : roles) {
419  CHECK(import_buffers.find("role_name") != import_buffers.end());
420  import_buffers["role_name"]->addString(role);
421  }
422 }
#define CHECK(condition)
Definition: Logger.h:223

+ 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 106 of file InternalCatalogDataWrapper.cpp.

References foreign_storage::get_db_name(), get_table_ddl(), get_table_type(), get_user_name(), and run_benchmark_import::tables.

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

108  {
109  for (const auto& [db_id, tables] : tables_by_database) {
110  for (const auto& table : tables) {
111  if (import_buffers.find("database_id") != import_buffers.end()) {
112  import_buffers["database_id"]->addInt(db_id);
113  }
114  if (import_buffers.find("database_name") != import_buffers.end()) {
115  import_buffers["database_name"]->addString(get_db_name(db_id));
116  }
117  if (import_buffers.find("table_id") != import_buffers.end()) {
118  import_buffers["table_id"]->addInt(table.tableId);
119  }
120  if (import_buffers.find("table_name") != import_buffers.end()) {
121  import_buffers["table_name"]->addString(table.tableName);
122  }
123  if (import_buffers.find("owner_id") != import_buffers.end()) {
124  import_buffers["owner_id"]->addInt(table.userId);
125  }
126  if (import_buffers.find("owner_user_name") != import_buffers.end()) {
127  import_buffers["owner_user_name"]->addString(get_user_name(table.userId));
128  }
129  if (import_buffers.find("column_count") != import_buffers.end()) {
130  import_buffers["column_count"]->addInt(table.nColumns);
131  }
132  if (import_buffers.find("table_type") != import_buffers.end()) {
133  import_buffers["table_type"]->addString(get_table_type(table));
134  }
135  if (import_buffers.find("view_sql") != import_buffers.end()) {
136  import_buffers["view_sql"]->addString(table.viewSQL);
137  }
138  if (import_buffers.find("max_fragment_size") != import_buffers.end()) {
139  import_buffers["max_fragment_size"]->addInt(table.maxFragRows);
140  }
141  if (import_buffers.find("max_chunk_size") != import_buffers.end()) {
142  import_buffers["max_chunk_size"]->addBigint(table.maxChunkSize);
143  }
144  if (import_buffers.find("fragment_page_size") != import_buffers.end()) {
145  import_buffers["fragment_page_size"]->addInt(table.fragPageSize);
146  }
147  if (import_buffers.find("max_rows") != import_buffers.end()) {
148  import_buffers["max_rows"]->addBigint(table.maxRows);
149  }
150  if (import_buffers.find("max_rollback_epochs") != import_buffers.end()) {
151  import_buffers["max_rollback_epochs"]->addInt(table.maxRollbackEpochs);
152  }
153  if (import_buffers.find("shard_count") != import_buffers.end()) {
154  import_buffers["shard_count"]->addInt(table.nShards);
155  }
156  if (import_buffers.find("ddl_statement") != import_buffers.end()) {
157  import_buffers["ddl_statement"]->addString(get_table_ddl(db_id, table));
158  }
159  }
160  }
161 }
std::string get_table_ddl(int32_t db_id, const TableDescriptor &td)
std::string get_db_name(int32_t db_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_users ( const std::list< Catalog_Namespace::UserMetadata > &  all_users,
std::map< std::string, import_export::TypedImportBuffer * > &  import_buffers 
)

Definition at line 42 of file InternalCatalogDataWrapper.cpp.

References foreign_storage::get_db_name(), and set_null().

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

44  {
45  for (const auto& user : all_users) {
46  if (import_buffers.find("user_id") != import_buffers.end()) {
47  import_buffers["user_id"]->addInt(user.userId);
48  }
49  if (import_buffers.find("user_name") != import_buffers.end()) {
50  import_buffers["user_name"]->addString(user.userName);
51  }
52  if (import_buffers.find("is_super_user") != import_buffers.end()) {
53  import_buffers["is_super_user"]->addBoolean(user.isSuper);
54  }
55  if (import_buffers.find("default_db_id") != import_buffers.end()) {
56  import_buffers["default_db_id"]->addInt(user.defaultDbId);
57  }
58  if (import_buffers.find("default_db_name") != import_buffers.end()) {
59  if (user.defaultDbId > 0) {
60  import_buffers["default_db_name"]->addString(get_db_name(user.defaultDbId));
61  } else {
62  set_null(import_buffers["default_db_name"]);
63  }
64  }
65  if (import_buffers.find("can_login") != import_buffers.end()) {
66  import_buffers["can_login"]->addBoolean(user.can_login);
67  }
68  }
69 }
CONSTEXPR DEVICE void set_null(T &value)
std::string get_db_name(int32_t db_id)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void foreign_storage::anonymous_namespace{InternalCatalogDataWrapper.cpp}::set_null ( import_export::TypedImportBuffer import_buffer)

Definition at line 38 of file InternalCatalogDataWrapper.cpp.

References import_export::TypedImportBuffer::add_value(), and import_export::TypedImportBuffer::getColumnDesc().

38  {
39  import_buffer->add_value(import_buffer->getColumnDesc(), "", true, {});
40 }
const ColumnDescriptor * getColumnDesc() const
Definition: Importer.h:314
void add_value(const ColumnDescriptor *cd, const std::string_view val, const bool is_null, const CopyParams &copy_params, const bool check_not_null=true)
Definition: Importer.cpp:566

+ Here is the call graph for this function: