1 | //===----------------------------------------------------------------------===// |
---|---|
2 | // DuckDB |
3 | // |
4 | // duckdb/parser/statement/update_statement.hpp |
5 | // |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #pragma once |
10 | |
11 | #include "duckdb/parser/parsed_expression.hpp" |
12 | #include "duckdb/parser/sql_statement.hpp" |
13 | #include "duckdb/parser/tableref.hpp" |
14 | #include "duckdb/common/vector.hpp" |
15 | #include "duckdb/parser/query_node.hpp" |
16 | |
17 | namespace duckdb { |
18 | |
19 | class UpdateSetInfo { |
20 | public: |
21 | UpdateSetInfo(); |
22 | |
23 | public: |
24 | unique_ptr<UpdateSetInfo> Copy() const; |
25 | |
26 | public: |
27 | // The condition that needs to be met to perform the update |
28 | unique_ptr<ParsedExpression> condition; |
29 | // The columns to update |
30 | vector<string> columns; |
31 | // The set expressions to execute |
32 | vector<unique_ptr<ParsedExpression>> expressions; |
33 | |
34 | protected: |
35 | UpdateSetInfo(const UpdateSetInfo &other); |
36 | }; |
37 | |
38 | class UpdateStatement : public SQLStatement { |
39 | public: |
40 | static constexpr const StatementType TYPE = StatementType::UPDATE_STATEMENT; |
41 | |
42 | public: |
43 | UpdateStatement(); |
44 | |
45 | unique_ptr<TableRef> table; |
46 | unique_ptr<TableRef> from_table; |
47 | //! keep track of optional returningList if statement contains a RETURNING keyword |
48 | vector<unique_ptr<ParsedExpression>> returning_list; |
49 | unique_ptr<UpdateSetInfo> set_info; |
50 | //! CTEs |
51 | CommonTableExpressionMap cte_map; |
52 | |
53 | protected: |
54 | UpdateStatement(const UpdateStatement &other); |
55 | |
56 | public: |
57 | string ToString() const override; |
58 | unique_ptr<SQLStatement> Copy() const override; |
59 | }; |
60 | |
61 | } // namespace duckdb |
62 |