1#include "duckdb/planner/binder.hpp"
2#include "duckdb/parser/statement/prepare_statement.hpp"
3#include "duckdb/planner/planner.hpp"
4#include "duckdb/planner/operator/logical_prepare.hpp"
5
6namespace duckdb {
7
8BoundStatement Binder::Bind(PrepareStatement &stmt) {
9 Planner prepared_planner(context);
10 auto prepared_data = prepared_planner.PrepareSQLStatement(statement: std::move(stmt.statement));
11 this->bound_tables = prepared_planner.binder->bound_tables;
12
13 auto prepare = make_uniq<LogicalPrepare>(args&: stmt.name, args: std::move(prepared_data), args: std::move(prepared_planner.plan));
14 // we can always prepare, even if the transaction has been invalidated
15 // this is required because most clients ALWAYS invoke prepared statements
16 properties.requires_valid_transaction = false;
17 properties.allow_stream_result = false;
18 properties.bound_all_parameters = true;
19 properties.parameter_count = 0;
20 properties.return_type = StatementReturnType::NOTHING;
21
22 BoundStatement result;
23 result.names = {"Success"};
24 result.types = {LogicalType::BOOLEAN};
25 result.plan = std::move(prepare);
26 return result;
27}
28
29} // namespace duckdb
30