duckdb 0.7.2-dev2233.0 → 0.7.2-dev2320.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. package/binding.gyp +1 -0
  2. package/package.json +1 -1
  3. package/src/duckdb/src/catalog/catalog.cpp +18 -17
  4. package/src/duckdb/src/catalog/catalog_entry/duck_table_entry.cpp +0 -4
  5. package/src/duckdb/src/catalog/catalog_entry/table_catalog_entry.cpp +0 -4
  6. package/src/duckdb/src/catalog/catalog_set.cpp +3 -3
  7. package/src/duckdb/src/common/adbc/adbc.cpp +441 -0
  8. package/src/duckdb/src/common/adbc/driver_manager.cpp +749 -0
  9. package/src/duckdb/src/common/arrow/arrow_wrapper.cpp +1 -1
  10. package/src/duckdb/src/common/tree_renderer.cpp +3 -3
  11. package/src/duckdb/src/common/types/conflict_manager.cpp +2 -1
  12. package/src/duckdb/src/execution/column_binding_resolver.cpp +1 -1
  13. package/src/duckdb/src/execution/operator/aggregate/physical_ungrouped_aggregate.cpp +1 -1
  14. package/src/duckdb/src/execution/operator/filter/physical_filter.cpp +2 -2
  15. package/src/duckdb/src/execution/operator/helper/physical_execute.cpp +2 -2
  16. package/src/duckdb/src/execution/operator/helper/physical_result_collector.cpp +5 -5
  17. package/src/duckdb/src/execution/operator/join/physical_cross_product.cpp +1 -1
  18. package/src/duckdb/src/execution/operator/join/physical_delim_join.cpp +11 -10
  19. package/src/duckdb/src/execution/operator/join/physical_hash_join.cpp +3 -3
  20. package/src/duckdb/src/execution/operator/join/physical_iejoin.cpp +9 -9
  21. package/src/duckdb/src/execution/operator/join/physical_index_join.cpp +4 -4
  22. package/src/duckdb/src/execution/operator/join/physical_join.cpp +7 -7
  23. package/src/duckdb/src/execution/operator/join/physical_nested_loop_join.cpp +3 -3
  24. package/src/duckdb/src/execution/operator/join/physical_piecewise_merge_join.cpp +3 -3
  25. package/src/duckdb/src/execution/operator/join/physical_positional_join.cpp +2 -2
  26. package/src/duckdb/src/execution/operator/persistent/csv_reader_options.cpp +8 -9
  27. package/src/duckdb/src/execution/operator/persistent/physical_batch_insert.cpp +20 -19
  28. package/src/duckdb/src/execution/operator/persistent/physical_export.cpp +3 -3
  29. package/src/duckdb/src/execution/operator/persistent/physical_insert.cpp +25 -24
  30. package/src/duckdb/src/execution/operator/persistent/physical_update.cpp +1 -1
  31. package/src/duckdb/src/execution/operator/projection/physical_projection.cpp +2 -2
  32. package/src/duckdb/src/execution/operator/scan/physical_column_data_scan.cpp +12 -6
  33. package/src/duckdb/src/execution/operator/set/physical_recursive_cte.cpp +10 -11
  34. package/src/duckdb/src/execution/operator/set/physical_union.cpp +2 -2
  35. package/src/duckdb/src/execution/physical_operator.cpp +13 -13
  36. package/src/duckdb/src/execution/physical_plan/plan_column_data_get.cpp +2 -4
  37. package/src/duckdb/src/execution/physical_plan/plan_comparison_join.cpp +1 -1
  38. package/src/duckdb/src/execution/physical_plan/plan_create_table.cpp +5 -5
  39. package/src/duckdb/src/execution/physical_plan/plan_delete.cpp +3 -3
  40. package/src/duckdb/src/execution/physical_plan/plan_delim_join.cpp +6 -7
  41. package/src/duckdb/src/execution/physical_plan/plan_explain.cpp +2 -4
  42. package/src/duckdb/src/execution/physical_plan/plan_insert.cpp +2 -2
  43. package/src/duckdb/src/execution/physical_plan/plan_show_select.cpp +2 -4
  44. package/src/duckdb/src/execution/physical_plan/plan_update.cpp +3 -3
  45. package/src/duckdb/src/function/compression_config.cpp +9 -9
  46. package/src/duckdb/src/function/scalar/date/strftime.cpp +1 -1
  47. package/src/duckdb/src/function/table/copy_csv.cpp +5 -0
  48. package/src/duckdb/src/function/table/pragma_detailed_profiling_output.cpp +6 -5
  49. package/src/duckdb/src/function/table/pragma_last_profiling_output.cpp +7 -5
  50. package/src/duckdb/src/function/table/system/duckdb_databases.cpp +1 -1
  51. package/src/duckdb/src/function/table/system/duckdb_dependencies.cpp +1 -1
  52. package/src/duckdb/src/function/table/system/duckdb_extensions.cpp +1 -1
  53. package/src/duckdb/src/function/table/system/duckdb_indexes.cpp +1 -1
  54. package/src/duckdb/src/function/table/system/duckdb_keywords.cpp +1 -1
  55. package/src/duckdb/src/function/table/system/duckdb_schemas.cpp +1 -1
  56. package/src/duckdb/src/function/table/system/duckdb_sequences.cpp +1 -1
  57. package/src/duckdb/src/function/table/system/duckdb_settings.cpp +1 -1
  58. package/src/duckdb/src/function/table/system/duckdb_tables.cpp +1 -1
  59. package/src/duckdb/src/function/table/system/duckdb_temporary_files.cpp +1 -1
  60. package/src/duckdb/src/function/table/system/duckdb_types.cpp +1 -1
  61. package/src/duckdb/src/function/table/system/pragma_collations.cpp +1 -1
  62. package/src/duckdb/src/function/table/system/pragma_database_size.cpp +1 -1
  63. package/src/duckdb/src/function/table/system/pragma_storage_info.cpp +5 -5
  64. package/src/duckdb/src/function/table/system/pragma_table_info.cpp +1 -1
  65. package/src/duckdb/src/function/table/system/test_all_types.cpp +1 -1
  66. package/src/duckdb/src/function/table/table_scan.cpp +3 -4
  67. package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
  68. package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +3 -3
  69. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_table_entry.hpp +1 -2
  70. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_catalog_entry.hpp +1 -2
  71. package/src/duckdb/src/include/duckdb/common/adbc/adbc-init.hpp +37 -0
  72. package/src/duckdb/src/include/duckdb/common/adbc/adbc.h +1088 -0
  73. package/src/duckdb/src/include/duckdb/common/adbc/adbc.hpp +85 -0
  74. package/src/duckdb/src/include/duckdb/common/adbc/driver_manager.h +84 -0
  75. package/src/duckdb/src/include/duckdb/common/helper.hpp +3 -0
  76. package/src/duckdb/src/include/duckdb/common/types/conflict_manager.hpp +3 -2
  77. package/src/duckdb/src/include/duckdb/common/types.hpp +0 -1
  78. package/src/duckdb/src/include/duckdb/execution/executor.hpp +7 -7
  79. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_execute.hpp +1 -1
  80. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_result_collector.hpp +1 -1
  81. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_cross_product.hpp +1 -1
  82. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_delim_join.hpp +3 -3
  83. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_index_join.hpp +1 -1
  84. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_join.hpp +1 -1
  85. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_positional_join.hpp +1 -1
  86. package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_reader_options.hpp +2 -1
  87. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_batch_insert.hpp +2 -2
  88. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_export.hpp +1 -1
  89. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_insert.hpp +2 -2
  90. package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_column_data_scan.hpp +3 -4
  91. package/src/duckdb/src/include/duckdb/execution/operator/set/physical_recursive_cte.hpp +1 -1
  92. package/src/duckdb/src/include/duckdb/execution/operator/set/physical_union.hpp +1 -1
  93. package/src/duckdb/src/include/duckdb/execution/physical_operator.hpp +3 -3
  94. package/src/duckdb/src/include/duckdb/execution/physical_operator_states.hpp +1 -1
  95. package/src/duckdb/src/include/duckdb/function/cast/cast_function_set.hpp +1 -1
  96. package/src/duckdb/src/include/duckdb/main/config.hpp +2 -2
  97. package/src/duckdb/src/include/duckdb/main/query_profiler.hpp +10 -9
  98. package/src/duckdb/src/include/duckdb/parallel/meta_pipeline.hpp +4 -4
  99. package/src/duckdb/src/include/duckdb/parallel/pipeline.hpp +18 -17
  100. package/src/duckdb/src/include/duckdb/parallel/pipeline_executor.hpp +2 -2
  101. package/src/duckdb/src/include/duckdb/planner/bind_context.hpp +14 -17
  102. package/src/duckdb/src/include/duckdb/planner/binder.hpp +6 -6
  103. package/src/duckdb/src/include/duckdb/planner/expression_binder/index_binder.hpp +4 -4
  104. package/src/duckdb/src/include/duckdb/planner/expression_binder/where_binder.hpp +2 -2
  105. package/src/duckdb/src/include/duckdb/planner/operator/logical_create.hpp +3 -2
  106. package/src/duckdb/src/include/duckdb/planner/operator/logical_create_table.hpp +2 -2
  107. package/src/duckdb/src/include/duckdb/planner/operator/logical_delete.hpp +2 -2
  108. package/src/duckdb/src/include/duckdb/planner/operator/logical_insert.hpp +2 -2
  109. package/src/duckdb/src/include/duckdb/planner/operator/logical_update.hpp +2 -2
  110. package/src/duckdb/src/include/duckdb/planner/parsed_data/bound_create_function_info.hpp +3 -2
  111. package/src/duckdb/src/include/duckdb/planner/parsed_data/bound_create_table_info.hpp +3 -2
  112. package/src/duckdb/src/include/duckdb/planner/table_binding.hpp +6 -5
  113. package/src/duckdb/src/include/duckdb/planner/tableref/bound_basetableref.hpp +2 -2
  114. package/src/duckdb/src/include/duckdb/storage/compression/chimp/chimp_compress.hpp +3 -7
  115. package/src/duckdb/src/include/duckdb/storage/compression/patas/patas_compress.hpp +3 -7
  116. package/src/duckdb/src/include/duckdb/storage/data_table.hpp +1 -1
  117. package/src/duckdb/src/include/duckdb/storage/storage_manager.hpp +1 -1
  118. package/src/duckdb/src/include/duckdb/storage/table/column_data_checkpointer.hpp +2 -1
  119. package/src/duckdb/src/include/duckdb/storage/table/column_segment.hpp +2 -2
  120. package/src/duckdb/src/include/duckdb/storage/table/row_group.hpp +1 -1
  121. package/src/duckdb/src/include/duckdb/storage/table/row_group_collection.hpp +1 -1
  122. package/src/duckdb/src/include/duckdb/storage/table/update_segment.hpp +4 -4
  123. package/src/duckdb/src/include/duckdb/storage/write_ahead_log.hpp +3 -3
  124. package/src/duckdb/src/include/duckdb/transaction/cleanup_state.hpp +3 -3
  125. package/src/duckdb/src/include/duckdb/transaction/commit_state.hpp +5 -5
  126. package/src/duckdb/src/include/duckdb/transaction/duck_transaction.hpp +3 -3
  127. package/src/duckdb/src/include/duckdb/transaction/local_storage.hpp +31 -30
  128. package/src/duckdb/src/include/duckdb/transaction/transaction_data.hpp +2 -1
  129. package/src/duckdb/src/include/duckdb/transaction/undo_buffer.hpp +1 -1
  130. package/src/duckdb/src/main/client_context.cpp +1 -1
  131. package/src/duckdb/src/main/query_profiler.cpp +24 -22
  132. package/src/duckdb/src/parallel/executor.cpp +55 -49
  133. package/src/duckdb/src/parallel/meta_pipeline.cpp +5 -5
  134. package/src/duckdb/src/parallel/pipeline.cpp +43 -26
  135. package/src/duckdb/src/parallel/pipeline_executor.cpp +22 -22
  136. package/src/duckdb/src/planner/bind_context.cpp +67 -71
  137. package/src/duckdb/src/planner/binder/statement/bind_create.cpp +6 -7
  138. package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +6 -8
  139. package/src/duckdb/src/planner/binder/statement/bind_delete.cpp +3 -4
  140. package/src/duckdb/src/planner/binder/statement/bind_insert.cpp +17 -18
  141. package/src/duckdb/src/planner/binder/statement/bind_update.cpp +16 -17
  142. package/src/duckdb/src/planner/binder/statement/bind_vacuum.cpp +6 -5
  143. package/src/duckdb/src/planner/binder/tableref/bind_basetableref.cpp +9 -9
  144. package/src/duckdb/src/planner/binder/tableref/bind_joinref.cpp +20 -18
  145. package/src/duckdb/src/planner/binder/tableref/plan_joinref.cpp +1 -1
  146. package/src/duckdb/src/planner/binder.cpp +4 -4
  147. package/src/duckdb/src/planner/expression_binder/index_binder.cpp +2 -1
  148. package/src/duckdb/src/planner/expression_binder/where_binder.cpp +3 -2
  149. package/src/duckdb/src/planner/operator/logical_create_table.cpp +1 -1
  150. package/src/duckdb/src/planner/operator/logical_delete.cpp +5 -5
  151. package/src/duckdb/src/planner/operator/logical_insert.cpp +6 -7
  152. package/src/duckdb/src/planner/operator/logical_update.cpp +6 -7
  153. package/src/duckdb/src/planner/parsed_data/bound_create_table_info.cpp +4 -5
  154. package/src/duckdb/src/planner/table_binding.cpp +6 -5
  155. package/src/duckdb/src/storage/compression/bitpacking.cpp +5 -6
  156. package/src/duckdb/src/storage/compression/dictionary_compression.cpp +5 -6
  157. package/src/duckdb/src/storage/compression/fsst.cpp +3 -5
  158. package/src/duckdb/src/storage/compression/rle.cpp +4 -6
  159. package/src/duckdb/src/storage/data_table.cpp +27 -28
  160. package/src/duckdb/src/storage/local_storage.cpp +70 -68
  161. package/src/duckdb/src/storage/storage_manager.cpp +12 -13
  162. package/src/duckdb/src/storage/table/column_checkpoint_state.cpp +2 -2
  163. package/src/duckdb/src/storage/table/column_data.cpp +2 -2
  164. package/src/duckdb/src/storage/table/column_data_checkpointer.cpp +18 -6
  165. package/src/duckdb/src/storage/table/column_segment.cpp +23 -24
  166. package/src/duckdb/src/storage/table/row_group.cpp +3 -3
  167. package/src/duckdb/src/storage/table/row_group_collection.cpp +1 -1
  168. package/src/duckdb/src/storage/table/update_segment.cpp +15 -15
  169. package/src/duckdb/src/storage/wal_replay.cpp +1 -1
  170. package/src/duckdb/src/transaction/cleanup_state.cpp +10 -10
  171. package/src/duckdb/src/transaction/commit_state.cpp +19 -19
  172. package/src/duckdb/src/transaction/duck_transaction.cpp +7 -7
  173. package/src/duckdb/src/transaction/rollback_state.cpp +1 -1
  174. package/src/duckdb/src/transaction/undo_buffer.cpp +2 -1
  175. package/src/duckdb/ub_src_common_adbc.cpp +4 -0
  176. package/src/duckdb/src/include/duckdb/common/single_thread_ptr.hpp +0 -185
