OmniSciDB  6686921089
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
InternalCatalogDataWrapper.cpp
Go to the documentation of this file.
1 /*
2  * Copyright 2021 OmniSci, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
18 
19 #include "Catalog/Catalog.h"
20 #include "Catalog/SysCatalog.h"
21 #include "ForeignTableSchema.h"
22 #include "FsiChunkUtils.h"
23 #include "ImportExport/Importer.h"
24 #include "TextFileBufferParser.h"
25 
26 namespace foreign_storage {
28  : db_id_(-1), foreign_table_(nullptr) {}
29 
31  const ForeignTable* foreign_table)
32  : db_id_(db_id), foreign_table_(foreign_table) {}
33 
35  const ForeignServer* foreign_server) const {}
36 
38  const ForeignTable* foreign_table) const {}
39 
40 const std::set<std::string_view>& InternalCatalogDataWrapper::getSupportedTableOptions()
41  const {
42  static const std::set<std::string_view> supported_table_options{};
43  return supported_table_options;
44 }
45 
47  const UserMapping* user_mapping,
48  const ForeignServer* foreign_server) const {}
49 
50 const std::set<std::string_view>&
52  static const std::set<std::string_view> supported_user_mapping_options{};
53  return supported_user_mapping_options;
54 }
55 
56 namespace {
58  const std::list<Catalog_Namespace::UserMetadata>& all_users,
59  std::map<std::string, import_export::TypedImportBuffer*>& import_buffers) {
60  for (const auto& user : all_users) {
61  if (import_buffers.find("user_id") != import_buffers.end()) {
62  import_buffers["user_id"]->addInt(user.userId);
63  }
64  if (import_buffers.find("user_name") != import_buffers.end()) {
65  import_buffers["user_name"]->addString(user.userName);
66  }
67  if (import_buffers.find("is_super_user") != import_buffers.end()) {
68  import_buffers["is_super_user"]->addBoolean(user.isSuper);
69  }
70  if (import_buffers.find("default_db_id") != import_buffers.end()) {
71  import_buffers["default_db_id"]->addInt(user.defaultDbId);
72  }
73  if (import_buffers.find("can_login") != import_buffers.end()) {
74  import_buffers["can_login"]->addBoolean(user.can_login);
75  }
76  }
77 }
78 
80  const std::map<int32_t, std::vector<TableDescriptor>>& tables_by_database,
81  std::map<std::string, import_export::TypedImportBuffer*>& import_buffers) {
82  for (const auto& [db_id, tables] : tables_by_database) {
83  for (const auto& table : tables) {
84  if (import_buffers.find("database_id") != import_buffers.end()) {
85  import_buffers["database_id"]->addInt(db_id);
86  }
87  if (import_buffers.find("table_id") != import_buffers.end()) {
88  import_buffers["table_id"]->addInt(table.tableId);
89  }
90  if (import_buffers.find("table_name") != import_buffers.end()) {
91  import_buffers["table_name"]->addString(table.tableName);
92  }
93  if (import_buffers.find("owner_id") != import_buffers.end()) {
94  import_buffers["owner_id"]->addInt(table.userId);
95  }
96  if (import_buffers.find("column_count") != import_buffers.end()) {
97  import_buffers["column_count"]->addInt(table.nColumns);
98  }
99  if (import_buffers.find("is_view") != import_buffers.end()) {
100  import_buffers["is_view"]->addBoolean(table.isView);
101  }
102  if (import_buffers.find("view_sql") != import_buffers.end()) {
103  import_buffers["view_sql"]->addString(table.viewSQL);
104  }
105  if (import_buffers.find("max_fragment_size") != import_buffers.end()) {
106  import_buffers["max_fragment_size"]->addInt(table.maxFragRows);
107  }
108  if (import_buffers.find("max_chunk_size") != import_buffers.end()) {
109  import_buffers["max_chunk_size"]->addBigint(table.maxChunkSize);
110  }
111  if (import_buffers.find("fragment_page_size") != import_buffers.end()) {
112  import_buffers["fragment_page_size"]->addInt(table.fragPageSize);
113  }
114  if (import_buffers.find("max_rows") != import_buffers.end()) {
115  import_buffers["max_rows"]->addBigint(table.maxRows);
116  }
117  if (import_buffers.find("max_rollback_epochs") != import_buffers.end()) {
118  import_buffers["max_rollback_epochs"]->addInt(table.maxRollbackEpochs);
119  }
120  if (import_buffers.find("shard_count") != import_buffers.end()) {
121  import_buffers["shard_count"]->addInt(table.nShards);
122  }
123  }
124  }
125 }
126 
128  const std::map<int32_t, std::vector<DashboardDescriptor>>& dashboards_by_database,
129  std::map<std::string, import_export::TypedImportBuffer*>& import_buffers) {
130  for (const auto& [db_id, dashboards] : dashboards_by_database) {
131  for (const auto& dashboard : dashboards) {
132  if (import_buffers.find("database_id") != import_buffers.end()) {
133  import_buffers["database_id"]->addInt(db_id);
134  }
135  if (import_buffers.find("dashboard_id") != import_buffers.end()) {
136  import_buffers["dashboard_id"]->addInt(dashboard.dashboardId);
137  }
138  if (import_buffers.find("dashboard_name") != import_buffers.end()) {
139  import_buffers["dashboard_name"]->addString(dashboard.dashboardName);
140  }
141  if (import_buffers.find("owner_id") != import_buffers.end()) {
142  import_buffers["owner_id"]->addInt(dashboard.userId);
143  }
144  if (import_buffers.find("last_updated_at") != import_buffers.end()) {
145  auto& buffer = import_buffers["last_updated_at"];
146  import_buffers["last_updated_at"]->add_value(
147  buffer->getColumnDesc(), dashboard.updateTime, false, {});
148  }
149  }
150  }
151 }
152 
153 std::vector<std::string> get_permissions(const AccessPrivileges privileges,
154  int32_t object_type,
155  int32_t object_id) {
156  std::vector<std::string> permissions;
157  auto type = static_cast<DBObjectType>(object_type);
160  permissions.emplace_back("all");
161  } else {
163  permissions.emplace_back("view_sql_editor");
164  }
166  permissions.emplace_back("access");
167  }
168  }
169  } else if (type == DBObjectType::TableDBObjectType) {
171  permissions.emplace_back("all");
172  } else {
173  std::string suffix;
174  if (object_id == -1) {
175  suffix = " table";
176  }
178  permissions.emplace_back("select" + suffix);
179  }
181  permissions.emplace_back("insert" + suffix);
182  }
184  permissions.emplace_back("update" + suffix);
185  }
187  permissions.emplace_back("delete" + suffix);
188  }
190  permissions.emplace_back("truncate" + suffix);
191  }
193  permissions.emplace_back("alter" + suffix);
194  }
196  permissions.emplace_back("drop" + suffix);
197  }
199  permissions.emplace_back("create table");
200  }
201  }
204  permissions.emplace_back("all");
205  } else {
206  std::string suffix;
207  if (object_id == -1) {
208  suffix = " dashboard";
209  }
211  permissions.emplace_back("view" + suffix);
212  }
214  permissions.emplace_back("edit" + suffix);
215  }
217  permissions.emplace_back("delete" + suffix);
218  }
220  permissions.emplace_back("create dashboard");
221  }
222  }
223  } else if (type == DBObjectType::ViewDBObjectType) {
225  permissions.emplace_back("all");
226  } else {
227  std::string suffix;
228  if (object_id == -1) {
229  suffix = " view";
230  }
232  permissions.emplace_back("select" + suffix);
233  }
235  permissions.emplace_back("drop" + suffix);
236  }
238  permissions.emplace_back("create view");
239  }
240  }
241  } else if (type == DBObjectType::ServerDBObjectType) {
243  permissions.emplace_back("all");
244  } else {
245  std::string suffix;
246  if (object_id == -1) {
247  suffix = " server";
248  }
250  permissions.emplace_back("alter" + suffix);
251  }
253  permissions.emplace_back("usage" + suffix);
254  }
256  permissions.emplace_back("drop" + suffix);
257  }
259  permissions.emplace_back("create server");
260  }
261  }
262  } else {
263  UNREACHABLE() << "Unexpected object type: " << object_type;
264  }
265  return permissions;
266 }
267 
268 std::string get_object_type_str(int32_t object_type) {
269  std::string object_type_str;
270  auto type = static_cast<DBObjectType>(object_type);
272  object_type_str = "database";
273  } else if (type == DBObjectType::TableDBObjectType) {
274  object_type_str = "table";
276  object_type_str = "dashboard";
277  } else if (type == DBObjectType::ViewDBObjectType) {
278  object_type_str = "view";
279  } else if (type == DBObjectType::ServerDBObjectType) {
280  object_type_str = "server";
281  } else {
282  UNREACHABLE() << "Unexpected object type: " << object_type;
283  }
284  return object_type_str;
285 }
286 
288  const std::vector<ObjectRoleDescriptor>& object_permissions,
289  std::map<std::string, import_export::TypedImportBuffer*>& import_buffers) {
290  for (const auto& permission : object_permissions) {
291  if (import_buffers.find("role_name") != import_buffers.end()) {
292  import_buffers["role_name"]->addString(permission.roleName);
293  }
294  if (import_buffers.find("is_user_role") != import_buffers.end()) {
295  import_buffers["is_user_role"]->addBoolean(permission.roleType);
296  }
297  if (import_buffers.find("database_id") != import_buffers.end()) {
298  import_buffers["database_id"]->addInt(permission.dbId);
299  }
300  if (import_buffers.find("object_name") != import_buffers.end()) {
301  import_buffers["object_name"]->addString(permission.objectName);
302  }
303  if (import_buffers.find("object_id") != import_buffers.end()) {
304  import_buffers["object_id"]->addInt(permission.objectId);
305  }
306  if (import_buffers.find("object_owner_id") != import_buffers.end()) {
307  import_buffers["object_owner_id"]->addInt(permission.objectOwnerId);
308  }
309  if (import_buffers.find("object_permission_type") != import_buffers.end()) {
310  import_buffers["object_permission_type"]->addString(
311  get_object_type_str(permission.objectType));
312  }
313  if (import_buffers.find("object_permissions") != import_buffers.end()) {
314  auto permissions =
315  get_permissions(permission.privs, permission.objectType, permission.objectId);
316  import_buffers["object_permissions"]->addStringArray(permissions);
317  }
318  }
319 }
320 
322  const std::list<Catalog_Namespace::DBMetadata>& databases,
323  std::map<std::string, import_export::TypedImportBuffer*>& import_buffers) {
324  for (const auto& db : databases) {
325  if (import_buffers.find("database_id") != import_buffers.end()) {
326  import_buffers["database_id"]->addInt(db.dbId);
327  }
328  if (import_buffers.find("database_name") != import_buffers.end()) {
329  import_buffers["database_name"]->addString(db.dbName);
330  }
331  if (import_buffers.find("owner_id") != import_buffers.end()) {
332  import_buffers["owner_id"]->addInt(db.dbOwner);
333  }
334  }
335 }
336 
338  const std::set<std::string>& roles,
339  std::map<std::string, import_export::TypedImportBuffer*>& import_buffers) {
340  for (const auto& role : roles) {
341  CHECK(import_buffers.find("role_name") != import_buffers.end());
342  import_buffers["role_name"]->addString(role);
343  }
344 }
345 
347  const std::map<std::string, std::vector<std::string>>& user_names_by_role_,
348  std::map<std::string, import_export::TypedImportBuffer*>& import_buffers) {
349  for (const auto& [role, user_names] : user_names_by_role_) {
350  for (const auto& user_name : user_names) {
351  if (import_buffers.find("role_name") != import_buffers.end()) {
352  import_buffers["role_name"]->addString(role);
353  }
354  if (import_buffers.find("user_name") != import_buffers.end()) {
355  import_buffers["user_name"]->addString(user_name);
356  }
357  }
358  }
359 }
360 
361 std::map<int32_t, std::vector<TableDescriptor>> get_all_tables() {
362  std::map<int32_t, std::vector<TableDescriptor>> tables_by_database;
363  auto& sys_catalog = Catalog_Namespace::SysCatalog::instance();
364  for (const auto& catalog : sys_catalog.getCatalogsForAllDbs()) {
365  if (catalog->name() != INFORMATION_SCHEMA_DB) {
366  for (const auto& td : catalog->getAllTableMetadataCopy()) {
367  tables_by_database[catalog->getDatabaseId()].emplace_back(td);
368  }
369  }
370  }
371  return tables_by_database;
372 }
373 
374 std::map<int32_t, std::vector<DashboardDescriptor>> get_all_dashboards() {
375  std::map<int32_t, std::vector<DashboardDescriptor>> dashboards_by_database;
376  auto& sys_catalog = Catalog_Namespace::SysCatalog::instance();
377  for (const auto& catalog : sys_catalog.getCatalogsForAllDbs()) {
378  for (const auto& dashboard : catalog->getAllDashboardsMetadataCopy()) {
379  dashboards_by_database[catalog->getDatabaseId()].emplace_back(dashboard);
380  }
381  }
382  return dashboards_by_database;
383 }
384 
385 std::map<std::string, std::vector<std::string>> get_all_role_assignments() {
386  auto& sys_catalog = Catalog_Namespace::SysCatalog::instance();
387  const auto& users = sys_catalog.getAllUserMetadata();
388  std::map<std::string, std::vector<std::string>> user_names_by_role;
389  for (const auto& user : users) {
390  for (const auto& role :
391  sys_catalog.getRoles(false, user.isSuper, user.userName, true)) {
392  user_names_by_role[role].emplace_back(user.userName);
393  }
394  }
395  return user_names_by_role;
396 }
397 
398 void set_default_chunk_metadata(int32_t db_id,
399  const ForeignTable* foreign_table,
400  size_t row_count,
401  ChunkMetadataVector& chunk_metadata_vector) {
402  foreign_storage::ForeignTableSchema schema(db_id, foreign_table);
403  for (auto column : schema.getLogicalColumns()) {
404  ChunkKey chunk_key = {db_id, foreign_table->tableId, column->columnId, 0};
405  if (column->columnType.is_varlen_indeed()) {
406  chunk_key.emplace_back(1);
407  }
408  ForeignStorageBuffer empty_buffer;
409  // Use default encoder metadata
410  empty_buffer.initEncoder(column->columnType);
411  auto chunk_metadata = empty_buffer.getEncoder()->getMetadata(column->columnType);
412  chunk_metadata->numElements = row_count;
413  if (!column->columnType.is_varlen_indeed()) {
414  chunk_metadata->numBytes = column->columnType.get_size() * row_count;
415  }
416  if (column->columnType.is_array()) {
417  ForeignStorageBuffer scalar_buffer;
418  scalar_buffer.initEncoder(column->columnType.get_elem_type());
419  auto scalar_metadata =
420  scalar_buffer.getEncoder()->getMetadata(column->columnType.get_elem_type());
421  chunk_metadata->chunkStats.min = scalar_metadata->chunkStats.min;
422  chunk_metadata->chunkStats.max = scalar_metadata->chunkStats.max;
423  }
424  chunk_metadata->chunkStats.has_nulls = true;
425  chunk_metadata_vector.emplace_back(chunk_key, chunk_metadata);
426  }
427 }
428 
429 void initialize_chunks(std::map<ChunkKey, Chunk_NS::Chunk>& chunks,
430  const ChunkToBufferMap& buffers,
431  size_t row_count,
432  std::set<const ColumnDescriptor*>& columns_to_parse,
433  int32_t fragment_id,
434  const Catalog_Namespace::Catalog& catalog) {
435  for (auto& [chunk_key, buffer] : buffers) {
436  CHECK_EQ(fragment_id, chunk_key[CHUNK_KEY_FRAGMENT_IDX]);
437  const auto column = catalog.getMetadataForColumn(chunk_key[CHUNK_KEY_TABLE_IDX],
438  chunk_key[CHUNK_KEY_COLUMN_IDX]);
439  if (is_varlen_index_key(chunk_key)) {
440  continue;
441  }
442  chunks[chunk_key] = Chunk_NS::Chunk{column};
443  if (column->columnType.is_varlen_indeed()) {
444  CHECK(is_varlen_data_key(chunk_key));
445  size_t index_offset_size{0};
446  if (column->columnType.is_string()) {
447  index_offset_size = sizeof(StringOffsetT);
448  } else if (column->columnType.is_array()) {
449  index_offset_size = sizeof(ArrayOffsetT);
450  } else {
451  UNREACHABLE() << "Unexpected column type: " << column->columnType.to_string();
452  }
453  ChunkKey index_chunk_key = chunk_key;
454  index_chunk_key[CHUNK_KEY_VARLEN_IDX] = 2;
455  CHECK(buffers.find(index_chunk_key) != buffers.end());
456  AbstractBuffer* index_buffer = buffers.find(index_chunk_key)->second;
457  index_buffer->reserve(index_offset_size * row_count + 1);
458  chunks[chunk_key].setIndexBuffer(index_buffer);
459  }
460 
461  if (!column->columnType.is_varlen_indeed()) {
462  buffer->reserve(column->columnType.get_size() * row_count);
463  }
464  chunks[chunk_key].setBuffer(buffer);
465  chunks[chunk_key].initEncoder();
466  columns_to_parse.emplace(column);
467  }
468 }
469 
471  std::vector<std::unique_ptr<import_export::TypedImportBuffer>>& import_buffers,
472  std::map<std::string, import_export::TypedImportBuffer*>& import_buffers_map,
473  const std::set<const ColumnDescriptor*>& columns_to_parse,
474  const Catalog_Namespace::Catalog& catalog) {
475  for (const auto column : columns_to_parse) {
476  StringDictionary* string_dictionary = nullptr;
477  if (column->columnType.is_dict_encoded_string() ||
478  (column->columnType.is_array() && IS_STRING(column->columnType.get_subtype()) &&
479  column->columnType.get_compression() == kENCODING_DICT)) {
480  auto dict_descriptor =
481  catalog.getMetadataForDict(column->columnType.get_comp_param(), true);
482  string_dictionary = dict_descriptor->stringDict.get();
483  }
484  import_buffers.emplace_back(
485  std::make_unique<import_export::TypedImportBuffer>(column, string_dictionary));
486  import_buffers_map[column->columnName] = import_buffers.back().get();
487  }
488 }
489 } // namespace
490 
492  ChunkMetadataVector& chunk_metadata_vector) {
493  auto timer = DEBUG_TIMER(__func__);
494  auto& sys_catalog = Catalog_Namespace::SysCatalog::instance();
495  auto catalog = sys_catalog.getCatalog(db_id_);
496  CHECK(catalog);
497  CHECK_EQ(catalog->name(), INFORMATION_SCHEMA_DB);
498 
501 }
502 
504  const ChunkToBufferMap& required_buffers,
505  const ChunkToBufferMap& optional_buffers) {
506  auto timer = DEBUG_TIMER(__func__);
507  CHECK(optional_buffers.empty());
508 
509  auto& sys_catalog = Catalog_Namespace::SysCatalog::instance();
510  auto catalog = sys_catalog.getCatalog(db_id_);
511  CHECK(catalog);
512  CHECK_EQ(catalog->name(), INFORMATION_SCHEMA_DB);
513 
514  auto fragment_id = required_buffers.begin()->first[CHUNK_KEY_FRAGMENT_IDX];
515  CHECK_EQ(fragment_id, 0);
516 
517  std::map<ChunkKey, Chunk_NS::Chunk> chunks;
518  std::set<const ColumnDescriptor*> columns_to_parse;
520  chunks, required_buffers, row_count_, columns_to_parse, fragment_id, *catalog);
521 
522  // initialize import buffers from columns.
523  std::vector<std::unique_ptr<import_export::TypedImportBuffer>> import_buffers;
524  std::map<std::string, import_export::TypedImportBuffer*> import_buffers_map;
526  import_buffers, import_buffers_map, columns_to_parse, *catalog);
528 
529  auto column_id_to_data_blocks_map =
531  for (auto& [chunk_key, chunk] : chunks) {
532  auto data_block_entry =
533  column_id_to_data_blocks_map.find(chunk_key[CHUNK_KEY_COLUMN_IDX]);
534  CHECK(data_block_entry != column_id_to_data_blocks_map.end());
535  chunk.appendData(data_block_entry->second, row_count_, 0);
536  auto cd = chunk.getColumnDesc();
537  if (!cd->columnType.is_varlen_indeed()) {
539  auto metadata = chunk.getBuffer()->getEncoder()->getMetadata(cd->columnType);
540  foreign_table_->fragmenter->updateColumnChunkMetadata(cd, fragment_id, metadata);
541  }
542  chunk.setBuffer(nullptr);
543  chunk.setIndexBuffer(nullptr);
544  }
545 }
546 
548  const std::string& table_name) {
549  row_count_ = 0;
550  auto& sys_catalog = Catalog_Namespace::SysCatalog::instance();
552  users_.clear();
553  users_ = sys_catalog.getAllUserMetadata();
554  row_count_ = users_.size();
556  tables_by_database_.clear();
558  for (const auto& [db_id, tables] : tables_by_database_) {
559  row_count_ += tables.size();
560  }
562  dashboards_by_database_.clear();
564  for (const auto& [db_id, dashboards] : dashboards_by_database_) {
565  row_count_ += dashboards.size();
566  }
568  object_permissions_.clear();
569  object_permissions_ = sys_catalog.getMetadataForAllObjects();
572  databases_.clear();
573  databases_ = sys_catalog.getAllDBMetadata();
574  row_count_ = databases_.size();
576  roles_.clear();
577  roles_ = sys_catalog.getCreatedRoles();
578  row_count_ = roles_.size();
579  } else if (foreign_table_->tableName ==
581  user_names_by_role_.clear();
583  for (const auto& [role, user_names] : user_names_by_role_) {
584  row_count_ += user_names.size();
585  }
586  } else {
587  UNREACHABLE() << "Unexpected table name: " << foreign_table_->tableName;
588  }
589 }
590 
592  const std::string& table_name,
593  std::map<std::string, import_export::TypedImportBuffer*>& import_buffers) {
600  import_buffers);
607  } else if (foreign_table_->tableName ==
610  import_buffers);
611  } else {
612  UNREACHABLE() << "Unexpected table name: " << foreign_table_->tableName;
613  }
614 }
615 
617  return {};
618 }
619 
621  const std::string& file_path,
622  const ChunkMetadataVector& chunk_metadata) {}
623 
625  return false;
626 }
627 } // namespace foreign_storage
static const AccessPrivileges VIEW_SQL_EDITOR
Definition: DBObject.h:154
#define CHECK_EQ(x, y)
Definition: Logger.h:217
std::vector< int > ChunkKey
Definition: types.h:37
static const AccessPrivileges VIEW_DASHBOARD
Definition: DBObject.h:173
static const AccessPrivileges DROP_SERVER
Definition: DBObject.h:191
static std::map< int, DataBlockPtr > convertImportBuffersToDataBlocks(const std::vector< std::unique_ptr< import_export::TypedImportBuffer >> &import_buffers)
class for a per-database catalog. also includes metadata for the current database and the current use...
Definition: Catalog.h:111
std::string tableName
static const AccessPrivileges ALL_DATABASE
Definition: DBObject.h:153
static const AccessPrivileges ALTER_TABLE
Definition: DBObject.h:167
bool is_varlen_data_key(const ChunkKey &key)
Definition: types.h:71
DBObjectType
Definition: DBObject.h:42
void initialize_chunks(std::map< ChunkKey, Chunk_NS::Chunk > &chunks, const ChunkToBufferMap &buffers, size_t row_count, std::set< const ColumnDescriptor * > &columns_to_parse, int32_t fragment_id, const Catalog_Namespace::Catalog &catalog)
std::vector< std::string > get_permissions(const AccessPrivileges privileges, int32_t object_type, int32_t object_id)
static const AccessPrivileges TRUNCATE_TABLE
Definition: DBObject.h:166
static constexpr const char * DASHBOARDS_SYS_TABLE_NAME
Definition: Catalog.h:99
void validateUserMappingOptions(const UserMapping *user_mapping, const ForeignServer *foreign_server) const override
std::map< int32_t, std::vector< DashboardDescriptor > > get_all_dashboards()
#define CHUNK_KEY_FRAGMENT_IDX
Definition: types.h:42
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)
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
std::map< ChunkKey, AbstractBuffer * > ChunkToBufferMap
static const AccessPrivileges SELECT_FROM_TABLE
Definition: DBObject.h:162
void initEncoder(const SQLTypeInfo &tmp_sql_type)
std::string suffix(SQLTypes type)
Definition: Codegen.cpp:68
static const AccessPrivileges ALL_VIEW
Definition: DBObject.h:179
int32_t StringOffsetT
Definition: sqltypes.h:1075
std::vector< ObjectRoleDescriptor > object_permissions_
virtual void getMetadata(const std::shared_ptr< ChunkMetadata > &chunkMetadata)
Definition: Encoder.cpp:227
void populateChunkMetadata(ChunkMetadataVector &chunk_metadata_vector) override
static const AccessPrivileges ALTER_SERVER
Definition: DBObject.h:192
This file contains the class specification and related data structures for Catalog.
static constexpr const char * ROLES_SYS_TABLE_NAME
Definition: Catalog.h:102
static SysCatalog & instance()
Definition: SysCatalog.h:325
This file contains the class specification and related data structures for SysCatalog.
const std::set< std::string_view > & getSupportedTableOptions() const override
void validateTableOptions(const ForeignTable *foreign_table) const override
bool is_varlen_index_key(const ChunkKey &key)
Definition: types.h:75
static const AccessPrivileges DROP_TABLE
Definition: DBObject.h:161
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_tables(const std::map< int32_t, std::vector< TableDescriptor >> &tables_by_database, std::map< std::string, import_export::TypedImportBuffer * > &import_buffers)
const ColumnDescriptor * getMetadataForColumn(int tableId, const std::string &colName) const
#define CHUNK_KEY_TABLE_IDX
Definition: types.h:40
std::list< Catalog_Namespace::UserMetadata > users_
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)
void restoreDataWrapperInternals(const std::string &file_path, const ChunkMetadataVector &chunk_metadata) override
std::vector< std::pair< ChunkKey, std::shared_ptr< ChunkMetadata >>> ChunkMetadataVector
static const AccessPrivileges ALL_SERVER
Definition: DBObject.h:189
void populateChunkBuffersForTable(const std::string &table_name, std::map< std::string, import_export::TypedImportBuffer * > &import_buffers)
static const AccessPrivileges CREATE_SERVER
Definition: DBObject.h:190
std::map< int32_t, std::vector< TableDescriptor > > get_all_tables()
static const AccessPrivileges DELETE_FROM_TABLE
Definition: DBObject.h:165
An AbstractBuffer is a unit of data management for a data manager.
const DictDescriptor * getMetadataForDict(int dict_ref, bool loadDict=true) const
Definition: Catalog.cpp:1537
static constexpr const char * ROLE_ASSIGNMENTS_SYS_TABLE_NAME
Definition: Catalog.h:103
static const AccessPrivileges CREATE_TABLE
Definition: DBObject.h:160
static constexpr const char * USERS_SYS_TABLE_NAME
Definition: Catalog.h:97
std::shared_ptr< Fragmenter_Namespace::AbstractFragmenter > fragmenter
static constexpr const char * DATABASES_SYS_TABLE_NAME
Definition: Catalog.h:100
void validateServerOptions(const ForeignServer *foreign_server) const override
std::list< Catalog_Namespace::DBMetadata > databases_
static constexpr const char * TABLES_SYS_TABLE_NAME
Definition: Catalog.h:98
void populate_import_buffers_for_catalog_databases(const std::list< Catalog_Namespace::DBMetadata > &databases, std::map< std::string, import_export::TypedImportBuffer * > &import_buffers)
static const AccessPrivileges SELECT_FROM_VIEW
Definition: DBObject.h:182
int32_t ArrayOffsetT
Definition: sqltypes.h:1076
void set_default_chunk_metadata(int32_t db_id, const ForeignTable *foreign_table, size_t row_count, ChunkMetadataVector &chunk_metadata_vector)
static constexpr const char * PERMISSIONS_SYS_TABLE_NAME
Definition: Catalog.h:101
std::map< std::string, std::vector< std::string > > get_all_role_assignments()
static const AccessPrivileges ALL_DASHBOARD
Definition: DBObject.h:171
static const AccessPrivileges ACCESS
Definition: DBObject.h:155
#define CHUNK_KEY_VARLEN_IDX
Definition: types.h:43
static const AccessPrivileges ALL_TABLE
Definition: DBObject.h:159
void populate_import_buffers_for_catalog_users(const std::list< Catalog_Namespace::UserMetadata > &all_users, std::map< std::string, import_export::TypedImportBuffer * > &import_buffers)
#define IS_STRING(T)
Definition: sqltypes.h:250
const std::list< const ColumnDescriptor * > & getLogicalColumns() const
static const AccessPrivileges DROP_VIEW
Definition: DBObject.h:181
#define CHECK(condition)
Definition: Logger.h:209
static const AccessPrivileges CREATE_VIEW
Definition: DBObject.h:180
#define DEBUG_TIMER(name)
Definition: Logger.h:352
void initialize_import_buffers(std::vector< std::unique_ptr< import_export::TypedImportBuffer >> &import_buffers, std::map< std::string, import_export::TypedImportBuffer * > &import_buffers_map, const std::set< const ColumnDescriptor * > &columns_to_parse, const Catalog_Namespace::Catalog &catalog)
const std::set< std::string_view > & getSupportedUserMappingOptions() const override
std::map< std::string, std::vector< std::string > > user_names_by_role_
static const AccessPrivileges DELETE_DASHBOARD
Definition: DBObject.h:175
int64_t privileges
Definition: DBObject.h:135
#define CHUNK_KEY_COLUMN_IDX
Definition: types.h:41
void populateChunkBuffers(const ChunkToBufferMap &required_buffers, const ChunkToBufferMap &optional_buffers) override
std::map< int32_t, std::vector< TableDescriptor > > tables_by_database_
void initializeObjectsForTable(const std::string &table_name)
void populate_import_buffers_for_catalog_roles(const std::set< std::string > &roles, std::map< std::string, import_export::TypedImportBuffer * > &import_buffers)
static const AccessPrivileges EDIT_DASHBOARD
Definition: DBObject.h:174
static const AccessPrivileges UPDATE_IN_TABLE
Definition: DBObject.h:164
virtual void reserve(size_t num_bytes)=0
bool hasPermission(int permission) const
Definition: DBObject.h:143
const std::string INFORMATION_SCHEMA_DB
Definition: SysCatalog.h:65
std::map< int32_t, std::vector< DashboardDescriptor > > dashboards_by_database_