duckdb 0.6.2-dev2091.0 → 0.6.2-dev2096.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/src/catalog/catalog_entry/duck_table_entry.cpp +52 -33
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_table_entry.hpp +3 -0
- package/src/duckdb/src/main/extension/extension_alias.cpp +1 -0
- package/src/duckdb/src/main/extension/extension_helper.cpp +1 -0
package/package.json
CHANGED
|
@@ -300,37 +300,13 @@ unique_ptr<CatalogEntry> DuckTableEntry::AddColumn(ClientContext &context, AddCo
|
|
|
300
300
|
return make_unique<DuckTableEntry>(catalog, schema, (BoundCreateTableInfo *)bound_create_info.get(), new_storage);
|
|
301
301
|
}
|
|
302
302
|
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
throw CatalogException("Cannot drop column: rowid column cannot be dropped");
|
|
308
|
-
}
|
|
309
|
-
return nullptr;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
auto create_info = make_unique<CreateTableInfo>(schema, name);
|
|
313
|
-
create_info->temporary = temporary;
|
|
314
|
-
|
|
315
|
-
logical_index_set_t removed_columns;
|
|
316
|
-
if (column_dependency_manager.HasDependents(removed_index)) {
|
|
317
|
-
removed_columns = column_dependency_manager.GetDependents(removed_index);
|
|
318
|
-
}
|
|
319
|
-
if (!removed_columns.empty() && !info.cascade) {
|
|
320
|
-
throw CatalogException("Cannot drop column: column is a dependency of 1 or more generated column(s)");
|
|
321
|
-
}
|
|
322
|
-
for (auto &col : columns.Logical()) {
|
|
323
|
-
if (col.Logical() == removed_index || removed_columns.count(col.Logical())) {
|
|
324
|
-
continue;
|
|
325
|
-
}
|
|
326
|
-
create_info->columns.AddColumn(col.Copy());
|
|
327
|
-
}
|
|
328
|
-
if (create_info->columns.empty()) {
|
|
329
|
-
throw CatalogException("Cannot drop column: table only has one column remaining!");
|
|
330
|
-
}
|
|
331
|
-
auto adjusted_indices = column_dependency_manager.RemoveColumn(removed_index, columns.LogicalColumnCount());
|
|
303
|
+
void DuckTableEntry::UpdateConstraintsOnColumnDrop(const LogicalIndex &removed_index,
|
|
304
|
+
const vector<LogicalIndex> &adjusted_indices,
|
|
305
|
+
const RemoveColumnInfo &info, CreateTableInfo &create_info,
|
|
306
|
+
bool is_generated) {
|
|
332
307
|
// handle constraints for the new table
|
|
333
308
|
D_ASSERT(constraints.size() == bound_constraints.size());
|
|
309
|
+
|
|
334
310
|
for (idx_t constr_idx = 0; constr_idx < constraints.size(); constr_idx++) {
|
|
335
311
|
auto &constraint = constraints[constr_idx];
|
|
336
312
|
auto &bound_constraint = bound_constraints[constr_idx];
|
|
@@ -342,14 +318,20 @@ unique_ptr<CatalogEntry> DuckTableEntry::RemoveColumn(ClientContext &context, Re
|
|
|
342
318
|
// the constraint is not about this column: we need to copy it
|
|
343
319
|
// we might need to shift the index back by one though, to account for the removed column
|
|
344
320
|
auto new_index = adjusted_indices[not_null_index.index];
|
|
345
|
-
create_info
|
|
321
|
+
create_info.constraints.push_back(make_unique<NotNullConstraint>(new_index));
|
|
346
322
|
}
|
|
347
323
|
break;
|
|
348
324
|
}
|
|
349
325
|
case ConstraintType::CHECK: {
|
|
326
|
+
// Generated columns can not be part of an index
|
|
350
327
|
// CHECK constraint
|
|
351
328
|
auto &bound_check = (BoundCheckConstraint &)*bound_constraint;
|
|
352
329
|
// check if the removed column is part of the check constraint
|
|
330
|
+
if (is_generated) {
|
|
331
|
+
// generated columns can not be referenced by constraints, we can just add the constraint back
|
|
332
|
+
create_info.constraints.push_back(constraint->Copy());
|
|
333
|
+
break;
|
|
334
|
+
}
|
|
353
335
|
auto physical_index = columns.LogicalToPhysical(removed_index);
|
|
354
336
|
if (bound_check.bound_columns.find(physical_index) != bound_check.bound_columns.end()) {
|
|
355
337
|
if (bound_check.bound_columns.size() > 1) {
|
|
@@ -362,7 +344,7 @@ unique_ptr<CatalogEntry> DuckTableEntry::RemoveColumn(ClientContext &context, Re
|
|
|
362
344
|
}
|
|
363
345
|
} else {
|
|
364
346
|
// check constraint does not concern the removed column: simply re-add it
|
|
365
|
-
create_info
|
|
347
|
+
create_info.constraints.push_back(constraint->Copy());
|
|
366
348
|
}
|
|
367
349
|
break;
|
|
368
350
|
}
|
|
@@ -377,7 +359,7 @@ unique_ptr<CatalogEntry> DuckTableEntry::RemoveColumn(ClientContext &context, Re
|
|
|
377
359
|
}
|
|
378
360
|
unique.index = adjusted_indices[unique.index.index];
|
|
379
361
|
}
|
|
380
|
-
create_info
|
|
362
|
+
create_info.constraints.push_back(std::move(copy));
|
|
381
363
|
break;
|
|
382
364
|
}
|
|
383
365
|
case ConstraintType::FOREIGN_KEY: {
|
|
@@ -398,13 +380,50 @@ unique_ptr<CatalogEntry> DuckTableEntry::RemoveColumn(ClientContext &context, Re
|
|
|
398
380
|
info.removed_column);
|
|
399
381
|
}
|
|
400
382
|
}
|
|
401
|
-
create_info
|
|
383
|
+
create_info.constraints.push_back(std::move(copy));
|
|
402
384
|
break;
|
|
403
385
|
}
|
|
404
386
|
default:
|
|
405
387
|
throw InternalException("Unsupported constraint for entry!");
|
|
406
388
|
}
|
|
407
389
|
}
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
unique_ptr<CatalogEntry> DuckTableEntry::RemoveColumn(ClientContext &context, RemoveColumnInfo &info) {
|
|
393
|
+
auto removed_index = GetColumnIndex(info.removed_column, info.if_column_exists);
|
|
394
|
+
if (!removed_index.IsValid()) {
|
|
395
|
+
if (!info.if_column_exists) {
|
|
396
|
+
throw CatalogException("Cannot drop column: rowid column cannot be dropped");
|
|
397
|
+
}
|
|
398
|
+
return nullptr;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
auto create_info = make_unique<CreateTableInfo>(schema, name);
|
|
402
|
+
create_info->temporary = temporary;
|
|
403
|
+
|
|
404
|
+
logical_index_set_t removed_columns;
|
|
405
|
+
if (column_dependency_manager.HasDependents(removed_index)) {
|
|
406
|
+
removed_columns = column_dependency_manager.GetDependents(removed_index);
|
|
407
|
+
}
|
|
408
|
+
if (!removed_columns.empty() && !info.cascade) {
|
|
409
|
+
throw CatalogException("Cannot drop column: column is a dependency of 1 or more generated column(s)");
|
|
410
|
+
}
|
|
411
|
+
bool dropped_column_is_generated = false;
|
|
412
|
+
for (auto &col : columns.Logical()) {
|
|
413
|
+
if (col.Logical() == removed_index || removed_columns.count(col.Logical())) {
|
|
414
|
+
if (col.Generated()) {
|
|
415
|
+
dropped_column_is_generated = true;
|
|
416
|
+
}
|
|
417
|
+
continue;
|
|
418
|
+
}
|
|
419
|
+
create_info->columns.AddColumn(col.Copy());
|
|
420
|
+
}
|
|
421
|
+
if (create_info->columns.empty()) {
|
|
422
|
+
throw CatalogException("Cannot drop column: table only has one column remaining!");
|
|
423
|
+
}
|
|
424
|
+
auto adjusted_indices = column_dependency_manager.RemoveColumn(removed_index, columns.LogicalColumnCount());
|
|
425
|
+
|
|
426
|
+
UpdateConstraintsOnColumnDrop(removed_index, adjusted_indices, info, *create_info, dropped_column_is_generated);
|
|
408
427
|
|
|
409
428
|
auto binder = Binder::CreateBinder(context);
|
|
410
429
|
auto bound_create_info = binder->BindCreateTableInfo(std::move(create_info));
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#ifndef DUCKDB_VERSION
|
|
2
|
-
#define DUCKDB_VERSION "0.6.2-
|
|
2
|
+
#define DUCKDB_VERSION "0.6.2-dev2096"
|
|
3
3
|
#endif
|
|
4
4
|
#ifndef DUCKDB_SOURCE_ID
|
|
5
|
-
#define DUCKDB_SOURCE_ID "
|
|
5
|
+
#define DUCKDB_SOURCE_ID "f596d7b0fe"
|
|
6
6
|
#endif
|
|
7
7
|
#include "duckdb/function/table/system_functions.hpp"
|
|
8
8
|
#include "duckdb/main/database.hpp"
|
|
@@ -57,6 +57,9 @@ private:
|
|
|
57
57
|
unique_ptr<CatalogEntry> AddForeignKeyConstraint(ClientContext &context, AlterForeignKeyInfo &info);
|
|
58
58
|
unique_ptr<CatalogEntry> DropForeignKeyConstraint(ClientContext &context, AlterForeignKeyInfo &info);
|
|
59
59
|
|
|
60
|
+
void UpdateConstraintsOnColumnDrop(const LogicalIndex &removed_index, const vector<LogicalIndex> &adjusted_indices,
|
|
61
|
+
const RemoveColumnInfo &info, CreateTableInfo &create_info, bool is_generated);
|
|
62
|
+
|
|
60
63
|
private:
|
|
61
64
|
//! A reference to the underlying storage unit used for this table
|
|
62
65
|
std::shared_ptr<DataTable> storage;
|
|
@@ -97,6 +97,7 @@ static DefaultExtension internal_extensions[] = {
|
|
|
97
97
|
{"httpfs", "Adds support for reading and writing files over a HTTP(S) connection", HTTPFS_STATICALLY_LOADED},
|
|
98
98
|
{"json", "Adds support for JSON operations", JSON_STATICALLY_LOADED},
|
|
99
99
|
{"jemalloc", "Overwrites system allocator with JEMalloc", JEMALLOC_STATICALLY_LOADED},
|
|
100
|
+
{"motherduck", "Enables motherduck integration with the system", false},
|
|
100
101
|
{"sqlite_scanner", "Adds support for reading SQLite database files", false},
|
|
101
102
|
{"postgres_scanner", "Adds support for reading from a Postgres database", false},
|
|
102
103
|
{"inet", "Adds support for IP-related data types and functions", false},
|