| 1 | //===----------------------------------------------------------------------===// |
|---|---|
| 2 | // DuckDB |
| 3 | // |
| 4 | // duckdb/planner/planner.hpp |
| 5 | // |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #pragma once |
| 10 | |
| 11 | #include "duckdb/parser/sql_statement.hpp" |
| 12 | #include "duckdb/planner/binder.hpp" |
| 13 | #include "duckdb/planner/logical_operator.hpp" |
| 14 | #include "duckdb/planner/expression/bound_parameter_data.hpp" |
| 15 | |
| 16 | namespace duckdb { |
| 17 | class ClientContext; |
| 18 | class PreparedStatementData; |
| 19 | |
| 20 | //! The planner creates a logical query plan from the parsed SQL statements |
| 21 | //! using the Binder and LogicalPlanGenerator. |
| 22 | class Planner { |
| 23 | friend class Binder; |
| 24 | |
| 25 | public: |
| 26 | explicit Planner(ClientContext &context); |
| 27 | |
| 28 | unique_ptr<LogicalOperator> plan; |
| 29 | vector<string> names; |
| 30 | vector<LogicalType> types; |
| 31 | bound_parameter_map_t value_map; |
| 32 | vector<BoundParameterData> parameter_data; |
| 33 | |
| 34 | shared_ptr<Binder> binder; |
| 35 | ClientContext &context; |
| 36 | |
| 37 | StatementProperties properties; |
| 38 | |
| 39 | public: |
| 40 | void CreatePlan(unique_ptr<SQLStatement> statement); |
| 41 | static void VerifyPlan(ClientContext &context, unique_ptr<LogicalOperator> &op, |
| 42 | bound_parameter_map_t *map = nullptr); |
| 43 | |
| 44 | private: |
| 45 | void CreatePlan(SQLStatement &statement); |
| 46 | shared_ptr<PreparedStatementData> PrepareSQLStatement(unique_ptr<SQLStatement> statement); |
| 47 | }; |
| 48 | } // namespace duckdb |
| 49 |