1#include "duckdb/catalog/catalog_entry/table_catalog_entry.hpp"
2#include "duckdb/execution/operator/persistent/physical_delete.hpp"
3#include "duckdb/execution/physical_plan_generator.hpp"
4#include "duckdb/planner/expression/bound_reference_expression.hpp"
5#include "duckdb/planner/operator/logical_delete.hpp"
6
7using namespace duckdb;
8using namespace std;
9
10unique_ptr<PhysicalOperator> PhysicalPlanGenerator::CreatePlan(LogicalDelete &op) {
11 assert(op.children.size() == 1);
12 assert(op.expressions.size() == 1);
13 assert(op.expressions[0]->type == ExpressionType::BOUND_REF);
14
15 auto plan = CreatePlan(*op.children[0]);
16
17 // get the index of the row_id column
18 auto &bound_ref = (BoundReferenceExpression &)*op.expressions[0];
19
20 dependencies.insert(op.table);
21 auto del = make_unique<PhysicalDelete>(op, *op.table, *op.table->storage, bound_ref.index);
22 del->children.push_back(move(plan));
23 return move(del);
24}
25