1 | #include "duckdb/catalog/catalog_entry/table_catalog_entry.hpp" |
2 | #include "duckdb/execution/operator/persistent/physical_update.hpp" |
3 | #include "duckdb/execution/physical_plan_generator.hpp" |
4 | #include "duckdb/planner/operator/logical_update.hpp" |
5 | #include "duckdb/catalog/duck_catalog.hpp" |
6 | |
7 | namespace duckdb { |
8 | |
9 | unique_ptr<PhysicalOperator> DuckCatalog::PlanUpdate(ClientContext &context, LogicalUpdate &op, |
10 | unique_ptr<PhysicalOperator> plan) { |
11 | auto update = |
12 | make_uniq<PhysicalUpdate>(args&: op.types, args&: op.table, args&: op.table.GetStorage(), args&: op.columns, args: std::move(op.expressions), |
13 | args: std::move(op.bound_defaults), args&: op.estimated_cardinality, args&: op.return_chunk); |
14 | |
15 | update->update_is_del_and_insert = op.update_is_del_and_insert; |
16 | update->children.push_back(x: std::move(plan)); |
17 | return std::move(update); |
18 | } |
19 | |
20 | unique_ptr<PhysicalOperator> PhysicalPlanGenerator::CreatePlan(LogicalUpdate &op) { |
21 | D_ASSERT(op.children.size() == 1); |
22 | |
23 | auto plan = CreatePlan(op&: *op.children[0]); |
24 | |
25 | dependencies.AddDependency(entry&: op.table); |
26 | return op.table.catalog.PlanUpdate(context, op, plan: std::move(plan)); |
27 | } |
28 | |
29 | } // namespace duckdb |
30 | |