1#include "duckdb/parser/parsed_data/create_info.hpp"
2
3#include "duckdb/parser/parsed_data/create_index_info.hpp"
4#include "duckdb/parser/parsed_data/create_schema_info.hpp"
5#include "duckdb/parser/parsed_data/create_table_info.hpp"
6#include "duckdb/parser/parsed_data/create_view_info.hpp"
7#include "duckdb/parser/parsed_data/create_sequence_info.hpp"
8#include "duckdb/parser/parsed_data/create_type_info.hpp"
9#include "duckdb/parser/parsed_data/alter_info.hpp"
10#include "duckdb/parser/parsed_data/create_macro_info.hpp"
11
12namespace duckdb {
13
14void CreateInfo::Serialize(Serializer &serializer) const {
15 serializer.Write(element: type);
16 serializer.WriteString(val: catalog);
17 serializer.WriteString(val: schema);
18 serializer.Write(element: on_conflict);
19 serializer.Write(element: temporary);
20 serializer.Write(element: internal);
21 serializer.WriteString(val: sql);
22 SerializeInternal(serializer);
23}
24
25void CreateInfo::DeserializeBase(Deserializer &deserializer) {
26 this->catalog = deserializer.Read<string>();
27 this->schema = deserializer.Read<string>();
28 this->on_conflict = deserializer.Read<OnCreateConflict>();
29 this->temporary = deserializer.Read<bool>();
30 this->internal = deserializer.Read<bool>();
31 this->sql = deserializer.Read<string>();
32}
33
34unique_ptr<CreateInfo> CreateInfo::Deserialize(Deserializer &deserializer) {
35 auto type = deserializer.Read<CatalogType>();
36 switch (type) {
37 case CatalogType::INDEX_ENTRY:
38 return CreateIndexInfo::Deserialize(deserializer);
39 case CatalogType::TABLE_ENTRY:
40 return CreateTableInfo::Deserialize(deserializer);
41 case CatalogType::SCHEMA_ENTRY:
42 return CreateSchemaInfo::Deserialize(deserializer);
43 case CatalogType::VIEW_ENTRY:
44 return CreateViewInfo::Deserialize(deserializer);
45 case CatalogType::TYPE_ENTRY:
46 return CreateTypeInfo::Deserialize(deserializer);
47 case CatalogType::MACRO_ENTRY:
48 case CatalogType::TABLE_MACRO_ENTRY:
49 return CreateMacroInfo::Deserialize(deserializer);
50 case CatalogType::SEQUENCE_ENTRY:
51 return CreateSequenceInfo::Deserialize(deserializer);
52 default:
53 throw NotImplementedException("Cannot deserialize '%s'", CatalogTypeToString(type));
54 }
55}
56
57unique_ptr<CreateInfo> CreateInfo::Deserialize(Deserializer &source, PlanDeserializationState &state) {
58 return Deserialize(deserializer&: source);
59}
60
61void CreateInfo::CopyProperties(CreateInfo &other) const {
62 other.type = type;
63 other.catalog = catalog;
64 other.schema = schema;
65 other.on_conflict = on_conflict;
66 other.temporary = temporary;
67 other.internal = internal;
68 other.sql = sql;
69}
70
71unique_ptr<AlterInfo> CreateInfo::GetAlterInfo() const {
72 throw NotImplementedException("GetAlterInfo not implemented for this type");
73}
74
75} // namespace duckdb
76