1 | //===----------------------------------------------------------------------===// |
2 | // DuckDB |
3 | // |
4 | // duckdb/verification/statement_verifier.hpp |
5 | // |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #pragma once |
10 | |
11 | #include "duckdb/main/client_context.hpp" |
12 | #include "duckdb/main/materialized_query_result.hpp" |
13 | #include "duckdb/parser/statement/select_statement.hpp" |
14 | |
15 | namespace duckdb { |
16 | |
17 | enum class VerificationType : uint8_t { |
18 | ORIGINAL, |
19 | COPIED, |
20 | DESERIALIZED, |
21 | DESERIALIZED_V2, |
22 | PARSED, |
23 | UNOPTIMIZED, |
24 | NO_OPERATOR_CACHING, |
25 | PREPARED, |
26 | EXTERNAL, |
27 | |
28 | INVALID |
29 | }; |
30 | |
31 | class StatementVerifier { |
32 | public: |
33 | StatementVerifier(VerificationType type, string name, unique_ptr<SQLStatement> statement_p); |
34 | explicit StatementVerifier(unique_ptr<SQLStatement> statement_p); |
35 | static unique_ptr<StatementVerifier> Create(VerificationType type, const SQLStatement &statement_p); |
36 | virtual ~StatementVerifier() noexcept; |
37 | |
38 | //! Check whether expressions in this verifier and the other verifier match |
39 | void CheckExpressions(const StatementVerifier &other) const; |
40 | //! Check whether expressions within this verifier match |
41 | void CheckExpressions() const; |
42 | |
43 | //! Run the select statement and store the result |
44 | virtual bool Run(ClientContext &context, const string &query, |
45 | const std::function<unique_ptr<QueryResult>(const string &, unique_ptr<SQLStatement>)> &run); |
46 | //! Compare this verifier's results with another verifier |
47 | string CompareResults(const StatementVerifier &other); |
48 | |
49 | public: |
50 | const VerificationType type; |
51 | const string name; |
52 | unique_ptr<SelectStatement> statement; |
53 | const vector<unique_ptr<ParsedExpression>> &select_list; |
54 | unique_ptr<MaterializedQueryResult> materialized_result; |
55 | |
56 | virtual bool RequireEquality() const { |
57 | return true; |
58 | } |
59 | |
60 | virtual bool DisableOptimizer() const { |
61 | return false; |
62 | } |
63 | |
64 | virtual bool DisableOperatorCaching() const { |
65 | return false; |
66 | } |
67 | |
68 | virtual bool ForceExternal() const { |
69 | return false; |
70 | } |
71 | }; |
72 | |
73 | } // namespace duckdb |
74 | |