duckdb 0.7.1-dev37.0 → 0.7.1-dev415.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.
- package/README.md +1 -1
- package/binding.gyp +7 -7
- package/package.json +3 -3
- package/src/duckdb/extension/json/buffered_json_reader.cpp +50 -9
- package/src/duckdb/extension/json/include/buffered_json_reader.hpp +7 -2
- package/src/duckdb/extension/json/include/json_scan.hpp +45 -10
- package/src/duckdb/extension/json/json_functions/copy_json.cpp +35 -22
- package/src/duckdb/extension/json/json_functions/json_create.cpp +8 -8
- package/src/duckdb/extension/json/json_functions/json_structure.cpp +8 -3
- package/src/duckdb/extension/json/json_functions/json_transform.cpp +54 -10
- package/src/duckdb/extension/json/json_functions/read_json.cpp +104 -49
- package/src/duckdb/extension/json/json_functions/read_json_objects.cpp +5 -3
- package/src/duckdb/extension/json/json_functions.cpp +7 -0
- package/src/duckdb/extension/json/json_scan.cpp +144 -37
- package/src/duckdb/extension/parquet/column_reader.cpp +7 -0
- package/src/duckdb/extension/parquet/include/column_reader.hpp +1 -0
- package/src/duckdb/extension/parquet/parquet-extension.cpp +2 -9
- package/src/duckdb/src/catalog/catalog.cpp +62 -13
- package/src/duckdb/src/catalog/catalog_entry/index_catalog_entry.cpp +8 -7
- package/src/duckdb/src/catalog/catalog_entry/schema_catalog_entry.cpp +1 -1
- package/src/duckdb/src/catalog/catalog_set.cpp +1 -1
- package/src/duckdb/src/catalog/default/default_views.cpp +1 -1
- package/src/duckdb/src/common/bind_helpers.cpp +55 -0
- package/src/duckdb/src/common/enums/logical_operator_type.cpp +2 -0
- package/src/duckdb/src/common/enums/physical_operator_type.cpp +2 -0
- package/src/duckdb/src/common/enums/statement_type.cpp +2 -0
- package/src/duckdb/src/common/file_system.cpp +28 -0
- package/src/duckdb/src/common/hive_partitioning.cpp +1 -0
- package/src/duckdb/src/common/local_file_system.cpp +4 -4
- package/src/duckdb/src/common/operator/cast_operators.cpp +10 -4
- package/src/duckdb/src/common/string_util.cpp +8 -4
- package/src/duckdb/src/common/types/partitioned_column_data.cpp +1 -0
- package/src/duckdb/src/common/types/time.cpp +1 -1
- package/src/duckdb/src/common/types/timestamp.cpp +35 -4
- package/src/duckdb/src/common/types.cpp +37 -11
- package/src/duckdb/src/execution/column_binding_resolver.cpp +5 -2
- package/src/duckdb/src/execution/index/art/art.cpp +117 -67
- package/src/duckdb/src/execution/index/art/art_key.cpp +24 -12
- package/src/duckdb/src/execution/index/art/leaf.cpp +7 -8
- package/src/duckdb/src/execution/index/art/node.cpp +13 -27
- package/src/duckdb/src/execution/index/art/node16.cpp +5 -8
- package/src/duckdb/src/execution/index/art/node256.cpp +3 -5
- package/src/duckdb/src/execution/index/art/node4.cpp +4 -7
- package/src/duckdb/src/execution/index/art/node48.cpp +5 -8
- package/src/duckdb/src/execution/index/art/prefix.cpp +2 -3
- package/src/duckdb/src/execution/operator/aggregate/physical_window.cpp +6 -27
- package/src/duckdb/src/execution/operator/helper/physical_reset.cpp +1 -9
- package/src/duckdb/src/execution/operator/helper/physical_set.cpp +1 -9
- package/src/duckdb/src/execution/operator/join/physical_iejoin.cpp +7 -9
- package/src/duckdb/src/execution/operator/persistent/base_csv_reader.cpp +6 -11
- package/src/duckdb/src/execution/operator/persistent/buffered_csv_reader.cpp +13 -13
- package/src/duckdb/src/execution/operator/schema/physical_detach.cpp +37 -0
- package/src/duckdb/src/execution/operator/schema/physical_drop.cpp +0 -5
- package/src/duckdb/src/execution/physical_operator.cpp +6 -6
- package/src/duckdb/src/execution/physical_plan/plan_simple.cpp +4 -0
- package/src/duckdb/src/execution/physical_plan_generator.cpp +1 -0
- package/src/duckdb/src/function/pragma/pragma_queries.cpp +38 -11
- package/src/duckdb/src/function/scalar/generic/current_setting.cpp +2 -2
- package/src/duckdb/src/function/scalar/map/map.cpp +69 -21
- package/src/duckdb/src/function/table/read_csv.cpp +17 -5
- package/src/duckdb/src/function/table/system/duckdb_temporary_files.cpp +59 -0
- package/src/duckdb/src/function/table/system_functions.cpp +1 -0
- package/src/duckdb/src/function/table/table_scan.cpp +3 -0
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +7 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_index_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/index_catalog_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/bind_helpers.hpp +2 -0
- package/src/duckdb/src/include/duckdb/common/enums/logical_operator_type.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/enums/physical_operator_type.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/enums/statement_type.hpp +3 -2
- package/src/duckdb/src/include/duckdb/common/enums/wal_type.hpp +3 -0
- package/src/duckdb/src/include/duckdb/common/exception.hpp +10 -0
- package/src/duckdb/src/include/duckdb/common/file_system.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/hive_partitioning.hpp +9 -1
- package/src/duckdb/src/include/duckdb/common/radix_partitioning.hpp +4 -4
- package/src/duckdb/src/include/duckdb/common/string_util.hpp +9 -2
- package/src/duckdb/src/include/duckdb/common/types/timestamp.hpp +5 -1
- package/src/duckdb/src/include/duckdb/execution/index/art/art.hpp +37 -41
- package/src/duckdb/src/include/duckdb/execution/index/art/art_key.hpp +8 -11
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/base_csv_reader.hpp +1 -3
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/buffered_csv_reader.hpp +0 -2
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_reader_options.hpp +2 -0
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_detach.hpp +32 -0
- package/src/duckdb/src/include/duckdb/function/table/system_functions.hpp +4 -0
- package/src/duckdb/src/include/duckdb/main/client_data.hpp +2 -2
- package/src/duckdb/src/include/duckdb/main/config.hpp +2 -3
- package/src/duckdb/src/include/duckdb/main/{extension_functions.hpp → extension_entries.hpp} +26 -5
- package/src/duckdb/src/include/duckdb/main/extension_helper.hpp +3 -0
- package/src/duckdb/src/include/duckdb/main/settings.hpp +9 -0
- package/src/duckdb/src/include/duckdb/parallel/pipeline_executor.hpp +0 -7
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_database_info.hpp +0 -4
- package/src/duckdb/src/include/duckdb/parser/parsed_data/detach_info.hpp +32 -0
- package/src/duckdb/src/include/duckdb/parser/query_node/select_node.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/sql_statement.hpp +2 -2
- package/src/duckdb/src/include/duckdb/parser/statement/copy_statement.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/statement/detach_statement.hpp +29 -0
- package/src/duckdb/src/include/duckdb/parser/statement/list.hpp +1 -0
- package/src/duckdb/src/include/duckdb/parser/statement/select_statement.hpp +3 -3
- package/src/duckdb/src/include/duckdb/parser/tableref/subqueryref.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/tokens.hpp +1 -0
- package/src/duckdb/src/include/duckdb/parser/transformer.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/binder.hpp +4 -0
- package/src/duckdb/src/include/duckdb/planner/expression_binder/index_binder.hpp +10 -3
- package/src/duckdb/src/include/duckdb/planner/operator/logical_execute.hpp +1 -5
- package/src/duckdb/src/include/duckdb/planner/operator/logical_show.hpp +1 -2
- package/src/duckdb/src/include/duckdb/storage/buffer_manager.hpp +8 -0
- package/src/duckdb/src/include/duckdb/storage/data_table.hpp +7 -1
- package/src/duckdb/src/include/duckdb/storage/index.hpp +47 -38
- package/src/duckdb/src/include/duckdb/storage/storage_extension.hpp +7 -0
- package/src/duckdb/src/include/duckdb/storage/table/update_segment.hpp +2 -0
- package/src/duckdb/src/include/duckdb/storage/write_ahead_log.hpp +7 -0
- package/src/duckdb/src/main/client_context.cpp +2 -0
- package/src/duckdb/src/main/config.cpp +1 -0
- package/src/duckdb/src/main/database.cpp +14 -5
- package/src/duckdb/src/main/extension/extension_alias.cpp +2 -1
- package/src/duckdb/src/main/extension/extension_install.cpp +43 -9
- package/src/duckdb/src/main/extension/extension_load.cpp +29 -5
- package/src/duckdb/src/main/settings/settings.cpp +16 -0
- package/src/duckdb/src/optimizer/statistics/operator/propagate_join.cpp +2 -6
- package/src/duckdb/src/parallel/pipeline_executor.cpp +1 -55
- package/src/duckdb/src/parser/parsed_data/create_index_info.cpp +3 -0
- package/src/duckdb/src/parser/statement/copy_statement.cpp +2 -13
- package/src/duckdb/src/parser/statement/delete_statement.cpp +3 -0
- package/src/duckdb/src/parser/statement/detach_statement.cpp +15 -0
- package/src/duckdb/src/parser/statement/insert_statement.cpp +9 -0
- package/src/duckdb/src/parser/statement/update_statement.cpp +3 -0
- package/src/duckdb/src/parser/transform/expression/transform_case.cpp +3 -3
- package/src/duckdb/src/parser/transform/statement/transform_create_database.cpp +0 -1
- package/src/duckdb/src/parser/transform/statement/transform_detach.cpp +19 -0
- package/src/duckdb/src/parser/transformer.cpp +2 -0
- package/src/duckdb/src/planner/bind_context.cpp +1 -1
- package/src/duckdb/src/planner/binder/expression/bind_aggregate_expression.cpp +3 -0
- package/src/duckdb/src/planner/binder/statement/bind_copy.cpp +7 -14
- package/src/duckdb/src/planner/binder/statement/bind_create.cpp +16 -14
- package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +13 -0
- package/src/duckdb/src/planner/binder/statement/bind_detach.cpp +19 -0
- package/src/duckdb/src/planner/binder/statement/bind_drop.cpp +29 -4
- package/src/duckdb/src/planner/binder/statement/bind_insert.cpp +22 -1
- package/src/duckdb/src/planner/binder.cpp +2 -0
- package/src/duckdb/src/planner/expression_binder/index_binder.cpp +32 -1
- package/src/duckdb/src/planner/logical_operator.cpp +6 -1
- package/src/duckdb/src/planner/planner.cpp +1 -0
- package/src/duckdb/src/storage/buffer_manager.cpp +105 -26
- package/src/duckdb/src/storage/compression/bitpacking.cpp +16 -7
- package/src/duckdb/src/storage/data_table.cpp +66 -3
- package/src/duckdb/src/storage/index.cpp +1 -1
- package/src/duckdb/src/storage/local_storage.cpp +1 -1
- package/src/duckdb/src/storage/table/column_data.cpp +4 -2
- package/src/duckdb/src/storage/table/update_segment.cpp +15 -0
- package/src/duckdb/src/storage/table_index_list.cpp +1 -2
- package/src/duckdb/src/storage/wal_replay.cpp +68 -0
- package/src/duckdb/src/storage/write_ahead_log.cpp +21 -1
- package/src/duckdb/src/transaction/commit_state.cpp +5 -2
- package/src/duckdb/third_party/concurrentqueue/blockingconcurrentqueue.h +2 -2
- package/src/duckdb/third_party/fmt/include/fmt/core.h +1 -2
- package/src/duckdb/third_party/libpg_query/include/nodes/nodes.hpp +1 -0
- package/src/duckdb/third_party/libpg_query/include/nodes/parsenodes.hpp +14 -0
- package/src/duckdb/third_party/libpg_query/include/parser/gram.hpp +530 -1006
- package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +17659 -17626
- package/src/duckdb/ub_extension_icu_third_party_icu_i18n.cpp +4 -4
- package/src/duckdb/ub_src_execution_operator_schema.cpp +2 -0
- package/src/duckdb/ub_src_function_table_system.cpp +2 -0
- package/src/duckdb/ub_src_parser_statement.cpp +2 -0
- package/src/duckdb/ub_src_parser_transform_statement.cpp +2 -0
- package/src/duckdb/ub_src_planner_binder_statement.cpp +2 -0
- package/src/statement.cpp +46 -12
- package/test/arrow.test.ts +3 -3
- package/test/prepare.test.ts +39 -1
- package/test/typescript_decls.test.ts +1 -1
- package/src/duckdb/src/include/duckdb/function/create_database_extension.hpp +0 -37
|
@@ -299,16 +299,11 @@ Node *Node::Deserialize(ART &art, idx_t block_id, idx_t offset) {
|
|
|
299
299
|
NodeType node_type((NodeType)(n));
|
|
300
300
|
|
|
301
301
|
Node *deserialized_node = nullptr;
|
|
302
|
-
auto old_memory_size = art.memory_size;
|
|
303
302
|
switch (node_type) {
|
|
304
303
|
case NodeType::NLeaf: {
|
|
305
304
|
auto leaf = Leaf::New();
|
|
306
305
|
leaf->Deserialize(art, reader);
|
|
307
|
-
art.
|
|
308
|
-
D_ASSERT(art.memory_size >= old_memory_size);
|
|
309
|
-
if (art.track_memory) {
|
|
310
|
-
art.buffer_manager.IncreaseUsedMemory(art.memory_size - old_memory_size);
|
|
311
|
-
}
|
|
306
|
+
art.IncreaseMemorySize(leaf->MemorySize(art, false));
|
|
312
307
|
return leaf;
|
|
313
308
|
}
|
|
314
309
|
case NodeType::N4: {
|
|
@@ -331,11 +326,7 @@ Node *Node::Deserialize(ART &art, idx_t block_id, idx_t offset) {
|
|
|
331
326
|
throw InternalException("Unrecognized node type");
|
|
332
327
|
}
|
|
333
328
|
deserialized_node->DeserializeInternal(art, reader);
|
|
334
|
-
art.
|
|
335
|
-
D_ASSERT(art.memory_size >= old_memory_size);
|
|
336
|
-
if (art.track_memory) {
|
|
337
|
-
art.buffer_manager.IncreaseUsedMemory(art.memory_size - old_memory_size);
|
|
338
|
-
}
|
|
329
|
+
art.IncreaseMemorySize(deserialized_node->MemorySize(art, false));
|
|
339
330
|
return deserialized_node;
|
|
340
331
|
}
|
|
341
332
|
|
|
@@ -356,12 +347,10 @@ void SwapNodes(MergeInfo &info, ParentsOfNodes &parents) {
|
|
|
356
347
|
auto l_node_memory_size = info.l_node->MemorySize(*info.l_art, true);
|
|
357
348
|
auto r_node_memory_size = info.r_node->MemorySize(*info.r_art, true);
|
|
358
349
|
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
info.root_l_art->
|
|
362
|
-
info.root_r_art->
|
|
363
|
-
info.root_l_art->memory_size += r_node_memory_size;
|
|
364
|
-
info.root_r_art->memory_size += l_node_memory_size;
|
|
350
|
+
info.root_l_art->DecreaseMemorySize(l_node_memory_size);
|
|
351
|
+
info.root_r_art->DecreaseMemorySize(r_node_memory_size);
|
|
352
|
+
info.root_l_art->IncreaseMemorySize(r_node_memory_size);
|
|
353
|
+
info.root_r_art->IncreaseMemorySize(l_node_memory_size);
|
|
365
354
|
|
|
366
355
|
// actual swap
|
|
367
356
|
swap(info.l_art, info.r_art);
|
|
@@ -409,9 +398,8 @@ bool Merge(MergeInfo &info, ParentsOfNodes &parents) {
|
|
|
409
398
|
auto r_memory_size = r_child->MemorySize(*info.r_art, true);
|
|
410
399
|
Node::InsertChild(*info.root_l_art, info.l_node, key_byte, r_child);
|
|
411
400
|
|
|
412
|
-
info.root_l_art->
|
|
413
|
-
|
|
414
|
-
info.root_r_art->memory_size -= r_memory_size;
|
|
401
|
+
info.root_l_art->IncreaseMemorySize(r_memory_size);
|
|
402
|
+
info.root_r_art->DecreaseMemorySize(r_memory_size);
|
|
415
403
|
if (parents.l_parent) {
|
|
416
404
|
parents.l_parent->ReplaceChildPointer(parents.l_pos, info.l_node);
|
|
417
405
|
}
|
|
@@ -473,9 +461,8 @@ bool ResolvePrefixesAndMerge(MergeInfo &info, ParentsOfNodes &parents) {
|
|
|
473
461
|
auto r_memory_size = r_node->MemorySize(*info.r_art, true);
|
|
474
462
|
Node::InsertChild(*info.root_l_art, l_node, mismatch_byte, r_node);
|
|
475
463
|
|
|
476
|
-
info.root_l_art->
|
|
477
|
-
|
|
478
|
-
info.root_r_art->memory_size -= r_memory_size;
|
|
464
|
+
info.root_l_art->IncreaseMemorySize(r_memory_size);
|
|
465
|
+
info.root_r_art->DecreaseMemorySize(r_memory_size);
|
|
479
466
|
UpdateParentsOfNodes(l_node, null_parent, parents);
|
|
480
467
|
r_node = nullptr;
|
|
481
468
|
return true;
|
|
@@ -493,7 +480,7 @@ bool ResolvePrefixesAndMerge(MergeInfo &info, ParentsOfNodes &parents) {
|
|
|
493
480
|
// create new node
|
|
494
481
|
Node *new_node = Node4::New();
|
|
495
482
|
new_node->prefix = Prefix(l_node->prefix, mismatch_pos);
|
|
496
|
-
info.root_l_art->
|
|
483
|
+
info.root_l_art->IncreaseMemorySize(new_node->MemorySize(*info.l_art, false));
|
|
497
484
|
|
|
498
485
|
// insert l_node, break up prefix of l_node
|
|
499
486
|
auto key_byte = l_node->prefix.Reduce(*info.root_l_art, mismatch_pos);
|
|
@@ -504,9 +491,8 @@ bool ResolvePrefixesAndMerge(MergeInfo &info, ParentsOfNodes &parents) {
|
|
|
504
491
|
auto r_memory_size = r_node->MemorySize(*info.r_art, true);
|
|
505
492
|
Node4::InsertChild(*info.root_l_art, new_node, key_byte, r_node);
|
|
506
493
|
|
|
507
|
-
info.root_l_art->
|
|
508
|
-
|
|
509
|
-
info.root_r_art->memory_size -= r_memory_size;
|
|
494
|
+
info.root_l_art->IncreaseMemorySize(r_memory_size);
|
|
495
|
+
info.root_r_art->DecreaseMemorySize(r_memory_size);
|
|
510
496
|
|
|
511
497
|
l_node = new_node;
|
|
512
498
|
UpdateParentsOfNodes(l_node, null_parent, parents);
|
|
@@ -104,7 +104,7 @@ void Node16::InsertChild(ART &art, Node *&node, uint8_t key_byte, Node *new_chil
|
|
|
104
104
|
} else {
|
|
105
105
|
// node is full, grow to Node48
|
|
106
106
|
auto new_node = Node48::New();
|
|
107
|
-
art.
|
|
107
|
+
art.IncreaseMemorySize(new_node->MemorySize(art, false));
|
|
108
108
|
new_node->count = node->count;
|
|
109
109
|
new_node->prefix = std::move(n->prefix);
|
|
110
110
|
|
|
@@ -114,8 +114,7 @@ void Node16::InsertChild(ART &art, Node *&node, uint8_t key_byte, Node *new_chil
|
|
|
114
114
|
n->children[i] = nullptr;
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
|
|
118
|
-
art.memory_size -= node->MemorySize(art, false);
|
|
117
|
+
art.DecreaseMemorySize(node->MemorySize(art, false));
|
|
119
118
|
Node::Delete(node);
|
|
120
119
|
node = new_node;
|
|
121
120
|
Node48::InsertChild(art, node, key_byte, new_child);
|
|
@@ -130,8 +129,7 @@ void Node16::EraseChild(ART &art, Node *&node, idx_t pos) {
|
|
|
130
129
|
// adjust the ART size
|
|
131
130
|
if (n->ChildIsInMemory(pos)) {
|
|
132
131
|
auto child = n->GetChild(art, pos);
|
|
133
|
-
|
|
134
|
-
art.memory_size -= child->MemorySize(art, true);
|
|
132
|
+
art.DecreaseMemorySize(child->MemorySize(art, true));
|
|
135
133
|
}
|
|
136
134
|
|
|
137
135
|
// erase the child and decrease the count
|
|
@@ -155,7 +153,7 @@ void Node16::EraseChild(ART &art, Node *&node, idx_t pos) {
|
|
|
155
153
|
if (node->count < Node4::GetSize()) {
|
|
156
154
|
|
|
157
155
|
auto new_node = Node4::New();
|
|
158
|
-
art.
|
|
156
|
+
art.IncreaseMemorySize(new_node->MemorySize(art, false));
|
|
159
157
|
new_node->prefix = std::move(n->prefix);
|
|
160
158
|
|
|
161
159
|
for (idx_t i = 0; i < n->count; i++) {
|
|
@@ -164,8 +162,7 @@ void Node16::EraseChild(ART &art, Node *&node, idx_t pos) {
|
|
|
164
162
|
n->children[i] = nullptr;
|
|
165
163
|
}
|
|
166
164
|
|
|
167
|
-
|
|
168
|
-
art.memory_size -= node->MemorySize(art, false);
|
|
165
|
+
art.DecreaseMemorySize(node->MemorySize(art, false));
|
|
169
166
|
Node::Delete(node);
|
|
170
167
|
node = new_node;
|
|
171
168
|
}
|
|
@@ -92,8 +92,7 @@ void Node256::EraseChild(ART &art, Node *&node, idx_t pos) {
|
|
|
92
92
|
// adjust the ART size
|
|
93
93
|
if (n->ChildIsInMemory(pos)) {
|
|
94
94
|
auto child = n->GetChild(art, pos);
|
|
95
|
-
|
|
96
|
-
art.memory_size -= child->MemorySize(art, true);
|
|
95
|
+
art.DecreaseMemorySize(child->MemorySize(art, true));
|
|
97
96
|
}
|
|
98
97
|
|
|
99
98
|
// erase the child and decrease the count
|
|
@@ -104,7 +103,7 @@ void Node256::EraseChild(ART &art, Node *&node, idx_t pos) {
|
|
|
104
103
|
if (node->count <= NODE_256_SHRINK_THRESHOLD) {
|
|
105
104
|
|
|
106
105
|
auto new_node = Node48::New();
|
|
107
|
-
art.
|
|
106
|
+
art.IncreaseMemorySize(new_node->MemorySize(art, false));
|
|
108
107
|
new_node->prefix = std::move(n->prefix);
|
|
109
108
|
|
|
110
109
|
for (idx_t i = 0; i < Node256::GetSize(); i++) {
|
|
@@ -115,8 +114,7 @@ void Node256::EraseChild(ART &art, Node *&node, idx_t pos) {
|
|
|
115
114
|
}
|
|
116
115
|
}
|
|
117
116
|
|
|
118
|
-
|
|
119
|
-
art.memory_size -= node->MemorySize(art, false);
|
|
117
|
+
art.DecreaseMemorySize(node->MemorySize(art, false));
|
|
120
118
|
Node::Delete(node);
|
|
121
119
|
node = new_node;
|
|
122
120
|
}
|
|
@@ -101,7 +101,7 @@ void Node4::InsertChild(ART &art, Node *&node, uint8_t key_byte, Node *new_child
|
|
|
101
101
|
} else {
|
|
102
102
|
// node is full, grow to Node16
|
|
103
103
|
auto new_node = Node16::New();
|
|
104
|
-
art.
|
|
104
|
+
art.IncreaseMemorySize(new_node->MemorySize(art, false));
|
|
105
105
|
new_node->count = n->count;
|
|
106
106
|
new_node->prefix = std::move(node->prefix);
|
|
107
107
|
|
|
@@ -112,8 +112,7 @@ void Node4::InsertChild(ART &art, Node *&node, uint8_t key_byte, Node *new_child
|
|
|
112
112
|
}
|
|
113
113
|
n->count = 0;
|
|
114
114
|
|
|
115
|
-
|
|
116
|
-
art.memory_size -= node->MemorySize(art, false);
|
|
115
|
+
art.DecreaseMemorySize(node->MemorySize(art, false));
|
|
117
116
|
Node::Delete(node);
|
|
118
117
|
node = new_node;
|
|
119
118
|
Node16::InsertChild(art, node, key_byte, new_child);
|
|
@@ -129,8 +128,7 @@ void Node4::EraseChild(ART &art, Node *&node, idx_t pos) {
|
|
|
129
128
|
// adjust the ART size
|
|
130
129
|
if (n->ChildIsInMemory(pos)) {
|
|
131
130
|
auto child = n->GetChild(art, pos);
|
|
132
|
-
|
|
133
|
-
art.memory_size -= child->MemorySize(art, true);
|
|
131
|
+
art.DecreaseMemorySize(child->MemorySize(art, true));
|
|
134
132
|
}
|
|
135
133
|
|
|
136
134
|
// erase the child and decrease the count
|
|
@@ -158,8 +156,7 @@ void Node4::EraseChild(ART &art, Node *&node, idx_t pos) {
|
|
|
158
156
|
// ensure that when deleting the node, we do not delete the child (because we move it)
|
|
159
157
|
n->children[0] = nullptr;
|
|
160
158
|
|
|
161
|
-
|
|
162
|
-
art.memory_size -= n->MemorySize(art, false);
|
|
159
|
+
art.DecreaseMemorySize(n->MemorySize(art, false));
|
|
163
160
|
Node::Delete(node);
|
|
164
161
|
node = child_ref;
|
|
165
162
|
}
|
|
@@ -105,7 +105,7 @@ void Node48::InsertChild(ART &art, Node *&node, uint8_t key_byte, Node *new_chil
|
|
|
105
105
|
} else {
|
|
106
106
|
// node is full, grow to Node256
|
|
107
107
|
auto new_node = Node256::New();
|
|
108
|
-
art.
|
|
108
|
+
art.IncreaseMemorySize(new_node->MemorySize(art, false));
|
|
109
109
|
new_node->count = n->count;
|
|
110
110
|
new_node->prefix = std::move(n->prefix);
|
|
111
111
|
|
|
@@ -116,8 +116,7 @@ void Node48::InsertChild(ART &art, Node *&node, uint8_t key_byte, Node *new_chil
|
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
|
|
120
|
-
art.memory_size -= node->MemorySize(art, false);
|
|
119
|
+
art.DecreaseMemorySize(node->MemorySize(art, false));
|
|
121
120
|
Node::Delete(node);
|
|
122
121
|
node = new_node;
|
|
123
122
|
Node256::InsertChild(art, node, key_byte, new_child);
|
|
@@ -130,8 +129,7 @@ void Node48::EraseChild(ART &art, Node *&node, idx_t pos) {
|
|
|
130
129
|
// adjust the ART size
|
|
131
130
|
if (n->ChildIsInMemory(pos)) {
|
|
132
131
|
auto child = n->GetChild(art, pos);
|
|
133
|
-
|
|
134
|
-
art.memory_size -= child->MemorySize(art, true);
|
|
132
|
+
art.DecreaseMemorySize(child->MemorySize(art, true));
|
|
135
133
|
}
|
|
136
134
|
|
|
137
135
|
// erase the child and decrease the count
|
|
@@ -143,7 +141,7 @@ void Node48::EraseChild(ART &art, Node *&node, idx_t pos) {
|
|
|
143
141
|
if (node->count < NODE_48_SHRINK_THRESHOLD) {
|
|
144
142
|
|
|
145
143
|
auto new_node = Node16::New();
|
|
146
|
-
art.
|
|
144
|
+
art.IncreaseMemorySize(new_node->MemorySize(art, false));
|
|
147
145
|
new_node->prefix = std::move(n->prefix);
|
|
148
146
|
|
|
149
147
|
for (idx_t i = 0; i < Node256::GetSize(); i++) {
|
|
@@ -154,8 +152,7 @@ void Node48::EraseChild(ART &art, Node *&node, idx_t pos) {
|
|
|
154
152
|
}
|
|
155
153
|
}
|
|
156
154
|
|
|
157
|
-
|
|
158
|
-
art.memory_size -= node->MemorySize(art, false);
|
|
155
|
+
art.DecreaseMemorySize(node->MemorySize(art, false));
|
|
159
156
|
Node::Delete(node);
|
|
160
157
|
node = new_node;
|
|
161
158
|
}
|
|
@@ -113,7 +113,7 @@ void Prefix::Overwrite(uint32_t new_size, uint8_t *data) {
|
|
|
113
113
|
|
|
114
114
|
void Prefix::Concatenate(ART &art, uint8_t key, Prefix &other) {
|
|
115
115
|
auto new_size = size + 1 + other.size;
|
|
116
|
-
art.
|
|
116
|
+
art.IncreaseMemorySize((new_size - size) * sizeof(uint8_t));
|
|
117
117
|
// have to allocate space in our prefix array
|
|
118
118
|
auto new_prefix = AllocateArray<uint8_t>(new_size);
|
|
119
119
|
idx_t new_prefix_idx = 0;
|
|
@@ -136,8 +136,7 @@ void Prefix::Concatenate(ART &art, uint8_t key, Prefix &other) {
|
|
|
136
136
|
|
|
137
137
|
uint8_t Prefix::Reduce(ART &art, uint32_t n) {
|
|
138
138
|
auto new_size = size - n - 1;
|
|
139
|
-
|
|
140
|
-
art.memory_size -= (size - new_size) * sizeof(uint8_t);
|
|
139
|
+
art.DecreaseMemorySize((size - new_size) * sizeof(uint8_t));
|
|
141
140
|
auto prefix = GetPrefixData();
|
|
142
141
|
auto partial_key = prefix[n];
|
|
143
142
|
|
|
@@ -169,6 +169,10 @@ private:
|
|
|
169
169
|
};
|
|
170
170
|
|
|
171
171
|
void WindowGlobalSinkState::ResizeGroupingData(idx_t cardinality) {
|
|
172
|
+
// Have we started to combine? Then just live with it.
|
|
173
|
+
if (grouping_data && !grouping_data->GetPartitions().empty()) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
172
176
|
// Is the average partition size too large?
|
|
173
177
|
const idx_t partition_size = STANDARD_ROW_GROUPS_SIZE;
|
|
174
178
|
const auto bits = grouping_data ? grouping_data->GetRadixBits() : 0;
|
|
@@ -180,31 +184,7 @@ void WindowGlobalSinkState::ResizeGroupingData(idx_t cardinality) {
|
|
|
180
184
|
// Repartition the grouping data
|
|
181
185
|
if (new_bits != bits) {
|
|
182
186
|
const auto hash_col_idx = payload_types.size();
|
|
183
|
-
|
|
184
|
-
make_unique<RadixPartitionedColumnData>(context, grouping_types, new_bits, hash_col_idx);
|
|
185
|
-
|
|
186
|
-
// We have to append to a shared copy for some reason
|
|
187
|
-
if (grouping_data) {
|
|
188
|
-
auto new_shared = new_grouping_data->CreateShared();
|
|
189
|
-
PartitionedColumnDataAppendState shared_append;
|
|
190
|
-
new_shared->InitializeAppendState(shared_append);
|
|
191
|
-
|
|
192
|
-
auto &partitions = grouping_data->GetPartitions();
|
|
193
|
-
for (auto &partition : partitions) {
|
|
194
|
-
ColumnDataScanState scanner;
|
|
195
|
-
partition->InitializeScan(scanner);
|
|
196
|
-
|
|
197
|
-
DataChunk scan_chunk;
|
|
198
|
-
partition->InitializeScanChunk(scan_chunk);
|
|
199
|
-
for (scan_chunk.Reset(); partition->Scan(scanner, scan_chunk); scan_chunk.Reset()) {
|
|
200
|
-
new_shared->Append(shared_append, scan_chunk);
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
new_shared->FlushAppendState(shared_append);
|
|
204
|
-
new_grouping_data->Combine(*new_shared);
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
grouping_data = std::move(new_grouping_data);
|
|
187
|
+
grouping_data = make_unique<RadixPartitionedColumnData>(context, grouping_types, new_bits, hash_col_idx);
|
|
208
188
|
}
|
|
209
189
|
}
|
|
210
190
|
|
|
@@ -432,8 +412,6 @@ void WindowLocalSinkState::Sink(DataChunk &input_chunk, WindowGlobalSinkState &g
|
|
|
432
412
|
}
|
|
433
413
|
|
|
434
414
|
// OVER(...)
|
|
435
|
-
gstate.UpdateLocalPartition(local_partition, local_append);
|
|
436
|
-
|
|
437
415
|
payload_chunk.Reset();
|
|
438
416
|
auto &hash_vector = payload_chunk.data.back();
|
|
439
417
|
Hash(input_chunk, hash_vector);
|
|
@@ -442,6 +420,7 @@ void WindowLocalSinkState::Sink(DataChunk &input_chunk, WindowGlobalSinkState &g
|
|
|
442
420
|
}
|
|
443
421
|
payload_chunk.SetCardinality(input_chunk);
|
|
444
422
|
|
|
423
|
+
gstate.UpdateLocalPartition(local_partition, local_append);
|
|
445
424
|
local_partition->Append(*local_append, payload_chunk);
|
|
446
425
|
}
|
|
447
426
|
|
|
@@ -27,15 +27,7 @@ void PhysicalReset::GetData(ExecutionContext &context, DataChunk &chunk, GlobalS
|
|
|
27
27
|
auto &config = DBConfig::GetConfig(context.client);
|
|
28
28
|
auto entry = config.extension_parameters.find(name);
|
|
29
29
|
if (entry == config.extension_parameters.end()) {
|
|
30
|
-
|
|
31
|
-
// get a list of all options
|
|
32
|
-
vector<string> potential_names = DBConfig::GetOptionNames();
|
|
33
|
-
for (auto &entry : config.extension_parameters) {
|
|
34
|
-
potential_names.push_back(entry.first);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
throw CatalogException("unrecognized configuration parameter \"%s\"\n%s", name,
|
|
38
|
-
StringUtil::CandidatesErrorMessage(potential_names, name, "Did you mean"));
|
|
30
|
+
throw Catalog::UnrecognizedConfigurationError(context.client, name);
|
|
39
31
|
}
|
|
40
32
|
ResetExtensionVariable(context, config, entry->second);
|
|
41
33
|
return;
|
|
@@ -30,15 +30,7 @@ void PhysicalSet::GetData(ExecutionContext &context, DataChunk &chunk, GlobalSou
|
|
|
30
30
|
auto &config = DBConfig::GetConfig(context.client);
|
|
31
31
|
auto entry = config.extension_parameters.find(name);
|
|
32
32
|
if (entry == config.extension_parameters.end()) {
|
|
33
|
-
|
|
34
|
-
// get a list of all options
|
|
35
|
-
vector<string> potential_names = DBConfig::GetOptionNames();
|
|
36
|
-
for (auto &entry : config.extension_parameters) {
|
|
37
|
-
potential_names.push_back(entry.first);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
throw CatalogException("unrecognized configuration parameter \"%s\"\n%s", name,
|
|
41
|
-
StringUtil::CandidatesErrorMessage(potential_names, name, "Did you mean"));
|
|
33
|
+
throw Catalog::UnrecognizedConfigurationError(context.client, name);
|
|
42
34
|
}
|
|
43
35
|
SetExtensionVariable(context.client, entry->second, name, scope, value);
|
|
44
36
|
return;
|
|
@@ -664,6 +664,7 @@ public:
|
|
|
664
664
|
if (!matches[outer_idx]) {
|
|
665
665
|
true_sel.set_index(count++, outer_idx);
|
|
666
666
|
if (count >= STANDARD_VECTOR_SIZE) {
|
|
667
|
+
outer_idx++;
|
|
667
668
|
break;
|
|
668
669
|
}
|
|
669
670
|
}
|
|
@@ -847,8 +848,6 @@ public:
|
|
|
847
848
|
|
|
848
849
|
lstate.joiner = make_unique<IEJoinUnion>(client, op, left_table, b1, right_table, b2);
|
|
849
850
|
return;
|
|
850
|
-
} else {
|
|
851
|
-
--next_pair;
|
|
852
851
|
}
|
|
853
852
|
|
|
854
853
|
// Outer joins
|
|
@@ -864,6 +863,7 @@ public:
|
|
|
864
863
|
// Left outer blocks
|
|
865
864
|
const auto l = next_left++;
|
|
866
865
|
if (l < left_outers) {
|
|
866
|
+
lstate.joiner = nullptr;
|
|
867
867
|
lstate.left_block_index = l;
|
|
868
868
|
lstate.left_base = left_bases[l];
|
|
869
869
|
|
|
@@ -873,12 +873,12 @@ public:
|
|
|
873
873
|
return;
|
|
874
874
|
} else {
|
|
875
875
|
lstate.left_matches = nullptr;
|
|
876
|
-
--next_left;
|
|
877
876
|
}
|
|
878
877
|
|
|
879
878
|
// Right outer block
|
|
880
879
|
const auto r = next_right++;
|
|
881
880
|
if (r < right_outers) {
|
|
881
|
+
lstate.joiner = nullptr;
|
|
882
882
|
lstate.right_block_index = r;
|
|
883
883
|
lstate.right_base = right_bases[r];
|
|
884
884
|
|
|
@@ -888,7 +888,6 @@ public:
|
|
|
888
888
|
return;
|
|
889
889
|
} else {
|
|
890
890
|
lstate.right_matches = nullptr;
|
|
891
|
-
--next_right;
|
|
892
891
|
}
|
|
893
892
|
}
|
|
894
893
|
|
|
@@ -936,7 +935,7 @@ void PhysicalIEJoin::GetData(ExecutionContext &context, DataChunk &result, Globa
|
|
|
936
935
|
|
|
937
936
|
ie_gstate.Initialize(ie_sink);
|
|
938
937
|
|
|
939
|
-
if (!ie_lstate.joiner) {
|
|
938
|
+
if (!ie_lstate.joiner && !ie_lstate.left_matches && !ie_lstate.right_matches) {
|
|
940
939
|
ie_gstate.GetNextPair(context.client, ie_sink, ie_lstate);
|
|
941
940
|
}
|
|
942
941
|
|
|
@@ -959,8 +958,7 @@ void PhysicalIEJoin::GetData(ExecutionContext &context, DataChunk &result, Globa
|
|
|
959
958
|
ie_gstate.GetNextPair(context.client, ie_sink, ie_lstate);
|
|
960
959
|
continue;
|
|
961
960
|
}
|
|
962
|
-
|
|
963
|
-
SliceSortedPayload(result, ie_sink.tables[0]->global_sort_state, ie_lstate.left_base, ie_lstate.true_sel,
|
|
961
|
+
SliceSortedPayload(result, ie_sink.tables[0]->global_sort_state, ie_lstate.left_block_index, ie_lstate.true_sel,
|
|
964
962
|
count);
|
|
965
963
|
|
|
966
964
|
// Fill in NULLs to the right
|
|
@@ -983,8 +981,8 @@ void PhysicalIEJoin::GetData(ExecutionContext &context, DataChunk &result, Globa
|
|
|
983
981
|
continue;
|
|
984
982
|
}
|
|
985
983
|
|
|
986
|
-
SliceSortedPayload(result, ie_sink.tables[1]->global_sort_state, ie_lstate.
|
|
987
|
-
count, left_cols);
|
|
984
|
+
SliceSortedPayload(result, ie_sink.tables[1]->global_sort_state, ie_lstate.right_block_index,
|
|
985
|
+
ie_lstate.true_sel, count, left_cols);
|
|
988
986
|
|
|
989
987
|
// Fill in NULLs to the left
|
|
990
988
|
for (idx_t col_idx = 0; col_idx < left_cols; ++col_idx) {
|
|
@@ -30,15 +30,10 @@ string BaseCSVReader::GetLineNumberStr(idx_t linenr, bool linenr_estimated) {
|
|
|
30
30
|
return to_string(linenr + 1) + estimated;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
BaseCSVReader::BaseCSVReader(
|
|
34
|
-
BufferedCSVReaderOptions options_p, const vector<LogicalType> &requested_types)
|
|
35
|
-
: fs(fs_p), allocator(allocator), opener(opener_p), options(std::move(options_p)) {
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
BaseCSVReader::BaseCSVReader(ClientContext &context, BufferedCSVReaderOptions options_p,
|
|
33
|
+
BaseCSVReader::BaseCSVReader(ClientContext &context_p, BufferedCSVReaderOptions options_p,
|
|
39
34
|
const vector<LogicalType> &requested_types)
|
|
40
|
-
:
|
|
41
|
-
|
|
35
|
+
: context(context_p), fs(FileSystem::GetFileSystem(context)), allocator(Allocator::Get(context)),
|
|
36
|
+
opener(FileSystem::GetFileOpener(context)), options(std::move(options_p)) {
|
|
42
37
|
}
|
|
43
38
|
|
|
44
39
|
BaseCSVReader::~BaseCSVReader() {
|
|
@@ -144,7 +139,7 @@ bool BaseCSVReader::TryCastValue(const Value &value, const LogicalType &sql_type
|
|
|
144
139
|
} else {
|
|
145
140
|
Value new_value;
|
|
146
141
|
string error_message;
|
|
147
|
-
return value.
|
|
142
|
+
return value.TryCastAs(context, sql_type, new_value, &error_message, true);
|
|
148
143
|
}
|
|
149
144
|
}
|
|
150
145
|
|
|
@@ -481,8 +476,8 @@ bool BaseCSVReader::Flush(DataChunk &insert_chunk, bool try_add_line) {
|
|
|
481
476
|
error_message, return_types[col_idx]);
|
|
482
477
|
} else {
|
|
483
478
|
// target type is not varchar: perform a cast
|
|
484
|
-
success = VectorOperations::
|
|
485
|
-
|
|
479
|
+
success = VectorOperations::TryCast(context, parse_chunk.data[col_idx], insert_chunk.data[insert_idx],
|
|
480
|
+
parse_chunk.size(), &error_message);
|
|
486
481
|
}
|
|
487
482
|
if (success) {
|
|
488
483
|
continue;
|
|
@@ -23,25 +23,16 @@
|
|
|
23
23
|
|
|
24
24
|
namespace duckdb {
|
|
25
25
|
|
|
26
|
-
BufferedCSVReader::BufferedCSVReader(FileSystem &fs_p, Allocator &allocator, FileOpener *opener_p,
|
|
27
|
-
BufferedCSVReaderOptions options_p, const vector<LogicalType> &requested_types)
|
|
28
|
-
: BaseCSVReader(fs_p, allocator, opener_p, std::move(options_p), requested_types), buffer_size(0), position(0),
|
|
29
|
-
start(0) {
|
|
30
|
-
file_handle = OpenCSV(options);
|
|
31
|
-
Initialize(requested_types);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
26
|
BufferedCSVReader::BufferedCSVReader(ClientContext &context, BufferedCSVReaderOptions options_p,
|
|
35
27
|
const vector<LogicalType> &requested_types)
|
|
36
|
-
:
|
|
37
|
-
|
|
28
|
+
: BaseCSVReader(context, std::move(options_p), requested_types), buffer_size(0), position(0), start(0) {
|
|
29
|
+
file_handle = OpenCSV(options);
|
|
30
|
+
Initialize(requested_types);
|
|
38
31
|
}
|
|
39
32
|
|
|
40
33
|
BufferedCSVReader::BufferedCSVReader(ClientContext &context, string filename, BufferedCSVReaderOptions options_p,
|
|
41
34
|
const vector<LogicalType> &requested_types)
|
|
42
|
-
: BaseCSVReader(
|
|
43
|
-
std::move(options_p), requested_types),
|
|
44
|
-
buffer_size(0), position(0), start(0) {
|
|
35
|
+
: BaseCSVReader(context, std::move(options_p), requested_types), buffer_size(0), position(0), start(0) {
|
|
45
36
|
options.file_path = std::move(filename);
|
|
46
37
|
file_handle = OpenCSV(options);
|
|
47
38
|
Initialize(requested_types);
|
|
@@ -730,6 +721,9 @@ void BufferedCSVReader::DetectHeader(const vector<vector<LogicalType>> &best_sql
|
|
|
730
721
|
names.push_back(column_name);
|
|
731
722
|
}
|
|
732
723
|
}
|
|
724
|
+
for (idx_t i = 0; i < MinValue<idx_t>(names.size(), options.name_list.size()); i++) {
|
|
725
|
+
names[i] = options.name_list[i];
|
|
726
|
+
}
|
|
733
727
|
}
|
|
734
728
|
|
|
735
729
|
vector<LogicalType> BufferedCSVReader::RefineTypeDetection(const vector<LogicalType> &type_candidates,
|
|
@@ -899,6 +893,12 @@ vector<LogicalType> BufferedCSVReader::SniffCSV(const vector<LogicalType> &reque
|
|
|
899
893
|
DetectCandidateTypes(type_candidates, format_template_candidates, info_candidates, original_options, best_num_cols,
|
|
900
894
|
best_sql_types_candidates, best_format_candidates, best_header_row);
|
|
901
895
|
|
|
896
|
+
if (best_format_candidates.empty() || best_header_row.size() == 0) {
|
|
897
|
+
throw InvalidInputException(
|
|
898
|
+
"Error in file \"%s\": CSV options could not be auto-detected. Consider setting parser options manually.",
|
|
899
|
+
original_options.file_path);
|
|
900
|
+
}
|
|
901
|
+
|
|
902
902
|
// #######
|
|
903
903
|
// ### header detection
|
|
904
904
|
// #######
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
#include "duckdb/execution/operator/schema/physical_detach.hpp"
|
|
2
|
+
#include "duckdb/parser/parsed_data/detach_info.hpp"
|
|
3
|
+
#include "duckdb/catalog/catalog.hpp"
|
|
4
|
+
#include "duckdb/main/database_manager.hpp"
|
|
5
|
+
#include "duckdb/main/attached_database.hpp"
|
|
6
|
+
#include "duckdb/main/database.hpp"
|
|
7
|
+
#include "duckdb/storage/storage_extension.hpp"
|
|
8
|
+
|
|
9
|
+
namespace duckdb {
|
|
10
|
+
|
|
11
|
+
//===--------------------------------------------------------------------===//
|
|
12
|
+
// Source
|
|
13
|
+
//===--------------------------------------------------------------------===//
|
|
14
|
+
class DetachSourceState : public GlobalSourceState {
|
|
15
|
+
public:
|
|
16
|
+
DetachSourceState() : finished(false) {
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
bool finished;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
unique_ptr<GlobalSourceState> PhysicalDetach::GetGlobalSourceState(ClientContext &context) const {
|
|
23
|
+
return make_unique<DetachSourceState>();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
void PhysicalDetach::GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
|
|
27
|
+
LocalSourceState &lstate) const {
|
|
28
|
+
auto &state = (DetachSourceState &)gstate;
|
|
29
|
+
if (state.finished) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
auto &db_manager = DatabaseManager::Get(context.client);
|
|
33
|
+
db_manager.DetachDatabase(context.client, info->name, info->if_exists);
|
|
34
|
+
state.finished = true;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
} // namespace duckdb
|
|
@@ -38,11 +38,6 @@ void PhysicalDrop::GetData(ExecutionContext &context, DataChunk &chunk, GlobalSo
|
|
|
38
38
|
}
|
|
39
39
|
break;
|
|
40
40
|
}
|
|
41
|
-
case CatalogType::DATABASE_ENTRY: {
|
|
42
|
-
auto &db_manager = DatabaseManager::Get(context.client);
|
|
43
|
-
db_manager.DetachDatabase(context.client, info->name, info->if_exists);
|
|
44
|
-
break;
|
|
45
|
-
}
|
|
46
41
|
case CatalogType::SCHEMA_ENTRY: {
|
|
47
42
|
auto &catalog = Catalog::GetCatalog(context.client, info->catalog);
|
|
48
43
|
catalog.DropEntry(context.client, info.get());
|
|
@@ -252,15 +252,15 @@ OperatorResultType CachingPhysicalOperator::Execute(ExecutionContext &context, D
|
|
|
252
252
|
if (!state.initialized) {
|
|
253
253
|
state.initialized = true;
|
|
254
254
|
state.can_cache_chunk = true;
|
|
255
|
+
|
|
255
256
|
if (!context.pipeline || !caching_supported) {
|
|
256
257
|
state.can_cache_chunk = false;
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
if (context.pipeline->GetSink() && context.pipeline->GetSink()->RequiresBatchIndex()) {
|
|
258
|
+
} else if (!context.pipeline->GetSink()) {
|
|
259
|
+
// Disabling for pipelines without Sink, i.e. when pulling
|
|
260
260
|
state.can_cache_chunk = false;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
if (context.pipeline->IsOrderDependent()) {
|
|
261
|
+
} else if (context.pipeline->GetSink()->RequiresBatchIndex()) {
|
|
262
|
+
state.can_cache_chunk = false;
|
|
263
|
+
} else if (context.pipeline->IsOrderDependent()) {
|
|
264
264
|
state.can_cache_chunk = false;
|
|
265
265
|
}
|
|
266
266
|
}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
#include "duckdb/execution/operator/schema/physical_create_schema.hpp"
|
|
7
7
|
#include "duckdb/execution/operator/schema/physical_create_sequence.hpp"
|
|
8
8
|
#include "duckdb/execution/operator/schema/physical_create_view.hpp"
|
|
9
|
+
#include "duckdb/execution/operator/schema/physical_detach.hpp"
|
|
9
10
|
#include "duckdb/execution/operator/schema/physical_drop.hpp"
|
|
10
11
|
#include "duckdb/execution/physical_plan_generator.hpp"
|
|
11
12
|
#include "duckdb/planner/logical_operator.hpp"
|
|
@@ -39,6 +40,9 @@ unique_ptr<PhysicalOperator> PhysicalPlanGenerator::CreatePlan(LogicalSimple &op
|
|
|
39
40
|
case LogicalOperatorType::LOGICAL_ATTACH:
|
|
40
41
|
return make_unique<PhysicalAttach>(unique_ptr_cast<ParseInfo, AttachInfo>(std::move(op.info)),
|
|
41
42
|
op.estimated_cardinality);
|
|
43
|
+
case LogicalOperatorType::LOGICAL_DETACH:
|
|
44
|
+
return make_unique<PhysicalDetach>(unique_ptr_cast<ParseInfo, DetachInfo>(std::move(op.info)),
|
|
45
|
+
op.estimated_cardinality);
|
|
42
46
|
default:
|
|
43
47
|
throw NotImplementedException("Unimplemented type for logical simple operator");
|
|
44
48
|
}
|
|
@@ -184,6 +184,7 @@ unique_ptr<PhysicalOperator> PhysicalPlanGenerator::CreatePlan(LogicalOperator &
|
|
|
184
184
|
case LogicalOperatorType::LOGICAL_VACUUM:
|
|
185
185
|
case LogicalOperatorType::LOGICAL_LOAD:
|
|
186
186
|
case LogicalOperatorType::LOGICAL_ATTACH:
|
|
187
|
+
case LogicalOperatorType::LOGICAL_DETACH:
|
|
187
188
|
plan = CreatePlan((LogicalSimple &)op);
|
|
188
189
|
break;
|
|
189
190
|
case LogicalOperatorType::LOGICAL_RECURSIVE_CTE:
|