1#include "duckdb/parser/parsed_data/create_sequence_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
8CreateSequenceInfo::CreateSequenceInfo()
9 : CreateInfo(CatalogType::SEQUENCE_ENTRY, INVALID_SCHEMA), name(string()), usage_count(0), increment(1),
10 min_value(1), max_value(NumericLimits<int64_t>::Maximum()), start_value(1), cycle(false) {
11}
12
13unique_ptr<CreateInfo> CreateSequenceInfo::Copy() const {
14 auto result = make_uniq<CreateSequenceInfo>();
15 CopyProperties(other&: *result);
16 result->name = name;
17 result->schema = schema;
18 result->usage_count = usage_count;
19 result->increment = increment;
20 result->min_value = min_value;
21 result->max_value = max_value;
22 result->start_value = start_value;
23 result->cycle = cycle;
24 return std::move(result);
25}
26
27void CreateSequenceInfo::SerializeInternal(Serializer &serializer) const {
28 FieldWriter writer(serializer);
29 writer.WriteString(val: name);
30 writer.WriteField(element: usage_count);
31 writer.WriteField(element: increment);
32 writer.WriteField(element: min_value);
33 writer.WriteField(element: max_value);
34 writer.WriteField(element: start_value);
35 writer.WriteField(element: cycle);
36 writer.Finalize();
37}
38
39unique_ptr<CreateSequenceInfo> CreateSequenceInfo::Deserialize(Deserializer &deserializer) {
40 auto result = make_uniq<CreateSequenceInfo>();
41 result->DeserializeBase(deserializer);
42
43 FieldReader reader(deserializer);
44 result->name = reader.ReadRequired<string>();
45 result->usage_count = reader.ReadRequired<uint64_t>();
46 result->increment = reader.ReadRequired<int64_t>();
47 result->min_value = reader.ReadRequired<int64_t>();
48 result->max_value = reader.ReadRequired<int64_t>();
49 result->start_value = reader.ReadRequired<int64_t>();
50 result->cycle = reader.ReadRequired<bool>();
51 reader.Finalize();
52
53 return result;
54}
55
56} // namespace duckdb
57