duckdb 0.8.2-dev2842.0 → 0.8.2-dev2850.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/duckdb/extension/json/include/json_deserializer.hpp +1 -1
- package/src/duckdb/extension/json/include/json_serializer.hpp +1 -1
- package/src/duckdb/extension/json/json_deserializer.cpp +7 -5
- package/src/duckdb/extension/json/json_serializer.cpp +2 -3
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/parser/transform/constraint/transform_constraint.cpp +55 -38
package/package.json
CHANGED
@@ -48,7 +48,7 @@ private:
|
|
48
48
|
void ThrowTypeError(yyjson_val *val, const char *expected);
|
49
49
|
|
50
50
|
// Set the 'tag' of the property to read
|
51
|
-
void SetTag(const field_id_t
|
51
|
+
void SetTag(const field_id_t, const char *tag) final;
|
52
52
|
|
53
53
|
//===--------------------------------------------------------------------===//
|
54
54
|
// Nested Types Hooks
|
@@ -42,7 +42,7 @@ public:
|
|
42
42
|
return stack.front();
|
43
43
|
};
|
44
44
|
|
45
|
-
void SetTag(const field_id_t
|
45
|
+
void SetTag(const field_id_t, const char *tag) final;
|
46
46
|
|
47
47
|
//===--------------------------------------------------------------------===//
|
48
48
|
// Nested Types Hooks
|
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
namespace duckdb {
|
5
5
|
|
6
|
-
void JsonDeserializer::SetTag(const field_id_t
|
6
|
+
void JsonDeserializer::SetTag(const field_id_t, const char *tag) {
|
7
7
|
current_tag = tag;
|
8
8
|
}
|
9
9
|
|
@@ -43,8 +43,10 @@ void JsonDeserializer::ThrowTypeError(yyjson_val *val, const char *expected) {
|
|
43
43
|
if (yyjson_is_obj(parent.val)) {
|
44
44
|
auto msg =
|
45
45
|
StringUtil::Format("property '%s' expected type '%s', but got type: '%s'", current_tag, expected, actual);
|
46
|
+
throw ParserException(msg);
|
46
47
|
} else if (yyjson_is_arr(parent.val)) {
|
47
48
|
auto msg = StringUtil::Format("Sequence expect child of type '%s', but got type: %s", expected, actual);
|
49
|
+
throw ParserException(msg);
|
48
50
|
} else {
|
49
51
|
// unreachable?
|
50
52
|
throw InternalException("cannot get nested value from non object or array-type");
|
@@ -178,7 +180,7 @@ bool JsonDeserializer::ReadBool() {
|
|
178
180
|
|
179
181
|
int8_t JsonDeserializer::ReadSignedInt8() {
|
180
182
|
auto val = GetNextValue();
|
181
|
-
if (!
|
183
|
+
if (!yyjson_is_int(val)) {
|
182
184
|
ThrowTypeError(val, "int8_t");
|
183
185
|
}
|
184
186
|
return yyjson_get_sint(val);
|
@@ -194,7 +196,7 @@ uint8_t JsonDeserializer::ReadUnsignedInt8() {
|
|
194
196
|
|
195
197
|
int16_t JsonDeserializer::ReadSignedInt16() {
|
196
198
|
auto val = GetNextValue();
|
197
|
-
if (!
|
199
|
+
if (!yyjson_is_int(val)) {
|
198
200
|
ThrowTypeError(val, "int16_t");
|
199
201
|
}
|
200
202
|
return yyjson_get_sint(val);
|
@@ -210,7 +212,7 @@ uint16_t JsonDeserializer::ReadUnsignedInt16() {
|
|
210
212
|
|
211
213
|
int32_t JsonDeserializer::ReadSignedInt32() {
|
212
214
|
auto val = GetNextValue();
|
213
|
-
if (!
|
215
|
+
if (!yyjson_is_int(val)) {
|
214
216
|
ThrowTypeError(val, "int32_t");
|
215
217
|
}
|
216
218
|
return yyjson_get_sint(val);
|
@@ -226,7 +228,7 @@ uint32_t JsonDeserializer::ReadUnsignedInt32() {
|
|
226
228
|
|
227
229
|
int64_t JsonDeserializer::ReadSignedInt64() {
|
228
230
|
auto val = GetNextValue();
|
229
|
-
if (!
|
231
|
+
if (!yyjson_is_int(val)) {
|
230
232
|
ThrowTypeError(val, "int64_t");
|
231
233
|
}
|
232
234
|
return yyjson_get_sint(val);
|
@@ -19,8 +19,7 @@ void JsonSerializer::PushValue(yyjson_mut_val *val) {
|
|
19
19
|
}
|
20
20
|
}
|
21
21
|
|
22
|
-
void JsonSerializer::SetTag(const field_id_t
|
23
|
-
(void)field_id;
|
22
|
+
void JsonSerializer::SetTag(const field_id_t, const char *tag) {
|
24
23
|
current_tag = yyjson_mut_strcpy(doc, tag);
|
25
24
|
}
|
26
25
|
|
@@ -173,7 +172,7 @@ void JsonSerializer::WriteValue(uint32_t value) {
|
|
173
172
|
}
|
174
173
|
|
175
174
|
void JsonSerializer::WriteValue(int32_t value) {
|
176
|
-
auto val =
|
175
|
+
auto val = yyjson_mut_sint(doc, value);
|
177
176
|
PushValue(val);
|
178
177
|
}
|
179
178
|
|
@@ -1,8 +1,8 @@
|
|
1
1
|
#ifndef DUCKDB_VERSION
|
2
|
-
#define DUCKDB_VERSION "0.8.2-
|
2
|
+
#define DUCKDB_VERSION "0.8.2-dev2850"
|
3
3
|
#endif
|
4
4
|
#ifndef DUCKDB_SOURCE_ID
|
5
|
-
#define DUCKDB_SOURCE_ID "
|
5
|
+
#define DUCKDB_SOURCE_ID "e2128946cc"
|
6
6
|
#endif
|
7
7
|
#include "duckdb/function/table/system_functions.hpp"
|
8
8
|
#include "duckdb/main/database.hpp"
|
@@ -17,8 +17,58 @@ static void ParseSchemaTableNameFK(duckdb_libpgquery::PGRangeVar *input, Foreign
|
|
17
17
|
fk_info.table = input->relname;
|
18
18
|
}
|
19
19
|
|
20
|
+
static bool ForeignKeyActionSupported(char action) {
|
21
|
+
switch (action) {
|
22
|
+
case PG_FKCONSTR_ACTION_NOACTION:
|
23
|
+
case PG_FKCONSTR_ACTION_RESTRICT:
|
24
|
+
return true;
|
25
|
+
case PG_FKCONSTR_ACTION_CASCADE:
|
26
|
+
case PG_FKCONSTR_ACTION_SETDEFAULT:
|
27
|
+
case PG_FKCONSTR_ACTION_SETNULL:
|
28
|
+
return false;
|
29
|
+
default:
|
30
|
+
D_ASSERT(false);
|
31
|
+
}
|
32
|
+
return false;
|
33
|
+
}
|
34
|
+
|
35
|
+
static unique_ptr<ForeignKeyConstraint>
|
36
|
+
TransformForeignKeyConstraint(duckdb_libpgquery::PGConstraint *constraint,
|
37
|
+
optional_ptr<const string> override_fk_column = nullptr) {
|
38
|
+
D_ASSERT(constraint);
|
39
|
+
if (!ForeignKeyActionSupported(constraint->fk_upd_action) ||
|
40
|
+
!ForeignKeyActionSupported(constraint->fk_del_action)) {
|
41
|
+
throw ParserException("FOREIGN KEY constraints cannot use CASCADE, SET NULL or SET DEFAULT");
|
42
|
+
}
|
43
|
+
ForeignKeyInfo fk_info;
|
44
|
+
fk_info.type = ForeignKeyType::FK_TYPE_FOREIGN_KEY_TABLE;
|
45
|
+
ParseSchemaTableNameFK(constraint->pktable, fk_info);
|
46
|
+
vector<string> pk_columns, fk_columns;
|
47
|
+
if (override_fk_column) {
|
48
|
+
D_ASSERT(!constraint->fk_attrs);
|
49
|
+
fk_columns.emplace_back(*override_fk_column);
|
50
|
+
} else if (constraint->fk_attrs) {
|
51
|
+
for (auto kc = constraint->fk_attrs->head; kc; kc = kc->next) {
|
52
|
+
fk_columns.emplace_back(reinterpret_cast<duckdb_libpgquery::PGValue *>(kc->data.ptr_value)->val.str);
|
53
|
+
}
|
54
|
+
}
|
55
|
+
if (constraint->pk_attrs) {
|
56
|
+
for (auto kc = constraint->pk_attrs->head; kc; kc = kc->next) {
|
57
|
+
pk_columns.emplace_back(reinterpret_cast<duckdb_libpgquery::PGValue *>(kc->data.ptr_value)->val.str);
|
58
|
+
}
|
59
|
+
}
|
60
|
+
if (!pk_columns.empty() && pk_columns.size() != fk_columns.size()) {
|
61
|
+
throw ParserException("The number of referencing and referenced columns for foreign keys must be the same");
|
62
|
+
}
|
63
|
+
if (fk_columns.empty()) {
|
64
|
+
throw ParserException("The set of referencing and referenced columns for foreign keys must be not empty");
|
65
|
+
}
|
66
|
+
return make_uniq<ForeignKeyConstraint>(pk_columns, fk_columns, std::move(fk_info));
|
67
|
+
}
|
68
|
+
|
20
69
|
unique_ptr<Constraint> Transformer::TransformConstraint(duckdb_libpgquery::PGListCell *cell) {
|
21
70
|
auto constraint = reinterpret_cast<duckdb_libpgquery::PGConstraint *>(cell->data.ptr_value);
|
71
|
+
D_ASSERT(constraint);
|
22
72
|
switch (constraint->contype) {
|
23
73
|
case duckdb_libpgquery::PG_CONSTR_UNIQUE:
|
24
74
|
case duckdb_libpgquery::PG_CONSTR_PRIMARY: {
|
@@ -36,27 +86,9 @@ unique_ptr<Constraint> Transformer::TransformConstraint(duckdb_libpgquery::PGLis
|
|
36
86
|
}
|
37
87
|
return make_uniq<CheckConstraint>(TransformExpression(constraint->raw_expr));
|
38
88
|
}
|
39
|
-
case duckdb_libpgquery::PG_CONSTR_FOREIGN:
|
40
|
-
|
41
|
-
|
42
|
-
ParseSchemaTableNameFK(constraint->pktable, fk_info);
|
43
|
-
vector<string> pk_columns, fk_columns;
|
44
|
-
for (auto kc = constraint->fk_attrs->head; kc; kc = kc->next) {
|
45
|
-
fk_columns.emplace_back(reinterpret_cast<duckdb_libpgquery::PGValue *>(kc->data.ptr_value)->val.str);
|
46
|
-
}
|
47
|
-
if (constraint->pk_attrs) {
|
48
|
-
for (auto kc = constraint->pk_attrs->head; kc; kc = kc->next) {
|
49
|
-
pk_columns.emplace_back(reinterpret_cast<duckdb_libpgquery::PGValue *>(kc->data.ptr_value)->val.str);
|
50
|
-
}
|
51
|
-
}
|
52
|
-
if (!pk_columns.empty() && pk_columns.size() != fk_columns.size()) {
|
53
|
-
throw ParserException("The number of referencing and referenced columns for foreign keys must be the same");
|
54
|
-
}
|
55
|
-
if (fk_columns.empty()) {
|
56
|
-
throw ParserException("The set of referencing and referenced columns for foreign keys must be not empty");
|
57
|
-
}
|
58
|
-
return make_uniq<ForeignKeyConstraint>(pk_columns, fk_columns, std::move(fk_info));
|
59
|
-
}
|
89
|
+
case duckdb_libpgquery::PG_CONSTR_FOREIGN:
|
90
|
+
return TransformForeignKeyConstraint(constraint);
|
91
|
+
|
60
92
|
default:
|
61
93
|
throw NotImplementedException("Constraint type not handled yet!");
|
62
94
|
}
|
@@ -96,23 +128,8 @@ unique_ptr<Constraint> Transformer::TransformConstraint(duckdb_libpgquery::PGLis
|
|
96
128
|
"dictionary, pfor, bitpacking or fsst");
|
97
129
|
}
|
98
130
|
return nullptr;
|
99
|
-
case duckdb_libpgquery::PG_CONSTR_FOREIGN:
|
100
|
-
|
101
|
-
fk_info.type = ForeignKeyType::FK_TYPE_FOREIGN_KEY_TABLE;
|
102
|
-
ParseSchemaTableNameFK(constraint->pktable, fk_info);
|
103
|
-
|
104
|
-
vector<string> pk_columns, fk_columns;
|
105
|
-
fk_columns.emplace_back(column.Name().c_str());
|
106
|
-
if (constraint->pk_attrs) {
|
107
|
-
for (auto kc = constraint->pk_attrs->head; kc; kc = kc->next) {
|
108
|
-
pk_columns.emplace_back(reinterpret_cast<duckdb_libpgquery::PGValue *>(kc->data.ptr_value)->val.str);
|
109
|
-
}
|
110
|
-
}
|
111
|
-
if (!pk_columns.empty() && pk_columns.size() != fk_columns.size()) {
|
112
|
-
throw ParserException("The number of referencing and referenced columns for foreign keys must be the same");
|
113
|
-
}
|
114
|
-
return make_uniq<ForeignKeyConstraint>(pk_columns, fk_columns, std::move(fk_info));
|
115
|
-
}
|
131
|
+
case duckdb_libpgquery::PG_CONSTR_FOREIGN:
|
132
|
+
return TransformForeignKeyConstraint(constraint, &column.Name());
|
116
133
|
default:
|
117
134
|
throw NotImplementedException("Constraint not implemented!");
|
118
135
|
}
|