1#include "duckdb/parser/parsed_data/create_index_info.hpp"
2
3#include "duckdb/common/field_writer.hpp"
4
5namespace duckdb {
6
7unique_ptr<CreateInfo> CreateIndexInfo::Copy() const {
8 auto result = make_uniq<CreateIndexInfo>();
9 CopyProperties(other&: *result);
10
11 result->index_type = index_type;
12 result->index_name = index_name;
13 result->constraint_type = constraint_type;
14 result->table = unique_ptr_cast<TableRef, BaseTableRef>(src: table->Copy());
15 for (auto &expr : expressions) {
16 result->expressions.push_back(x: expr->Copy());
17 }
18 for (auto &expr : parsed_expressions) {
19 result->parsed_expressions.push_back(x: expr->Copy());
20 }
21
22 result->scan_types = scan_types;
23 result->names = names;
24 result->column_ids = column_ids;
25 return std::move(result);
26}
27
28void CreateIndexInfo::SerializeInternal(Serializer &serializer) const {
29 FieldWriter writer(serializer);
30 writer.WriteField(element: index_type);
31 writer.WriteString(val: index_name);
32 writer.WriteField(element: constraint_type);
33
34 writer.WriteSerializableList<ParsedExpression>(elements: parsed_expressions);
35
36 writer.WriteRegularSerializableList(elements: scan_types);
37 writer.WriteList<string>(elements: names);
38 writer.WriteList<column_t>(elements: column_ids);
39 writer.Finalize();
40}
41
42unique_ptr<CreateIndexInfo> CreateIndexInfo::Deserialize(Deserializer &deserializer) {
43 auto result = make_uniq<CreateIndexInfo>();
44 result->DeserializeBase(deserializer);
45
46 FieldReader reader(deserializer);
47 result->index_type = reader.ReadRequired<IndexType>();
48 result->index_name = reader.ReadRequired<string>();
49 result->constraint_type = reader.ReadRequired<IndexConstraintType>();
50
51 result->parsed_expressions = reader.ReadRequiredSerializableList<ParsedExpression>();
52
53 result->scan_types = reader.ReadRequiredSerializableList<LogicalType, LogicalType>();
54 result->names = reader.ReadRequiredList<string>();
55 result->column_ids = reader.ReadRequiredList<column_t>();
56 reader.Finalize();
57 return result;
58}
59} // namespace duckdb
60