1 | #include "duckdb/parser/statement/update_statement.hpp" |
---|---|
2 | #include "duckdb/parser/transformer.hpp" |
3 | |
4 | using namespace duckdb; |
5 | using namespace std; |
6 | |
7 | unique_ptr<UpdateStatement> Transformer::TransformUpdate(PGNode *node) { |
8 | auto stmt = reinterpret_cast<PGUpdateStmt *>(node); |
9 | assert(stmt); |
10 | |
11 | auto result = make_unique<UpdateStatement>(); |
12 | |
13 | result->table = TransformRangeVar(stmt->relation); |
14 | result->condition = TransformExpression(stmt->whereClause); |
15 | |
16 | auto root = stmt->targetList; |
17 | for (auto cell = root->head; cell != NULL; cell = cell->next) { |
18 | auto target = (PGResTarget *)(cell->data.ptr_value); |
19 | result->columns.push_back(target->name); |
20 | result->expressions.push_back(TransformExpression(target->val)); |
21 | } |
22 | return result; |
23 | } |
24 |