1#include "duckdb/execution/operator/persistent/physical_delete.hpp"
2
3#include "duckdb/execution/expression_executor.hpp"
4#include "duckdb/storage/data_table.hpp"
5
6using namespace duckdb;
7using namespace std;
8
9void PhysicalDelete::GetChunkInternal(ClientContext &context, DataChunk &chunk, PhysicalOperatorState *state) {
10 int64_t deleted_count = 0;
11 while (true) {
12 children[0]->GetChunk(context, state->child_chunk, state->child_state.get());
13 if (state->child_chunk.size() == 0) {
14 break;
15 }
16 // delete data in the base table
17 // the row ids are given to us as the last column of the child chunk
18 table.Delete(tableref, context, state->child_chunk.data[row_id_index], state->child_chunk.size());
19 deleted_count += state->child_chunk.size();
20 }
21
22 chunk.SetCardinality(1);
23 chunk.SetValue(0, 0, Value::BIGINT(deleted_count));
24
25 state->finished = true;
26}
27