| 1 | //===----------------------------------------------------------------------===// |
|---|---|
| 2 | // DuckDB |
| 3 | // |
| 4 | // duckdb/main/prepared_statement_data.hpp |
| 5 | // |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #pragma once |
| 10 | |
| 11 | #include "duckdb/common/enums/statement_type.hpp" |
| 12 | #include "duckdb/common/types/value.hpp" |
| 13 | #include "duckdb/common/unordered_map.hpp" |
| 14 | #include "duckdb/common/unordered_set.hpp" |
| 15 | #include "duckdb/common/winapi.hpp" |
| 16 | #include "duckdb/planner/expression/bound_parameter_data.hpp" |
| 17 | |
| 18 | namespace duckdb { |
| 19 | class CatalogEntry; |
| 20 | class ClientContext; |
| 21 | class PhysicalOperator; |
| 22 | class SQLStatement; |
| 23 | |
| 24 | class PreparedStatementData { |
| 25 | public: |
| 26 | DUCKDB_API explicit PreparedStatementData(StatementType type); |
| 27 | DUCKDB_API ~PreparedStatementData(); |
| 28 | |
| 29 | StatementType statement_type; |
| 30 | //! The unbound SQL statement that was prepared |
| 31 | unique_ptr<SQLStatement> unbound_statement; |
| 32 | //! The fully prepared physical plan of the prepared statement |
| 33 | unique_ptr<PhysicalOperator> plan; |
| 34 | //! The map of parameter index to the actual value entry |
| 35 | bound_parameter_map_t value_map; |
| 36 | |
| 37 | //! The result names of the transaction |
| 38 | vector<string> names; |
| 39 | //! The result types of the transaction |
| 40 | vector<LogicalType> types; |
| 41 | |
| 42 | //! The statement properties |
| 43 | StatementProperties properties; |
| 44 | |
| 45 | //! The catalog version of when the prepared statement was bound |
| 46 | //! If this version is lower than the current catalog version, we have to rebind the prepared statement |
| 47 | idx_t catalog_version; |
| 48 | |
| 49 | public: |
| 50 | void CheckParameterCount(idx_t parameter_count); |
| 51 | //! Whether or not the prepared statement data requires the query to rebound for the given parameters |
| 52 | bool RequireRebind(ClientContext &context, const vector<Value> &values); |
| 53 | //! Bind a set of values to the prepared statement data |
| 54 | DUCKDB_API void Bind(vector<Value> values); |
| 55 | //! Get the expected SQL Type of the bound parameter |
| 56 | DUCKDB_API LogicalType GetType(idx_t param_index); |
| 57 | //! Try to get the expected SQL Type of the bound parameter |
| 58 | DUCKDB_API bool TryGetType(idx_t param_idx, LogicalType &result); |
| 59 | }; |
| 60 | |
| 61 | } // namespace duckdb |
| 62 |