1 | //===----------------------------------------------------------------------===// |
---|---|
2 | // DuckDB |
3 | // |
4 | // duckdb/planner/expression/bound_parameter_data.hpp |
5 | // |
6 | // |
7 | //===----------------------------------------------------------------------===// |
8 | |
9 | #pragma once |
10 | |
11 | #include "duckdb/common/types/value.hpp" |
12 | #include "duckdb/planner/bound_parameter_map.hpp" |
13 | #include "duckdb/common/field_writer.hpp" |
14 | |
15 | namespace duckdb { |
16 | |
17 | struct BoundParameterData { |
18 | BoundParameterData() { |
19 | } |
20 | BoundParameterData(Value val) : value(std::move(val)), return_type(value.type()) { |
21 | } |
22 | |
23 | Value value; |
24 | LogicalType return_type; |
25 | |
26 | public: |
27 | void Serialize(Serializer &serializer) const { |
28 | FieldWriter writer(serializer); |
29 | value.Serialize(main_serializer&: writer.GetSerializer()); |
30 | writer.WriteSerializable(element: return_type); |
31 | writer.Finalize(); |
32 | } |
33 | |
34 | static shared_ptr<BoundParameterData> Deserialize(Deserializer &source) { |
35 | FieldReader reader(source); |
36 | auto value = Value::Deserialize(main_source&: reader.GetSource()); |
37 | auto result = make_shared<BoundParameterData>(args: std::move(value)); |
38 | result->return_type = reader.ReadRequiredSerializable<LogicalType, LogicalType>(); |
39 | reader.Finalize(); |
40 | return result; |
41 | } |
42 | }; |
43 | |
44 | struct BoundParameterMap { |
45 | BoundParameterMap(vector<BoundParameterData> ¶meter_data) : parameter_data(parameter_data) { |
46 | } |
47 | |
48 | bound_parameter_map_t parameters; |
49 | vector<BoundParameterData> ¶meter_data; |
50 | |
51 | LogicalType GetReturnType(idx_t index) { |
52 | if (index >= parameter_data.size()) { |
53 | return LogicalTypeId::UNKNOWN; |
54 | } |
55 | return parameter_data[index].return_type; |
56 | } |
57 | }; |
58 | |
59 | } // namespace duckdb |
60 |