duckdb 0.7.2-dev3441.0 → 0.7.2-dev3546.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 (160) hide show
  1. package/configure.py +2 -0
  2. package/package.json +2 -2
  3. package/src/duckdb/extension/json/json_functions/json_create.cpp +1 -1
  4. package/src/duckdb/extension/json/json_functions/read_json.cpp +1 -0
  5. package/src/duckdb/src/catalog/catalog_entry/macro_catalog_entry.cpp +42 -0
  6. package/src/duckdb/src/catalog/catalog_search_path.cpp +5 -0
  7. package/src/duckdb/src/catalog/catalog_set.cpp +1 -1
  8. package/src/duckdb/src/catalog/default/default_functions.cpp +1 -0
  9. package/src/duckdb/src/common/arrow/arrow_converter.cpp +4 -4
  10. package/src/duckdb/src/common/compressed_file_system.cpp +2 -2
  11. package/src/duckdb/src/common/constants.cpp +1 -0
  12. package/src/duckdb/src/common/file_system.cpp +2 -2
  13. package/src/duckdb/src/common/row_operations/row_gather.cpp +2 -2
  14. package/src/duckdb/src/common/serializer/binary_deserializer.cpp +1 -1
  15. package/src/duckdb/src/common/serializer/buffered_file_reader.cpp +1 -1
  16. package/src/duckdb/src/common/serializer/buffered_file_writer.cpp +1 -1
  17. package/src/duckdb/src/common/serializer/buffered_serializer.cpp +4 -3
  18. package/src/duckdb/src/common/serializer.cpp +1 -1
  19. package/src/duckdb/src/common/sort/radix_sort.cpp +5 -5
  20. package/src/duckdb/src/common/string_util.cpp +2 -2
  21. package/src/duckdb/src/common/types/bit.cpp +2 -2
  22. package/src/duckdb/src/common/types/blob.cpp +2 -2
  23. package/src/duckdb/src/common/types/data_chunk.cpp +2 -2
  24. package/src/duckdb/src/common/types/date.cpp +1 -1
  25. package/src/duckdb/src/common/types/decimal.cpp +2 -2
  26. package/src/duckdb/src/common/types/row/tuple_data_scatter_gather.cpp +14 -2
  27. package/src/duckdb/src/common/types/selection_vector.cpp +1 -1
  28. package/src/duckdb/src/common/types/time.cpp +1 -1
  29. package/src/duckdb/src/common/types/vector.cpp +10 -10
  30. package/src/duckdb/src/common/types/vector_buffer.cpp +11 -3
  31. package/src/duckdb/src/common/types/vector_cache.cpp +5 -5
  32. package/src/duckdb/src/common/virtual_file_system.cpp +4 -0
  33. package/src/duckdb/src/common/windows_util.cpp +2 -2
  34. package/src/duckdb/src/core_functions/aggregate/distributive/string_agg.cpp +6 -3
  35. package/src/duckdb/src/core_functions/scalar/list/list_aggregates.cpp +2 -5
  36. package/src/duckdb/src/core_functions/scalar/string/printf.cpp +1 -1
  37. package/src/duckdb/src/execution/aggregate_hashtable.cpp +1 -1
  38. package/src/duckdb/src/execution/join_hashtable.cpp +3 -3
  39. package/src/duckdb/src/execution/operator/aggregate/physical_ungrouped_aggregate.cpp +2 -2
  40. package/src/duckdb/src/execution/operator/join/outer_join_marker.cpp +1 -1
  41. package/src/duckdb/src/execution/operator/join/perfect_hash_join_executor.cpp +1 -1
  42. package/src/duckdb/src/execution/operator/join/physical_range_join.cpp +1 -1
  43. package/src/duckdb/src/execution/operator/persistent/base_csv_reader.cpp +2 -7
  44. package/src/duckdb/src/execution/operator/persistent/buffered_csv_reader.cpp +4 -41
  45. package/src/duckdb/src/execution/operator/persistent/csv_file_handle.cpp +158 -0
  46. package/src/duckdb/src/execution/operator/projection/physical_pivot.cpp +1 -1
  47. package/src/duckdb/src/execution/operator/schema/physical_create_type.cpp +2 -2
  48. package/src/duckdb/src/execution/perfect_aggregate_hashtable.cpp +2 -2
  49. package/src/duckdb/src/execution/radix_partitioned_hashtable.cpp +3 -4
  50. package/src/duckdb/src/execution/window_segment_tree.cpp +1 -1
  51. package/src/duckdb/src/function/macro_function.cpp +43 -0
  52. package/src/duckdb/src/function/pragma/pragma_queries.cpp +1 -1
  53. package/src/duckdb/src/function/scalar/strftime_format.cpp +2 -1
  54. package/src/duckdb/src/function/scalar/string/concat.cpp +1 -1
  55. package/src/duckdb/src/function/scalar/string/like.cpp +2 -2
  56. package/src/duckdb/src/function/scalar/system/aggregate_export.cpp +5 -5
  57. package/src/duckdb/src/function/scalar_macro_function.cpp +10 -0
  58. package/src/duckdb/src/function/table/copy_csv.cpp +3 -7
  59. package/src/duckdb/src/function/table/read_csv.cpp +60 -35
  60. package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
  61. package/src/duckdb/src/function/table_macro_function.cpp +10 -0
  62. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/macro_catalog_entry.hpp +3 -1
  63. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/scalar_macro_catalog_entry.hpp +0 -6
  64. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_macro_catalog_entry.hpp +0 -6
  65. package/src/duckdb/src/include/duckdb/common/allocator.hpp +3 -0
  66. package/src/duckdb/src/include/duckdb/common/compressed_file_system.hpp +3 -3
  67. package/src/duckdb/src/include/duckdb/common/constants.hpp +2 -5
  68. package/src/duckdb/src/include/duckdb/common/field_writer.hpp +3 -3
  69. package/src/duckdb/src/include/duckdb/common/helper.hpp +22 -9
  70. package/src/duckdb/src/include/duckdb/common/memory_safety.hpp +15 -0
  71. package/src/duckdb/src/include/duckdb/common/optional_ptr.hpp +1 -0
  72. package/src/duckdb/src/include/duckdb/common/serializer/buffered_file_reader.hpp +1 -1
  73. package/src/duckdb/src/include/duckdb/common/serializer/buffered_file_writer.hpp +1 -1
  74. package/src/duckdb/src/include/duckdb/common/serializer/buffered_serializer.hpp +3 -2
  75. package/src/duckdb/src/include/duckdb/common/serializer/serialization_traits.hpp +2 -3
  76. package/src/duckdb/src/include/duckdb/common/sort/duckdb_pdqsort.hpp +11 -6
  77. package/src/duckdb/src/include/duckdb/common/types/data_chunk.hpp +2 -1
  78. package/src/duckdb/src/include/duckdb/common/types/selection_vector.hpp +1 -1
  79. package/src/duckdb/src/include/duckdb/common/types/validity_mask.hpp +3 -3
  80. package/src/duckdb/src/include/duckdb/common/types/vector_buffer.hpp +16 -6
  81. package/src/duckdb/src/include/duckdb/common/unique_ptr.hpp +53 -22
  82. package/src/duckdb/src/include/duckdb/common/vector.hpp +5 -2
  83. package/src/duckdb/src/include/duckdb/execution/aggregate_hashtable.hpp +1 -1
  84. package/src/duckdb/src/include/duckdb/execution/join_hashtable.hpp +4 -4
  85. package/src/duckdb/src/include/duckdb/execution/operator/join/outer_join_marker.hpp +1 -1
  86. package/src/duckdb/src/include/duckdb/execution/operator/join/perfect_hash_join_executor.hpp +1 -1
  87. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_range_join.hpp +1 -1
  88. package/src/duckdb/src/include/duckdb/execution/operator/persistent/base_csv_reader.hpp +0 -2
  89. package/src/duckdb/src/include/duckdb/execution/operator/persistent/buffered_csv_reader.hpp +2 -2
  90. package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_file_handle.hpp +27 -127
  91. package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_reader_options.hpp +1 -2
  92. package/src/duckdb/src/include/duckdb/execution/operator/persistent/parallel_csv_reader.hpp +2 -2
  93. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_type.hpp +1 -1
  94. package/src/duckdb/src/include/duckdb/execution/perfect_aggregate_hashtable.hpp +2 -2
  95. package/src/duckdb/src/include/duckdb/execution/window_segment_tree.hpp +1 -1
  96. package/src/duckdb/src/include/duckdb/function/macro_function.hpp +7 -1
  97. package/src/duckdb/src/include/duckdb/function/scalar/strftime_format.hpp +3 -4
  98. package/src/duckdb/src/include/duckdb/function/scalar_macro_function.hpp +7 -2
  99. package/src/duckdb/src/include/duckdb/function/table/read_csv.hpp +2 -4
  100. package/src/duckdb/src/include/duckdb/function/table_macro_function.hpp +5 -0
  101. package/src/duckdb/src/include/duckdb/optimizer/join_order/join_relation.hpp +3 -3
  102. package/src/duckdb/src/include/duckdb/parser/parsed_data/attach_info.hpp +4 -7
  103. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_macro_info.hpp +8 -12
  104. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_sequence_info.hpp +6 -20
  105. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_type_info.hpp +6 -18
  106. package/src/duckdb/src/include/duckdb/parser/parsed_data/detach_info.hpp +4 -8
  107. package/src/duckdb/src/include/duckdb/parser/parsed_data/drop_info.hpp +4 -38
  108. package/src/duckdb/src/include/duckdb/parser/parsed_data/transaction_info.hpp +5 -2
  109. package/src/duckdb/src/include/duckdb/parser/parsed_data/vacuum_info.hpp +10 -10
  110. package/src/duckdb/src/include/duckdb/parser/statement/insert_statement.hpp +5 -0
  111. package/src/duckdb/src/include/duckdb/storage/arena_allocator.hpp +2 -2
  112. package/src/duckdb/src/include/duckdb/storage/buffer/buffer_handle.hpp +9 -2
  113. package/src/duckdb/src/include/duckdb/storage/statistics/base_statistics.hpp +1 -1
  114. package/src/duckdb/src/include/duckdb/storage/table/append_state.hpp +1 -1
  115. package/src/duckdb/src/include/duckdb/storage/table/scan_state.hpp +1 -1
  116. package/src/duckdb/src/include/duckdb/storage/table/update_segment.hpp +2 -2
  117. package/src/duckdb/src/optimizer/join_order/join_relation_set.cpp +5 -5
  118. package/src/duckdb/src/optimizer/unnest_rewriter.cpp +14 -6
  119. package/src/duckdb/src/parser/parsed_data/attach_info.cpp +42 -0
  120. package/src/duckdb/src/parser/parsed_data/create_index_info.cpp +0 -7
  121. package/src/duckdb/src/parser/parsed_data/create_info.cpp +19 -8
  122. package/src/duckdb/src/parser/parsed_data/create_macro_info.cpp +46 -0
  123. package/src/duckdb/src/parser/parsed_data/create_sequence_info.cpp +56 -0
  124. package/src/duckdb/src/parser/parsed_data/create_type_info.cpp +47 -0
  125. package/src/duckdb/src/parser/parsed_data/detach_info.cpp +34 -0
  126. package/src/duckdb/src/parser/parsed_data/drop_info.cpp +46 -0
  127. package/src/duckdb/src/parser/parsed_data/transaction_info.cpp +24 -0
  128. package/src/duckdb/src/parser/parsed_data/vacuum_info.cpp +37 -0
  129. package/src/duckdb/src/parser/statement/insert_statement.cpp +4 -1
  130. package/src/duckdb/src/parser/transform/statement/transform_insert.cpp +10 -0
  131. package/src/duckdb/src/planner/binder/expression/bind_star_expression.cpp +27 -9
  132. package/src/duckdb/src/planner/binder/statement/bind_create.cpp +2 -1
  133. package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +1 -0
  134. package/src/duckdb/src/planner/binder/statement/bind_insert.cpp +32 -7
  135. package/src/duckdb/src/planner/logical_operator.cpp +1 -2
  136. package/src/duckdb/src/planner/operator/logical_create_index.cpp +16 -25
  137. package/src/duckdb/src/planner/operator/logical_insert.cpp +30 -0
  138. package/src/duckdb/src/planner/operator/logical_simple.cpp +33 -5
  139. package/src/duckdb/src/planner/parsed_data/bound_create_table_info.cpp +6 -16
  140. package/src/duckdb/src/planner/planner.cpp +4 -13
  141. package/src/duckdb/src/storage/arena_allocator.cpp +1 -1
  142. package/src/duckdb/src/storage/buffer/buffer_handle.cpp +2 -11
  143. package/src/duckdb/src/storage/checkpoint/write_overflow_strings_to_disk.cpp +1 -1
  144. package/src/duckdb/src/storage/checkpoint_manager.cpp +12 -6
  145. package/src/duckdb/src/storage/compression/string_uncompressed.cpp +2 -2
  146. package/src/duckdb/src/storage/statistics/list_stats.cpp +1 -1
  147. package/src/duckdb/src/storage/statistics/struct_stats.cpp +1 -1
  148. package/src/duckdb/src/storage/storage_info.cpp +1 -1
  149. package/src/duckdb/src/storage/table/row_group.cpp +2 -2
  150. package/src/duckdb/src/storage/table/update_segment.cpp +7 -6
  151. package/src/duckdb/third_party/fsst/libfsst.cpp +1 -2
  152. package/src/duckdb/third_party/libpg_query/include/nodes/nodes.hpp +9 -0
  153. package/src/duckdb/third_party/libpg_query/include/nodes/parsenodes.hpp +13 -12
  154. package/src/duckdb/third_party/libpg_query/include/parser/gram.hpp +2 -1
  155. package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +12537 -12415
  156. package/src/duckdb/ub_src_catalog_catalog_entry.cpp +1 -1
  157. package/src/duckdb/ub_src_execution_operator_persistent.cpp +2 -0
  158. package/src/duckdb/ub_src_parser_parsed_data.cpp +16 -0
  159. package/src/statement.cpp +15 -13
  160. package/src/duckdb/src/catalog/catalog_entry/scalar_macro_catalog_entry.cpp +0 -104
