1 | #include "duckdb/catalog/catalog_entry/sequence_catalog_entry.hpp" |
2 | |
3 | #include "duckdb/catalog/catalog_entry/schema_catalog_entry.hpp" |
4 | #include "duckdb/common/exception.hpp" |
5 | #include "duckdb/common/serializer.hpp" |
6 | #include "duckdb/parser/parsed_data/create_sequence_info.hpp" |
7 | |
8 | #include <algorithm> |
9 | |
10 | using namespace duckdb; |
11 | using namespace std; |
12 | |
13 | SequenceCatalogEntry::SequenceCatalogEntry(Catalog *catalog, SchemaCatalogEntry *schema, CreateSequenceInfo *info) |
14 | : StandardEntry(CatalogType::SEQUENCE, schema, catalog, info->name), usage_count(info->usage_count), |
15 | counter(info->start_value), increment(info->increment), start_value(info->start_value), |
16 | min_value(info->min_value), max_value(info->max_value), cycle(info->cycle) { |
17 | this->temporary = info->temporary; |
18 | } |
19 | |
20 | void SequenceCatalogEntry::Serialize(Serializer &serializer) { |
21 | serializer.WriteString(schema->name); |
22 | serializer.WriteString(name); |
23 | // serializer.Write<int64_t>(counter); |
24 | serializer.Write<uint64_t>(usage_count); |
25 | serializer.Write<int64_t>(increment); |
26 | serializer.Write<int64_t>(min_value); |
27 | serializer.Write<int64_t>(max_value); |
28 | serializer.Write<int64_t>(counter); |
29 | serializer.Write<bool>(cycle); |
30 | } |
31 | |
32 | unique_ptr<CreateSequenceInfo> SequenceCatalogEntry::Deserialize(Deserializer &source) { |
33 | auto info = make_unique<CreateSequenceInfo>(); |
34 | info->schema = source.Read<string>(); |
35 | info->name = source.Read<string>(); |
36 | // info->counter = source.Read<int64_t>(); |
37 | info->usage_count = source.Read<uint64_t>(); |
38 | info->increment = source.Read<int64_t>(); |
39 | info->min_value = source.Read<int64_t>(); |
40 | info->max_value = source.Read<int64_t>(); |
41 | info->start_value = source.Read<int64_t>(); |
42 | info->cycle = source.Read<bool>(); |
43 | return info; |
44 | } |
45 | |