10
10
namespace duckdb {
11
11
12
12
// ===--------------------------------------------------------------------===//
13
- // Extra Type Info
13
+ // Extension Type Info
14
14
// ===--------------------------------------------------------------------===//
15
- ExtraTypeInfo::ExtraTypeInfo (ExtraTypeInfoType type) : type(type) {
16
- }
17
- ExtraTypeInfo::ExtraTypeInfo (ExtraTypeInfoType type, string alias) : type(type), alias(std::move(alias)) {
18
- }
19
- ExtraTypeInfo::~ExtraTypeInfo () {
20
- }
21
- shared_ptr<ExtraTypeInfo> ExtraTypeInfo::Copy () const {
22
- return make_shared_ptr<ExtraTypeInfo>(*this );
23
- }
24
15
25
16
static bool CompareModifiers (const vector<Value> &left, const vector<Value> &right) {
26
17
// Check if the common prefix of the properties is the same for both types
27
- auto common_props = MinValue (left.size (), right.size ());
18
+ const auto common_props = MinValue (left.size (), right.size ());
28
19
for (idx_t i = 0 ; i < common_props; i++) {
29
20
if (left[i].type () != right[i].type ()) {
30
21
return false ;
@@ -34,13 +25,65 @@ static bool CompareModifiers(const vector<Value> &left, const vector<Value> &rig
34
25
if (left[i].IsNull () || right[i].IsNull ()) {
35
26
continue ;
36
27
}
28
+
37
29
if (left[i] != right[i]) {
38
30
return false ;
39
31
}
40
32
}
41
33
return true ;
42
34
}
43
35
36
+ bool ExtensionTypeInfo::Equals (optional_ptr<ExtensionTypeInfo> other_p) const {
37
+ if (other_p == nullptr ) {
38
+ return false ;
39
+ }
40
+ if (!CompareModifiers (modifiers, other_p->modifiers )) {
41
+ return false ;
42
+ }
43
+
44
+ // Properties are optional, so only compare those present in both
45
+ for (auto &kv : properties) {
46
+ auto it = other_p->properties .find (kv.first );
47
+ if (it == other_p->properties .end ()) {
48
+ continue ;
49
+ }
50
+ if (kv.second != it->second ) {
51
+ return false ;
52
+ }
53
+ }
54
+
55
+ return true ;
56
+ }
57
+
58
+ // ===--------------------------------------------------------------------===//
59
+ // Extra Type Info
60
+ // ===--------------------------------------------------------------------===//
61
+ ExtraTypeInfo::ExtraTypeInfo (ExtraTypeInfoType type) : type(type) {
62
+ }
63
+ ExtraTypeInfo::ExtraTypeInfo (ExtraTypeInfoType type, string alias) : type(type), alias(std::move(alias)) {
64
+ }
65
+ ExtraTypeInfo::~ExtraTypeInfo () {
66
+ }
67
+
68
+ ExtraTypeInfo::ExtraTypeInfo (const ExtraTypeInfo &other) : type(other.type), alias(other.alias) {
69
+ if (other.extension_info ) {
70
+ extension_info = make_uniq<ExtensionTypeInfo>(*other.extension_info );
71
+ }
72
+ }
73
+
74
+ ExtraTypeInfo &ExtraTypeInfo::operator =(const ExtraTypeInfo &other) {
75
+ type = other.type ;
76
+ alias = other.alias ;
77
+ if (other.extension_info ) {
78
+ extension_info = make_uniq<ExtensionTypeInfo>(*other.extension_info );
79
+ }
80
+ return *this ;
81
+ }
82
+
83
+ shared_ptr<ExtraTypeInfo> ExtraTypeInfo::Copy () const {
84
+ return shared_ptr<ExtraTypeInfo>(new ExtraTypeInfo (*this ));
85
+ }
86
+
44
87
bool ExtraTypeInfo::Equals (ExtraTypeInfo *other_p) const {
45
88
if (type == ExtraTypeInfoType::INVALID_TYPE_INFO || type == ExtraTypeInfoType::STRING_TYPE_INFO ||
46
89
type == ExtraTypeInfoType::GENERIC_TYPE_INFO) {
@@ -54,7 +97,7 @@ bool ExtraTypeInfo::Equals(ExtraTypeInfo *other_p) const {
54
97
if (alias != other_p->alias ) {
55
98
return false ;
56
99
}
57
- if (! CompareModifiers (modifiers, other_p->modifiers )) {
100
+ if (extension_info && !extension_info-> Equals ( other_p->extension_info . get () )) {
58
101
return false ;
59
102
}
60
103
return true ;
@@ -68,7 +111,7 @@ bool ExtraTypeInfo::Equals(ExtraTypeInfo *other_p) const {
68
111
if (alias != other_p->alias ) {
69
112
return false ;
70
113
}
71
- if (! CompareModifiers (modifiers, other_p->modifiers )) {
114
+ if (extension_info && !extension_info-> Equals ( other_p->extension_info . get () )) {
72
115
return false ;
73
116
}
74
117
return EqualsInternal (other_p);
0 commit comments