package/configure.py CHANGED
@@ -63,6 +63,8 @@ elif 'DUCKDB_NODE_BINDIR' in os.environ:
63
63
  cflags += ['-g']
64
64
  if '-O0' in os.environ['DUCKDB_NODE_CFLAGS']:
65
65
  cflags += ['-O0']
66
+ if '-DNDEBUG' in os.environ['DUCKDB_NODE_CFLAGS']:
67
+ defines += ['NDEBUG']
66
68
 
67
69
  if 'DUCKDB_NODE_BUILD_CACHE' in os.environ:
68
70
  cache = {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "duckdb",
3
3
  "main": "./lib/duckdb.js",
4
4
  "types": "./lib/duckdb.d.ts",
5
- "version": "0.7.2-dev3441.0",
5
+ "version": "0.7.2-dev3546.0",
6
6
  "description": "DuckDB node.js API",
7
7
  "gypfile": true,
8
8
  "dependencies": {
@@ -19,7 +19,7 @@
19
19
  "install": "node-pre-gyp install --fallback-to-build",
20
20
  "pretest": "node test/support/createdb.js",
21
21
  "test": "mocha -R spec --timeout 480000 --expose-gc",
22
- "test-path": "mocha -R spec --timeout 480000 --exclude 'test/*.ts'",
22
+ "test-path": "mocha -R spec --timeout 480000 --expose-gc --exclude 'test/*.ts'",
23
23
  "pack": "node-pre-gyp package"
24
24
  },
25
25
  "directories": {
@@ -639,7 +639,7 @@ public:
639
639
  for (auto &csn : const_struct_names) {
640
640
  result->const_struct_names.emplace(csn.first, make_uniq<Vector>(csn.second->GetValue(0)));
641
641
  }
642
- return result;
642
+ return std::move(result);
643
643
  }
644
644
 
645
645
  public:
@@ -276,6 +276,7 @@ static void ReadJSONFunction(ClientContext &context, TableFunctionInput &data_p,
276
276
  TableFunction JSONFunctions::GetReadJSONTableFunction(shared_ptr<JSONScanInfo> function_info) {
277
277
  TableFunction table_function({LogicalType::VARCHAR}, ReadJSONFunction, ReadJSONBind,
278
278
  JSONGlobalTableFunctionState::Init, JSONLocalTableFunctionState::Init);
279
+ table_function.name = "read_json";
279
280
 
280
281
  JSONScan::TableFunctionDefaults(table_function);
281
282
  table_function.named_parameters["columns"] = LogicalType::ANY;
@@ -0,0 +1,42 @@
1
+ #include "duckdb/catalog/catalog_entry/scalar_macro_catalog_entry.hpp"
2
+ #include "duckdb/catalog/catalog_entry/table_macro_catalog_entry.hpp"
3
+ #include "duckdb/common/field_writer.hpp"
4
+ #include "duckdb/function/scalar_macro_function.hpp"
5
+
6
+ namespace duckdb {
7
+
8
+ MacroCatalogEntry::MacroCatalogEntry(Catalog &catalog, SchemaCatalogEntry &schema, CreateMacroInfo &info)
9
+ : FunctionEntry(
10
+ (info.function->type == MacroType::SCALAR_MACRO ? CatalogType::MACRO_ENTRY : CatalogType::TABLE_MACRO_ENTRY),
11
+ catalog, schema, info),
12
+ function(std::move(info.function)) {
13
+ this->temporary = info.temporary;
14
+ this->internal = info.internal;
15
+ }
16
+
17
+ ScalarMacroCatalogEntry::ScalarMacroCatalogEntry(Catalog &catalog, SchemaCatalogEntry &schema, CreateMacroInfo &info)
18
+ : MacroCatalogEntry(catalog, schema, info) {
19
+ }
20
+
21
+ TableMacroCatalogEntry::TableMacroCatalogEntry(Catalog &catalog, SchemaCatalogEntry &schema, CreateMacroInfo &info)
22
+ : MacroCatalogEntry(catalog, schema, info) {
23
+ }
24
+
25
+ unique_ptr<CreateMacroInfo> MacroCatalogEntry::GetInfoForSerialization() const {
26
+ auto info = make_uniq<CreateMacroInfo>(type);
27
+ info->catalog = catalog.GetName();
28
+ info->schema = schema.name;
29
+ info->name = name;
30
+ info->function = function->Copy();
31
+ return info;
32
+ }
33
+ void MacroCatalogEntry::Serialize(Serializer &serializer) const {
34
+ auto info = GetInfoForSerialization();
35
+ info->Serialize(serializer);
36
+ }
37
+
38
+ unique_ptr<CreateMacroInfo> MacroCatalogEntry::Deserialize(Deserializer &main_source, ClientContext &context) {
39
+ return unique_ptr_cast<CreateInfo, CreateMacroInfo>(CreateInfo::Deserialize(main_source));
40
+ }
41
+
42
+ } // namespace duckdb
@@ -145,6 +145,11 @@ void CatalogSearchPath::Set(vector<CatalogSearchEntry> new_paths, bool is_set_sc
145
145
  is_set_schema ? "schema" : "search_path", path.ToString());
146
146
  }
147
147
  }
148
+ if (is_set_schema) {
149
+ if (new_paths[0].catalog == TEMP_CATALOG || new_paths[0].catalog == SYSTEM_CATALOG) {
150
+ throw CatalogException("SET schema cannot be set to internal schema \"%s\"", new_paths[0].catalog);
151
+ }
152
+ }
148
153
  this->set_paths = std::move(new_paths);
149
154
  SetPaths(set_paths);
150
155
  }
