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.
- package/binding.gyp +1 -0
- package/package.json +1 -1
- package/src/duckdb/src/catalog/catalog.cpp +18 -17
- package/src/duckdb/src/catalog/catalog_entry/duck_table_entry.cpp +0 -4
- package/src/duckdb/src/catalog/catalog_entry/table_catalog_entry.cpp +0 -4
- package/src/duckdb/src/catalog/catalog_set.cpp +3 -3
- package/src/duckdb/src/common/adbc/adbc.cpp +441 -0
- package/src/duckdb/src/common/adbc/driver_manager.cpp +749 -0
- package/src/duckdb/src/common/arrow/arrow_wrapper.cpp +1 -1
- package/src/duckdb/src/common/tree_renderer.cpp +3 -3
- package/src/duckdb/src/common/types/conflict_manager.cpp +2 -1
- package/src/duckdb/src/execution/column_binding_resolver.cpp +1 -1
- package/src/duckdb/src/execution/operator/aggregate/physical_ungrouped_aggregate.cpp +1 -1
- package/src/duckdb/src/execution/operator/filter/physical_filter.cpp +2 -2
- package/src/duckdb/src/execution/operator/helper/physical_execute.cpp +2 -2
- package/src/duckdb/src/execution/operator/helper/physical_result_collector.cpp +5 -5
- package/src/duckdb/src/execution/operator/join/physical_cross_product.cpp +1 -1
- package/src/duckdb/src/execution/operator/join/physical_delim_join.cpp +11 -10
- package/src/duckdb/src/execution/operator/join/physical_hash_join.cpp +3 -3
- package/src/duckdb/src/execution/operator/join/physical_iejoin.cpp +9 -9
- package/src/duckdb/src/execution/operator/join/physical_index_join.cpp +4 -4
- package/src/duckdb/src/execution/operator/join/physical_join.cpp +7 -7
- package/src/duckdb/src/execution/operator/join/physical_nested_loop_join.cpp +3 -3
- package/src/duckdb/src/execution/operator/join/physical_piecewise_merge_join.cpp +3 -3
- package/src/duckdb/src/execution/operator/join/physical_positional_join.cpp +2 -2
- package/src/duckdb/src/execution/operator/persistent/csv_reader_options.cpp +8 -9
- package/src/duckdb/src/execution/operator/persistent/physical_batch_insert.cpp +20 -19
- package/src/duckdb/src/execution/operator/persistent/physical_export.cpp +3 -3
- package/src/duckdb/src/execution/operator/persistent/physical_insert.cpp +25 -24
- package/src/duckdb/src/execution/operator/persistent/physical_update.cpp +1 -1
- package/src/duckdb/src/execution/operator/projection/physical_projection.cpp +2 -2
- package/src/duckdb/src/execution/operator/scan/physical_column_data_scan.cpp +12 -6
- package/src/duckdb/src/execution/operator/set/physical_recursive_cte.cpp +10 -11
- package/src/duckdb/src/execution/operator/set/physical_union.cpp +2 -2
- package/src/duckdb/src/execution/physical_operator.cpp +13 -13
- package/src/duckdb/src/execution/physical_plan/plan_column_data_get.cpp +2 -4
- package/src/duckdb/src/execution/physical_plan/plan_comparison_join.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_create_table.cpp +5 -5
- package/src/duckdb/src/execution/physical_plan/plan_delete.cpp +3 -3
- package/src/duckdb/src/execution/physical_plan/plan_delim_join.cpp +6 -7
- package/src/duckdb/src/execution/physical_plan/plan_explain.cpp +2 -4
- package/src/duckdb/src/execution/physical_plan/plan_insert.cpp +2 -2
- package/src/duckdb/src/execution/physical_plan/plan_show_select.cpp +2 -4
- package/src/duckdb/src/execution/physical_plan/plan_update.cpp +3 -3
- package/src/duckdb/src/function/compression_config.cpp +9 -9
- package/src/duckdb/src/function/scalar/date/strftime.cpp +1 -1
- package/src/duckdb/src/function/table/copy_csv.cpp +5 -0
- package/src/duckdb/src/function/table/pragma_detailed_profiling_output.cpp +6 -5
- package/src/duckdb/src/function/table/pragma_last_profiling_output.cpp +7 -5
- package/src/duckdb/src/function/table/system/duckdb_databases.cpp +1 -1
- package/src/duckdb/src/function/table/system/duckdb_dependencies.cpp +1 -1
- package/src/duckdb/src/function/table/system/duckdb_extensions.cpp +1 -1
- package/src/duckdb/src/function/table/system/duckdb_indexes.cpp +1 -1
- package/src/duckdb/src/function/table/system/duckdb_keywords.cpp +1 -1
- package/src/duckdb/src/function/table/system/duckdb_schemas.cpp +1 -1
- package/src/duckdb/src/function/table/system/duckdb_sequences.cpp +1 -1
- package/src/duckdb/src/function/table/system/duckdb_settings.cpp +1 -1
- package/src/duckdb/src/function/table/system/duckdb_tables.cpp +1 -1
- package/src/duckdb/src/function/table/system/duckdb_temporary_files.cpp +1 -1
- package/src/duckdb/src/function/table/system/duckdb_types.cpp +1 -1
- package/src/duckdb/src/function/table/system/pragma_collations.cpp +1 -1
- package/src/duckdb/src/function/table/system/pragma_database_size.cpp +1 -1
- package/src/duckdb/src/function/table/system/pragma_storage_info.cpp +5 -5
- package/src/duckdb/src/function/table/system/pragma_table_info.cpp +1 -1
- package/src/duckdb/src/function/table/system/test_all_types.cpp +1 -1
- package/src/duckdb/src/function/table/table_scan.cpp +3 -4
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +3 -3
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_table_entry.hpp +1 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_catalog_entry.hpp +1 -2
- package/src/duckdb/src/include/duckdb/common/adbc/adbc-init.hpp +37 -0
- package/src/duckdb/src/include/duckdb/common/adbc/adbc.h +1088 -0
- package/src/duckdb/src/include/duckdb/common/adbc/adbc.hpp +85 -0
- package/src/duckdb/src/include/duckdb/common/adbc/driver_manager.h +84 -0
- package/src/duckdb/src/include/duckdb/common/helper.hpp +3 -0
- package/src/duckdb/src/include/duckdb/common/types/conflict_manager.hpp +3 -2
- package/src/duckdb/src/include/duckdb/common/types.hpp +0 -1
- package/src/duckdb/src/include/duckdb/execution/executor.hpp +7 -7
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_execute.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_result_collector.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_cross_product.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_delim_join.hpp +3 -3
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_index_join.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_join.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_positional_join.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_reader_options.hpp +2 -1
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_batch_insert.hpp +2 -2
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_export.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_insert.hpp +2 -2
- package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_column_data_scan.hpp +3 -4
- package/src/duckdb/src/include/duckdb/execution/operator/set/physical_recursive_cte.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/set/physical_union.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/physical_operator.hpp +3 -3
- package/src/duckdb/src/include/duckdb/execution/physical_operator_states.hpp +1 -1
- package/src/duckdb/src/include/duckdb/function/cast/cast_function_set.hpp +1 -1
- package/src/duckdb/src/include/duckdb/main/config.hpp +2 -2
- package/src/duckdb/src/include/duckdb/main/query_profiler.hpp +10 -9
- package/src/duckdb/src/include/duckdb/parallel/meta_pipeline.hpp +4 -4
- package/src/duckdb/src/include/duckdb/parallel/pipeline.hpp +18 -17
- package/src/duckdb/src/include/duckdb/parallel/pipeline_executor.hpp +2 -2
- package/src/duckdb/src/include/duckdb/planner/bind_context.hpp +14 -17
- package/src/duckdb/src/include/duckdb/planner/binder.hpp +6 -6
- package/src/duckdb/src/include/duckdb/planner/expression_binder/index_binder.hpp +4 -4
- package/src/duckdb/src/include/duckdb/planner/expression_binder/where_binder.hpp +2 -2
- package/src/duckdb/src/include/duckdb/planner/operator/logical_create.hpp +3 -2
- package/src/duckdb/src/include/duckdb/planner/operator/logical_create_table.hpp +2 -2
- package/src/duckdb/src/include/duckdb/planner/operator/logical_delete.hpp +2 -2
- package/src/duckdb/src/include/duckdb/planner/operator/logical_insert.hpp +2 -2
- package/src/duckdb/src/include/duckdb/planner/operator/logical_update.hpp +2 -2
- package/src/duckdb/src/include/duckdb/planner/parsed_data/bound_create_function_info.hpp +3 -2
- package/src/duckdb/src/include/duckdb/planner/parsed_data/bound_create_table_info.hpp +3 -2
- package/src/duckdb/src/include/duckdb/planner/table_binding.hpp +6 -5
- package/src/duckdb/src/include/duckdb/planner/tableref/bound_basetableref.hpp +2 -2
- package/src/duckdb/src/include/duckdb/storage/compression/chimp/chimp_compress.hpp +3 -7
- package/src/duckdb/src/include/duckdb/storage/compression/patas/patas_compress.hpp +3 -7
- package/src/duckdb/src/include/duckdb/storage/data_table.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/storage_manager.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/table/column_data_checkpointer.hpp +2 -1
- package/src/duckdb/src/include/duckdb/storage/table/column_segment.hpp +2 -2
- package/src/duckdb/src/include/duckdb/storage/table/row_group.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/table/row_group_collection.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/table/update_segment.hpp +4 -4
- package/src/duckdb/src/include/duckdb/storage/write_ahead_log.hpp +3 -3
- package/src/duckdb/src/include/duckdb/transaction/cleanup_state.hpp +3 -3
- package/src/duckdb/src/include/duckdb/transaction/commit_state.hpp +5 -5
- package/src/duckdb/src/include/duckdb/transaction/duck_transaction.hpp +3 -3
- package/src/duckdb/src/include/duckdb/transaction/local_storage.hpp +31 -30
- package/src/duckdb/src/include/duckdb/transaction/transaction_data.hpp +2 -1
- package/src/duckdb/src/include/duckdb/transaction/undo_buffer.hpp +1 -1
- package/src/duckdb/src/main/client_context.cpp +1 -1
- package/src/duckdb/src/main/query_profiler.cpp +24 -22
- package/src/duckdb/src/parallel/executor.cpp +55 -49
- package/src/duckdb/src/parallel/meta_pipeline.cpp +5 -5
- package/src/duckdb/src/parallel/pipeline.cpp +43 -26
- package/src/duckdb/src/parallel/pipeline_executor.cpp +22 -22
- package/src/duckdb/src/planner/bind_context.cpp +67 -71
- package/src/duckdb/src/planner/binder/statement/bind_create.cpp +6 -7
- package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +6 -8
- package/src/duckdb/src/planner/binder/statement/bind_delete.cpp +3 -4
- package/src/duckdb/src/planner/binder/statement/bind_insert.cpp +17 -18
- package/src/duckdb/src/planner/binder/statement/bind_update.cpp +16 -17
- package/src/duckdb/src/planner/binder/statement/bind_vacuum.cpp +6 -5
- package/src/duckdb/src/planner/binder/tableref/bind_basetableref.cpp +9 -9
- package/src/duckdb/src/planner/binder/tableref/bind_joinref.cpp +20 -18
- package/src/duckdb/src/planner/binder/tableref/plan_joinref.cpp +1 -1
- package/src/duckdb/src/planner/binder.cpp +4 -4
- package/src/duckdb/src/planner/expression_binder/index_binder.cpp +2 -1
- package/src/duckdb/src/planner/expression_binder/where_binder.cpp +3 -2
- package/src/duckdb/src/planner/operator/logical_create_table.cpp +1 -1
- package/src/duckdb/src/planner/operator/logical_delete.cpp +5 -5
- package/src/duckdb/src/planner/operator/logical_insert.cpp +6 -7
- package/src/duckdb/src/planner/operator/logical_update.cpp +6 -7
- package/src/duckdb/src/planner/parsed_data/bound_create_table_info.cpp +4 -5
- package/src/duckdb/src/planner/table_binding.cpp +6 -5
- package/src/duckdb/src/storage/compression/bitpacking.cpp +5 -6
- package/src/duckdb/src/storage/compression/dictionary_compression.cpp +5 -6
- package/src/duckdb/src/storage/compression/fsst.cpp +3 -5
- package/src/duckdb/src/storage/compression/rle.cpp +4 -6
- package/src/duckdb/src/storage/data_table.cpp +27 -28
- package/src/duckdb/src/storage/local_storage.cpp +70 -68
- package/src/duckdb/src/storage/storage_manager.cpp +12 -13
- package/src/duckdb/src/storage/table/column_checkpoint_state.cpp +2 -2
- package/src/duckdb/src/storage/table/column_data.cpp +2 -2
- package/src/duckdb/src/storage/table/column_data_checkpointer.cpp +18 -6
- package/src/duckdb/src/storage/table/column_segment.cpp +23 -24
- package/src/duckdb/src/storage/table/row_group.cpp +3 -3
- package/src/duckdb/src/storage/table/row_group_collection.cpp +1 -1
- package/src/duckdb/src/storage/table/update_segment.cpp +15 -15
- package/src/duckdb/src/storage/wal_replay.cpp +1 -1
- package/src/duckdb/src/transaction/cleanup_state.cpp +10 -10
- package/src/duckdb/src/transaction/commit_state.cpp +19 -19
- package/src/duckdb/src/transaction/duck_transaction.cpp +7 -7
- package/src/duckdb/src/transaction/rollback_state.cpp +1 -1
- package/src/duckdb/src/transaction/undo_buffer.cpp +2 -1
- package/src/duckdb/ub_src_common_adbc.cpp +4 -0
- package/src/duckdb/src/include/duckdb/common/single_thread_ptr.hpp +0 -185
@@ -81,8 +81,9 @@ bool Pipeline::ScheduleParallel(shared_ptr<Event> &event) {
|
|
81
81
|
if (!source->ParallelSource()) {
|
82
82
|
return false;
|
83
83
|
}
|
84
|
-
for (auto &
|
85
|
-
|
84
|
+
for (auto &op_ref : operators) {
|
85
|
+
auto &op = op_ref.get();
|
86
|
+
if (!op.ParallelOperator()) {
|
86
87
|
return false;
|
87
88
|
}
|
88
89
|
}
|
@@ -107,11 +108,12 @@ bool Pipeline::IsOrderDependent() const {
|
|
107
108
|
return false;
|
108
109
|
}
|
109
110
|
}
|
110
|
-
for (auto &
|
111
|
-
|
111
|
+
for (auto &op_ref : operators) {
|
112
|
+
auto &op = op_ref.get();
|
113
|
+
if (op.OperatorOrder() == OrderPreservationType::NO_ORDER) {
|
112
114
|
return false;
|
113
115
|
}
|
114
|
-
if (op
|
116
|
+
if (op.OperatorOrder() == OrderPreservationType::FIXED_ORDER) {
|
115
117
|
return true;
|
116
118
|
}
|
117
119
|
}
|
@@ -169,12 +171,11 @@ void Pipeline::ResetSink() {
|
|
169
171
|
|
170
172
|
void Pipeline::Reset() {
|
171
173
|
ResetSink();
|
172
|
-
for (auto &
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
}
|
174
|
+
for (auto &op_ref : operators) {
|
175
|
+
auto &op = op_ref.get();
|
176
|
+
lock_guard<mutex> guard(op.lock);
|
177
|
+
if (!op.op_state) {
|
178
|
+
op.op_state = op.GetGlobalOperatorState(GetClientContext());
|
178
179
|
}
|
179
180
|
}
|
180
181
|
ResetSource(false);
|
@@ -238,13 +239,28 @@ void Pipeline::PrintDependencies() const {
|
|
238
239
|
}
|
239
240
|
}
|
240
241
|
|
241
|
-
vector<PhysicalOperator
|
242
|
-
vector<PhysicalOperator
|
242
|
+
vector<reference<PhysicalOperator>> Pipeline::GetOperators() {
|
243
|
+
vector<reference<PhysicalOperator>> result;
|
244
|
+
D_ASSERT(source);
|
245
|
+
result.push_back(*source);
|
246
|
+
for (auto &op : operators) {
|
247
|
+
result.push_back(op.get());
|
248
|
+
}
|
249
|
+
if (sink) {
|
250
|
+
result.push_back(*sink);
|
251
|
+
}
|
252
|
+
return result;
|
253
|
+
}
|
254
|
+
|
255
|
+
vector<const_reference<PhysicalOperator>> Pipeline::GetOperators() const {
|
256
|
+
vector<const_reference<PhysicalOperator>> result;
|
243
257
|
D_ASSERT(source);
|
244
|
-
result.push_back(source);
|
245
|
-
|
258
|
+
result.push_back(*source);
|
259
|
+
for (auto &op : operators) {
|
260
|
+
result.push_back(op.get());
|
261
|
+
}
|
246
262
|
if (sink) {
|
247
|
-
result.push_back(sink);
|
263
|
+
result.push_back(*sink);
|
248
264
|
}
|
249
265
|
return result;
|
250
266
|
}
|
@@ -252,38 +268,39 @@ vector<PhysicalOperator *> Pipeline::GetOperators() const {
|
|
252
268
|
//===--------------------------------------------------------------------===//
|
253
269
|
// Pipeline Build State
|
254
270
|
//===--------------------------------------------------------------------===//
|
255
|
-
void PipelineBuildState::SetPipelineSource(Pipeline &pipeline, PhysicalOperator
|
256
|
-
pipeline.source = op;
|
271
|
+
void PipelineBuildState::SetPipelineSource(Pipeline &pipeline, PhysicalOperator &op) {
|
272
|
+
pipeline.source = &op;
|
257
273
|
}
|
258
274
|
|
259
|
-
void PipelineBuildState::SetPipelineSink(Pipeline &pipeline, PhysicalOperator
|
275
|
+
void PipelineBuildState::SetPipelineSink(Pipeline &pipeline, optional_ptr<PhysicalOperator> op,
|
276
|
+
idx_t sink_pipeline_count) {
|
260
277
|
pipeline.sink = op;
|
261
278
|
// set the base batch index of this pipeline based on how many other pipelines have this node as their sink
|
262
279
|
pipeline.base_batch_index = BATCH_INCREMENT * sink_pipeline_count;
|
263
280
|
}
|
264
281
|
|
265
|
-
void PipelineBuildState::AddPipelineOperator(Pipeline &pipeline, PhysicalOperator
|
282
|
+
void PipelineBuildState::AddPipelineOperator(Pipeline &pipeline, PhysicalOperator &op) {
|
266
283
|
pipeline.operators.push_back(op);
|
267
284
|
}
|
268
285
|
|
269
|
-
PhysicalOperator
|
286
|
+
optional_ptr<PhysicalOperator> PipelineBuildState::GetPipelineSource(Pipeline &pipeline) {
|
270
287
|
return pipeline.source;
|
271
288
|
}
|
272
289
|
|
273
|
-
PhysicalOperator
|
290
|
+
optional_ptr<PhysicalOperator> PipelineBuildState::GetPipelineSink(Pipeline &pipeline) {
|
274
291
|
return pipeline.sink;
|
275
292
|
}
|
276
293
|
|
277
|
-
void PipelineBuildState::SetPipelineOperators(Pipeline &pipeline, vector<PhysicalOperator
|
294
|
+
void PipelineBuildState::SetPipelineOperators(Pipeline &pipeline, vector<reference<PhysicalOperator>> operators) {
|
278
295
|
pipeline.operators = std::move(operators);
|
279
296
|
}
|
280
297
|
|
281
298
|
shared_ptr<Pipeline> PipelineBuildState::CreateChildPipeline(Executor &executor, Pipeline &pipeline,
|
282
|
-
PhysicalOperator
|
283
|
-
return executor.CreateChildPipeline(
|
299
|
+
PhysicalOperator &op) {
|
300
|
+
return executor.CreateChildPipeline(pipeline, op);
|
284
301
|
}
|
285
302
|
|
286
|
-
vector<PhysicalOperator
|
303
|
+
vector<reference<PhysicalOperator>> PipelineBuildState::GetPipelineOperators(Pipeline &pipeline) {
|
287
304
|
return pipeline.operators;
|
288
305
|
}
|
289
306
|
|
@@ -16,17 +16,17 @@ PipelineExecutor::PipelineExecutor(ClientContext &context_p, Pipeline &pipeline_
|
|
16
16
|
intermediate_chunks.reserve(pipeline.operators.size());
|
17
17
|
intermediate_states.reserve(pipeline.operators.size());
|
18
18
|
for (idx_t i = 0; i < pipeline.operators.size(); i++) {
|
19
|
-
auto prev_operator = i == 0 ? pipeline.source : pipeline.operators[i - 1];
|
20
|
-
auto current_operator = pipeline.operators[i];
|
19
|
+
auto &prev_operator = i == 0 ? *pipeline.source : pipeline.operators[i - 1].get();
|
20
|
+
auto ¤t_operator = pipeline.operators[i].get();
|
21
21
|
|
22
22
|
auto chunk = make_uniq<DataChunk>();
|
23
|
-
chunk->Initialize(Allocator::Get(context.client), prev_operator
|
23
|
+
chunk->Initialize(Allocator::Get(context.client), prev_operator.GetTypes());
|
24
24
|
intermediate_chunks.push_back(std::move(chunk));
|
25
25
|
|
26
|
-
auto op_state = current_operator
|
26
|
+
auto op_state = current_operator.GetOperatorState(context);
|
27
27
|
intermediate_states.push_back(std::move(op_state));
|
28
28
|
|
29
|
-
if (current_operator
|
29
|
+
if (current_operator.IsSink() && current_operator.sink_state->state == SinkFinalizeType::NO_OUTPUT_POSSIBLE) {
|
30
30
|
// one of the operators has already figured out no output is possible
|
31
31
|
// we can skip executing the pipeline
|
32
32
|
FinishProcessing();
|
@@ -98,11 +98,11 @@ OperatorResultType PipelineExecutor::ExecutePushInternal(DataChunk &input, idx_t
|
|
98
98
|
}
|
99
99
|
auto &sink_chunk = final_chunk;
|
100
100
|
if (sink_chunk.size() > 0) {
|
101
|
-
StartOperator(pipeline.sink);
|
101
|
+
StartOperator(*pipeline.sink);
|
102
102
|
D_ASSERT(pipeline.sink);
|
103
103
|
D_ASSERT(pipeline.sink->sink_state);
|
104
104
|
auto sink_result = pipeline.sink->Sink(context, *pipeline.sink->sink_state, *local_sink_state, sink_chunk);
|
105
|
-
EndOperator(pipeline.sink, nullptr);
|
105
|
+
EndOperator(*pipeline.sink, nullptr);
|
106
106
|
if (sink_result == SinkResultType::FINISHED) {
|
107
107
|
FinishProcessing();
|
108
108
|
return OperatorResultType::FINISHED;
|
@@ -118,7 +118,7 @@ OperatorResultType PipelineExecutor::ExecutePushInternal(DataChunk &input, idx_t
|
|
118
118
|
void PipelineExecutor::FlushCachingOperatorsPush() {
|
119
119
|
idx_t start_idx = IsFinished() ? idx_t(finished_processing_idx) : 0;
|
120
120
|
for (idx_t op_idx = start_idx; op_idx < pipeline.operators.size(); op_idx++) {
|
121
|
-
if (!pipeline.operators[op_idx]
|
121
|
+
if (!pipeline.operators[op_idx].get().RequiresFinalExecute()) {
|
122
122
|
continue;
|
123
123
|
}
|
124
124
|
|
@@ -128,10 +128,10 @@ void PipelineExecutor::FlushCachingOperatorsPush() {
|
|
128
128
|
do {
|
129
129
|
auto &curr_chunk =
|
130
130
|
op_idx + 1 >= intermediate_chunks.size() ? final_chunk : *intermediate_chunks[op_idx + 1];
|
131
|
-
auto current_operator = pipeline.operators[op_idx];
|
131
|
+
auto ¤t_operator = pipeline.operators[op_idx].get();
|
132
132
|
StartOperator(current_operator);
|
133
|
-
finalize_result = current_operator
|
134
|
-
|
133
|
+
finalize_result = current_operator.FinalExecute(context, curr_chunk, *current_operator.op_state,
|
134
|
+
*intermediate_states[op_idx]);
|
135
135
|
EndOperator(current_operator, &curr_chunk);
|
136
136
|
push_result = ExecutePushInternal(curr_chunk, op_idx + 1);
|
137
137
|
} while (finalize_result != OperatorFinalizeResultType::FINISHED &&
|
@@ -162,7 +162,7 @@ void PipelineExecutor::PushFinalize() {
|
|
162
162
|
|
163
163
|
// flush all query profiler info
|
164
164
|
for (idx_t i = 0; i < intermediate_states.size(); i++) {
|
165
|
-
intermediate_states[i]->Finalize(pipeline.operators[i], context);
|
165
|
+
intermediate_states[i]->Finalize(pipeline.operators[i].get(), context);
|
166
166
|
}
|
167
167
|
pipeline.executor.Flush(thread);
|
168
168
|
local_sink_state.reset();
|
@@ -263,13 +263,13 @@ OperatorResultType PipelineExecutor::Execute(DataChunk &input, DataChunk &result
|
|
263
263
|
auto &prev_chunk =
|
264
264
|
current_intermediate == initial_idx + 1 ? input : *intermediate_chunks[current_intermediate - 1];
|
265
265
|
auto operator_idx = current_idx - 1;
|
266
|
-
auto current_operator = pipeline.operators[operator_idx];
|
266
|
+
auto ¤t_operator = pipeline.operators[operator_idx].get();
|
267
267
|
|
268
268
|
// if current_idx > source_idx, we pass the previous' operators output through the Execute of the current
|
269
269
|
// operator
|
270
270
|
StartOperator(current_operator);
|
271
|
-
auto result = current_operator
|
272
|
-
|
271
|
+
auto result = current_operator.Execute(context, prev_chunk, current_chunk, *current_operator.op_state,
|
272
|
+
*intermediate_states[current_intermediate - 1]);
|
273
273
|
EndOperator(current_operator, ¤t_chunk);
|
274
274
|
if (result == OperatorResultType::HAVE_MORE_OUTPUT) {
|
275
275
|
// more data remains in this operator
|
@@ -308,7 +308,7 @@ OperatorResultType PipelineExecutor::Execute(DataChunk &input, DataChunk &result
|
|
308
308
|
}
|
309
309
|
|
310
310
|
void PipelineExecutor::FetchFromSource(DataChunk &result) {
|
311
|
-
StartOperator(pipeline.source);
|
311
|
+
StartOperator(*pipeline.source);
|
312
312
|
pipeline.source->GetData(context, result, *pipeline.source_state, *local_source_state);
|
313
313
|
if (result.size() != 0 && requires_batch_index) {
|
314
314
|
auto next_batch_index =
|
@@ -318,22 +318,22 @@ void PipelineExecutor::FetchFromSource(DataChunk &result) {
|
|
318
318
|
local_sink_state->batch_index == DConstants::INVALID_INDEX);
|
319
319
|
local_sink_state->batch_index = next_batch_index;
|
320
320
|
}
|
321
|
-
EndOperator(pipeline.source, &result);
|
321
|
+
EndOperator(*pipeline.source, &result);
|
322
322
|
}
|
323
323
|
|
324
324
|
void PipelineExecutor::InitializeChunk(DataChunk &chunk) {
|
325
|
-
|
326
|
-
chunk.Initialize(Allocator::DefaultAllocator(), last_op
|
325
|
+
auto &last_op = pipeline.operators.empty() ? *pipeline.source : pipeline.operators.back().get();
|
326
|
+
chunk.Initialize(Allocator::DefaultAllocator(), last_op.GetTypes());
|
327
327
|
}
|
328
328
|
|
329
|
-
void PipelineExecutor::StartOperator(PhysicalOperator
|
329
|
+
void PipelineExecutor::StartOperator(PhysicalOperator &op) {
|
330
330
|
if (context.client.interrupted) {
|
331
331
|
throw InterruptException();
|
332
332
|
}
|
333
|
-
context.thread.profiler.StartOperator(op);
|
333
|
+
context.thread.profiler.StartOperator(&op);
|
334
334
|
}
|
335
335
|
|
336
|
-
void PipelineExecutor::EndOperator(PhysicalOperator
|
336
|
+
void PipelineExecutor::EndOperator(PhysicalOperator &op, optional_ptr<DataChunk> chunk) {
|
337
337
|
context.thread.profiler.EndOperator(chunk);
|
338
338
|
|
339
339
|
if (chunk) {
|
@@ -51,7 +51,7 @@ vector<string> BindContext::GetSimilarBindings(const string &column_name) {
|
|
51
51
|
return StringUtil::TopNStrings(scores);
|
52
52
|
}
|
53
53
|
|
54
|
-
void BindContext::AddUsingBinding(const string &column_name, UsingColumnSet
|
54
|
+
void BindContext::AddUsingBinding(const string &column_name, UsingColumnSet &set) {
|
55
55
|
using_columns[column_name].insert(set);
|
56
56
|
}
|
57
57
|
|
@@ -59,25 +59,18 @@ void BindContext::AddUsingBindingSet(unique_ptr<UsingColumnSet> set) {
|
|
59
59
|
using_column_sets.push_back(std::move(set));
|
60
60
|
}
|
61
61
|
|
62
|
-
|
62
|
+
optional_ptr<UsingColumnSet> BindContext::GetUsingBinding(const string &column_name) {
|
63
63
|
auto entry = using_columns.find(column_name);
|
64
|
-
if (entry
|
65
|
-
*out = &entry->second;
|
66
|
-
return true;
|
67
|
-
}
|
68
|
-
return false;
|
69
|
-
}
|
70
|
-
|
71
|
-
UsingColumnSet *BindContext::GetUsingBinding(const string &column_name) {
|
72
|
-
unordered_set<UsingColumnSet *> *using_bindings;
|
73
|
-
if (!FindUsingBinding(column_name, &using_bindings)) {
|
64
|
+
if (entry == using_columns.end()) {
|
74
65
|
return nullptr;
|
75
66
|
}
|
76
|
-
|
67
|
+
auto &using_bindings = entry->second;
|
68
|
+
if (using_bindings.size() > 1) {
|
77
69
|
string error = "Ambiguous column reference: column \"" + column_name + "\" can refer to either:\n";
|
78
|
-
for (auto &
|
70
|
+
for (auto &using_set_ref : using_bindings) {
|
71
|
+
auto &using_set = using_set_ref.get();
|
79
72
|
string result_bindings;
|
80
|
-
for (auto &binding : using_set
|
73
|
+
for (auto &binding : using_set.bindings) {
|
81
74
|
if (result_bindings.empty()) {
|
82
75
|
result_bindings = "[";
|
83
76
|
} else {
|
@@ -91,33 +84,32 @@ UsingColumnSet *BindContext::GetUsingBinding(const string &column_name) {
|
|
91
84
|
}
|
92
85
|
throw BinderException(error);
|
93
86
|
}
|
94
|
-
for (auto &using_set :
|
95
|
-
return using_set;
|
87
|
+
for (auto &using_set : using_bindings) {
|
88
|
+
return &using_set.get();
|
96
89
|
}
|
97
90
|
throw InternalException("Using binding found but no entries");
|
98
91
|
}
|
99
92
|
|
100
|
-
UsingColumnSet
|
93
|
+
optional_ptr<UsingColumnSet> BindContext::GetUsingBinding(const string &column_name, const string &binding_name) {
|
101
94
|
if (binding_name.empty()) {
|
102
95
|
throw InternalException("GetUsingBinding: expected non-empty binding_name");
|
103
96
|
}
|
104
|
-
|
105
|
-
if (
|
97
|
+
auto entry = using_columns.find(column_name);
|
98
|
+
if (entry == using_columns.end()) {
|
106
99
|
return nullptr;
|
107
100
|
}
|
108
|
-
|
109
|
-
|
101
|
+
auto &using_bindings = entry->second;
|
102
|
+
for (auto &using_set_ref : using_bindings) {
|
103
|
+
auto &using_set = using_set_ref.get();
|
104
|
+
auto &bindings = using_set.bindings;
|
110
105
|
if (bindings.find(binding_name) != bindings.end()) {
|
111
|
-
return using_set;
|
106
|
+
return &using_set;
|
112
107
|
}
|
113
108
|
}
|
114
109
|
return nullptr;
|
115
110
|
}
|
116
111
|
|
117
|
-
void BindContext::RemoveUsingBinding(const string &column_name, UsingColumnSet
|
118
|
-
if (!set) {
|
119
|
-
return;
|
120
|
-
}
|
112
|
+
void BindContext::RemoveUsingBinding(const string &column_name, UsingColumnSet &set) {
|
121
113
|
auto entry = using_columns.find(column_name);
|
122
114
|
if (entry == using_columns.end()) {
|
123
115
|
throw InternalException("Attempting to remove using binding that is not there");
|
@@ -131,10 +123,12 @@ void BindContext::RemoveUsingBinding(const string &column_name, UsingColumnSet *
|
|
131
123
|
}
|
132
124
|
}
|
133
125
|
|
134
|
-
void BindContext::TransferUsingBinding(BindContext ¤t_context, UsingColumnSet
|
135
|
-
UsingColumnSet
|
126
|
+
void BindContext::TransferUsingBinding(BindContext ¤t_context, optional_ptr<UsingColumnSet> current_set,
|
127
|
+
UsingColumnSet &new_set, const string &binding, const string &using_column) {
|
136
128
|
AddUsingBinding(using_column, new_set);
|
137
|
-
|
129
|
+
if (current_set) {
|
130
|
+
current_context.RemoveUsingBinding(using_column, *current_set);
|
131
|
+
}
|
138
132
|
}
|
139
133
|
|
140
134
|
string BindContext::GetActualColumnName(const string &binding_name, const string &column_name) {
|
@@ -167,7 +161,7 @@ unique_ptr<ParsedExpression> BindContext::ExpandGeneratedColumn(const string &ta
|
|
167
161
|
|
168
162
|
auto binding = GetBinding(table_name, error_message);
|
169
163
|
D_ASSERT(binding);
|
170
|
-
auto &table_binding =
|
164
|
+
auto &table_binding = (TableBinding &)*binding;
|
171
165
|
auto result = table_binding.ExpandGeneratedColumn(column_name);
|
172
166
|
result->alias = column_name;
|
173
167
|
return result;
|
@@ -178,12 +172,12 @@ unique_ptr<ParsedExpression> BindContext::CreateColumnReference(const string &ta
|
|
178
172
|
return CreateColumnReference(schema_name, table_name, column_name);
|
179
173
|
}
|
180
174
|
|
181
|
-
static bool ColumnIsGenerated(Binding
|
182
|
-
if (binding
|
175
|
+
static bool ColumnIsGenerated(Binding &binding, column_t index) {
|
176
|
+
if (binding.binding_type != BindingType::TABLE) {
|
183
177
|
return false;
|
184
178
|
}
|
185
|
-
auto table_binding = (TableBinding
|
186
|
-
auto catalog_entry = table_binding
|
179
|
+
auto &table_binding = (TableBinding &)binding;
|
180
|
+
auto catalog_entry = table_binding.GetStandardEntry();
|
187
181
|
if (!catalog_entry) {
|
188
182
|
return false;
|
189
183
|
}
|
@@ -191,8 +185,8 @@ static bool ColumnIsGenerated(Binding *binding, column_t index) {
|
|
191
185
|
return false;
|
192
186
|
}
|
193
187
|
D_ASSERT(catalog_entry->type == CatalogType::TABLE_ENTRY);
|
194
|
-
auto table_entry = (
|
195
|
-
return table_entry
|
188
|
+
auto &table_entry = catalog_entry->Cast<TableCatalogEntry>();
|
189
|
+
return table_entry.GetColumn(LogicalIndex(index)).Generated();
|
196
190
|
}
|
197
191
|
|
198
192
|
unique_ptr<ParsedExpression> BindContext::CreateColumnReference(const string &catalog_name, const string &schema_name,
|
@@ -214,7 +208,7 @@ unique_ptr<ParsedExpression> BindContext::CreateColumnReference(const string &ca
|
|
214
208
|
return std::move(result);
|
215
209
|
}
|
216
210
|
auto column_index = binding->GetBindingIndex(column_name);
|
217
|
-
if (ColumnIsGenerated(binding, column_index)) {
|
211
|
+
if (ColumnIsGenerated(*binding, column_index)) {
|
218
212
|
return ExpandGeneratedColumn(table_name, column_name);
|
219
213
|
} else if (column_index < binding->names.size() && binding->names[column_index] != column_name) {
|
220
214
|
// because of case insensitivity in the binder we rename the column to the original name
|
@@ -230,7 +224,7 @@ unique_ptr<ParsedExpression> BindContext::CreateColumnReference(const string &sc
|
|
230
224
|
return CreateColumnReference(catalog_name, schema_name, table_name, column_name);
|
231
225
|
}
|
232
226
|
|
233
|
-
Binding
|
227
|
+
optional_ptr<Binding> BindContext::GetCTEBinding(const string &ctename) {
|
234
228
|
auto match = cte_bindings.find(ctename);
|
235
229
|
if (match == cte_bindings.end()) {
|
236
230
|
return nullptr;
|
@@ -238,7 +232,7 @@ Binding *BindContext::GetCTEBinding(const string &ctename) {
|
|
238
232
|
return match->second.get();
|
239
233
|
}
|
240
234
|
|
241
|
-
Binding
|
235
|
+
optional_ptr<Binding> BindContext::GetBinding(const string &name, string &out_error) {
|
242
236
|
auto match = bindings.find(name);
|
243
237
|
if (match == bindings.end()) {
|
244
238
|
// alias not found in this BindContext
|
@@ -271,16 +265,17 @@ string BindContext::BindColumn(PositionalReferenceExpression &ref, string &table
|
|
271
265
|
idx_t total_columns = 0;
|
272
266
|
idx_t current_position = ref.index - 1;
|
273
267
|
for (auto &entry : bindings_list) {
|
274
|
-
|
268
|
+
auto &binding = entry.get();
|
269
|
+
idx_t entry_column_count = binding.names.size();
|
275
270
|
if (ref.index == 0) {
|
276
271
|
// this is a row id
|
277
|
-
table_name =
|
272
|
+
table_name = binding.alias;
|
278
273
|
column_name = "rowid";
|
279
274
|
return string();
|
280
275
|
}
|
281
276
|
if (current_position < entry_column_count) {
|
282
|
-
table_name =
|
283
|
-
column_name =
|
277
|
+
table_name = binding.alias;
|
278
|
+
column_name = binding.names[current_position];
|
284
279
|
return string();
|
285
280
|
} else {
|
286
281
|
total_columns += entry_column_count;
|
@@ -301,7 +296,7 @@ BindResult BindContext::BindColumn(PositionalReferenceExpression &ref, idx_t dep
|
|
301
296
|
return BindColumn(*column_ref, depth);
|
302
297
|
}
|
303
298
|
|
304
|
-
bool BindContext::CheckExclusionList(StarExpression &expr,
|
299
|
+
bool BindContext::CheckExclusionList(StarExpression &expr, const string &column_name,
|
305
300
|
vector<unique_ptr<ParsedExpression>> &new_select_list,
|
306
301
|
case_insensitive_set_t &excluded_columns) {
|
307
302
|
if (expr.exclude_list.find(column_name) != expr.exclude_list.end()) {
|
@@ -328,16 +323,17 @@ void BindContext::GenerateAllColumnExpressions(StarExpression &expr,
|
|
328
323
|
if (expr.relation_name.empty()) {
|
329
324
|
// SELECT * case
|
330
325
|
// bind all expressions of each table in-order
|
331
|
-
|
326
|
+
reference_set_t<UsingColumnSet> handled_using_columns;
|
332
327
|
for (auto &entry : bindings_list) {
|
333
|
-
auto binding = entry.
|
334
|
-
for (auto &column_name : binding
|
335
|
-
if (CheckExclusionList(expr,
|
328
|
+
auto &binding = entry.get();
|
329
|
+
for (auto &column_name : binding.names) {
|
330
|
+
if (CheckExclusionList(expr, column_name, new_select_list, excluded_columns)) {
|
336
331
|
continue;
|
337
332
|
}
|
338
333
|
// check if this column is a USING column
|
339
|
-
auto
|
340
|
-
if (
|
334
|
+
auto using_binding_ptr = GetUsingBinding(column_name, binding.alias);
|
335
|
+
if (using_binding_ptr) {
|
336
|
+
auto &using_binding = *using_binding_ptr;
|
341
337
|
// it is!
|
342
338
|
// check if we have already emitted the using column
|
343
339
|
if (handled_using_columns.find(using_binding) != handled_using_columns.end()) {
|
@@ -345,10 +341,10 @@ void BindContext::GenerateAllColumnExpressions(StarExpression &expr,
|
|
345
341
|
continue;
|
346
342
|
}
|
347
343
|
// we have not! output the using column
|
348
|
-
if (using_binding
|
344
|
+
if (using_binding.primary_binding.empty()) {
|
349
345
|
// no primary binding: output a coalesce
|
350
346
|
auto coalesce = make_uniq<OperatorExpression>(ExpressionType::OPERATOR_COALESCE);
|
351
|
-
for (auto &child_binding : using_binding
|
347
|
+
for (auto &child_binding : using_binding.bindings) {
|
352
348
|
coalesce->children.push_back(make_uniq<ColumnRefExpression>(column_name, child_binding));
|
353
349
|
}
|
354
350
|
coalesce->alias = column_name;
|
@@ -356,12 +352,12 @@ void BindContext::GenerateAllColumnExpressions(StarExpression &expr,
|
|
356
352
|
} else {
|
357
353
|
// primary binding: output the qualified column ref
|
358
354
|
new_select_list.push_back(
|
359
|
-
make_uniq<ColumnRefExpression>(column_name, using_binding
|
355
|
+
make_uniq<ColumnRefExpression>(column_name, using_binding.primary_binding));
|
360
356
|
}
|
361
357
|
handled_using_columns.insert(using_binding);
|
362
358
|
continue;
|
363
359
|
}
|
364
|
-
new_select_list.push_back(make_uniq<ColumnRefExpression>(column_name, binding
|
360
|
+
new_select_list.push_back(make_uniq<ColumnRefExpression>(column_name, binding.alias));
|
365
361
|
}
|
366
362
|
}
|
367
363
|
} else {
|
@@ -391,7 +387,7 @@ void BindContext::GenerateAllColumnExpressions(StarExpression &expr,
|
|
391
387
|
column_names[0] = binding->alias;
|
392
388
|
column_names[1] = expr.relation_name;
|
393
389
|
for (auto &child : struct_children) {
|
394
|
-
if (CheckExclusionList(expr,
|
390
|
+
if (CheckExclusionList(expr, child.first, new_select_list, excluded_columns)) {
|
395
391
|
continue;
|
396
392
|
}
|
397
393
|
column_names[2] = child.first;
|
@@ -399,7 +395,7 @@ void BindContext::GenerateAllColumnExpressions(StarExpression &expr,
|
|
399
395
|
}
|
400
396
|
} else {
|
401
397
|
for (auto &column_name : binding->names) {
|
402
|
-
if (CheckExclusionList(expr,
|
398
|
+
if (CheckExclusionList(expr, column_name, new_select_list, excluded_columns)) {
|
403
399
|
continue;
|
404
400
|
}
|
405
401
|
|
@@ -423,7 +419,7 @@ void BindContext::GenerateAllColumnExpressions(StarExpression &expr,
|
|
423
419
|
|
424
420
|
void BindContext::GetTypesAndNames(vector<string> &result_names, vector<LogicalType> &result_types) {
|
425
421
|
for (auto &binding_entry : bindings_list) {
|
426
|
-
auto &binding =
|
422
|
+
auto &binding = binding_entry.get();
|
427
423
|
D_ASSERT(binding.names.size() == binding.types.size());
|
428
424
|
for (idx_t i = 0; i < binding.names.size(); i++) {
|
429
425
|
result_names.push_back(binding.names[i]);
|
@@ -436,7 +432,7 @@ void BindContext::AddBinding(const string &alias, unique_ptr<Binding> binding) {
|
|
436
432
|
if (bindings.find(alias) != bindings.end()) {
|
437
433
|
throw BinderException("Duplicate alias \"%s\" in query!", alias);
|
438
434
|
}
|
439
|
-
bindings_list.
|
435
|
+
bindings_list.push_back(*binding);
|
440
436
|
bindings[alias] = std::move(binding);
|
441
437
|
}
|
442
438
|
|
@@ -527,14 +523,14 @@ void BindContext::AddContext(BindContext other) {
|
|
527
523
|
bindings[binding.first] = std::move(binding.second);
|
528
524
|
}
|
529
525
|
for (auto &binding : other.bindings_list) {
|
530
|
-
bindings_list.push_back(
|
526
|
+
bindings_list.push_back(binding);
|
531
527
|
}
|
532
528
|
for (auto &entry : other.using_columns) {
|
533
529
|
for (auto &alias : entry.second) {
|
534
530
|
#ifdef DEBUG
|
535
531
|
for (auto &other_alias : using_columns[entry.first]) {
|
536
|
-
for (auto &col : alias
|
537
|
-
D_ASSERT(other_alias
|
532
|
+
for (auto &col : alias.get().bindings) {
|
533
|
+
D_ASSERT(other_alias.get().bindings.find(col) == other_alias.get().bindings.end());
|
538
534
|
}
|
539
535
|
}
|
540
536
|
#endif
|
@@ -543,19 +539,19 @@ void BindContext::AddContext(BindContext other) {
|
|
543
539
|
}
|
544
540
|
}
|
545
541
|
|
546
|
-
void BindContext::RemoveContext(vector<
|
542
|
+
void BindContext::RemoveContext(vector<reference<Binding>> &other_bindings_list) {
|
547
543
|
for (auto &other_binding : other_bindings_list) {
|
548
|
-
|
549
|
-
|
550
|
-
}
|
544
|
+
auto it = std::remove_if(bindings_list.begin(), bindings_list.end(), [other_binding](reference<Binding> x) {
|
545
|
+
return x.get().alias == other_binding.get().alias;
|
546
|
+
});
|
547
|
+
bindings_list.erase(it, bindings_list.end());
|
551
548
|
}
|
552
549
|
|
553
|
-
vector<idx_t> delete_list_indexes;
|
554
550
|
for (auto &other_binding : other_bindings_list) {
|
555
|
-
auto
|
556
|
-
|
557
|
-
|
558
|
-
|
551
|
+
auto &alias = other_binding.get().alias;
|
552
|
+
if (bindings.find(alias) != bindings.end()) {
|
553
|
+
bindings.erase(alias);
|
554
|
+
}
|
559
555
|
}
|
560
556
|
}
|
561
557
|
|
@@ -509,9 +509,8 @@ BoundStatement Binder::Bind(CreateStatement &stmt) {
|
|
509
509
|
throw BinderException("Can only create an index over a base table!");
|
510
510
|
}
|
511
511
|
auto &table_binding = bound_table->Cast<BoundBaseTableRef>();
|
512
|
-
;
|
513
|
-
|
514
|
-
if (table->temporary) {
|
512
|
+
auto &table = table_binding.table;
|
513
|
+
if (table.temporary) {
|
515
514
|
stmt.info->temporary = true;
|
516
515
|
}
|
517
516
|
// create a plan over the bound table
|
@@ -520,13 +519,13 @@ BoundStatement Binder::Bind(CreateStatement &stmt) {
|
|
520
519
|
throw BinderException("Cannot create index on a view!");
|
521
520
|
}
|
522
521
|
|
523
|
-
result.plan = table
|
522
|
+
result.plan = table.catalog->BindCreateIndex(*this, stmt, table, std::move(plan));
|
524
523
|
break;
|
525
524
|
}
|
526
525
|
case CatalogType::TABLE_ENTRY: {
|
527
526
|
auto &create_info = (CreateTableInfo &)*stmt.info;
|
528
527
|
// If there is a foreign key constraint, resolve primary key column's index from primary key column's name
|
529
|
-
|
528
|
+
reference_set_t<SchemaCatalogEntry> fk_schemas;
|
530
529
|
for (idx_t i = 0; i < create_info.constraints.size(); i++) {
|
531
530
|
auto &cond = create_info.constraints[i];
|
532
531
|
if (cond->type != ConstraintType::FOREIGN_KEY) {
|
@@ -549,7 +548,7 @@ BoundStatement Binder::Bind(CreateStatement &stmt) {
|
|
549
548
|
// have to resolve referenced table
|
550
549
|
auto pk_table_entry_ptr =
|
551
550
|
Catalog::GetEntry<TableCatalogEntry>(context, INVALID_CATALOG, fk.info.schema, fk.info.table);
|
552
|
-
fk_schemas.insert(pk_table_entry_ptr->schema);
|
551
|
+
fk_schemas.insert(*pk_table_entry_ptr->schema);
|
553
552
|
FindMatchingPrimaryKeyColumns(pk_table_entry_ptr->GetColumns(), pk_table_entry_ptr->GetConstraints(),
|
554
553
|
fk);
|
555
554
|
FindForeignKeyIndexes(pk_table_entry_ptr->GetColumns(), fk.pk_columns, fk.info.pk_keys);
|
@@ -574,7 +573,7 @@ BoundStatement Binder::Bind(CreateStatement &stmt) {
|
|
574
573
|
auto bound_info = BindCreateTableInfo(std::move(stmt.info));
|
575
574
|
auto root = std::move(bound_info->query);
|
576
575
|
for (auto &fk_schema : fk_schemas) {
|
577
|
-
if (fk_schema != bound_info->schema) {
|
576
|
+
if (&fk_schema.get() != &bound_info->schema) {
|
578
577
|
throw BinderException("Creating foreign keys across different schemas or catalogs is not supported");
|
579
578
|
}
|
580
579
|
}
|
@@ -253,8 +253,7 @@ static void ExtractDependencies(BoundCreateTableInfo &info) {
|
|
253
253
|
}
|
254
254
|
unique_ptr<BoundCreateTableInfo> Binder::BindCreateTableInfo(unique_ptr<CreateInfo> info, SchemaCatalogEntry &schema) {
|
255
255
|
auto &base = (CreateTableInfo &)*info;
|
256
|
-
auto result = make_uniq<BoundCreateTableInfo>(std::move(info));
|
257
|
-
result->schema = &schema;
|
256
|
+
auto result = make_uniq<BoundCreateTableInfo>(schema, std::move(info));
|
258
257
|
if (base.query) {
|
259
258
|
// construct the result object
|
260
259
|
auto query_obj = Bind(*base.query);
|
@@ -292,7 +291,7 @@ unique_ptr<BoundCreateTableInfo> Binder::BindCreateTableInfo(unique_ptr<CreateIn
|
|
292
291
|
if (column.Type().id() == LogicalTypeId::VARCHAR) {
|
293
292
|
ExpressionBinder::TestCollation(context, StringType::GetCollation(column.Type()));
|
294
293
|
}
|
295
|
-
BindLogicalType(context, column.TypeMutable(), result->schema
|
294
|
+
BindLogicalType(context, column.TypeMutable(), result->schema.catalog);
|
296
295
|
// We add a catalog dependency
|
297
296
|
auto type_dependency = LogicalType::GetCatalog(column.Type());
|
298
297
|
if (type_dependency) {
|
@@ -311,12 +310,11 @@ unique_ptr<BoundCreateTableInfo> Binder::BindCreateTableInfo(unique_ptr<CreateIn
|
|
311
310
|
return BindCreateTableInfo(std::move(info), schema);
|
312
311
|
}
|
313
312
|
|
314
|
-
vector<unique_ptr<Expression>> Binder::BindCreateIndexExpressions(TableCatalogEntry
|
315
|
-
|
316
|
-
auto index_binder = IndexBinder(*this, this->context, table, info);
|
313
|
+
vector<unique_ptr<Expression>> Binder::BindCreateIndexExpressions(TableCatalogEntry &table, CreateIndexInfo &info) {
|
314
|
+
auto index_binder = IndexBinder(*this, this->context, &table, &info);
|
317
315
|
vector<unique_ptr<Expression>> expressions;
|
318
|
-
expressions.reserve(info
|
319
|
-
for (auto &expr : info
|
316
|
+
expressions.reserve(info.expressions.size());
|
317
|
+
for (auto &expr : info.expressions) {
|
320
318
|
expressions.push_back(index_binder.Bind(expr));
|
321
319
|
}
|
322
320
|
|