duckdb 0.3.3-dev1401.0 → 0.3.3-dev1409.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.cpp +61 -26
- package/src/duckdb.hpp +4 -2
- package/src/parquet-amalgamation.cpp +35878 -35878
package/package.json
CHANGED
package/src/duckdb.cpp
CHANGED
|
@@ -155796,6 +155796,7 @@ public:
|
|
|
155796
155796
|
|
|
155797
155797
|
|
|
155798
155798
|
|
|
155799
|
+
|
|
155799
155800
|
namespace duckdb {
|
|
155800
155801
|
|
|
155801
155802
|
SchemaCatalogEntry *Binder::BindSchema(CreateInfo &info) {
|
|
@@ -156010,10 +156011,18 @@ BoundStatement Binder::Bind(CreateStatement &stmt) {
|
|
|
156010
156011
|
for (auto &keyname : fk.pk_columns) {
|
|
156011
156012
|
auto entry = pk_table_entry_ptr->name_map.find(keyname);
|
|
156012
156013
|
if (entry == pk_table_entry_ptr->name_map.end()) {
|
|
156013
|
-
throw
|
|
156014
|
+
throw BinderException("column \"%s\" named in key does not exist", keyname);
|
|
156014
156015
|
}
|
|
156015
156016
|
fk.info.pk_keys.push_back(entry->second);
|
|
156016
156017
|
}
|
|
156018
|
+
auto index = pk_table_entry_ptr->storage->info->indexes.FindForeignKeyIndex(
|
|
156019
|
+
fk.info.pk_keys, ForeignKeyType::FK_TYPE_PRIMARY_KEY_TABLE);
|
|
156020
|
+
if (!index) {
|
|
156021
|
+
auto fk_column_names = StringUtil::Join(fk.pk_columns, ",");
|
|
156022
|
+
throw BinderException("Failed to create foreign key on %s(%s): no UNIQUE or PRIMARY KEY constraint "
|
|
156023
|
+
"present on these columns",
|
|
156024
|
+
pk_table_entry_ptr->name, fk_column_names);
|
|
156025
|
+
}
|
|
156017
156026
|
}
|
|
156018
156027
|
}
|
|
156019
156028
|
// We first check if there are any user types, if yes we check to which custom types they refer.
|
|
@@ -156196,7 +156205,7 @@ static void BindConstraints(Binder &binder, BoundCreateTableInfo &info) {
|
|
|
156196
156205
|
for (auto &keyname : fk.pk_columns) {
|
|
156197
156206
|
auto entry = info.name_map.find(keyname);
|
|
156198
156207
|
if (entry == info.name_map.end()) {
|
|
156199
|
-
throw
|
|
156208
|
+
throw BinderException("column \"%s\" named in key does not exist", keyname);
|
|
156200
156209
|
}
|
|
156201
156210
|
fk.info.pk_keys.push_back(entry->second);
|
|
156202
156211
|
}
|
|
@@ -156205,7 +156214,7 @@ static void BindConstraints(Binder &binder, BoundCreateTableInfo &info) {
|
|
|
156205
156214
|
for (auto &keyname : fk.fk_columns) {
|
|
156206
156215
|
auto entry = info.name_map.find(keyname);
|
|
156207
156216
|
if (entry == info.name_map.end()) {
|
|
156208
|
-
throw
|
|
156217
|
+
throw BinderException("column \"%s\" named in key does not exist", keyname);
|
|
156209
156218
|
}
|
|
156210
156219
|
fk.info.fk_keys.push_back(entry->second);
|
|
156211
156220
|
}
|
|
@@ -161206,6 +161215,7 @@ string ExpressionBinder::Bind(unique_ptr<ParsedExpression> *expr, idx_t depth, b
|
|
|
161206
161215
|
|
|
161207
161216
|
|
|
161208
161217
|
|
|
161218
|
+
|
|
161209
161219
|
namespace duckdb {
|
|
161210
161220
|
|
|
161211
161221
|
void ExpressionIterator::EnumerateChildren(const Expression &expr,
|
|
@@ -161367,10 +161377,13 @@ void ExpressionIterator::EnumerateTableRefChildren(BoundTableRef &ref,
|
|
|
161367
161377
|
EnumerateQueryNodeChildren(*bound_subquery.subquery, callback);
|
|
161368
161378
|
break;
|
|
161369
161379
|
}
|
|
161370
|
-
|
|
161371
|
-
|
|
161372
|
-
|
|
161380
|
+
case TableReferenceType::TABLE_FUNCTION:
|
|
161381
|
+
case TableReferenceType::EMPTY:
|
|
161382
|
+
case TableReferenceType::BASE_TABLE:
|
|
161383
|
+
case TableReferenceType::CTE:
|
|
161373
161384
|
break;
|
|
161385
|
+
default:
|
|
161386
|
+
throw NotImplementedException("Unimplemented table reference type in ExpressionIterator");
|
|
161374
161387
|
}
|
|
161375
161388
|
}
|
|
161376
161389
|
|
|
@@ -161383,8 +161396,13 @@ void ExpressionIterator::EnumerateQueryNodeChildren(BoundQueryNode &node,
|
|
|
161383
161396
|
EnumerateQueryNodeChildren(*bound_setop.right, callback);
|
|
161384
161397
|
break;
|
|
161385
161398
|
}
|
|
161386
|
-
|
|
161387
|
-
|
|
161399
|
+
case QueryNodeType::RECURSIVE_CTE_NODE: {
|
|
161400
|
+
auto &cte_node = (BoundRecursiveCTENode &)node;
|
|
161401
|
+
EnumerateQueryNodeChildren(*cte_node.left, callback);
|
|
161402
|
+
EnumerateQueryNodeChildren(*cte_node.right, callback);
|
|
161403
|
+
break;
|
|
161404
|
+
}
|
|
161405
|
+
case QueryNodeType::SELECT_NODE: {
|
|
161388
161406
|
auto &bound_select = (BoundSelectNode &)node;
|
|
161389
161407
|
for (idx_t i = 0; i < bound_select.select_list.size(); i++) {
|
|
161390
161408
|
EnumerateExpression(bound_select.select_list[i], callback);
|
|
@@ -161408,6 +161426,9 @@ void ExpressionIterator::EnumerateQueryNodeChildren(BoundQueryNode &node,
|
|
|
161408
161426
|
}
|
|
161409
161427
|
break;
|
|
161410
161428
|
}
|
|
161429
|
+
default:
|
|
161430
|
+
throw NotImplementedException("Unimplemented query node in ExpressionIterator");
|
|
161431
|
+
}
|
|
161411
161432
|
for (idx_t i = 0; i < node.modifiers.size(); i++) {
|
|
161412
161433
|
switch (node.modifiers[i]->type) {
|
|
161413
161434
|
case ResultModifierType::DISTINCT_MODIFIER:
|
|
@@ -170374,11 +170395,17 @@ static void VerifyCheckConstraint(TableCatalogEntry &table, Expression &expr, Da
|
|
|
170374
170395
|
}
|
|
170375
170396
|
}
|
|
170376
170397
|
|
|
170377
|
-
static bool
|
|
170378
|
-
|
|
170398
|
+
static bool IsForeignKeyIndex(const vector<idx_t> &fk_keys, Index &index, ForeignKeyType fk_type) {
|
|
170399
|
+
if (fk_type == ForeignKeyType::FK_TYPE_PRIMARY_KEY_TABLE ? !index.IsUnique() : !index.IsForeign()) {
|
|
170400
|
+
return false;
|
|
170401
|
+
}
|
|
170402
|
+
if (fk_keys.size() != index.column_ids.size()) {
|
|
170403
|
+
return false;
|
|
170404
|
+
}
|
|
170405
|
+
for (auto &fk_key : fk_keys) {
|
|
170379
170406
|
bool is_found = false;
|
|
170380
|
-
for (
|
|
170381
|
-
if (
|
|
170407
|
+
for (auto &index_key : index.column_ids) {
|
|
170408
|
+
if (fk_key == index_key) {
|
|
170382
170409
|
is_found = true;
|
|
170383
170410
|
break;
|
|
170384
170411
|
}
|
|
@@ -170387,10 +170414,20 @@ static bool FindColumnIndex(const vector<idx_t> *keys_ptr, const vector<column_t
|
|
|
170387
170414
|
return false;
|
|
170388
170415
|
}
|
|
170389
170416
|
}
|
|
170390
|
-
|
|
170391
170417
|
return true;
|
|
170392
170418
|
}
|
|
170393
170419
|
|
|
170420
|
+
Index *TableIndexList::FindForeignKeyIndex(const vector<idx_t> &fk_keys, ForeignKeyType fk_type) {
|
|
170421
|
+
Index *result = nullptr;
|
|
170422
|
+
Scan([&](Index &index) {
|
|
170423
|
+
if (IsForeignKeyIndex(fk_keys, index, fk_type)) {
|
|
170424
|
+
result = &index;
|
|
170425
|
+
}
|
|
170426
|
+
return false;
|
|
170427
|
+
});
|
|
170428
|
+
return result;
|
|
170429
|
+
}
|
|
170430
|
+
|
|
170394
170431
|
static void VerifyForeignKeyConstraint(const BoundForeignKeyConstraint &bfk, ClientContext &context, DataChunk &chunk,
|
|
170395
170432
|
bool is_append) {
|
|
170396
170433
|
const vector<idx_t> *src_keys_ptr = &bfk.info.fk_keys;
|
|
@@ -170429,26 +170466,24 @@ static void VerifyForeignKeyConstraint(const BoundForeignKeyConstraint &bfk, Cli
|
|
|
170429
170466
|
err_msgs.resize(count);
|
|
170430
170467
|
tran_err_msgs.resize(count);
|
|
170431
170468
|
|
|
170469
|
+
auto fk_type = is_append ? ForeignKeyType::FK_TYPE_PRIMARY_KEY_TABLE : ForeignKeyType::FK_TYPE_FOREIGN_KEY_TABLE;
|
|
170432
170470
|
// check whether or not the chunk can be inserted or deleted into the referenced table' storage
|
|
170433
|
-
|
|
170434
|
-
|
|
170435
|
-
|
|
170436
|
-
|
|
170437
|
-
|
|
170438
|
-
|
|
170439
|
-
|
|
170440
|
-
|
|
170441
|
-
|
|
170442
|
-
return false;
|
|
170443
|
-
});
|
|
170444
|
-
|
|
170471
|
+
auto index = data_table->info->indexes.FindForeignKeyIndex(*dst_keys_ptr, fk_type);
|
|
170472
|
+
if (!index) {
|
|
170473
|
+
throw InternalException("Internal Foreign Key error: could not find index to verify...");
|
|
170474
|
+
}
|
|
170475
|
+
if (is_append) {
|
|
170476
|
+
index->VerifyAppendForeignKey(dst_chunk, err_msgs.data());
|
|
170477
|
+
} else {
|
|
170478
|
+
index->VerifyDeleteForeignKey(dst_chunk, err_msgs.data());
|
|
170479
|
+
}
|
|
170445
170480
|
// check whether or not the chunk can be inserted or deleted into the referenced table' transaction local storage
|
|
170446
170481
|
auto &transaction = Transaction::GetTransaction(context);
|
|
170447
170482
|
bool transaction_check = transaction.storage.Find(data_table);
|
|
170448
170483
|
if (transaction_check) {
|
|
170449
170484
|
vector<unique_ptr<Index>> &transact_index_vec = transaction.storage.GetIndexes(data_table);
|
|
170450
170485
|
for (idx_t i = 0; i < transact_index_vec.size(); i++) {
|
|
170451
|
-
if (
|
|
170486
|
+
if (IsForeignKeyIndex(*dst_keys_ptr, *transact_index_vec[i], fk_type)) {
|
|
170452
170487
|
if (is_append) {
|
|
170453
170488
|
transact_index_vec[i]->VerifyAppendForeignKey(dst_chunk, tran_err_msgs.data());
|
|
170454
170489
|
} else {
|
package/src/duckdb.hpp
CHANGED
|
@@ -11,8 +11,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
11
11
|
#pragma once
|
|
12
12
|
#define DUCKDB_AMALGAMATION 1
|
|
13
13
|
#define DUCKDB_AMALGAMATION_EXTENDED 1
|
|
14
|
-
#define DUCKDB_SOURCE_ID "
|
|
15
|
-
#define DUCKDB_VERSION "v0.3.3-
|
|
14
|
+
#define DUCKDB_SOURCE_ID "6ac91ddc1"
|
|
15
|
+
#define DUCKDB_VERSION "v0.3.3-dev1409"
|
|
16
16
|
//===----------------------------------------------------------------------===//
|
|
17
17
|
// DuckDB
|
|
18
18
|
//
|
|
@@ -20947,6 +20947,8 @@ public:
|
|
|
20947
20947
|
return indexes.size();
|
|
20948
20948
|
}
|
|
20949
20949
|
|
|
20950
|
+
Index *FindForeignKeyIndex(const vector<idx_t> &fk_keys, ForeignKeyType fk_type);
|
|
20951
|
+
|
|
20950
20952
|
private:
|
|
20951
20953
|
//! Indexes associated with the current table
|
|
20952
20954
|
mutex indexes_lock;
|