@@ -84,7 +84,7 @@ bool CatalogSet::CreateEntry(CatalogTransaction transaction, const string &name,
84
84
  throw InternalException("Attempting to create temporary entry \"%s\" in non-temporary catalog", name);
85
85
  }
86
86
  if (!value->temporary && catalog.IsTemporaryCatalog() && name != DEFAULT_SCHEMA) {
87
- throw InternalException("Attempting to create non-temporary entry \"%s\" in temporary catalog", name);
87
+ throw InvalidInputException("Cannot create non-temporary entry \"%s\" in temporary catalog", name);
88
88
  }
89
89
  }
90
90
  // lock the catalog for writing
@@ -92,6 +92,7 @@ static DefaultMacro internal_macros[] = {
92
92
  {DEFAULT_SCHEMA, "array_pop_front", {"arr", nullptr}, "arr[2:]"},
93
93
  {DEFAULT_SCHEMA, "array_push_back", {"arr", "e", nullptr}, "list_concat(arr, list_value(e))"},
94
94
  {DEFAULT_SCHEMA, "array_push_front", {"arr", "e", nullptr}, "list_concat(list_value(e), arr)"},
95
+ {DEFAULT_SCHEMA, "array_to_string", {"arr", "sep", nullptr}, "list_aggr(arr, 'string_agg', sep)"},
95
96
  {DEFAULT_SCHEMA, "generate_subscripts", {"arr", "dim", nullptr}, "unnest(generate_series(1, array_length(arr, dim)))"},
96
97
  {DEFAULT_SCHEMA, "fdiv", {"x", "y", nullptr}, "floor(x/y)"},
97
98
  {DEFAULT_SCHEMA, "fmod", {"x", "y", nullptr}, "(x-y*floor(x/y))"},
@@ -33,7 +33,7 @@ struct DuckDBArrowSchemaHolder {
33
33
  std::list<vector<ArrowSchema>> nested_children;
34
34
  std::list<vector<ArrowSchema *>> nested_children_ptr;
35
35
  //! This holds strings created to represent decimal types
36
- vector<unique_ptr<char[]>> owned_type_names;
36
+ vector<unsafe_array_ptr<char>> owned_type_names;
37
37
  };
38
38
 
39
39
  static void ReleaseDuckDBArrowSchema(ArrowSchema *schema) {
@@ -131,7 +131,7 @@ void SetArrowFormat(DuckDBArrowSchemaHolder &root_holder, ArrowSchema &child, co
131
131
  break;
132
132
  case LogicalTypeId::TIMESTAMP_TZ: {
133
133
  string format = "tsu:" + config_timezone;
134
- unique_ptr<char[]> format_ptr = unique_ptr<char[]>(new char[format.size() + 1]);
134
+ auto format_ptr = make_unsafe_array<char>(format.size() + 1);
135
135
  for (size_t i = 0; i < format.size(); i++) {
136
136
  format_ptr[i] = format[i];
137
137
  }
@@ -156,7 +156,7 @@ void SetArrowFormat(DuckDBArrowSchemaHolder &root_holder, ArrowSchema &child, co
156
156
  uint8_t width, scale;
157
157
  type.GetDecimalProperties(width, scale);
158
158
  string format = "d:" + to_string(width) + "," + to_string(scale);
159
- unique_ptr<char[]> format_ptr = unique_ptr<char[]>(new char[format.size() + 1]);
159
+ auto format_ptr = make_unsafe_array<char>(format.size() + 1);
160
160
  for (size_t i = 0; i < format.size(); i++) {
161
161
  format_ptr[i] = format[i];
162
162
  }
@@ -204,7 +204,7 @@ void SetArrowFormat(DuckDBArrowSchemaHolder &root_holder, ArrowSchema &child, co
204
204
  InitializeChild(*child.children[type_idx]);
205
205
 
206
206
  auto &struct_col_name = child_types[type_idx].first;
207
- unique_ptr<char[]> name_ptr = unique_ptr<char[]>(new char[struct_col_name.size() + 1]);
207
+ auto name_ptr = make_unsafe_array<char>(struct_col_name.size() + 1);
208
208
  for (size_t i = 0; i < struct_col_name.size(); i++) {
209
209
  name_ptr[i] = struct_col_name[i];
210
210
  }
@@ -19,10 +19,10 @@ void CompressedFile::Initialize(bool write) {
19
19
  this->write = write;
20
20
  stream_data.in_buf_size = compressed_fs.InBufferSize();
21
21
  stream_data.out_buf_size = compressed_fs.OutBufferSize();
22
- stream_data.in_buff = unique_ptr<data_t[]>(new data_t[stream_data.in_buf_size]);
22
+ stream_data.in_buff = make_unsafe_array<data_t>(stream_data.in_buf_size);
23
23
  stream_data.in_buff_start = stream_data.in_buff.get();
24
24
  stream_data.in_buff_end = stream_data.in_buff.get();
25
- stream_data.out_buff = unique_ptr<data_t[]>(new data_t[stream_data.out_buf_size]);
25
+ stream_data.out_buff = make_unsafe_array<data_t>(stream_data.out_buf_size);
26
26
  stream_data.out_buff_start = stream_data.out_buff.get();
27
27
  stream_data.out_buff_end = stream_data.out_buff.get();
28
28
 
@@ -2,6 +2,7 @@
2
2
 
3
3
  #include "duckdb/common/limits.hpp"
4
4
  #include "duckdb/common/vector_size.hpp"
5
+ #include "duckdb/common/serializer.hpp"
5
6
 
6
7
  namespace duckdb {
7
8
 
@@ -78,7 +78,7 @@ idx_t FileSystem::GetAvailableMemory() {
78
78
  }
79
79
 
80
80
  string FileSystem::GetWorkingDirectory() {
81
- auto buffer = unique_ptr<char[]>(new char[PATH_MAX]);
81
+ auto buffer = make_unsafe_array<char>(PATH_MAX);
82
82
  char *ret = getcwd(buffer.get(), PATH_MAX);
83
83
  if (!ret) {
84
84
  throw IOException("Could not get working directory!");
@@ -138,7 +138,7 @@ string FileSystem::GetWorkingDirectory() {
138
138
  if (count == 0) {
139
139
  throw IOException("Could not get working directory!");
140
140
  }
141
- auto buffer = unique_ptr<char[]>(new char[count]);
141
+ auto buffer = make_unsafe_array<char>(count);
142
142
  idx_t ret = GetCurrentDirectory(count, buffer.get());
143
143
  if (count != ret + 1) {
144
144
  throw IOException("Could not get working directory!");
@@ -95,8 +95,8 @@ static void GatherNestedVector(Vector &rows, const SelectionVector &row_sel, Vec
95
95
  auto ptrs = FlatVector::GetData<data_ptr_t>(rows);
96
96
 
97
97
  // Build the gather locations
98
- auto data_locations = unique_ptr<data_ptr_t[]>(new data_ptr_t[count]);
99
- auto mask_locations = unique_ptr<data_ptr_t[]>(new data_ptr_t[count]);
98
+ auto data_locations = make_unsafe_array<data_ptr_t>(count);
99
+ auto mask_locations = make_unsafe_array<data_ptr_t>(count);
100
100
  for (idx_t i = 0; i < count; i++) {
101
101
  auto row_idx = row_sel.get_index(i);
102
102
  auto row = ptrs[row_idx];
@@ -123,7 +123,7 @@ string BinaryDeserializer::ReadString() {
123
123
  if (size == 0) {
124
124
  return string();
125
125
  }
126
- auto buffer = unique_ptr<data_t[]>(new data_t[size]);
126
+ auto buffer = make_unsafe_array<data_t>(size);
127
127
  ReadData(buffer.get(), size);
128
128
  return string((char *)buffer.get(), size);
129
129
  }
@@ -9,7 +9,7 @@ namespace duckdb {
9
9
 
10
10
  BufferedFileReader::BufferedFileReader(FileSystem &fs, const char *path, optional_ptr<ClientContext> context,
11
11
  FileLockType lock_type, optional_ptr<FileOpener> opener)
12
- : fs(fs), data(unique_ptr<data_t[]>(new data_t[FILE_BUFFER_SIZE])), offset(0), read_data(0), total_read(0),
12
+ : fs(fs), data(make_unsafe_array<data_t>(FILE_BUFFER_SIZE)), offset(0), read_data(0), total_read(0),
13
13
  context(context) {
14
14
  handle = fs.OpenFile(path, FileFlags::FILE_FLAGS_READ, lock_type, FileSystem::DEFAULT_COMPRESSION, opener.get());
15
15
  file_size = fs.GetFileSize(*handle);
@@ -9,7 +9,7 @@ namespace duckdb {
9
9
  constexpr uint8_t BufferedFileWriter::DEFAULT_OPEN_FLAGS;
10
10
 
11
11
  BufferedFileWriter::BufferedFileWriter(FileSystem &fs, const string &path_p, uint8_t open_flags)
12
- : fs(fs), path(path_p), data(unique_ptr<data_t[]>(new data_t[FILE_BUFFER_SIZE])), offset(0), total_written(0) {
12
+ : fs(fs), path(path_p), data(make_unsafe_array<data_t>(FILE_BUFFER_SIZE)), offset(0), total_written(0) {
13
13
  handle = fs.OpenFile(path, open_flags, FileLockType::WRITE_LOCK);
14
14
  }
15
15
 
@@ -5,10 +5,11 @@
5
5
  namespace duckdb {
6
6
 
7
7
  BufferedSerializer::BufferedSerializer(idx_t maximum_size)
8
- : BufferedSerializer(unique_ptr<data_t[]>(new data_t[maximum_size]), maximum_size) {
8
+ : BufferedSerializer(make_unsafe_array<data_t>(maximum_size), maximum_size) {
9
9
  }
10
10
 
11
- BufferedSerializer::BufferedSerializer(unique_ptr<data_t[]> data, idx_t size) : maximum_size(size), data(data.get()) {
11
+ BufferedSerializer::BufferedSerializer(unsafe_array_ptr<data_t> data, idx_t size)
12
+ : maximum_size(size), data(data.get()) {
12
13
  blob.size = 0;
13
14
  blob.data = std::move(data);
14
15
  }
@@ -25,7 +26,7 @@ void BufferedSerializer::WriteData(const_data_ptr_t buffer, idx_t write_size) {
25
26
  auto new_data = new data_t[maximum_size];
26
27
  memcpy(new_data, data, blob.size);
27
28
  data = new_data;
28
- blob.data = unique_ptr<data_t[]>(new_data);
29
+ blob.data = unsafe_array_ptr<data_t>(new_data);
29
30
  }
30
31
 
31
32
  memcpy(data + blob.size, buffer, write_size);
@@ -8,7 +8,7 @@ string Deserializer::Read() {
8
8
  if (size == 0) {
9
9
  return string();
10
10
  }
11
- auto buffer = unique_ptr<data_t[]>(new data_t[size]);
11
+ auto buffer = make_unsafe_array<data_t>(size);
12
12
  ReadData(buffer.get(), size);
13
13
  return string((char *)buffer.get(), size);
14
14
  }
@@ -17,7 +17,7 @@ static void SortTiedBlobs(BufferManager &buffer_manager, const data_ptr_t datapt
17
17
  return;
18
18
  }
19
19
  // Fill pointer array for sorting
20
- auto ptr_block = unique_ptr<data_ptr_t[]>(new data_ptr_t[end - start]);
20
+ auto ptr_block = make_unsafe_array<data_ptr_t>(end - start);
21
21
  auto entry_ptrs = (data_ptr_t *)ptr_block.get();
22
22
  for (idx_t i = start; i < end; i++) {
23
23
  entry_ptrs[i - start] = row_ptr;
@@ -158,7 +158,7 @@ inline void InsertionSort(const data_ptr_t orig_ptr, const data_ptr_t temp_ptr,
158
158
  const data_ptr_t target_ptr = swap ? orig_ptr : temp_ptr;
159
159
  if (count > 1) {
160
160
  const idx_t total_offset = col_offset + offset;
161
- auto temp_val = unique_ptr<data_t[]>(new data_t[row_width]);
161
+ auto temp_val = make_unsafe_array<data_t>(row_width);
162
162
  const data_ptr_t val = temp_val.get();
163
163
  const auto comp_width = total_comp_width - offset;
164
164
  for (idx_t i = 1; i < count; i++) {
@@ -249,7 +249,7 @@ void RadixSort(BufferManager &buffer_manager, const data_ptr_t &dataptr, const i
249
249
  RadixSortLSD(buffer_manager, dataptr, count, col_offset, sort_layout.entry_size, sorting_size);
250
250
  } else {
251
251
  auto temp_block = buffer_manager.Allocate(MaxValue(count * sort_layout.entry_size, (idx_t)Storage::BLOCK_SIZE));
252
- auto preallocated_array = unique_ptr<idx_t[]>(new idx_t[sorting_size * SortConstants::MSD_RADIX_LOCATIONS]);
252
+ auto preallocated_array = make_unsafe_array<idx_t>(sorting_size * SortConstants::MSD_RADIX_LOCATIONS);
253
253
  RadixSortMSD(dataptr, temp_block.Ptr(), count, col_offset, sort_layout.entry_size, sorting_size, 0,
254
254
  preallocated_array.get(), false);
255
255
  }
@@ -291,7 +291,7 @@ void LocalSortState::SortInMemory() {
291
291
  // Radix sort and break ties until no more ties, or until all columns are sorted
292
292
  idx_t sorting_size = 0;
293
293
  idx_t col_offset = 0;
294
- unique_ptr<bool[]> ties_ptr;
294
+ unsafe_array_ptr<bool> ties_ptr;
295
295
  bool *ties = nullptr;
296
296
  bool contains_string = false;
297
297
  for (idx_t i = 0; i < sort_layout->column_count; i++) {
@@ -305,7 +305,7 @@ void LocalSortState::SortInMemory() {
305
305
  if (!ties) {
306
306
  // This is the first sort
307
307
  RadixSort(*buffer_manager, dataptr, count, col_offset, sorting_size, *sort_layout, contains_string);
308
- ties_ptr = unique_ptr<bool[]>(new bool[count]);
308
+ ties_ptr = make_unsafe_array<bool>(count);
309
309
  ties = ties_ptr.get();
310
310
  std::fill_n(ties, count - 1, true);
311
311
  ties[count - 1] = false;
@@ -277,7 +277,7 @@ vector<string> StringUtil::TopNStrings(vector<pair<string, idx_t>> scores, idx_t
277
277
 
278
278
  struct LevenshteinArray {
279
279
  LevenshteinArray(idx_t len1, idx_t len2) : len1(len1) {
280
- dist = unique_ptr<idx_t[]>(new idx_t[len1 * len2]);
280
+ dist = make_unsafe_array<idx_t>(len1 * len2);
281
281
  }
282
282
 
283
283
  idx_t &Score(idx_t i, idx_t j) {
@@ -286,7 +286,7 @@ struct LevenshteinArray {
286
286
 
287
287
  private:
288
288
  idx_t len1;
289
- unique_ptr<idx_t[]> dist;
289
+ unsafe_array_ptr<idx_t> dist;
290
290
 
291
291
  idx_t GetIndex(idx_t i, idx_t j) {
292
292
  return j * len1 + i;
@@ -78,7 +78,7 @@ void Bit::ToString(string_t bits, char *output) {
78
78
 
79
79
  string Bit::ToString(string_t str) {
80
80
  auto len = BitLength(str);
81
- auto buffer = unique_ptr<char[]>(new char[len]);
81
+ auto buffer = make_unsafe_array<char>(len);
82
82
  ToString(str, buffer.get());
83
83
  return string(buffer.get(), len);
84
84
  }
@@ -140,7 +140,7 @@ void Bit::ToBit(string_t str, string_t &output_str) {
140
140
 
141
141
  string Bit::ToBit(string_t str) {
142
142
  auto bit_len = GetBitSize(str);
143
- auto buffer = unique_ptr<char[]>(new char[bit_len]);
143
+ auto buffer = make_unsafe_array<char>(bit_len);
144
144
  string_t output_str(buffer.get(), bit_len);
145
145
  Bit::ToBit(str, output_str);
146
146
  return output_str.GetString();
@@ -64,7 +64,7 @@ void Blob::ToString(string_t blob, char *output) {
64
64
 
65
65
  string Blob::ToString(string_t blob) {
66
66
  auto str_len = GetStringSize(blob);
67
- auto buffer = unique_ptr<char[]>(new char[str_len]);
67
+ auto buffer = make_unsafe_array<char>(str_len);
68
68
  Blob::ToString(blob, buffer.get());
69
69
  return string(buffer.get(), str_len);
70
70
  }
@@ -136,7 +136,7 @@ void Blob::ToBlob(string_t str, data_ptr_t output) {
136
136
 
137
137
  string Blob::ToBlob(string_t str) {
138
138
  auto blob_len = GetBlobSize(str);
139
- auto buffer = unique_ptr<char[]>(new char[blob_len]);
139
+ auto buffer = make_unsafe_array<char>(blob_len);
140
140
  Blob::ToBlob(str, (data_ptr_t)buffer.get());
141
141
  return string(buffer.get(), blob_len);
142
142
  }
@@ -291,8 +291,8 @@ void DataChunk::Slice(DataChunk &other, const SelectionVector &sel, idx_t count_
291
291
  }
292
292
  }
293
293
 
294
- unique_ptr<UnifiedVectorFormat[]> DataChunk::ToUnifiedFormat() {
295
- auto orrified_data = unique_ptr<UnifiedVectorFormat[]>(new UnifiedVectorFormat[ColumnCount()]);
294
+ unsafe_array_ptr<UnifiedVectorFormat> DataChunk::ToUnifiedFormat() {
295
+ auto orrified_data = make_unsafe_array<UnifiedVectorFormat>(ColumnCount());
296
296
  for (idx_t col_idx = 0; col_idx < ColumnCount(); col_idx++) {
297
297
  data[col_idx].ToUnifiedFormat(size(), orrified_data[col_idx]);
298
298
  }
@@ -362,7 +362,7 @@ string Date::ToString(date_t date) {
362
362
  Date::Convert(date, date_units[0], date_units[1], date_units[2]);
363
363
 
364
364
  auto length = DateToStringCast::Length(date_units, year_length, add_bc);
365
- auto buffer = unique_ptr<char[]>(new char[length]);
365
+ auto buffer = make_unsafe_array<char>(length);
366
366
  DateToStringCast::Format(buffer.get(), date_units, year_length, add_bc);
367
367
  return string(buffer.get(), length);
368
368
  }
@@ -6,7 +6,7 @@ namespace duckdb {
6
6
  template <class SIGNED, class UNSIGNED>
7
7
  string TemplatedDecimalToString(SIGNED value, uint8_t width, uint8_t scale) {
8
8
  auto len = DecimalToString::DecimalLength<SIGNED, UNSIGNED>(value, width, scale);
9
- auto data = unique_ptr<char[]>(new char[len + 1]);
9
+ auto data = make_unsafe_array<char>(len + 1);
10
10
  DecimalToString::FormatDecimal<SIGNED, UNSIGNED>(value, width, scale, data.get(), len);
11
11
  return string(data.get(), len);
12
12
  }
@@ -25,7 +25,7 @@ string Decimal::ToString(int64_t value, uint8_t width, uint8_t scale) {
25
25
 
26
26
  string Decimal::ToString(hugeint_t value, uint8_t width, uint8_t scale) {
27
27
  auto len = HugeintToStringCast::DecimalLength(value, width, scale);
28
- auto data = unique_ptr<char[]>(new char[len + 1]);
28
+ auto data = make_unsafe_array<char>(len + 1);
29
29
  HugeintToStringCast::FormatDecimal(value, width, scale, data.get(), len);
30
30
  return string(data.get(), len);
31
31
  }
@@ -1,7 +1,7 @@
1
+ #include "duckdb/common/enum_util.hpp"
1
2
  #include "duckdb/common/fast_mem.hpp"
2
3
  #include "duckdb/common/types/null_value.hpp"
3
4
  #include "duckdb/common/types/row/tuple_data_collection.hpp"
4
- #include "duckdb/common/enum_util.hpp"
5
5
 
6
6
  namespace duckdb {
7
7
 
@@ -314,6 +314,19 @@ void TupleDataCollection::ListWithinListComputeHeapSizes(Vector &heap_sizes_v, c
314
314
  const auto child_list_entries = (list_entry_t *)child_list_data.data;
315
315
  const auto &child_list_validity = child_list_data.validity;
316
316
 
317
+ // Figure out actual child list size (differs from ListVector::GetListSize if dict/const vector)
318
+ idx_t child_list_child_count = ListVector::GetListSize(source_v);
319
+ for (idx_t i = 0; i < append_count; i++) {
320
+ const auto list_idx = list_sel.get_index(append_sel.get_index(i));
321
+ if (!list_validity.RowIsValid(list_idx)) {
322
+ continue;
323
+ }
324
+ const auto &list_entry = list_entries[list_idx];
325
+ const auto &list_offset = list_entry.offset;
326
+ const auto &list_length = list_entry.length;
327
+ child_list_child_count = MaxValue<idx_t>(child_list_child_count, list_offset + list_length);
328
+ }
329
+
317
330
  // Target
318
331
  auto heap_sizes = FlatVector::GetData<idx_t>(heap_sizes_v);
319
332
 
@@ -322,7 +335,6 @@ void TupleDataCollection::ListWithinListComputeHeapSizes(Vector &heap_sizes_v, c
322
335
  child_format.combined_list_data = make_uniq<CombinedListData>();
323
336
  auto &combined_list_data = *child_format.combined_list_data;
324
337
  auto &combined_list_entries = combined_list_data.combined_list_entries;
325
- const auto child_list_child_count = ListVector::GetListSize(source_v);
326
338
  SelectionVector combined_sel(child_list_child_count);
327
339
  for (idx_t i = 0; i < child_list_child_count; i++) {
328
340
  combined_sel.set_index(i, 0);
@@ -5,7 +5,7 @@
5
5
  namespace duckdb {
6
6
 
7
7
  SelectionData::SelectionData(idx_t count) {
8
- owned_data = unique_ptr<sel_t[]>(new sel_t[count]);
8
+ owned_data = make_unsafe_array<sel_t>(count);
9
9
  #ifdef DEBUG
10
10
  for (idx_t i = 0; i < count; i++) {
11
11
  owned_data[i] = std::numeric_limits<sel_t>::max();
@@ -158,7 +158,7 @@ string Time::ToString(dtime_t time) {
158
158
 
159
159
  char micro_buffer[6];
160
160
  auto length = TimeToStringCast::Length(time_units, micro_buffer);
161
- auto buffer = unique_ptr<char[]>(new char[length]);
161
+ auto buffer = make_unsafe_array<char>(length);
162
162
  TimeToStringCast::Format(buffer.get(), length, time_units, micro_buffer);
163
163
  return string(buffer.get(), length);
164
164
  }
@@ -297,7 +297,7 @@ void Vector::Resize(idx_t cur_size, idx_t new_size) {
297
297
  }
298
298
  for (auto &data_to_resize : to_resize) {
299
299
  if (!data_to_resize.is_nested) {
300
- auto new_data = unique_ptr<data_t[]>(new data_t[new_size * data_to_resize.type_size]);
300
+ auto new_data = make_unsafe_array<data_t>(new_size * data_to_resize.type_size);
301
301
  memcpy(new_data.get(), data_to_resize.data, cur_size * data_to_resize.type_size * sizeof(data_t));
302
302
  data_to_resize.buffer->SetData(std::move(new_data));
303
303
  data_to_resize.vec.data = data_to_resize.buffer->GetData();
@@ -920,7 +920,7 @@ void Vector::Serialize(idx_t count, Serializer &serializer) {
920
920
  if (TypeIsConstantSize(type.InternalType())) {
921
921
  // constant size type: simple copy
922
922
  idx_t write_size = GetTypeIdSize(type.InternalType()) * count;
923
- auto ptr = unique_ptr<data_t[]>(new data_t[write_size]);
923
+ auto ptr = make_unsafe_array<data_t>(write_size);
924
924
  VectorOperations::WriteToStorage(*this, count, ptr.get());
925
925
  serializer.WriteData(ptr.get(), write_size);
926
926
  } else {
@@ -947,7 +947,7 @@ void Vector::Serialize(idx_t count, Serializer &serializer) {
947
947
  auto list_size = ListVector::GetListSize(*this);
948
948
 
949
949
  // serialize the list entries in a flat array
950
- auto data = unique_ptr<list_entry_t[]>(new list_entry_t[count]);
950
+ auto data = make_unsafe_array<list_entry_t>(count);
951
951
  auto source_array = (list_entry_t *)vdata.data;
952
952
  for (idx_t i = 0; i < count; i++) {
953
953
  auto idx = vdata.sel->get_index(i);
@@ -988,7 +988,7 @@ void Vector::FormatSerialize(FormatSerializer &serializer, idx_t count) {
988
988
  if (TypeIsConstantSize(logical_type.InternalType())) {
989
989
  // constant size type: simple copy
990
990
  idx_t write_size = GetTypeIdSize(logical_type.InternalType()) * count;
991
- auto ptr = unique_ptr<data_t[]>(new data_t[write_size]);
991
+ auto ptr = make_unsafe_array<data_t>(write_size);
992
992
  VectorOperations::WriteToStorage(*this, count, ptr.get());
993
993
  serializer.WriteProperty("data", ptr.get(), write_size);
994
994
  } else {
@@ -1027,7 +1027,7 @@ void Vector::FormatSerialize(FormatSerializer &serializer, idx_t count) {
1027
1027
  auto list_size = ListVector::GetListSize(*this);
1028
1028
 
1029
1029
  // serialize the list entries in a flat array
1030
- auto entries = unique_ptr<list_entry_t[]>(new list_entry_t[count]);
1030
+ auto entries = make_unsafe_array<list_entry_t>(count);
1031
1031
  auto source_array = (list_entry_t *)vdata.data;
1032
1032
  for (idx_t i = 0; i < count; i++) {
1033
1033
  auto idx = vdata.sel->get_index(i);
@@ -1071,7 +1071,7 @@ void Vector::FormatDeserialize(FormatDeserializer &deserializer, idx_t count) {
1071
1071
  if (TypeIsConstantSize(logical_type.InternalType())) {
1072
1072
  // constant size type: read fixed amount of data
1073
1073
  auto column_size = GetTypeIdSize(logical_type.InternalType()) * count;
1074
- auto ptr = unique_ptr<data_t[]>(new data_t[column_size]);
1074
+ auto ptr = make_unsafe_array<data_t>(column_size);
1075
1075
  deserializer.ReadProperty("data", ptr.get(), column_size);
1076
1076
 
1077
1077
  VectorOperations::ReadFromStorage(ptr.get(), count, *this);
@@ -1158,7 +1158,7 @@ void Vector::Deserialize(idx_t count, Deserializer &source) {
1158
1158
  if (TypeIsConstantSize(type.InternalType())) {
1159
1159
  // constant size type: read fixed amount of data from
1160
1160
  auto column_size = GetTypeIdSize(type.InternalType()) * count;
1161
- auto ptr = unique_ptr<data_t[]>(new data_t[column_size]);
1161
+ auto ptr = make_unsafe_array<data_t>(column_size);
1162
1162
  source.ReadData(ptr.get(), column_size);
1163
1163
 
1164
1164
  VectorOperations::ReadFromStorage(ptr.get(), count, *this);
@@ -1868,7 +1868,7 @@ idx_t ListVector::GetListSize(const Vector &vec) {
1868
1868
  return ListVector::GetListSize(child);
1869
1869
  }
1870
1870
  D_ASSERT(vec.auxiliary);
1871
- return ((VectorListBuffer &)*vec.auxiliary).size;
1871
+ return ((VectorListBuffer &)*vec.auxiliary).GetSize();
1872
1872
  }
1873
1873
 
1874
1874
  idx_t ListVector::GetListCapacity(const Vector &vec) {
@@ -1877,7 +1877,7 @@ idx_t ListVector::GetListCapacity(const Vector &vec) {
1877
1877
  return ListVector::GetListSize(child);
1878
1878
  }
1879
1879
  D_ASSERT(vec.auxiliary);
1880
- return ((VectorListBuffer &)*vec.auxiliary).capacity;
1880
+ return ((VectorListBuffer &)*vec.auxiliary).GetCapacity();
1881
1881
  }
1882
1882
 
1883
1883
  void ListVector::ReferenceEntry(Vector &vector, Vector &other) {
@@ -1894,7 +1894,7 @@ void ListVector::SetListSize(Vector &vec, idx_t size) {
1894
1894
  auto &child = DictionaryVector::Child(vec);
1895
1895
  ListVector::SetListSize(child, size);
1896
1896
  }
1897
- ((VectorListBuffer &)*vec.auxiliary).size = size;
1897
+ ((VectorListBuffer &)*vec.auxiliary).SetSize(size);
1898
1898
  }
1899
1899
 
1900
1900
  void ListVector::Append(Vector &target, const Vector &source, idx_t source_size, idx_t source_offset) {
@@ -58,12 +58,12 @@ VectorStructBuffer::~VectorStructBuffer() {
58
58
  }
59
59
 
60
60
  VectorListBuffer::VectorListBuffer(unique_ptr<Vector> vector, idx_t initial_capacity)
61
- : VectorBuffer(VectorBufferType::LIST_BUFFER), capacity(initial_capacity), child(std::move(vector)) {
61
+ : VectorBuffer(VectorBufferType::LIST_BUFFER), child(std::move(vector)), capacity(initial_capacity) {
62
62
  }
63
63
 
64
64
  VectorListBuffer::VectorListBuffer(const LogicalType &list_type, idx_t initial_capacity)
65
- : VectorBuffer(VectorBufferType::LIST_BUFFER), capacity(initial_capacity),
66
- child(make_uniq<Vector>(ListType::GetChildType(list_type), initial_capacity)) {
65
+ : VectorBuffer(VectorBufferType::LIST_BUFFER),
66
+ child(make_uniq<Vector>(ListType::GetChildType(list_type), initial_capacity)), capacity(initial_capacity) {
67
67
  }
68
68
 
69
69
  void VectorListBuffer::Reserve(idx_t to_reserve) {
@@ -96,6 +96,14 @@ void VectorListBuffer::PushBack(const Value &insert) {
96
96
  child->SetValue(size++, insert);
97
97
  }
98
98
 
99
+ void VectorListBuffer::SetCapacity(idx_t new_capacity) {
100
+ this->capacity = new_capacity;
101
+ }
102
+
103
+ void VectorListBuffer::SetSize(idx_t new_size) {
104
+ this->size = new_size;
105
+ }
106
+
99
107
  VectorListBuffer::~VectorListBuffer() {
100
108
  }
101
109
 
@@ -16,7 +16,7 @@ public:
16
16
  owned_data = allocator.Allocate(capacity * GetTypeIdSize(internal_type));
17
17
  // child data of the list
18
18
  auto &child_type = ListType::GetChildType(type);
19
- child_caches.push_back(make_buffer<VectorCacheBuffer>(allocator, child_type));
19
+ child_caches.push_back(make_buffer<VectorCacheBuffer>(allocator, child_type, capacity));
20
20
  auto child_vector = make_uniq<Vector>(child_type, false, false);
21
21
  auxiliary = make_shared<VectorListBuffer>(std::move(child_vector));
22
22
  break;
@@ -24,7 +24,7 @@ public:
24
24
  case PhysicalType::STRUCT: {
25
25
  auto &child_types = StructType::GetChildTypes(type);
26
26
  for (auto &child_type : child_types) {
27
- child_caches.push_back(make_buffer<VectorCacheBuffer>(allocator, child_type.second));
27
+ child_caches.push_back(make_buffer<VectorCacheBuffer>(allocator, child_type.second, capacity));
28
28
  }
29
29
  auto struct_buffer = make_shared<VectorStructBuffer>(type);
30
30
  auxiliary = std::move(struct_buffer);
@@ -48,13 +48,13 @@ public:
48
48
  // reinitialize the VectorListBuffer
49
49
  AssignSharedPointer(result.auxiliary, auxiliary);
50
50
  // propagate through child
51
+ auto &child_cache = (VectorCacheBuffer &)*child_caches[0];
51
52
  auto &list_buffer = (VectorListBuffer &)*result.auxiliary;
52
- list_buffer.capacity = capacity;
53
- list_buffer.size = 0;
53
+ list_buffer.SetCapacity(child_cache.capacity);
54
+ list_buffer.SetSize(0);
54
55
  list_buffer.SetAuxiliaryData(nullptr);
55
56
 
56
57
  auto &list_child = list_buffer.GetChild();
57
- auto &child_cache = (VectorCacheBuffer &)*child_caches[0];
58
58
  child_cache.ResetFromCache(list_child, child_caches[0]);
59
59
  break;
60
60
  }