1//===----------------------------------------------------------------------===//
2// DuckDB
3//
4// duckdb/planner/operator/logical_prepare.hpp
5//
6//
7//===----------------------------------------------------------------------===//
8
9#pragma once
10
11#include "duckdb/common/unordered_map.hpp"
12#include "duckdb/common/unordered_set.hpp"
13#include "duckdb/main/prepared_statement_data.hpp"
14#include "duckdb/planner/logical_operator.hpp"
15
16namespace duckdb {
17
18class TableCatalogEntry;
19
20class LogicalPrepare : public LogicalOperator {
21public:
22 static constexpr const LogicalOperatorType TYPE = LogicalOperatorType::LOGICAL_PREPARE;
23
24public:
25 LogicalPrepare(string name, shared_ptr<PreparedStatementData> prepared, unique_ptr<LogicalOperator> logical_plan)
26 : LogicalOperator(LogicalOperatorType::LOGICAL_PREPARE), name(name), prepared(std::move(prepared)) {
27 if (logical_plan) {
28 children.push_back(x: std::move(logical_plan));
29 }
30 }
31
32 string name;
33 shared_ptr<PreparedStatementData> prepared;
34
35public:
36 void Serialize(FieldWriter &writer) const override;
37 static unique_ptr<LogicalOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader);
38 idx_t EstimateCardinality(ClientContext &context) override;
39 //! Skips the serialization check in VerifyPlan
40 bool SupportSerialization() const override {
41 return false;
42 }
43
44protected:
45 void ResolveTypes() override {
46 types.emplace_back(args: LogicalType::BOOLEAN);
47 }
48
49 bool RequireOptimizer() const override {
50 if (!prepared->properties.bound_all_parameters) {
51 return false;
52 }
53 return children[0]->RequireOptimizer();
54 }
55};
56} // namespace duckdb
57