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
@@ -21,16 +21,15 @@ BoundStatement Binder::Bind(DeleteStatement &stmt) {
|
|
21
21
|
throw BinderException("Can only delete from base table!");
|
22
22
|
}
|
23
23
|
auto &table_binding = bound_table->Cast<BoundBaseTableRef>();
|
24
|
-
;
|
25
|
-
auto table = table_binding.table;
|
24
|
+
auto &table = table_binding.table;
|
26
25
|
|
27
26
|
auto root = CreatePlan(*bound_table);
|
28
27
|
auto &get = root->Cast<LogicalGet>();
|
29
28
|
D_ASSERT(root->type == LogicalOperatorType::LOGICAL_GET);
|
30
29
|
|
31
|
-
if (!table
|
30
|
+
if (!table.temporary) {
|
32
31
|
// delete from persistent table: not read only!
|
33
|
-
properties.modified_databases.insert(table
|
32
|
+
properties.modified_databases.insert(table.catalog->GetName());
|
34
33
|
}
|
35
34
|
|
36
35
|
// Add CTEs as bindable
|
@@ -352,8 +352,8 @@ void Binder::BindOnConflictClause(LogicalInsert &insert, TableCatalogEntry &tabl
|
|
352
352
|
// Get the column_ids we need to fetch later on from the conflicting tuples
|
353
353
|
// of the original table, to execute the expressions
|
354
354
|
D_ASSERT(original_binding->binding_type == BindingType::TABLE);
|
355
|
-
auto table_binding = (TableBinding *
|
356
|
-
insert.columns_to_fetch = table_binding
|
355
|
+
auto &table_binding = (TableBinding &)*original_binding;
|
356
|
+
insert.columns_to_fetch = table_binding.GetBoundColumnIds();
|
357
357
|
return;
|
358
358
|
}
|
359
359
|
|
@@ -378,8 +378,8 @@ void Binder::BindOnConflictClause(LogicalInsert &insert, TableCatalogEntry &tabl
|
|
378
378
|
// Get the column_ids we need to fetch later on from the conflicting tuples
|
379
379
|
// of the original table, to execute the expressions
|
380
380
|
D_ASSERT(original_binding->binding_type == BindingType::TABLE);
|
381
|
-
auto table_binding = (TableBinding *
|
382
|
-
insert.columns_to_fetch = table_binding
|
381
|
+
auto &table_binding = (TableBinding &)*original_binding;
|
382
|
+
insert.columns_to_fetch = table_binding.GetBoundColumnIds();
|
383
383
|
|
384
384
|
// Replace the column bindings to refer to the child operator
|
385
385
|
for (auto &expr : insert.expressions) {
|
@@ -398,11 +398,10 @@ BoundStatement Binder::Bind(InsertStatement &stmt) {
|
|
398
398
|
result.types = {LogicalType::BIGINT};
|
399
399
|
|
400
400
|
BindSchemaOrCatalog(stmt.catalog, stmt.schema);
|
401
|
-
auto table = Catalog::GetEntry<TableCatalogEntry>(context, stmt.catalog, stmt.schema, stmt.table);
|
402
|
-
|
403
|
-
if (!table->temporary) {
|
401
|
+
auto &table = *Catalog::GetEntry<TableCatalogEntry>(context, stmt.catalog, stmt.schema, stmt.table);
|
402
|
+
if (!table.temporary) {
|
404
403
|
// inserting into a non-temporary table: alters underlying database
|
405
|
-
properties.modified_databases.insert(table
|
404
|
+
properties.modified_databases.insert(table.catalog->GetName());
|
406
405
|
}
|
407
406
|
|
408
407
|
auto insert = make_uniq<LogicalInsert>(table, GenerateTableIndex());
|
@@ -417,18 +416,18 @@ BoundStatement Binder::Bind(InsertStatement &stmt) {
|
|
417
416
|
case_insensitive_map_t<idx_t> column_name_map;
|
418
417
|
for (idx_t i = 0; i < stmt.columns.size(); i++) {
|
419
418
|
column_name_map[stmt.columns[i]] = i;
|
420
|
-
auto column_index = table
|
419
|
+
auto column_index = table.GetColumnIndex(stmt.columns[i]);
|
421
420
|
if (column_index.index == COLUMN_IDENTIFIER_ROW_ID) {
|
422
421
|
throw BinderException("Cannot explicitly insert values into rowid column");
|
423
422
|
}
|
424
|
-
auto &col = table
|
423
|
+
auto &col = table.GetColumn(column_index);
|
425
424
|
if (col.Generated()) {
|
426
425
|
throw BinderException("Cannot insert into a generated column");
|
427
426
|
}
|
428
427
|
insert->expected_types.push_back(col.Type());
|
429
428
|
named_column_map.push_back(column_index);
|
430
429
|
}
|
431
|
-
for (auto &col : table
|
430
|
+
for (auto &col : table.GetColumns().Physical()) {
|
432
431
|
auto entry = column_name_map.find(col.Name());
|
433
432
|
if (entry == column_name_map.end()) {
|
434
433
|
// column not specified, set index to DConstants::INVALID_INDEX
|
@@ -441,21 +440,21 @@ BoundStatement Binder::Bind(InsertStatement &stmt) {
|
|
441
440
|
} else {
|
442
441
|
// No columns specified, assume insertion into all columns
|
443
442
|
// Intentionally don't populate 'column_index_map' as an indication of this
|
444
|
-
for (auto &col : table
|
443
|
+
for (auto &col : table.GetColumns().Physical()) {
|
445
444
|
named_column_map.push_back(col.Logical());
|
446
445
|
insert->expected_types.push_back(col.Type());
|
447
446
|
}
|
448
447
|
}
|
449
448
|
|
450
449
|
// bind the default values
|
451
|
-
BindDefaultValues(table
|
450
|
+
BindDefaultValues(table.GetColumns(), insert->bound_defaults);
|
452
451
|
if (!stmt.select_statement) {
|
453
452
|
result.plan = std::move(insert);
|
454
453
|
return result;
|
455
454
|
}
|
456
455
|
|
457
456
|
// Exclude the generated columns from this amount
|
458
|
-
idx_t expected_columns = stmt.columns.empty() ? table
|
457
|
+
idx_t expected_columns = stmt.columns.empty() ? table.GetColumns().PhysicalColumnCount() : stmt.columns.size();
|
459
458
|
|
460
459
|
// special case: check if we are inserting from a VALUES statement
|
461
460
|
auto values_list = stmt.GetValuesList();
|
@@ -466,7 +465,7 @@ BoundStatement Binder::Bind(InsertStatement &stmt) {
|
|
466
465
|
|
467
466
|
D_ASSERT(expr_list.values.size() > 0);
|
468
467
|
CheckInsertColumnCountMismatch(expected_columns, expr_list.values[0].size(), !stmt.columns.empty(),
|
469
|
-
table
|
468
|
+
table.name.c_str());
|
470
469
|
|
471
470
|
// VALUES list!
|
472
471
|
for (idx_t col_idx = 0; col_idx < expected_columns; col_idx++) {
|
@@ -474,7 +473,7 @@ BoundStatement Binder::Bind(InsertStatement &stmt) {
|
|
474
473
|
auto &table_col_idx = named_column_map[col_idx];
|
475
474
|
|
476
475
|
// set the expected types as the types for the INSERT statement
|
477
|
-
auto &column = table
|
476
|
+
auto &column = table.GetColumn(table_col_idx);
|
478
477
|
expr_list.expected_types[col_idx] = column.Type();
|
479
478
|
expr_list.expected_names[col_idx] = column.Name();
|
480
479
|
|
@@ -494,12 +493,12 @@ BoundStatement Binder::Bind(InsertStatement &stmt) {
|
|
494
493
|
MoveCorrelatedExpressions(*select_binder);
|
495
494
|
|
496
495
|
CheckInsertColumnCountMismatch(expected_columns, root_select.types.size(), !stmt.columns.empty(),
|
497
|
-
table
|
496
|
+
table.name.c_str());
|
498
497
|
|
499
498
|
auto root = CastLogicalOperatorToTypes(root_select.types, insert->expected_types, std::move(root_select.plan));
|
500
499
|
insert->AddChild(std::move(root));
|
501
500
|
|
502
|
-
BindOnConflictClause(*insert,
|
501
|
+
BindOnConflictClause(*insert, table, stmt);
|
503
502
|
|
504
503
|
if (!stmt.returning_list.empty()) {
|
505
504
|
insert->return_chunk = true;
|
@@ -135,8 +135,8 @@ static void BindUpdateConstraints(TableCatalogEntry &table, LogicalGet &get, Log
|
|
135
135
|
|
136
136
|
// This creates a LogicalProjection and moves 'root' into it as a child
|
137
137
|
// unless there are no expressions to project, in which case it just returns 'root'
|
138
|
-
unique_ptr<LogicalOperator> Binder::BindUpdateSet(LogicalOperator
|
139
|
-
UpdateSetInfo &set_info, TableCatalogEntry
|
138
|
+
unique_ptr<LogicalOperator> Binder::BindUpdateSet(LogicalOperator &op, unique_ptr<LogicalOperator> root,
|
139
|
+
UpdateSetInfo &set_info, TableCatalogEntry &table,
|
140
140
|
vector<PhysicalIndex> &columns) {
|
141
141
|
auto proj_index = GenerateTableIndex();
|
142
142
|
|
@@ -145,10 +145,10 @@ unique_ptr<LogicalOperator> Binder::BindUpdateSet(LogicalOperator *op, unique_pt
|
|
145
145
|
for (idx_t i = 0; i < set_info.columns.size(); i++) {
|
146
146
|
auto &colname = set_info.columns[i];
|
147
147
|
auto &expr = set_info.expressions[i];
|
148
|
-
if (!table
|
148
|
+
if (!table.ColumnExists(colname)) {
|
149
149
|
throw BinderException("Referenced update column %s not found in table!", colname);
|
150
150
|
}
|
151
|
-
auto &column = table
|
151
|
+
auto &column = table.GetColumn(colname);
|
152
152
|
if (column.Generated()) {
|
153
153
|
throw BinderException("Cant update column \"%s\" because it is a generated column!", column.Name());
|
154
154
|
}
|
@@ -157,19 +157,19 @@ unique_ptr<LogicalOperator> Binder::BindUpdateSet(LogicalOperator *op, unique_pt
|
|
157
157
|
}
|
158
158
|
columns.push_back(column.Physical());
|
159
159
|
if (expr->type == ExpressionType::VALUE_DEFAULT) {
|
160
|
-
op
|
160
|
+
op.expressions.push_back(make_uniq<BoundDefaultExpression>(column.Type()));
|
161
161
|
} else {
|
162
162
|
UpdateBinder binder(*this, context);
|
163
163
|
binder.target_type = column.Type();
|
164
164
|
auto bound_expr = binder.Bind(expr);
|
165
165
|
PlanSubqueries(&bound_expr, &root);
|
166
166
|
|
167
|
-
op
|
167
|
+
op.expressions.push_back(make_uniq<BoundColumnRefExpression>(
|
168
168
|
bound_expr->return_type, ColumnBinding(proj_index, projection_expressions.size())));
|
169
169
|
projection_expressions.push_back(std::move(bound_expr));
|
170
170
|
}
|
171
171
|
}
|
172
|
-
if (op
|
172
|
+
if (op.type != LogicalOperatorType::LOGICAL_UPDATE && projection_expressions.empty()) {
|
173
173
|
return root;
|
174
174
|
}
|
175
175
|
// now create the projection
|
@@ -181,7 +181,6 @@ unique_ptr<LogicalOperator> Binder::BindUpdateSet(LogicalOperator *op, unique_pt
|
|
181
181
|
BoundStatement Binder::Bind(UpdateStatement &stmt) {
|
182
182
|
BoundStatement result;
|
183
183
|
unique_ptr<LogicalOperator> root;
|
184
|
-
LogicalGet *get;
|
185
184
|
|
186
185
|
// visit the table reference
|
187
186
|
auto bound_table = Bind(*stmt.table);
|
@@ -189,28 +188,28 @@ BoundStatement Binder::Bind(UpdateStatement &stmt) {
|
|
189
188
|
throw BinderException("Can only update base table!");
|
190
189
|
}
|
191
190
|
auto &table_binding = bound_table->Cast<BoundBaseTableRef>();
|
192
|
-
;
|
193
|
-
auto table = table_binding.table;
|
191
|
+
auto &table = table_binding.table;
|
194
192
|
|
195
193
|
// Add CTEs as bindable
|
196
194
|
AddCTEMap(stmt.cte_map);
|
197
195
|
|
196
|
+
optional_ptr<LogicalGet> get;
|
198
197
|
if (stmt.from_table) {
|
199
198
|
auto from_binder = Binder::CreateBinder(context, this);
|
200
199
|
BoundJoinRef bound_crossproduct(JoinRefType::CROSS);
|
201
200
|
bound_crossproduct.left = std::move(bound_table);
|
202
201
|
bound_crossproduct.right = from_binder->Bind(*stmt.from_table);
|
203
202
|
root = CreatePlan(bound_crossproduct);
|
204
|
-
get =
|
203
|
+
get = &root->children[0]->Cast<LogicalGet>();
|
205
204
|
bind_context.AddContext(std::move(from_binder->bind_context));
|
206
205
|
} else {
|
207
206
|
root = CreatePlan(*bound_table);
|
208
|
-
get =
|
207
|
+
get = &root->Cast<LogicalGet>();
|
209
208
|
}
|
210
209
|
|
211
|
-
if (!table
|
210
|
+
if (!table.temporary) {
|
212
211
|
// update of persistent table: not read only!
|
213
|
-
properties.modified_databases.insert(table
|
212
|
+
properties.modified_databases.insert(table.catalog->GetName());
|
214
213
|
}
|
215
214
|
auto update = make_uniq<LogicalUpdate>(table);
|
216
215
|
|
@@ -219,7 +218,7 @@ BoundStatement Binder::Bind(UpdateStatement &stmt) {
|
|
219
218
|
update->return_chunk = true;
|
220
219
|
}
|
221
220
|
// bind the default values
|
222
|
-
BindDefaultValues(table
|
221
|
+
BindDefaultValues(table.GetColumns(), update->bound_defaults);
|
223
222
|
|
224
223
|
// project any additional columns required for the condition/expressions
|
225
224
|
if (stmt.set_info->condition) {
|
@@ -235,12 +234,12 @@ BoundStatement Binder::Bind(UpdateStatement &stmt) {
|
|
235
234
|
D_ASSERT(stmt.set_info);
|
236
235
|
D_ASSERT(stmt.set_info->columns.size() == stmt.set_info->expressions.size());
|
237
236
|
|
238
|
-
auto proj_tmp = BindUpdateSet(update
|
237
|
+
auto proj_tmp = BindUpdateSet(*update, std::move(root), *stmt.set_info, table, update->columns);
|
239
238
|
D_ASSERT(proj_tmp->type == LogicalOperatorType::LOGICAL_PROJECTION);
|
240
239
|
auto proj = unique_ptr_cast<LogicalOperator, LogicalProjection>(std::move(proj_tmp));
|
241
240
|
|
242
241
|
// bind any extra columns necessary for CHECK constraints or indexes
|
243
|
-
BindUpdateConstraints(
|
242
|
+
BindUpdateConstraints(table, *get, *proj, *update);
|
244
243
|
// finally add the row id column to the projection list
|
245
244
|
proj->expressions.push_back(make_uniq<BoundColumnRefExpression>(
|
246
245
|
LogicalType::ROW_TYPE, ColumnBinding(get->table_index, get->column_ids.size())));
|
@@ -21,7 +21,8 @@ BoundStatement Binder::Bind(VacuumStatement &stmt) {
|
|
21
21
|
throw InvalidInputException("Can only vacuum/analyze base tables!");
|
22
22
|
}
|
23
23
|
auto ref = unique_ptr_cast<BoundTableRef, BoundBaseTableRef>(std::move(bound_table));
|
24
|
-
|
24
|
+
auto &table = ref->table;
|
25
|
+
stmt.info->table = &table;
|
25
26
|
|
26
27
|
auto &columns = stmt.info->columns;
|
27
28
|
vector<unique_ptr<Expression>> select_list;
|
@@ -38,16 +39,16 @@ BoundStatement Binder::Bind(VacuumStatement &stmt) {
|
|
38
39
|
throw BinderException("Vacuum the same column twice(same name in column name list)");
|
39
40
|
}
|
40
41
|
column_name_set.insert(col_name);
|
41
|
-
if (!
|
42
|
+
if (!table.ColumnExists(col_name)) {
|
42
43
|
throw BinderException("Column with name \"%s\" does not exist", col_name);
|
43
44
|
}
|
44
|
-
auto &col =
|
45
|
+
auto &col = table.GetColumn(col_name);
|
45
46
|
// ignore generated column
|
46
47
|
if (col.Generated()) {
|
47
48
|
continue;
|
48
49
|
}
|
49
50
|
non_generated_column_names.push_back(col_name);
|
50
|
-
ColumnRefExpression colref(col_name,
|
51
|
+
ColumnRefExpression colref(col_name, table.name);
|
51
52
|
auto result = bind_context.BindColumn(colref, 0);
|
52
53
|
if (result.HasError()) {
|
53
54
|
throw BinderException(result.error);
|
@@ -65,7 +66,7 @@ BoundStatement Binder::Bind(VacuumStatement &stmt) {
|
|
65
66
|
D_ASSERT(stmt.info->columns.size() == get.column_ids.size());
|
66
67
|
for (idx_t i = 0; i < get.column_ids.size(); i++) {
|
67
68
|
stmt.info->column_id_map[i] =
|
68
|
-
|
69
|
+
table.GetColumns().LogicalToPhysical(LogicalIndex(get.column_ids[i])).index;
|
69
70
|
}
|
70
71
|
|
71
72
|
auto projection = make_uniq<LogicalProjection>(GenerateTableIndex(), std::move(select_list));
|
@@ -117,10 +117,10 @@ unique_ptr<BoundTableRef> Binder::Bind(BaseTableRef &ref) {
|
|
117
117
|
case CatalogType::TABLE_ENTRY: {
|
118
118
|
// base table: create the BoundBaseTableRef node
|
119
119
|
auto table_index = GenerateTableIndex();
|
120
|
-
auto table = (
|
120
|
+
auto &table = table_or_view->Cast<TableCatalogEntry>();
|
121
121
|
|
122
122
|
unique_ptr<FunctionData> bind_data;
|
123
|
-
auto scan_function = table
|
123
|
+
auto scan_function = table.GetScanFunction(context, bind_data);
|
124
124
|
auto alias = ref.alias.empty() ? ref.table_name : ref.alias;
|
125
125
|
// TODO: bundle the type and name vector in a struct (e.g PackedColumnMetadata)
|
126
126
|
vector<LogicalType> table_types;
|
@@ -129,7 +129,7 @@ unique_ptr<BoundTableRef> Binder::Bind(BaseTableRef &ref) {
|
|
129
129
|
|
130
130
|
vector<LogicalType> return_types;
|
131
131
|
vector<string> return_names;
|
132
|
-
for (auto &col : table
|
132
|
+
for (auto &col : table.GetColumns().Logical()) {
|
133
133
|
table_types.push_back(col.Type());
|
134
134
|
table_names.push_back(col.Name());
|
135
135
|
return_types.push_back(col.Type());
|
@@ -145,19 +145,19 @@ unique_ptr<BoundTableRef> Binder::Bind(BaseTableRef &ref) {
|
|
145
145
|
}
|
146
146
|
case CatalogType::VIEW_ENTRY: {
|
147
147
|
// the node is a view: get the query that the view represents
|
148
|
-
auto view_catalog_entry = (
|
148
|
+
auto &view_catalog_entry = table_or_view->Cast<ViewCatalogEntry>();
|
149
149
|
// We need to use a new binder for the view that doesn't reference any CTEs
|
150
150
|
// defined for this binder so there are no collisions between the CTEs defined
|
151
151
|
// for the view and for the current query
|
152
152
|
bool inherit_ctes = false;
|
153
153
|
auto view_binder = Binder::CreateBinder(context, this, inherit_ctes);
|
154
154
|
view_binder->can_contain_nulls = true;
|
155
|
-
SubqueryRef subquery(unique_ptr_cast<SQLStatement, SelectStatement>(view_catalog_entry
|
155
|
+
SubqueryRef subquery(unique_ptr_cast<SQLStatement, SelectStatement>(view_catalog_entry.query->Copy()));
|
156
156
|
subquery.alias = ref.alias.empty() ? ref.table_name : ref.alias;
|
157
157
|
subquery.column_name_alias =
|
158
|
-
BindContext::AliasColumnNames(subquery.alias, view_catalog_entry
|
158
|
+
BindContext::AliasColumnNames(subquery.alias, view_catalog_entry.aliases, ref.column_name_alias);
|
159
159
|
// bind the child subquery
|
160
|
-
view_binder->AddBoundView(
|
160
|
+
view_binder->AddBoundView(view_catalog_entry);
|
161
161
|
auto bound_child = view_binder->Bind(subquery);
|
162
162
|
if (!view_binder->correlated_columns.empty()) {
|
163
163
|
throw BinderException("Contents of view were altered - view bound correlated columns");
|
@@ -167,11 +167,11 @@ unique_ptr<BoundTableRef> Binder::Bind(BaseTableRef &ref) {
|
|
167
167
|
// verify that the types and names match up with the expected types and names
|
168
168
|
auto &bound_subquery = bound_child->Cast<BoundSubqueryRef>();
|
169
169
|
if (GetBindingMode() != BindingMode::EXTRACT_NAMES &&
|
170
|
-
bound_subquery.subquery->types != view_catalog_entry
|
170
|
+
bound_subquery.subquery->types != view_catalog_entry.types) {
|
171
171
|
throw BinderException("Contents of view were altered: types don't match!");
|
172
172
|
}
|
173
173
|
bind_context.AddView(bound_subquery.subquery->GetRootIndex(), subquery.alias, subquery,
|
174
|
-
*bound_subquery.subquery, view_catalog_entry);
|
174
|
+
*bound_subquery.subquery, &view_catalog_entry);
|
175
175
|
return bound_child;
|
176
176
|
}
|
177
177
|
default:
|
@@ -68,7 +68,7 @@ string Binder::FindBinding(const string &using_column, const string &join_side)
|
|
68
68
|
return result;
|
69
69
|
}
|
70
70
|
|
71
|
-
static void AddUsingBindings(UsingColumnSet &set, UsingColumnSet
|
71
|
+
static void AddUsingBindings(UsingColumnSet &set, optional_ptr<UsingColumnSet> input_set, const string &input_binding) {
|
72
72
|
if (input_set) {
|
73
73
|
for (auto &entry : input_set->bindings) {
|
74
74
|
set.bindings.insert(entry);
|
@@ -95,8 +95,8 @@ static void SetPrimaryBinding(UsingColumnSet &set, JoinType join_type, const str
|
|
95
95
|
}
|
96
96
|
}
|
97
97
|
|
98
|
-
string Binder::RetrieveUsingBinding(Binder ¤t_binder, UsingColumnSet
|
99
|
-
const string &
|
98
|
+
string Binder::RetrieveUsingBinding(Binder ¤t_binder, optional_ptr<UsingColumnSet> current_set,
|
99
|
+
const string &using_column, const string &join_side) {
|
100
100
|
string binding;
|
101
101
|
if (!current_set) {
|
102
102
|
binding = current_binder.FindBinding(using_column, join_side);
|
@@ -150,7 +150,7 @@ unique_ptr<BoundTableRef> Binder::Bind(JoinRef &ref) {
|
|
150
150
|
case_insensitive_set_t lhs_columns;
|
151
151
|
auto &lhs_binding_list = left_binder.bind_context.GetBindingsList();
|
152
152
|
for (auto &binding : lhs_binding_list) {
|
153
|
-
for (auto &column_name : binding.
|
153
|
+
for (auto &column_name : binding.get().names) {
|
154
154
|
lhs_columns.insert(column_name);
|
155
155
|
}
|
156
156
|
}
|
@@ -175,20 +175,22 @@ unique_ptr<BoundTableRef> Binder::Bind(JoinRef &ref) {
|
|
175
175
|
// gather all left/right candidates
|
176
176
|
string left_candidates, right_candidates;
|
177
177
|
auto &rhs_binding_list = right_binder.bind_context.GetBindingsList();
|
178
|
-
for (auto &
|
179
|
-
|
178
|
+
for (auto &binding_ref : lhs_binding_list) {
|
179
|
+
auto &binding = binding_ref.get();
|
180
|
+
for (auto &column_name : binding.names) {
|
180
181
|
if (!left_candidates.empty()) {
|
181
182
|
left_candidates += ", ";
|
182
183
|
}
|
183
|
-
left_candidates += binding.
|
184
|
+
left_candidates += binding.alias + "." + column_name;
|
184
185
|
}
|
185
186
|
}
|
186
|
-
for (auto &
|
187
|
-
|
187
|
+
for (auto &binding_ref : rhs_binding_list) {
|
188
|
+
auto &binding = binding_ref.get();
|
189
|
+
for (auto &column_name : binding.names) {
|
188
190
|
if (!right_candidates.empty()) {
|
189
191
|
right_candidates += ", ";
|
190
192
|
}
|
191
|
-
right_candidates += binding.
|
193
|
+
right_candidates += binding.alias + "." + column_name;
|
192
194
|
}
|
193
195
|
}
|
194
196
|
error_msg += "\n Left candidates: " + left_candidates;
|
@@ -213,8 +215,8 @@ unique_ptr<BoundTableRef> Binder::Bind(JoinRef &ref) {
|
|
213
215
|
extra_using_columns = RemoveDuplicateUsingColumns(extra_using_columns);
|
214
216
|
|
215
217
|
if (!extra_using_columns.empty()) {
|
216
|
-
vector<UsingColumnSet
|
217
|
-
vector<UsingColumnSet
|
218
|
+
vector<optional_ptr<UsingColumnSet>> left_using_bindings;
|
219
|
+
vector<optional_ptr<UsingColumnSet>> right_using_bindings;
|
218
220
|
for (idx_t i = 0; i < extra_using_columns.size(); i++) {
|
219
221
|
auto &using_column = extra_using_columns[i];
|
220
222
|
// we check if there is ALREADY a using column of the same name in the left and right set
|
@@ -238,10 +240,10 @@ unique_ptr<BoundTableRef> Binder::Bind(JoinRef &ref) {
|
|
238
240
|
string right_binding;
|
239
241
|
|
240
242
|
auto set = make_uniq<UsingColumnSet>();
|
241
|
-
auto left_using_binding = left_using_bindings[i];
|
242
|
-
auto right_using_binding = right_using_bindings[i];
|
243
|
-
left_binding = RetrieveUsingBinding(left_binder, left_using_binding, using_column, "left"
|
244
|
-
right_binding = RetrieveUsingBinding(right_binder, right_using_binding, using_column, "right"
|
243
|
+
auto &left_using_binding = left_using_bindings[i];
|
244
|
+
auto &right_using_binding = right_using_bindings[i];
|
245
|
+
left_binding = RetrieveUsingBinding(left_binder, left_using_binding, using_column, "left");
|
246
|
+
right_binding = RetrieveUsingBinding(right_binder, right_using_binding, using_column, "right");
|
245
247
|
|
246
248
|
// Last column of ASOF JOIN ... USING is >=
|
247
249
|
const auto type = (ref.ref_type == JoinRefType::ASOF && i == extra_using_columns.size() - 1)
|
@@ -254,9 +256,9 @@ unique_ptr<BoundTableRef> Binder::Bind(JoinRef &ref) {
|
|
254
256
|
AddUsingBindings(*set, left_using_binding, left_binding);
|
255
257
|
AddUsingBindings(*set, right_using_binding, right_binding);
|
256
258
|
SetPrimaryBinding(*set, ref.type, left_binding, right_binding);
|
257
|
-
bind_context.TransferUsingBinding(left_binder.bind_context, left_using_binding, set
|
259
|
+
bind_context.TransferUsingBinding(left_binder.bind_context, left_using_binding, *set, left_binding,
|
258
260
|
using_column);
|
259
|
-
bind_context.TransferUsingBinding(right_binder.bind_context, right_using_binding, set
|
261
|
+
bind_context.TransferUsingBinding(right_binder.bind_context, right_using_binding, *set, right_binding,
|
260
262
|
using_column);
|
261
263
|
AddUsingBindingSet(std::move(set));
|
262
264
|
}
|
@@ -278,7 +278,7 @@ unique_ptr<LogicalOperator> Binder::CreatePlan(BoundJoinRef &ref) {
|
|
278
278
|
auto result = LogicalComparisonJoin::CreateJoin(ref.type, ref.ref_type, std::move(left), std::move(right),
|
279
279
|
std::move(ref.condition));
|
280
280
|
|
281
|
-
LogicalOperator
|
281
|
+
optional_ptr<LogicalOperator> join;
|
282
282
|
if (result->type == LogicalOperatorType::LOGICAL_FILTER) {
|
283
283
|
join = result->children[0].get();
|
284
284
|
} else {
|
@@ -438,7 +438,7 @@ void VerifyNotExcluded(ParsedExpression &expr) {
|
|
438
438
|
expr, [&](const ParsedExpression &child) { VerifyNotExcluded((ParsedExpression &)child); });
|
439
439
|
}
|
440
440
|
|
441
|
-
BoundStatement Binder::BindReturning(vector<unique_ptr<ParsedExpression>> returning_list, TableCatalogEntry
|
441
|
+
BoundStatement Binder::BindReturning(vector<unique_ptr<ParsedExpression>> returning_list, TableCatalogEntry &table,
|
442
442
|
const string &alias, idx_t update_table_index,
|
443
443
|
unique_ptr<LogicalOperator> child_operator, BoundStatement result) {
|
444
444
|
|
@@ -449,7 +449,7 @@ BoundStatement Binder::BindReturning(vector<unique_ptr<ParsedExpression>> return
|
|
449
449
|
|
450
450
|
vector<column_t> bound_columns;
|
451
451
|
idx_t column_count = 0;
|
452
|
-
for (auto &col : table
|
452
|
+
for (auto &col : table.GetColumns().Logical()) {
|
453
453
|
names.push_back(col.Name());
|
454
454
|
types.push_back(col.Type());
|
455
455
|
if (!col.Generated()) {
|
@@ -458,8 +458,8 @@ BoundStatement Binder::BindReturning(vector<unique_ptr<ParsedExpression>> return
|
|
458
458
|
column_count++;
|
459
459
|
}
|
460
460
|
|
461
|
-
binder->bind_context.AddBaseTable(update_table_index, alias.empty() ? table
|
462
|
-
bound_columns, table, false);
|
461
|
+
binder->bind_context.AddBaseTable(update_table_index, alias.empty() ? table.name : alias, names, types,
|
462
|
+
bound_columns, &table, false);
|
463
463
|
ReturningBinder returning_binder(*binder, context);
|
464
464
|
|
465
465
|
vector<unique_ptr<Expression>> projection_expressions;
|
@@ -7,7 +7,8 @@
|
|
7
7
|
|
8
8
|
namespace duckdb {
|
9
9
|
|
10
|
-
IndexBinder::IndexBinder(Binder &binder, ClientContext &context, TableCatalogEntry
|
10
|
+
IndexBinder::IndexBinder(Binder &binder, ClientContext &context, optional_ptr<TableCatalogEntry> table,
|
11
|
+
optional_ptr<CreateIndexInfo> info)
|
11
12
|
: ExpressionBinder(binder, context), table(table), info(info) {
|
12
13
|
}
|
13
14
|
|
@@ -1,15 +1,16 @@
|
|
1
1
|
#include "duckdb/planner/expression_binder/where_binder.hpp"
|
2
2
|
#include "duckdb/planner/expression_binder/column_alias_binder.hpp"
|
3
|
+
#include "duckdb/parser/expression/columnref_expression.hpp"
|
3
4
|
|
4
5
|
namespace duckdb {
|
5
6
|
|
6
|
-
WhereBinder::WhereBinder(Binder &binder, ClientContext &context, ColumnAliasBinder
|
7
|
+
WhereBinder::WhereBinder(Binder &binder, ClientContext &context, optional_ptr<ColumnAliasBinder> column_alias_binder)
|
7
8
|
: ExpressionBinder(binder, context), column_alias_binder(column_alias_binder) {
|
8
9
|
target_type = LogicalType(LogicalTypeId::BOOLEAN);
|
9
10
|
}
|
10
11
|
|
11
12
|
BindResult WhereBinder::BindColumnRef(unique_ptr<ParsedExpression> *expr_ptr, idx_t depth, bool root_expression) {
|
12
|
-
auto &expr = (ColumnRefExpression
|
13
|
+
auto &expr = (*expr_ptr)->Cast<ColumnRefExpression>();
|
13
14
|
auto result = ExpressionBinder::BindExpression(expr_ptr, depth);
|
14
15
|
if (!result.HasError() || !column_alias_binder) {
|
15
16
|
return result;
|
@@ -8,7 +8,7 @@ void LogicalCreateTable::Serialize(FieldWriter &writer) const {
|
|
8
8
|
|
9
9
|
unique_ptr<LogicalOperator> LogicalCreateTable::Deserialize(LogicalDeserializationState &state, FieldReader &reader) {
|
10
10
|
auto info = reader.ReadRequiredSerializable<BoundCreateTableInfo>(state.gstate);
|
11
|
-
auto schema = info->schema;
|
11
|
+
auto &schema = info->schema;
|
12
12
|
return make_uniq<LogicalCreateTable>(schema, std::move(info));
|
13
13
|
}
|
14
14
|
|
@@ -4,13 +4,13 @@
|
|
4
4
|
|
5
5
|
namespace duckdb {
|
6
6
|
|
7
|
-
LogicalDelete::LogicalDelete(TableCatalogEntry
|
7
|
+
LogicalDelete::LogicalDelete(TableCatalogEntry &table, idx_t table_index)
|
8
8
|
: LogicalOperator(LogicalOperatorType::LOGICAL_DELETE), table(table), table_index(table_index),
|
9
9
|
return_chunk(false) {
|
10
10
|
}
|
11
11
|
|
12
12
|
void LogicalDelete::Serialize(FieldWriter &writer) const {
|
13
|
-
table
|
13
|
+
table.Serialize(writer.GetSerializer());
|
14
14
|
writer.WriteField(table_index);
|
15
15
|
writer.WriteField(return_chunk);
|
16
16
|
}
|
@@ -23,7 +23,7 @@ unique_ptr<LogicalOperator> LogicalDelete::Deserialize(LogicalDeserializationSta
|
|
23
23
|
Catalog::GetEntry<TableCatalogEntry>(context, INVALID_CATALOG, info->schema, info->table);
|
24
24
|
|
25
25
|
auto table_index = reader.ReadRequired<idx_t>();
|
26
|
-
auto result = make_uniq<LogicalDelete>(table_catalog_entry, table_index);
|
26
|
+
auto result = make_uniq<LogicalDelete>(*table_catalog_entry, table_index);
|
27
27
|
result->return_chunk = reader.ReadRequired<bool>();
|
28
28
|
return std::move(result);
|
29
29
|
}
|
@@ -38,14 +38,14 @@ vector<idx_t> LogicalDelete::GetTableIndex() const {
|
|
38
38
|
|
39
39
|
vector<ColumnBinding> LogicalDelete::GetColumnBindings() {
|
40
40
|
if (return_chunk) {
|
41
|
-
return GenerateColumnBindings(table_index, table
|
41
|
+
return GenerateColumnBindings(table_index, table.GetTypes().size());
|
42
42
|
}
|
43
43
|
return {ColumnBinding(0, 0)};
|
44
44
|
}
|
45
45
|
|
46
46
|
void LogicalDelete::ResolveTypes() {
|
47
47
|
if (return_chunk) {
|
48
|
-
types = table
|
48
|
+
types = table.GetTypes();
|
49
49
|
} else {
|
50
50
|
types.emplace_back(LogicalType::BIGINT);
|
51
51
|
}
|
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
namespace duckdb {
|
7
7
|
|
8
|
-
LogicalInsert::LogicalInsert(TableCatalogEntry
|
8
|
+
LogicalInsert::LogicalInsert(TableCatalogEntry &table, idx_t table_index)
|
9
9
|
: LogicalOperator(LogicalOperatorType::LOGICAL_INSERT), table(table), table_index(table_index), return_chunk(false),
|
10
10
|
action_type(OnConflictAction::THROW) {
|
11
11
|
}
|
@@ -18,7 +18,7 @@ void LogicalInsert::Serialize(FieldWriter &writer) const {
|
|
18
18
|
|
19
19
|
writer.WriteList<idx_t>(column_index_map);
|
20
20
|
writer.WriteRegularSerializableList(expected_types);
|
21
|
-
table
|
21
|
+
table.Serialize(writer.GetSerializer());
|
22
22
|
writer.WriteField(table_index);
|
23
23
|
writer.WriteField(return_chunk);
|
24
24
|
writer.WriteSerializableList(bound_defaults);
|
@@ -43,15 +43,14 @@ unique_ptr<LogicalOperator> LogicalInsert::Deserialize(LogicalDeserializationSta
|
|
43
43
|
|
44
44
|
auto &catalog = Catalog::GetCatalog(context, INVALID_CATALOG);
|
45
45
|
|
46
|
-
|
46
|
+
auto table_catalog_entry = catalog.GetEntry<TableCatalogEntry>(context, info->schema, info->table);
|
47
47
|
|
48
48
|
if (!table_catalog_entry) {
|
49
49
|
throw InternalException("Cant find catalog entry for table %s", info->table);
|
50
50
|
}
|
51
51
|
|
52
|
-
auto result = make_uniq<LogicalInsert>(table_catalog_entry, table_index);
|
52
|
+
auto result = make_uniq<LogicalInsert>(*table_catalog_entry, table_index);
|
53
53
|
result->type = state.type;
|
54
|
-
result->table = table_catalog_entry;
|
55
54
|
result->return_chunk = return_chunk;
|
56
55
|
result->insert_values = std::move(insert_values);
|
57
56
|
result->column_index_map = column_index_map;
|
@@ -71,14 +70,14 @@ vector<idx_t> LogicalInsert::GetTableIndex() const {
|
|
71
70
|
|
72
71
|
vector<ColumnBinding> LogicalInsert::GetColumnBindings() {
|
73
72
|
if (return_chunk) {
|
74
|
-
return GenerateColumnBindings(table_index, table
|
73
|
+
return GenerateColumnBindings(table_index, table.GetTypes().size());
|
75
74
|
}
|
76
75
|
return {ColumnBinding(0, 0)};
|
77
76
|
}
|
78
77
|
|
79
78
|
void LogicalInsert::ResolveTypes() {
|
80
79
|
if (return_chunk) {
|
81
|
-
types = table
|
80
|
+
types = table.GetTypes();
|
82
81
|
} else {
|
83
82
|
types.emplace_back(LogicalType::BIGINT);
|
84
83
|
}
|