1#include "duckdb/parser/parsed_data/create_macro_info.hpp"
2#include "duckdb/catalog/catalog_entry/schema_catalog_entry.hpp"
3#include "duckdb/catalog/catalog_entry/table_catalog_entry.hpp"
4#include "duckdb/catalog/catalog.hpp"
5
6namespace duckdb {
7
8CreateMacroInfo::CreateMacroInfo() : CreateFunctionInfo(CatalogType::MACRO_ENTRY, INVALID_SCHEMA) {
9}
10
11CreateMacroInfo::CreateMacroInfo(CatalogType type) : CreateFunctionInfo(type, INVALID_SCHEMA) {
12}
13
14unique_ptr<CreateInfo> CreateMacroInfo::Copy() const {
15 auto result = make_uniq<CreateMacroInfo>();
16 result->function = function->Copy();
17 result->name = name;
18 CopyProperties(other&: *result);
19 return std::move(result);
20}
21
22void CreateMacroInfo::SerializeInternal(Serializer &serializer) const {
23 FieldWriter writer(serializer);
24 writer.WriteString(val: name);
25 writer.WriteSerializable(element: *function);
26 writer.Finalize();
27}
28
29unique_ptr<CreateMacroInfo> CreateMacroInfo::Deserialize(Deserializer &deserializer) {
30 auto result = make_uniq<CreateMacroInfo>();
31 result->DeserializeBase(deserializer);
32
33 FieldReader reader(deserializer);
34 result->name = reader.ReadRequired<string>();
35 result->function = reader.ReadRequiredSerializable<MacroFunction>();
36 reader.Finalize();
37
38 if (result->function->type == MacroType::TABLE_MACRO) {
39 result->type = CatalogType::TABLE_MACRO_ENTRY;
40 } else {
41 result->type = CatalogType::MACRO_ENTRY;
42 }
43 return result;
44}
45
46} // namespace duckdb
47