@@ -5,12 +5,12 @@
5
5
 
6
6
  namespace duckdb {
7
7
 
8
- LogicalUpdate::LogicalUpdate(TableCatalogEntry *table)
8
+ LogicalUpdate::LogicalUpdate(TableCatalogEntry &table)
9
9
  : LogicalOperator(LogicalOperatorType::LOGICAL_UPDATE), table(table), table_index(0), return_chunk(false) {
10
10
  }
11
11
 
12
12
  void LogicalUpdate::Serialize(FieldWriter &writer) const {
13
- table->Serialize(writer.GetSerializer());
13
+ table.Serialize(writer.GetSerializer());
14
14
  writer.WriteField(table_index);
15
15
  writer.WriteField(return_chunk);
16
16
  writer.WriteIndexList<PhysicalIndex>(columns);
@@ -23,13 +23,12 @@ unique_ptr<LogicalOperator> LogicalUpdate::Deserialize(LogicalDeserializationSta
23
23
  auto info = TableCatalogEntry::Deserialize(reader.GetSource(), context);
24
24
  auto &catalog = Catalog::GetCatalog(context, INVALID_CATALOG);
25
25
 
26
- TableCatalogEntry *table_catalog_entry = catalog.GetEntry<TableCatalogEntry>(context, info->schema, info->table);
27
-
26
+ auto table_catalog_entry = catalog.GetEntry<TableCatalogEntry>(context, info->schema, info->table);
28
27
  if (!table_catalog_entry) {
29
28
  throw InternalException("Cant find catalog entry for table %s", info->table);
30
29
  }
31
30
 
32
- auto result = make_uniq<LogicalUpdate>(table_catalog_entry);
31
+ auto result = make_uniq<LogicalUpdate>(*table_catalog_entry);
33
32
  result->table_index = reader.ReadRequired<idx_t>();
34
33
  result->return_chunk = reader.ReadRequired<bool>();
35
34
  result->columns = reader.ReadRequiredIndexList<PhysicalIndex>();
@@ -44,14 +43,14 @@ idx_t LogicalUpdate::EstimateCardinality(ClientContext &context) {
44
43
 
45
44
  vector<ColumnBinding> LogicalUpdate::GetColumnBindings() {
46
45
  if (return_chunk) {
47
- return GenerateColumnBindings(table_index, table->GetTypes().size());
46
+ return GenerateColumnBindings(table_index, table.GetTypes().size());
48
47
  }
49
48
  return {ColumnBinding(0, 0)};
50
49
  }
51
50
 
52
51
  void LogicalUpdate::ResolveTypes() {
53
52
  if (return_chunk) {
54
- types = table->GetTypes();
53
+ types = table.GetTypes();
55
54
  } else {
56
55
  types.emplace_back(LogicalType::BIGINT);
57
56
  }
@@ -5,8 +5,7 @@
5
5
 
6
6
  namespace duckdb {
7
7
  void BoundCreateTableInfo::Serialize(Serializer &serializer) const {
8
- D_ASSERT(schema);
9
- schema->Serialize(serializer);
8
+ schema.Serialize(serializer);
10
9
  serializer.WriteOptional(base);
11
10
 
12
11
  // TODO[YLM]: Review if we want/need to serialize more of the fields.
@@ -35,11 +34,11 @@ void BoundCreateTableInfo::Serialize(Serializer &serializer) const {
35
34
 
36
35
  unique_ptr<BoundCreateTableInfo> BoundCreateTableInfo::Deserialize(Deserializer &source,
37
36
  PlanDeserializationState &state) {
37
+ auto &context = state.context;
38
38
  auto create_info = SchemaCatalogEntry::Deserialize(source);
39
39
  auto schema_name = create_info->schema;
40
- auto result = make_uniq<BoundCreateTableInfo>(std::move(create_info));
41
- auto &context = state.context;
42
- result->schema = Catalog::GetSchema(context, INVALID_CATALOG, schema_name);
40
+ auto schema = Catalog::GetSchema(context, INVALID_CATALOG, schema_name);
41
+ auto result = make_uniq<BoundCreateTableInfo>(*schema, std::move(create_info));
43
42
  result->base = source.ReadOptional<CreateInfo>();
44
43
 
45
44
  source.ReadList<Constraint>(result->constraints);
@@ -73,7 +73,7 @@ BindResult Binding::Bind(ColumnRefExpression &colref, idx_t depth) {
73
73
  return BindResult(make_uniq<BoundColumnRefExpression>(colref.GetName(), sql_type, binding, depth));
74
74
  }
75
75
 
76
- StandardEntry *Binding::GetStandardEntry() {
76
+ optional_ptr<StandardEntry> Binding::GetStandardEntry() {
77
77
  return nullptr;
78
78
  }
79
79
 
@@ -82,12 +82,13 @@ EntryBinding::EntryBinding(const string &alias, vector<LogicalType> types_p, vec
82
82
  : Binding(BindingType::CATALOG_ENTRY, alias, std::move(types_p), std::move(names_p), index), entry(entry) {
83
83
  }
84
84
 
85
- StandardEntry *EntryBinding::GetStandardEntry() {
86
- return &this->entry;
85
+ optional_ptr<StandardEntry> EntryBinding::GetStandardEntry() {
86
+ return &entry;
87
87
  }
88
88
 
89
89
  TableBinding::TableBinding(const string &alias, vector<LogicalType> types_p, vector<string> names_p,
90
- vector<column_t> &bound_column_ids, StandardEntry *entry, idx_t index, bool add_row_id)
90
+ vector<column_t> &bound_column_ids, optional_ptr<StandardEntry> entry, idx_t index,
91
+ bool add_row_id)
91
92
  : Binding(BindingType::TABLE, alias, std::move(types_p), std::move(names_p), index),
92
93
  bound_column_ids(bound_column_ids), entry(entry) {
93
94
  if (add_row_id) {
@@ -213,7 +214,7 @@ BindResult TableBinding::Bind(ColumnRefExpression &colref, idx_t depth) {
213
214
  return BindResult(make_uniq<BoundColumnRefExpression>(colref.GetName(), col_type, binding, depth));
214
215
  }
215
216
 
216
- StandardEntry *TableBinding::GetStandardEntry() {
217
+ optional_ptr<StandardEntry> TableBinding::GetStandardEntry() {
217
218
  return entry;
218
219
  }
219
220
 
@@ -350,20 +350,19 @@ idx_t BitpackingFinalAnalyze(AnalyzeState &state) {
350
350
  template <class T, bool WRITE_STATISTICS, class T_S = typename std::make_signed<T>::type>
351
351
  struct BitpackingCompressState : public CompressionState {
352
352
  public:
353
- explicit BitpackingCompressState(ColumnDataCheckpointer &checkpointer) : checkpointer(checkpointer) {
354
- auto &db = checkpointer.GetDatabase();
355
- auto &type = checkpointer.GetType();
356
- auto &config = DBConfig::GetConfig(db);
357
- function = config.GetCompressionFunction(CompressionType::COMPRESSION_BITPACKING, type.InternalType());
353
+ explicit BitpackingCompressState(ColumnDataCheckpointer &checkpointer)
354
+ : checkpointer(checkpointer),
355
+ function(checkpointer.GetCompressionFunction(CompressionType::COMPRESSION_BITPACKING)) {
358
356
  CreateEmptySegment(checkpointer.GetRowGroup().start);
359
357
 
360
358
  state.data_ptr = (void *)this;
361
359
 
360
+ auto &config = DBConfig::GetConfig(checkpointer.GetDatabase());
362
361
  state.mode = config.options.force_bitpacking_mode;
363
362
  }
364
363
 
365
364
  ColumnDataCheckpointer &checkpointer;
366
- CompressionFunction *function;
365
+ CompressionFunction &function;
367
366
  unique_ptr<ColumnSegment> current_segment;
368
367
  BufferHandle handle;
369
368
 
@@ -130,16 +130,15 @@ struct DictionaryCompressionStorage {
130
130
  // scanning the whole dictionary at once and then scanning the selection buffer for each emitted vector. Secondly, it
131
131
  // allows for efficient bitpacking compression as the selection values should remain relatively small.
132
132
  struct DictionaryCompressionCompressState : public DictionaryCompressionState {
133
- explicit DictionaryCompressionCompressState(ColumnDataCheckpointer &checkpointer)
134
- : checkpointer(checkpointer), heap(BufferAllocator::Get(checkpointer.GetDatabase())) {
135
- auto &db = checkpointer.GetDatabase();
136
- auto &config = DBConfig::GetConfig(db);
137
- function = config.GetCompressionFunction(CompressionType::COMPRESSION_DICTIONARY, PhysicalType::VARCHAR);
133
+ explicit DictionaryCompressionCompressState(ColumnDataCheckpointer &checkpointer_p)
134
+ : checkpointer(checkpointer_p),
135
+ function(checkpointer.GetCompressionFunction(CompressionType::COMPRESSION_DICTIONARY)),
136
+ heap(BufferAllocator::Get(checkpointer.GetDatabase())) {
138
137
  CreateEmptySegment(checkpointer.GetRowGroup().start);
139
138
  }
140
139
 
141
140
  ColumnDataCheckpointer &checkpointer;
142
- CompressionFunction *function;
141
+ CompressionFunction &function;
143
142
 
144
143
  // State regarding current segment
145
144
  unique_ptr<ColumnSegment> current_segment;
@@ -199,10 +199,8 @@ idx_t FSSTStorage::StringFinalAnalyze(AnalyzeState &state_p) {
199
199
 
200
200
  class FSSTCompressionState : public CompressionState {
201
201
  public:
202
- explicit FSSTCompressionState(ColumnDataCheckpointer &checkpointer) : checkpointer(checkpointer) {
203
- auto &db = checkpointer.GetDatabase();
204
- auto &config = DBConfig::GetConfig(db);
205
- function = config.GetCompressionFunction(CompressionType::COMPRESSION_FSST, PhysicalType::VARCHAR);
202
+ explicit FSSTCompressionState(ColumnDataCheckpointer &checkpointer)
203
+ : checkpointer(checkpointer), function(checkpointer.GetCompressionFunction(CompressionType::COMPRESSION_FSST)) {
206
204
  CreateEmptySegment(checkpointer.GetRowGroup().start);
207
205
  }
208
206
 
@@ -372,7 +370,7 @@ public:
372
370
  }
373
371
 
374
372
  ColumnDataCheckpointer &checkpointer;
375
- CompressionFunction *function;
373
+ CompressionFunction &function;
376
374
 
377
375
  // State regarding current segment
378
376
  unique_ptr<ColumnSegment> current_segment;
@@ -136,11 +136,9 @@ struct RLECompressState : public CompressionState {
136
136
  return max_vector_count * STANDARD_VECTOR_SIZE;
137
137
  }
138
138
 
139
- explicit RLECompressState(ColumnDataCheckpointer &checkpointer_p) : checkpointer(checkpointer_p) {
140
- auto &db = checkpointer.GetDatabase();
141
- auto &type = checkpointer.GetType();
142
- auto &config = DBConfig::GetConfig(db);
143
- function = config.GetCompressionFunction(CompressionType::COMPRESSION_RLE, type.InternalType());
139
+ explicit RLECompressState(ColumnDataCheckpointer &checkpointer_p)
140
+ : checkpointer(checkpointer_p),
141
+ function(checkpointer.GetCompressionFunction(CompressionType::COMPRESSION_RLE)) {
144
142
  CreateEmptySegment(checkpointer.GetRowGroup().start);
145
143
 
146
144
  state.dataptr = (void *)this;
@@ -214,7 +212,7 @@ struct RLECompressState : public CompressionState {
214
212
  }
215
213
 
216
214
  ColumnDataCheckpointer &checkpointer;
217
- CompressionFunction *function;
215
+ CompressionFunction &function;
218
216
  unique_ptr<ColumnSegment> current_segment;
219
217
  BufferHandle handle;
220
218
 
@@ -69,7 +69,7 @@ DataTable::DataTable(ClientContext &context, DataTable &parent, ColumnDefinition
69
69
 
70
70
  // also add this column to client local storage
71
71
  auto &local_storage = LocalStorage::Get(context, db);
72
- local_storage.AddColumn(&parent, this, new_column, default_value);
72
+ local_storage.AddColumn(parent, *this, new_column, default_value);
73
73
 
74
74
  // this table replaces the previous table, hence the parent is no longer the root DataTable
75
75
  parent.is_root = false;
@@ -114,7 +114,7 @@ DataTable::DataTable(ClientContext &context, DataTable &parent, idx_t removed_co
114
114
 
115
115
  // scan the original table, and fill the new column with the transformed value
116
116
  auto &local_storage = LocalStorage::Get(context, db);
117
- local_storage.DropColumn(&parent, this, removed_column);
117
+ local_storage.DropColumn(parent, *this, removed_column);
118
118
 
119
119
  // this table replaces the previous table, hence the parent is no longer the root DataTable
120
120
  parent.is_root = false;
@@ -134,7 +134,7 @@ DataTable::DataTable(ClientContext &context, DataTable &parent, unique_ptr<Bound
134
134
 
135
135
  // Get the local data ownership from old dt
136
136
  auto &local_storage = LocalStorage::Get(context, db);
137
- local_storage.MoveStorage(&parent, this);
137
+ local_storage.MoveStorage(parent, *this);
138
138
  // this table replaces the previous table, hence the parent is no longer the root DataTable
139
139
  parent.is_root = false;
140
140
  }
@@ -166,7 +166,7 @@ DataTable::DataTable(ClientContext &context, DataTable &parent, idx_t changed_id
166
166
 
167
167
  // scan the original table, and fill the new column with the transformed value
168
168
  auto &local_storage = LocalStorage::Get(context, db);
169
- local_storage.ChangeType(&parent, this, changed_idx, target_type, bound_columns, cast_expr);
169
+ local_storage.ChangeType(parent, *this, changed_idx, target_type, bound_columns, cast_expr);
170
170
 
171
171
  // this table replaces the previous table, hence the parent is no longer the root DataTable
172
172
  parent.is_root = false;
@@ -197,7 +197,7 @@ void DataTable::InitializeScan(DuckTransaction &transaction, TableScanState &sta
197
197
  TableFilterSet *table_filters) {
198
198
  InitializeScan(state, column_ids, table_filters);
199
199
  auto &local_storage = LocalStorage::Get(transaction);
200
- local_storage.InitializeScan(this, state.local_state, table_filters);
200
+ local_storage.InitializeScan(*this, state.local_state, table_filters);
201
201
  }
202
202
 
203
203
  void DataTable::InitializeScanWithOffset(TableScanState &state, const vector<column_t> &column_ids, idx_t start_row,
@@ -219,7 +219,7 @@ void DataTable::InitializeParallelScan(ClientContext &context, ParallelTableScan
219
219
  row_groups->InitializeParallelScan(state.scan_state);
220
220
 
221
221
  auto &local_storage = LocalStorage::Get(context, db);
222
- local_storage.InitializeParallelScan(this, state.local_state);
222
+ local_storage.InitializeParallelScan(*this, state.local_state);
223
223
  }
224
224
 
225
225
  bool DataTable::NextParallelScan(ClientContext &context, ParallelTableScanState &state, TableScanState &scan_state) {
@@ -228,7 +228,7 @@ bool DataTable::NextParallelScan(ClientContext &context, ParallelTableScanState
228
228
  }
229
229
  scan_state.table_state.batch_index = state.scan_state.batch_index;
230
230
  auto &local_storage = LocalStorage::Get(context, db);
231
- if (local_storage.NextParallelScan(context, this, state.local_state, scan_state.local_state)) {
231
+ if (local_storage.NextParallelScan(context, *this, state.local_state, scan_state.local_state)) {
232
232
  return true;
233
233
  } else {
234
234
  // finished all scans: no more scans remaining
@@ -360,14 +360,13 @@ idx_t LocateErrorIndex(bool is_append, const ManagedSelection &matches) {
360
360
  return failed_index;
361
361
  }
362
362
 
363
- [[noreturn]] static void ThrowForeignKeyConstraintError(idx_t failed_index, bool is_append, Index *index,
363
+ [[noreturn]] static void ThrowForeignKeyConstraintError(idx_t failed_index, bool is_append, Index &index,
364
364
  DataChunk &input) {
365
365
  auto verify_type = is_append ? VerifyExistenceType::APPEND_FK : VerifyExistenceType::DELETE_FK;
366
366
 
367
367
  D_ASSERT(failed_index != DConstants::INVALID_INDEX);
368
- D_ASSERT(index->type == IndexType::ART);
369
- auto &art_index = index->Cast<ART>();
370
- ;
368
+ D_ASSERT(index.type == IndexType::ART);
369
+ auto &art_index = index.Cast<ART>();
371
370
  auto key_name = art_index.GenerateErrorKeyName(input, failed_index);
372
371
  auto exception_msg = art_index.GenerateConstraintErrorMessage(verify_type, key_name);
373
372
  throw ConstraintException(exception_msg);
@@ -414,7 +413,7 @@ void DataTable::VerifyForeignKeyConstraint(const BoundForeignKeyConstraint &bfk,
414
413
  dst_chunk.data[(*dst_keys_ptr)[i].index].Reference(chunk.data[(*src_keys_ptr)[i].index]);
415
414
  }
416
415
  dst_chunk.SetCardinality(chunk.size());
417
- auto data_table = table_entry_ptr->GetStoragePtr();
416
+ auto &data_table = table_entry_ptr->GetStorage();
418
417
 
419
418
  idx_t count = dst_chunk.size();
420
419
  if (count <= 0) {
@@ -429,7 +428,7 @@ void DataTable::VerifyForeignKeyConstraint(const BoundForeignKeyConstraint &bfk,
429
428
  regular_conflicts.SetMode(ConflictManagerMode::SCAN);
430
429
  transaction_conflicts.SetMode(ConflictManagerMode::SCAN);
431
430
 
432
- data_table->info->indexes.VerifyForeignKey(*dst_keys_ptr, dst_chunk, regular_conflicts);
431
+ data_table.info->indexes.VerifyForeignKey(*dst_keys_ptr, dst_chunk, regular_conflicts);
433
432
  regular_conflicts.Finalize();
434
433
  auto &regular_matches = regular_conflicts.Conflicts();
435
434
  // check whether or not the chunk can be inserted or deleted into the referenced table' transaction local storage
@@ -453,12 +452,12 @@ void DataTable::VerifyForeignKeyConstraint(const BoundForeignKeyConstraint &bfk,
453
452
  }
454
453
 
455
454
  // Some error occurred, and we likely want to throw
456
- Index *index;
457
- Index *transaction_index;
455
+ optional_ptr<Index> index;
456
+ optional_ptr<Index> transaction_index;
458
457
 
459
458
  auto fk_type = is_append ? ForeignKeyType::FK_TYPE_PRIMARY_KEY_TABLE : ForeignKeyType::FK_TYPE_FOREIGN_KEY_TABLE;
460
459
  // check whether or not the chunk can be inserted or deleted into the referenced table' storage
461
- index = data_table->info->indexes.FindForeignKeyIndex(*dst_keys_ptr, fk_type);
460
+ index = data_table.info->indexes.FindForeignKeyIndex(*dst_keys_ptr, fk_type);
462
461
  if (transaction_check) {
463
462
  auto &transact_index = local_storage.GetIndexes(data_table);
464
463
  // check whether or not the chunk can be inserted or deleted into the referenced table' storage
@@ -470,7 +469,7 @@ void DataTable::VerifyForeignKeyConstraint(const BoundForeignKeyConstraint &bfk,
470
469
  D_ASSERT(error);
471
470
  auto failed_index = LocateErrorIndex(is_append, regular_matches);
472
471
  D_ASSERT(failed_index != DConstants::INVALID_INDEX);
473
- ThrowForeignKeyConstraintError(failed_index, is_append, index, dst_chunk);
472
+ ThrowForeignKeyConstraintError(failed_index, is_append, *index, dst_chunk);
474
473
  }
475
474
  if (transaction_error && error && is_append) {
476
475
  // When we want to do an append, we only throw if the foreign key does not exist in both transaction and local
@@ -496,20 +495,20 @@ void DataTable::VerifyForeignKeyConstraint(const BoundForeignKeyConstraint &bfk,
496
495
  // We don't throw, every value was present in either regular or transaction storage
497
496
  return;
498
497
  }
499
- ThrowForeignKeyConstraintError(failed_index, true, index, dst_chunk);
498
+ ThrowForeignKeyConstraintError(failed_index, true, *index, dst_chunk);
500
499
  }
501
500
  if (!is_append && transaction_check) {
502
501
  auto &transaction_matches = transaction_conflicts.Conflicts();
503
502
  if (error) {
504
503
  auto failed_index = LocateErrorIndex(false, regular_matches);
505
504
  D_ASSERT(failed_index != DConstants::INVALID_INDEX);
506
- ThrowForeignKeyConstraintError(failed_index, false, index, dst_chunk);
505
+ ThrowForeignKeyConstraintError(failed_index, false, *index, dst_chunk);
507
506
  } else {
508
507
  D_ASSERT(transaction_error);
509
508
  D_ASSERT(transaction_matches.Count() != DConstants::INVALID_INDEX);
510
509
  auto failed_index = LocateErrorIndex(false, transaction_matches);
511
510
  D_ASSERT(failed_index != DConstants::INVALID_INDEX);
512
- ThrowForeignKeyConstraintError(failed_index, false, transaction_index, dst_chunk);
511
+ ThrowForeignKeyConstraintError(failed_index, false, *transaction_index, dst_chunk);
513
512
  }
514
513
  }
515
514
  }
@@ -636,7 +635,7 @@ void DataTable::InitializeLocalAppend(LocalAppendState &state, ClientContext &co
636
635
  throw TransactionException("Transaction conflict: adding entries to a table that has been altered!");
637
636
  }
638
637
  auto &local_storage = LocalStorage::Get(context, db);
639
- local_storage.InitializeAppend(state, this);
638
+ local_storage.InitializeAppend(state, *this);
640
639
  }
641
640
 
642
641
  void DataTable::LocalAppend(LocalAppendState &state, TableCatalogEntry &table, ClientContext &context, DataChunk &chunk,
@@ -664,14 +663,14 @@ void DataTable::FinalizeLocalAppend(LocalAppendState &state) {
664
663
  LocalStorage::FinalizeAppend(state);
665
664
  }
666
665
 
667
- OptimisticDataWriter *DataTable::CreateOptimisticWriter(ClientContext &context) {
666
+ OptimisticDataWriter &DataTable::CreateOptimisticWriter(ClientContext &context) {
668
667
  auto &local_storage = LocalStorage::Get(context, db);
669
- return local_storage.CreateOptimisticWriter(this);
668
+ return local_storage.CreateOptimisticWriter(*this);
670
669
  }
671
670
 
672
671
  void DataTable::LocalMerge(ClientContext &context, RowGroupCollection &collection) {
673
672
  auto &local_storage = LocalStorage::Get(context, db);
674
- local_storage.LocalMerge(this, collection);
673
+ local_storage.LocalMerge(*this, collection);
675
674
  }
676
675
 
677
676
  void DataTable::LocalAppend(TableCatalogEntry &table, ClientContext &context, DataChunk &chunk) {
@@ -982,10 +981,10 @@ idx_t DataTable::Delete(TableCatalogEntry &table, ClientContext &context, Vector
982
981
  // transaction-local delete
983
982
  if (has_delete_constraints) {
984
983
  // perform the constraint verification
985
- local_storage.FetchChunk(this, offset_ids, current_count, col_ids, verify_chunk, fetch_state);
984
+ local_storage.FetchChunk(*this, offset_ids, current_count, col_ids, verify_chunk, fetch_state);
986
985
  VerifyDeleteConstraints(table, context, verify_chunk);
987
986
  }
988
- delete_count += local_storage.Delete(this, offset_ids, current_count);
987
+ delete_count += local_storage.Delete(*this, offset_ids, current_count);
989
988
  } else {
990
989
  // regular table delete
991
990
  if (has_delete_constraints) {
@@ -993,7 +992,7 @@ idx_t DataTable::Delete(TableCatalogEntry &table, ClientContext &context, Vector
993
992
  Fetch(transaction, verify_chunk, col_ids, offset_ids, current_count, fetch_state);
994
993
  VerifyDeleteConstraints(table, context, verify_chunk);
995
994
  }
996
- delete_count += row_groups->Delete(transaction, this, ids + current_offset, current_count);
995
+ delete_count += row_groups->Delete(transaction, *this, ids + current_offset, current_count);
997
996
  }
998
997
  }
999
998
  return delete_count;
@@ -1114,7 +1113,7 @@ void DataTable::Update(TableCatalogEntry &table, ClientContext &context, Vector
1114
1113
  if (first_id >= MAX_ROW_ID) {
1115
1114
  // update is in transaction-local storage: push update into local storage
1116
1115
  auto &local_storage = LocalStorage::Get(context, db);
1117
- local_storage.Update(this, row_ids, column_ids, updates);
1116
+ local_storage.Update(*this, row_ids, column_ids, updates);
1118
1117
  return;
1119
1118
  }
1120
1119