duckdb 0.3.3-dev1399.0 → 0.3.3-dev1406.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 +51 -24
- package/src/duckdb.hpp +4 -2
- package/src/parquet-amalgamation.cpp +20637 -20637
package/package.json
CHANGED
package/src/duckdb.cpp
CHANGED
|
@@ -71601,17 +71601,21 @@ void RadixPartitionedHashTable::GetData(ExecutionContext &context, DataChunk &ch
|
|
|
71601
71601
|
// special case hack to sort out aggregating from empty intermediates
|
|
71602
71602
|
// for aggregations without groups
|
|
71603
71603
|
if (gstate.is_empty && grouping_set.empty()) {
|
|
71604
|
-
D_ASSERT(chunk.ColumnCount() == op.aggregates.size());
|
|
71604
|
+
D_ASSERT(chunk.ColumnCount() == null_groups.size() + op.aggregates.size());
|
|
71605
71605
|
// for each column in the aggregates, set to initial state
|
|
71606
71606
|
chunk.SetCardinality(1);
|
|
71607
|
-
for (
|
|
71607
|
+
for (auto null_group : null_groups) {
|
|
71608
|
+
chunk.data[null_group].SetVectorType(VectorType::CONSTANT_VECTOR);
|
|
71609
|
+
ConstantVector::SetNull(chunk.data[null_group], true);
|
|
71610
|
+
}
|
|
71611
|
+
for (idx_t i = 0; i < op.aggregates.size(); i++) {
|
|
71608
71612
|
D_ASSERT(op.aggregates[i]->GetExpressionClass() == ExpressionClass::BOUND_AGGREGATE);
|
|
71609
71613
|
auto &aggr = (BoundAggregateExpression &)*op.aggregates[i];
|
|
71610
71614
|
auto aggr_state = unique_ptr<data_t[]>(new data_t[aggr.function.state_size()]);
|
|
71611
71615
|
aggr.function.initialize(aggr_state.get());
|
|
71612
71616
|
|
|
71613
71617
|
Vector state_vector(Value::POINTER((uintptr_t)aggr_state.get()));
|
|
71614
|
-
aggr.function.finalize(state_vector, aggr.bind_info.get(), chunk.data[i], 1, 0);
|
|
71618
|
+
aggr.function.finalize(state_vector, aggr.bind_info.get(), chunk.data[null_groups.size() + i], 1, 0);
|
|
71615
71619
|
if (aggr.function.destructor) {
|
|
71616
71620
|
aggr.function.destructor(state_vector, 1);
|
|
71617
71621
|
}
|
|
@@ -155792,6 +155796,7 @@ public:
|
|
|
155792
155796
|
|
|
155793
155797
|
|
|
155794
155798
|
|
|
155799
|
+
|
|
155795
155800
|
namespace duckdb {
|
|
155796
155801
|
|
|
155797
155802
|
SchemaCatalogEntry *Binder::BindSchema(CreateInfo &info) {
|
|
@@ -156006,10 +156011,18 @@ BoundStatement Binder::Bind(CreateStatement &stmt) {
|
|
|
156006
156011
|
for (auto &keyname : fk.pk_columns) {
|
|
156007
156012
|
auto entry = pk_table_entry_ptr->name_map.find(keyname);
|
|
156008
156013
|
if (entry == pk_table_entry_ptr->name_map.end()) {
|
|
156009
|
-
throw
|
|
156014
|
+
throw BinderException("column \"%s\" named in key does not exist", keyname);
|
|
156010
156015
|
}
|
|
156011
156016
|
fk.info.pk_keys.push_back(entry->second);
|
|
156012
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
|
+
}
|
|
156013
156026
|
}
|
|
156014
156027
|
}
|
|
156015
156028
|
// We first check if there are any user types, if yes we check to which custom types they refer.
|
|
@@ -156192,7 +156205,7 @@ static void BindConstraints(Binder &binder, BoundCreateTableInfo &info) {
|
|
|
156192
156205
|
for (auto &keyname : fk.pk_columns) {
|
|
156193
156206
|
auto entry = info.name_map.find(keyname);
|
|
156194
156207
|
if (entry == info.name_map.end()) {
|
|
156195
|
-
throw
|
|
156208
|
+
throw BinderException("column \"%s\" named in key does not exist", keyname);
|
|
156196
156209
|
}
|
|
156197
156210
|
fk.info.pk_keys.push_back(entry->second);
|
|
156198
156211
|
}
|
|
@@ -156201,7 +156214,7 @@ static void BindConstraints(Binder &binder, BoundCreateTableInfo &info) {
|
|
|
156201
156214
|
for (auto &keyname : fk.fk_columns) {
|
|
156202
156215
|
auto entry = info.name_map.find(keyname);
|
|
156203
156216
|
if (entry == info.name_map.end()) {
|
|
156204
|
-
throw
|
|
156217
|
+
throw BinderException("column \"%s\" named in key does not exist", keyname);
|
|
156205
156218
|
}
|
|
156206
156219
|
fk.info.fk_keys.push_back(entry->second);
|
|
156207
156220
|
}
|
|
@@ -170370,11 +170383,17 @@ static void VerifyCheckConstraint(TableCatalogEntry &table, Expression &expr, Da
|
|
|
170370
170383
|
}
|
|
170371
170384
|
}
|
|
170372
170385
|
|
|
170373
|
-
static bool
|
|
170374
|
-
|
|
170386
|
+
static bool IsForeignKeyIndex(const vector<idx_t> &fk_keys, Index &index, ForeignKeyType fk_type) {
|
|
170387
|
+
if (fk_type == ForeignKeyType::FK_TYPE_PRIMARY_KEY_TABLE ? !index.IsUnique() : !index.IsForeign()) {
|
|
170388
|
+
return false;
|
|
170389
|
+
}
|
|
170390
|
+
if (fk_keys.size() != index.column_ids.size()) {
|
|
170391
|
+
return false;
|
|
170392
|
+
}
|
|
170393
|
+
for (auto &fk_key : fk_keys) {
|
|
170375
170394
|
bool is_found = false;
|
|
170376
|
-
for (
|
|
170377
|
-
if (
|
|
170395
|
+
for (auto &index_key : index.column_ids) {
|
|
170396
|
+
if (fk_key == index_key) {
|
|
170378
170397
|
is_found = true;
|
|
170379
170398
|
break;
|
|
170380
170399
|
}
|
|
@@ -170383,10 +170402,20 @@ static bool FindColumnIndex(const vector<idx_t> *keys_ptr, const vector<column_t
|
|
|
170383
170402
|
return false;
|
|
170384
170403
|
}
|
|
170385
170404
|
}
|
|
170386
|
-
|
|
170387
170405
|
return true;
|
|
170388
170406
|
}
|
|
170389
170407
|
|
|
170408
|
+
Index *TableIndexList::FindForeignKeyIndex(const vector<idx_t> &fk_keys, ForeignKeyType fk_type) {
|
|
170409
|
+
Index *result = nullptr;
|
|
170410
|
+
Scan([&](Index &index) {
|
|
170411
|
+
if (IsForeignKeyIndex(fk_keys, index, fk_type)) {
|
|
170412
|
+
result = &index;
|
|
170413
|
+
}
|
|
170414
|
+
return false;
|
|
170415
|
+
});
|
|
170416
|
+
return result;
|
|
170417
|
+
}
|
|
170418
|
+
|
|
170390
170419
|
static void VerifyForeignKeyConstraint(const BoundForeignKeyConstraint &bfk, ClientContext &context, DataChunk &chunk,
|
|
170391
170420
|
bool is_append) {
|
|
170392
170421
|
const vector<idx_t> *src_keys_ptr = &bfk.info.fk_keys;
|
|
@@ -170425,26 +170454,24 @@ static void VerifyForeignKeyConstraint(const BoundForeignKeyConstraint &bfk, Cli
|
|
|
170425
170454
|
err_msgs.resize(count);
|
|
170426
170455
|
tran_err_msgs.resize(count);
|
|
170427
170456
|
|
|
170457
|
+
auto fk_type = is_append ? ForeignKeyType::FK_TYPE_PRIMARY_KEY_TABLE : ForeignKeyType::FK_TYPE_FOREIGN_KEY_TABLE;
|
|
170428
170458
|
// check whether or not the chunk can be inserted or deleted into the referenced table' storage
|
|
170429
|
-
|
|
170430
|
-
|
|
170431
|
-
|
|
170432
|
-
|
|
170433
|
-
|
|
170434
|
-
|
|
170435
|
-
|
|
170436
|
-
|
|
170437
|
-
|
|
170438
|
-
return false;
|
|
170439
|
-
});
|
|
170440
|
-
|
|
170459
|
+
auto index = data_table->info->indexes.FindForeignKeyIndex(*dst_keys_ptr, fk_type);
|
|
170460
|
+
if (!index) {
|
|
170461
|
+
throw InternalException("Internal Foreign Key error: could not find index to verify...");
|
|
170462
|
+
}
|
|
170463
|
+
if (is_append) {
|
|
170464
|
+
index->VerifyAppendForeignKey(dst_chunk, err_msgs.data());
|
|
170465
|
+
} else {
|
|
170466
|
+
index->VerifyDeleteForeignKey(dst_chunk, err_msgs.data());
|
|
170467
|
+
}
|
|
170441
170468
|
// check whether or not the chunk can be inserted or deleted into the referenced table' transaction local storage
|
|
170442
170469
|
auto &transaction = Transaction::GetTransaction(context);
|
|
170443
170470
|
bool transaction_check = transaction.storage.Find(data_table);
|
|
170444
170471
|
if (transaction_check) {
|
|
170445
170472
|
vector<unique_ptr<Index>> &transact_index_vec = transaction.storage.GetIndexes(data_table);
|
|
170446
170473
|
for (idx_t i = 0; i < transact_index_vec.size(); i++) {
|
|
170447
|
-
if (
|
|
170474
|
+
if (IsForeignKeyIndex(*dst_keys_ptr, *transact_index_vec[i], fk_type)) {
|
|
170448
170475
|
if (is_append) {
|
|
170449
170476
|
transact_index_vec[i]->VerifyAppendForeignKey(dst_chunk, tran_err_msgs.data());
|
|
170450
170477
|
} 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 "71b07693f"
|
|
15
|
+
#define DUCKDB_VERSION "v0.3.3-dev1406"
|
|
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;
|