duckdb 0.7.2-dev2507.0 → 0.7.2-dev2552.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/connection.cpp +1 -1
- package/src/duckdb/extension/icu/icu-dateadd.cpp +3 -3
- package/src/duckdb/extension/icu/icu-datepart.cpp +3 -3
- package/src/duckdb/extension/icu/icu-datesub.cpp +2 -2
- package/src/duckdb/extension/icu/icu-datetrunc.cpp +1 -1
- package/src/duckdb/extension/icu/icu-extension.cpp +3 -3
- package/src/duckdb/extension/icu/icu-list-range.cpp +2 -2
- package/src/duckdb/extension/icu/icu-makedate.cpp +1 -1
- package/src/duckdb/extension/icu/icu-strptime.cpp +4 -4
- package/src/duckdb/extension/icu/icu-table-range.cpp +2 -2
- package/src/duckdb/extension/icu/icu-timebucket.cpp +1 -1
- package/src/duckdb/extension/icu/icu-timezone.cpp +4 -4
- package/src/duckdb/extension/json/json-extension.cpp +6 -6
- package/src/duckdb/extension/parquet/parquet-extension.cpp +9 -8
- package/src/duckdb/src/catalog/catalog.cpp +166 -127
- package/src/duckdb/src/catalog/catalog_entry/copy_function_catalog_entry.cpp +3 -3
- package/src/duckdb/src/catalog/catalog_entry/duck_index_entry.cpp +1 -1
- package/src/duckdb/src/catalog/catalog_entry/duck_schema_entry.cpp +90 -82
- package/src/duckdb/src/catalog/catalog_entry/duck_table_entry.cpp +65 -67
- package/src/duckdb/src/catalog/catalog_entry/index_catalog_entry.cpp +3 -3
- package/src/duckdb/src/catalog/catalog_entry/pragma_function_catalog_entry.cpp +4 -4
- package/src/duckdb/src/catalog/catalog_entry/scalar_function_catalog_entry.cpp +8 -8
- package/src/duckdb/src/catalog/catalog_entry/scalar_macro_catalog_entry.cpp +10 -10
- package/src/duckdb/src/catalog/catalog_entry/schema_catalog_entry.cpp +6 -6
- package/src/duckdb/src/catalog/catalog_entry/sequence_catalog_entry.cpp +6 -6
- package/src/duckdb/src/catalog/catalog_entry/table_catalog_entry.cpp +4 -4
- package/src/duckdb/src/catalog/catalog_entry/table_function_catalog_entry.cpp +9 -9
- package/src/duckdb/src/catalog/catalog_entry/type_catalog_entry.cpp +5 -5
- package/src/duckdb/src/catalog/catalog_entry/view_catalog_entry.cpp +23 -23
- package/src/duckdb/src/catalog/catalog_entry.cpp +27 -6
- package/src/duckdb/src/catalog/catalog_search_path.cpp +2 -2
- package/src/duckdb/src/catalog/catalog_set.cpp +84 -87
- package/src/duckdb/src/catalog/catalog_transaction.cpp +1 -1
- package/src/duckdb/src/catalog/default/default_functions.cpp +1 -1
- package/src/duckdb/src/catalog/default/default_schemas.cpp +1 -1
- package/src/duckdb/src/catalog/default/default_types.cpp +1 -1
- package/src/duckdb/src/catalog/default/default_views.cpp +1 -1
- package/src/duckdb/src/catalog/dependency_list.cpp +2 -2
- package/src/duckdb/src/catalog/dependency_manager.cpp +9 -10
- package/src/duckdb/src/catalog/duck_catalog.cpp +30 -26
- package/src/duckdb/src/catalog/similar_catalog_entry.cpp +1 -1
- package/src/duckdb/src/common/types.cpp +15 -27
- package/src/duckdb/src/execution/operator/join/physical_index_join.cpp +2 -2
- package/src/duckdb/src/execution/operator/persistent/physical_batch_insert.cpp +4 -3
- package/src/duckdb/src/execution/operator/persistent/physical_export.cpp +19 -18
- package/src/duckdb/src/execution/operator/persistent/physical_insert.cpp +5 -5
- package/src/duckdb/src/execution/operator/schema/physical_alter.cpp +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_create_function.cpp +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_create_index.cpp +6 -5
- package/src/duckdb/src/execution/operator/schema/physical_create_schema.cpp +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_create_sequence.cpp +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_create_table.cpp +2 -2
- package/src/duckdb/src/execution/operator/schema/physical_create_type.cpp +4 -3
- package/src/duckdb/src/execution/operator/schema/physical_create_view.cpp +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_detach.cpp +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_drop.cpp +2 -2
- package/src/duckdb/src/execution/physical_plan/plan_aggregate.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_comparison_join.cpp +4 -4
- package/src/duckdb/src/execution/physical_plan/plan_create_table.cpp +4 -3
- package/src/duckdb/src/execution/physical_plan/plan_delete.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_insert.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_update.cpp +1 -1
- package/src/duckdb/src/function/built_in_functions.cpp +10 -10
- package/src/duckdb/src/function/function_binder.cpp +3 -3
- package/src/duckdb/src/function/scalar/list/list_aggregates.cpp +5 -6
- package/src/duckdb/src/function/scalar/operators/arithmetic.cpp +2 -2
- package/src/duckdb/src/function/scalar/sequence/nextval.cpp +9 -8
- package/src/duckdb/src/function/scalar/system/aggregate_export.cpp +6 -6
- package/src/duckdb/src/function/table/arrow.cpp +5 -5
- package/src/duckdb/src/function/table/system/duckdb_columns.cpp +8 -7
- package/src/duckdb/src/function/table/system/duckdb_constraints.cpp +14 -14
- package/src/duckdb/src/function/table/system/duckdb_databases.cpp +2 -2
- package/src/duckdb/src/function/table/system/duckdb_functions.cpp +26 -25
- package/src/duckdb/src/function/table/system/duckdb_indexes.cpp +13 -12
- package/src/duckdb/src/function/table/system/duckdb_schemas.cpp +7 -7
- package/src/duckdb/src/function/table/system/duckdb_sequences.cpp +8 -9
- package/src/duckdb/src/function/table/system/duckdb_tables.cpp +10 -9
- package/src/duckdb/src/function/table/system/duckdb_types.cpp +13 -13
- package/src/duckdb/src/function/table/system/duckdb_views.cpp +11 -10
- package/src/duckdb/src/function/table/system/pragma_collations.cpp +2 -2
- package/src/duckdb/src/function/table/system/pragma_database_size.cpp +5 -5
- package/src/duckdb/src/function/table/system/pragma_storage_info.cpp +3 -3
- package/src/duckdb/src/function/table/system/pragma_table_info.cpp +2 -2
- package/src/duckdb/src/function/table/table_scan.cpp +39 -37
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/function/udf_function.cpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +122 -81
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/aggregate_function_catalog_entry.hpp +2 -3
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/collate_catalog_entry.hpp +3 -3
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/copy_function_catalog_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_index_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_schema_entry.hpp +24 -20
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_table_entry.hpp +3 -3
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/index_catalog_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/macro_catalog_entry.hpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/pragma_function_catalog_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/scalar_function_catalog_entry.hpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/scalar_macro_catalog_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/schema_catalog_entry.hpp +22 -17
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/sequence_catalog_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_catalog_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_function_catalog_entry.hpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_macro_catalog_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/type_catalog_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/view_catalog_entry.hpp +3 -3
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry.hpp +28 -7
- package/src/duckdb/src/include/duckdb/catalog/catalog_set.hpp +20 -19
- package/src/duckdb/src/include/duckdb/catalog/duck_catalog.hpp +9 -9
- package/src/duckdb/src/include/duckdb/catalog/similar_catalog_entry.hpp +2 -1
- package/src/duckdb/src/include/duckdb/catalog/standard_entry.hpp +10 -4
- package/src/duckdb/src/include/duckdb/common/enums/on_entry_not_found.hpp +17 -0
- package/src/duckdb/src/include/duckdb/common/types.hpp +3 -4
- package/src/duckdb/src/include/duckdb/function/function_serialization.hpp +4 -4
- package/src/duckdb/src/include/duckdb/function/scalar_function.hpp +3 -2
- package/src/duckdb/src/include/duckdb/function/table/table_scan.hpp +5 -4
- package/src/duckdb/src/include/duckdb/function/table_function.hpp +28 -15
- package/src/duckdb/src/include/duckdb/main/attached_database.hpp +2 -0
- package/src/duckdb/src/include/duckdb/main/client_context.hpp +1 -1
- package/src/duckdb/src/include/duckdb/main/database_manager.hpp +3 -2
- package/src/duckdb/src/include/duckdb/parser/expression/bound_expression.hpp +2 -0
- package/src/duckdb/src/include/duckdb/parser/keyword_helper.hpp +2 -2
- package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_info.hpp +7 -5
- package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_table_info.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_table_info.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_view_info.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/parsed_data/detach_info.hpp +3 -2
- package/src/duckdb/src/include/duckdb/parser/parsed_data/drop_info.hpp +5 -5
- package/src/duckdb/src/include/duckdb/parser/parsed_data/parse_info.hpp +13 -0
- package/src/duckdb/src/include/duckdb/parser/tableref.hpp +5 -2
- package/src/duckdb/src/include/duckdb/parser/transformer.hpp +2 -0
- package/src/duckdb/src/include/duckdb/planner/binder.hpp +2 -2
- package/src/duckdb/src/include/duckdb/planner/expression_binder/base_select_binder.hpp +1 -2
- package/src/duckdb/src/include/duckdb/planner/expression_binder.hpp +4 -7
- package/src/duckdb/src/include/duckdb/planner/operator/logical_get.hpp +1 -1
- package/src/duckdb/src/include/duckdb/transaction/transaction.hpp +12 -0
- package/src/duckdb/src/main/attached_database.cpp +12 -6
- package/src/duckdb/src/main/capi/table_function-c.cpp +17 -16
- package/src/duckdb/src/main/client_context.cpp +12 -11
- package/src/duckdb/src/main/database_manager.cpp +13 -12
- package/src/duckdb/src/optimizer/join_order/cardinality_estimator.cpp +1 -2
- package/src/duckdb/src/parser/parsed_data/alter_info.cpp +3 -3
- package/src/duckdb/src/parser/parsed_data/alter_scalar_function_info.cpp +2 -2
- package/src/duckdb/src/parser/parsed_data/alter_table_function_info.cpp +2 -2
- package/src/duckdb/src/parser/parsed_data/alter_table_info.cpp +9 -9
- package/src/duckdb/src/parser/parsed_data/create_scalar_function_info.cpp +2 -2
- package/src/duckdb/src/parser/parsed_data/create_table_function_info.cpp +2 -2
- package/src/duckdb/src/parser/parsed_data/create_table_info.cpp +2 -2
- package/src/duckdb/src/parser/parsed_data/create_view_info.cpp +2 -2
- package/src/duckdb/src/parser/transform/statement/transform_alter_sequence.cpp +3 -2
- package/src/duckdb/src/parser/transform/statement/transform_alter_table.cpp +5 -1
- package/src/duckdb/src/parser/transform/statement/transform_detach.cpp +1 -1
- package/src/duckdb/src/parser/transform/statement/transform_drop.cpp +1 -1
- package/src/duckdb/src/parser/transform/statement/transform_rename.cpp +1 -1
- package/src/duckdb/src/planner/binder/expression/bind_aggregate_expression.cpp +26 -27
- package/src/duckdb/src/planner/binder/expression/bind_between_expression.cpp +17 -17
- package/src/duckdb/src/planner/binder/expression/bind_case_expression.cpp +9 -9
- package/src/duckdb/src/planner/binder/expression/bind_cast_expression.cpp +6 -6
- package/src/duckdb/src/planner/binder/expression/bind_collate_expression.cpp +6 -6
- package/src/duckdb/src/planner/binder/expression/bind_columnref_expression.cpp +2 -2
- package/src/duckdb/src/planner/binder/expression/bind_comparison_expression.cpp +21 -21
- package/src/duckdb/src/planner/binder/expression/bind_conjunction_expression.cpp +2 -3
- package/src/duckdb/src/planner/binder/expression/bind_function_expression.cpp +33 -36
- package/src/duckdb/src/planner/binder/expression/bind_macro_expression.cpp +5 -5
- package/src/duckdb/src/planner/binder/expression/bind_operator_expression.cpp +23 -23
- package/src/duckdb/src/planner/binder/expression/bind_subquery_expression.cpp +4 -4
- package/src/duckdb/src/planner/binder/expression/bind_unnest_expression.cpp +7 -7
- package/src/duckdb/src/planner/binder/expression/bind_window_expression.cpp +23 -23
- package/src/duckdb/src/planner/binder/query_node/bind_table_macro_node.cpp +4 -4
- package/src/duckdb/src/planner/binder/statement/bind_copy.cpp +14 -13
- package/src/duckdb/src/planner/binder/statement/bind_create.cpp +36 -35
- package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +3 -3
- package/src/duckdb/src/planner/binder/statement/bind_delete.cpp +1 -1
- package/src/duckdb/src/planner/binder/statement/bind_drop.cpp +4 -4
- package/src/duckdb/src/planner/binder/statement/bind_export.cpp +10 -10
- package/src/duckdb/src/planner/binder/statement/bind_insert.cpp +2 -2
- package/src/duckdb/src/planner/binder/statement/bind_pragma.cpp +4 -4
- package/src/duckdb/src/planner/binder/statement/bind_simple.cpp +5 -4
- package/src/duckdb/src/planner/binder/statement/bind_update.cpp +1 -1
- package/src/duckdb/src/planner/binder/tableref/bind_basetableref.cpp +3 -3
- package/src/duckdb/src/planner/binder/tableref/bind_table_function.cpp +10 -12
- package/src/duckdb/src/planner/binder.cpp +2 -2
- package/src/duckdb/src/planner/expression/bound_expression.cpp +11 -2
- package/src/duckdb/src/planner/operator/logical_copy_to_file.cpp +2 -5
- package/src/duckdb/src/planner/operator/logical_create.cpp +2 -1
- package/src/duckdb/src/planner/operator/logical_create_index.cpp +2 -2
- package/src/duckdb/src/planner/operator/logical_delete.cpp +2 -2
- package/src/duckdb/src/planner/operator/logical_get.cpp +1 -1
- package/src/duckdb/src/planner/operator/logical_insert.cpp +2 -7
- package/src/duckdb/src/planner/operator/logical_update.cpp +2 -6
- package/src/duckdb/src/planner/parsed_data/bound_create_table_info.cpp +2 -2
- package/src/duckdb/src/planner/pragma_handler.cpp +3 -4
- package/src/duckdb/src/storage/checkpoint_manager.cpp +46 -46
- package/src/duckdb/src/storage/data_table.cpp +3 -6
- package/src/duckdb/src/storage/table/update_segment.cpp +1 -1
- package/src/duckdb/src/storage/wal_replay.cpp +28 -30
- package/src/duckdb/src/storage/write_ahead_log.cpp +8 -8
- package/src/duckdb/src/transaction/cleanup_state.cpp +1 -1
- package/src/duckdb/src/transaction/commit_state.cpp +3 -4
- package/src/duckdb/src/transaction/transaction_context.cpp +1 -1
@@ -12,6 +12,7 @@
|
|
12
12
|
#include "duckdb/parser/expression/constant_expression.hpp"
|
13
13
|
#include "duckdb/catalog/mapping_value.hpp"
|
14
14
|
#include "duckdb/catalog/catalog_entry/table_catalog_entry.hpp"
|
15
|
+
#include "duckdb/catalog/catalog_entry/type_catalog_entry.hpp"
|
15
16
|
|
16
17
|
namespace duckdb {
|
17
18
|
|
@@ -106,7 +107,7 @@ bool CatalogSet::CreateEntry(CatalogTransaction transaction, const string &name,
|
|
106
107
|
// first create a dummy deleted entry for this entry
|
107
108
|
// so transactions started before the commit of this transaction don't
|
108
109
|
// see it yet
|
109
|
-
auto dummy_node = make_uniq<
|
110
|
+
auto dummy_node = make_uniq<InCatalogEntry>(CatalogType::INVALID, value->ParentCatalog(), name);
|
110
111
|
dummy_node->timestamp = 0;
|
111
112
|
dummy_node->deleted = true;
|
112
113
|
dummy_node->set = this;
|
@@ -143,7 +144,7 @@ bool CatalogSet::CreateEntry(CatalogTransaction transaction, const string &name,
|
|
143
144
|
PutEntry(std::move(entry_index), std::move(value));
|
144
145
|
// push the old entry in the undo buffer for this transaction
|
145
146
|
if (transaction.transaction) {
|
146
|
-
auto &dtransaction =
|
147
|
+
auto &dtransaction = transaction.transaction->Cast<DuckTransaction>();
|
147
148
|
dtransaction.PushCatalogEntry(*value_ptr->child);
|
148
149
|
}
|
149
150
|
return true;
|
@@ -154,64 +155,58 @@ bool CatalogSet::CreateEntry(ClientContext &context, const string &name, unique_
|
|
154
155
|
return CreateEntry(catalog.GetCatalogTransaction(context), name, std::move(value), dependencies);
|
155
156
|
}
|
156
157
|
|
157
|
-
|
158
|
-
|
159
|
-
catalog_entry = entry_index.GetEntry().get();
|
158
|
+
optional_ptr<CatalogEntry> CatalogSet::GetEntryInternal(CatalogTransaction transaction, EntryIndex &entry_index) {
|
159
|
+
auto &catalog_entry = *entry_index.GetEntry();
|
160
160
|
// if it does: we have to retrieve the entry and to check version numbers
|
161
|
-
if (HasConflict(transaction, catalog_entry
|
161
|
+
if (HasConflict(transaction, catalog_entry.timestamp)) {
|
162
162
|
// current version has been written to by a currently active
|
163
163
|
// transaction
|
164
|
-
throw TransactionException("Catalog write-write conflict on alter with \"%s\"", catalog_entry
|
164
|
+
throw TransactionException("Catalog write-write conflict on alter with \"%s\"", catalog_entry.name);
|
165
165
|
}
|
166
166
|
// there is a current version that has been committed by this transaction
|
167
|
-
if (catalog_entry
|
167
|
+
if (catalog_entry.deleted) {
|
168
168
|
// if the entry was already deleted, it now does not exist anymore
|
169
169
|
// so we return that we could not find it
|
170
|
-
return
|
170
|
+
return nullptr;
|
171
171
|
}
|
172
|
-
return
|
172
|
+
return &catalog_entry;
|
173
173
|
}
|
174
174
|
|
175
|
-
|
176
|
-
|
175
|
+
optional_ptr<CatalogEntry> CatalogSet::GetEntryInternal(CatalogTransaction transaction, const string &name,
|
176
|
+
EntryIndex *entry_index) {
|
177
177
|
auto mapping_value = GetMapping(transaction, name);
|
178
178
|
if (mapping_value == nullptr || mapping_value->deleted) {
|
179
179
|
// the entry does not exist, check if we can create a default entry
|
180
|
-
return
|
180
|
+
return nullptr;
|
181
181
|
}
|
182
182
|
if (entry_index) {
|
183
183
|
*entry_index = mapping_value->index.Copy();
|
184
184
|
}
|
185
|
-
return GetEntryInternal(transaction, mapping_value->index
|
185
|
+
return GetEntryInternal(transaction, mapping_value->index);
|
186
186
|
}
|
187
187
|
|
188
|
-
bool CatalogSet::AlterOwnership(CatalogTransaction transaction, ChangeOwnershipInfo
|
189
|
-
|
190
|
-
if (!
|
191
|
-
return false;
|
192
|
-
}
|
193
|
-
|
194
|
-
auto owner_entry = catalog.GetEntry(transaction.GetContext(), info->owner_schema, info->owner_name);
|
195
|
-
if (!owner_entry) {
|
188
|
+
bool CatalogSet::AlterOwnership(CatalogTransaction transaction, ChangeOwnershipInfo &info) {
|
189
|
+
auto entry = GetEntryInternal(transaction, info.name, nullptr);
|
190
|
+
if (!entry) {
|
196
191
|
return false;
|
197
192
|
}
|
198
193
|
|
199
|
-
catalog.
|
200
|
-
|
194
|
+
auto &owner_entry = catalog.GetEntry(transaction.GetContext(), info.owner_schema, info.owner_name);
|
195
|
+
catalog.GetDependencyManager().AddOwnership(transaction, owner_entry, *entry);
|
201
196
|
return true;
|
202
197
|
}
|
203
198
|
|
204
|
-
bool CatalogSet::AlterEntry(CatalogTransaction transaction, const string &name, AlterInfo
|
199
|
+
bool CatalogSet::AlterEntry(CatalogTransaction transaction, const string &name, AlterInfo &alter_info) {
|
205
200
|
// lock the catalog for writing
|
206
201
|
lock_guard<mutex> write_lock(catalog.GetWriteLock());
|
207
202
|
|
208
203
|
// first check if the entry exists in the unordered set
|
209
204
|
EntryIndex entry_index;
|
210
|
-
|
211
|
-
if (!
|
205
|
+
auto entry = GetEntryInternal(transaction, name, &entry_index);
|
206
|
+
if (!entry) {
|
212
207
|
return false;
|
213
208
|
}
|
214
|
-
if (!alter_info
|
209
|
+
if (!alter_info.allow_internal && entry->internal) {
|
215
210
|
throw CatalogException("Cannot alter entry \"%s\" because it is an internal system entry", entry->name);
|
216
211
|
}
|
217
212
|
|
@@ -235,8 +230,8 @@ bool CatalogSet::AlterEntry(CatalogTransaction transaction, const string &name,
|
|
235
230
|
if (value->name != original_name) {
|
236
231
|
auto mapping_value = GetMapping(transaction, value->name);
|
237
232
|
if (mapping_value && !mapping_value->deleted) {
|
238
|
-
auto original_entry = GetEntryForTransaction(transaction, mapping_value->index.GetEntry()
|
239
|
-
if (!original_entry
|
233
|
+
auto &original_entry = GetEntryForTransaction(transaction, *mapping_value->index.GetEntry());
|
234
|
+
if (!original_entry.deleted) {
|
240
235
|
entry->UndoAlter(context, alter_info);
|
241
236
|
string rename_err_msg =
|
242
237
|
"Could not rename \"%s\" to \"%s\": another entry with this name already exists!";
|
@@ -258,13 +253,13 @@ bool CatalogSet::AlterEntry(CatalogTransaction transaction, const string &name,
|
|
258
253
|
|
259
254
|
// serialize the AlterInfo into a temporary buffer
|
260
255
|
BufferedSerializer serializer;
|
261
|
-
serializer.WriteString(alter_info
|
262
|
-
alter_info
|
256
|
+
serializer.WriteString(alter_info.GetColumnName());
|
257
|
+
alter_info.Serialize(serializer);
|
263
258
|
BinaryData serialized_alter = serializer.GetData();
|
264
259
|
|
265
260
|
// push the old entry in the undo buffer for this transaction
|
266
261
|
if (transaction.transaction) {
|
267
|
-
auto &dtransaction =
|
262
|
+
auto &dtransaction = transaction.transaction->Cast<DuckTransaction>();
|
268
263
|
dtransaction.PushCatalogEntry(*new_entry->child, serialized_alter.data.get(), serialized_alter.size);
|
269
264
|
}
|
270
265
|
|
@@ -286,8 +281,9 @@ void CatalogSet::DropEntryDependencies(CatalogTransaction transaction, EntryInde
|
|
286
281
|
entry_index.GetEntry()->deleted = true;
|
287
282
|
|
288
283
|
// check any dependencies of this object
|
289
|
-
D_ASSERT(entry.
|
290
|
-
|
284
|
+
D_ASSERT(entry.ParentCatalog().IsDuckCatalog());
|
285
|
+
auto &duck_catalog = entry.ParentCatalog().Cast<DuckCatalog>();
|
286
|
+
duck_catalog.GetDependencyManager().DropObject(transaction, entry, cascade);
|
291
287
|
|
292
288
|
// dropper destructor is called here
|
293
289
|
// the destructor makes sure to return the value to the previous state
|
@@ -301,7 +297,7 @@ void CatalogSet::DropEntryInternal(CatalogTransaction transaction, EntryIndex en
|
|
301
297
|
// create a new entry and replace the currently stored one
|
302
298
|
// set the timestamp to the timestamp of the current transaction
|
303
299
|
// and point it at the dummy node
|
304
|
-
auto value = make_uniq<
|
300
|
+
auto value = make_uniq<InCatalogEntry>(CatalogType::DELETED_ENTRY, entry.ParentCatalog(), entry.name);
|
305
301
|
value->timestamp = transaction.transaction_id;
|
306
302
|
value->set = this;
|
307
303
|
value->deleted = true;
|
@@ -310,7 +306,7 @@ void CatalogSet::DropEntryInternal(CatalogTransaction transaction, EntryIndex en
|
|
310
306
|
|
311
307
|
// push the old entry in the undo buffer for this transaction
|
312
308
|
if (transaction.transaction) {
|
313
|
-
auto &dtransaction =
|
309
|
+
auto &dtransaction = transaction.transaction->Cast<DuckTransaction>();
|
314
310
|
dtransaction.PushCatalogEntry(*value_ptr->child);
|
315
311
|
}
|
316
312
|
}
|
@@ -320,8 +316,8 @@ bool CatalogSet::DropEntry(CatalogTransaction transaction, const string &name, b
|
|
320
316
|
lock_guard<mutex> write_lock(catalog.GetWriteLock());
|
321
317
|
// we can only delete an entry that exists
|
322
318
|
EntryIndex entry_index;
|
323
|
-
|
324
|
-
if (!
|
319
|
+
auto entry = GetEntryInternal(transaction, name, &entry_index);
|
320
|
+
if (!entry) {
|
325
321
|
return false;
|
326
322
|
}
|
327
323
|
if (entry->internal && !allow_drop_internal) {
|
@@ -341,25 +337,25 @@ DuckCatalog &CatalogSet::GetCatalog() {
|
|
341
337
|
return catalog;
|
342
338
|
}
|
343
339
|
|
344
|
-
void CatalogSet::CleanupEntry(CatalogEntry
|
340
|
+
void CatalogSet::CleanupEntry(CatalogEntry &catalog_entry) {
|
345
341
|
// destroy the backed up entry: it is no longer required
|
346
|
-
D_ASSERT(catalog_entry
|
347
|
-
if (catalog_entry
|
342
|
+
D_ASSERT(catalog_entry.parent);
|
343
|
+
if (catalog_entry.parent->type != CatalogType::UPDATED_ENTRY) {
|
348
344
|
lock_guard<mutex> write_lock(catalog.GetWriteLock());
|
349
345
|
lock_guard<mutex> lock(catalog_lock);
|
350
|
-
if (!catalog_entry
|
346
|
+
if (!catalog_entry.deleted) {
|
351
347
|
// delete the entry from the dependency manager, if it is not deleted yet
|
352
|
-
D_ASSERT(catalog_entry
|
353
|
-
((
|
348
|
+
D_ASSERT(catalog_entry.ParentCatalog().IsDuckCatalog());
|
349
|
+
catalog_entry.ParentCatalog().Cast<DuckCatalog>().GetDependencyManager().EraseObject(catalog_entry);
|
354
350
|
}
|
355
|
-
auto parent = catalog_entry
|
356
|
-
parent->child = std::move(catalog_entry
|
351
|
+
auto parent = catalog_entry.parent;
|
352
|
+
parent->child = std::move(catalog_entry.child);
|
357
353
|
if (parent->deleted && !parent->child && !parent->parent) {
|
358
354
|
auto mapping_entry = mapping.find(parent->name);
|
359
355
|
D_ASSERT(mapping_entry != mapping.end());
|
360
|
-
auto entry = mapping_entry->second->index.GetEntry()
|
356
|
+
auto &entry = mapping_entry->second->index.GetEntry();
|
361
357
|
D_ASSERT(entry);
|
362
|
-
if (entry == parent) {
|
358
|
+
if (entry.get() == parent.get()) {
|
363
359
|
mapping.erase(mapping_entry);
|
364
360
|
}
|
365
361
|
}
|
@@ -371,8 +367,8 @@ bool CatalogSet::HasConflict(CatalogTransaction transaction, transaction_t times
|
|
371
367
|
(timestamp < TRANSACTION_ID_START && timestamp > transaction.start_time);
|
372
368
|
}
|
373
369
|
|
374
|
-
MappingValue
|
375
|
-
MappingValue
|
370
|
+
optional_ptr<MappingValue> CatalogSet::GetMapping(CatalogTransaction transaction, const string &name, bool get_latest) {
|
371
|
+
optional_ptr<MappingValue> mapping_value;
|
376
372
|
auto entry = mapping.find(name);
|
377
373
|
if (entry != mapping.end()) {
|
378
374
|
mapping_value = entry->second.get();
|
@@ -430,27 +426,27 @@ bool CatalogSet::UseTimestamp(CatalogTransaction transaction, transaction_t time
|
|
430
426
|
return false;
|
431
427
|
}
|
432
428
|
|
433
|
-
CatalogEntry
|
434
|
-
|
435
|
-
|
429
|
+
CatalogEntry &CatalogSet::GetEntryForTransaction(CatalogTransaction transaction, CatalogEntry ¤t) {
|
430
|
+
reference<CatalogEntry> entry(current);
|
431
|
+
while (entry.get().child) {
|
432
|
+
if (UseTimestamp(transaction, entry.get().timestamp)) {
|
436
433
|
break;
|
437
434
|
}
|
438
|
-
|
439
|
-
D_ASSERT(current);
|
435
|
+
entry = *entry.get().child;
|
440
436
|
}
|
441
|
-
return
|
437
|
+
return entry.get();
|
442
438
|
}
|
443
439
|
|
444
|
-
CatalogEntry
|
445
|
-
|
446
|
-
|
440
|
+
CatalogEntry &CatalogSet::GetCommittedEntry(CatalogEntry ¤t) {
|
441
|
+
reference<CatalogEntry> entry(current);
|
442
|
+
while (entry.get().child) {
|
443
|
+
if (entry.get().timestamp < TRANSACTION_ID_START) {
|
447
444
|
// this entry is committed: use it
|
448
445
|
break;
|
449
446
|
}
|
450
|
-
|
451
|
-
D_ASSERT(current);
|
447
|
+
entry = *entry.get().child;
|
452
448
|
}
|
453
|
-
return
|
449
|
+
return entry.get();
|
454
450
|
}
|
455
451
|
|
456
452
|
SimilarCatalogEntry CatalogSet::SimilarEntry(CatalogTransaction transaction, const string &name) {
|
@@ -471,7 +467,8 @@ SimilarCatalogEntry CatalogSet::SimilarEntry(CatalogTransaction transaction, con
|
|
471
467
|
return result;
|
472
468
|
}
|
473
469
|
|
474
|
-
CatalogEntry
|
470
|
+
optional_ptr<CatalogEntry> CatalogSet::CreateEntryInternal(CatalogTransaction transaction,
|
471
|
+
unique_ptr<CatalogEntry> entry) {
|
475
472
|
if (mapping.find(entry->name) != mapping.end()) {
|
476
473
|
return nullptr;
|
477
474
|
}
|
@@ -487,8 +484,8 @@ CatalogEntry *CatalogSet::CreateEntryInternal(CatalogTransaction transaction, un
|
|
487
484
|
return catalog_entry;
|
488
485
|
}
|
489
486
|
|
490
|
-
CatalogEntry
|
491
|
-
|
487
|
+
optional_ptr<CatalogEntry> CatalogSet::CreateDefaultEntry(CatalogTransaction transaction, const string &name,
|
488
|
+
unique_lock<mutex> &lock) {
|
492
489
|
// no entry found with this name, check for defaults
|
493
490
|
if (!defaults || defaults->created_all_entries) {
|
494
491
|
// no defaults either: return null
|
@@ -520,24 +517,24 @@ CatalogEntry *CatalogSet::CreateDefaultEntry(CatalogTransaction transaction, con
|
|
520
517
|
return GetEntry(transaction, name);
|
521
518
|
}
|
522
519
|
|
523
|
-
CatalogEntry
|
520
|
+
optional_ptr<CatalogEntry> CatalogSet::GetEntry(CatalogTransaction transaction, const string &name) {
|
524
521
|
unique_lock<mutex> lock(catalog_lock);
|
525
522
|
auto mapping_value = GetMapping(transaction, name);
|
526
523
|
if (mapping_value != nullptr && !mapping_value->deleted) {
|
527
524
|
// we found an entry for this name
|
528
525
|
// check the version numbers
|
529
526
|
|
530
|
-
auto catalog_entry = mapping_value->index.GetEntry()
|
531
|
-
|
532
|
-
if (current
|
527
|
+
auto &catalog_entry = *mapping_value->index.GetEntry();
|
528
|
+
auto ¤t = GetEntryForTransaction(transaction, catalog_entry);
|
529
|
+
if (current.deleted || (current.name != name && !UseTimestamp(transaction, mapping_value->timestamp))) {
|
533
530
|
return nullptr;
|
534
531
|
}
|
535
|
-
return current;
|
532
|
+
return ¤t;
|
536
533
|
}
|
537
534
|
return CreateDefaultEntry(transaction, name, lock);
|
538
535
|
}
|
539
536
|
|
540
|
-
CatalogEntry
|
537
|
+
optional_ptr<CatalogEntry> CatalogSet::GetEntry(ClientContext &context, const string &name) {
|
541
538
|
return GetEntry(catalog.GetCatalogTransaction(context), name);
|
542
539
|
}
|
543
540
|
|
@@ -547,11 +544,11 @@ void CatalogSet::UpdateTimestamp(CatalogEntry &entry, transaction_t timestamp) {
|
|
547
544
|
}
|
548
545
|
|
549
546
|
void CatalogSet::AdjustUserDependency(CatalogEntry &entry, ColumnDefinition &column, bool remove) {
|
550
|
-
|
547
|
+
auto user_type_catalog_p = EnumType::GetCatalog(column.Type());
|
551
548
|
if (!user_type_catalog_p) {
|
552
549
|
return;
|
553
550
|
}
|
554
|
-
auto &user_type_catalog =
|
551
|
+
auto &user_type_catalog = user_type_catalog_p->Cast<CatalogEntry>();
|
555
552
|
auto &dependency_manager = catalog.GetDependencyManager();
|
556
553
|
if (remove) {
|
557
554
|
dependency_manager.dependents_map[user_type_catalog].erase(*entry.parent);
|
@@ -685,42 +682,42 @@ void CatalogSet::CreateDefaultEntries(CatalogTransaction transaction, unique_loc
|
|
685
682
|
defaults->created_all_entries = true;
|
686
683
|
}
|
687
684
|
|
688
|
-
void CatalogSet::Scan(CatalogTransaction transaction, const std::function<void(CatalogEntry
|
685
|
+
void CatalogSet::Scan(CatalogTransaction transaction, const std::function<void(CatalogEntry &)> &callback) {
|
689
686
|
// lock the catalog set
|
690
687
|
unique_lock<mutex> lock(catalog_lock);
|
691
688
|
CreateDefaultEntries(transaction, lock);
|
692
689
|
|
693
690
|
for (auto &kv : entries) {
|
694
|
-
auto entry = kv.second.entry.get();
|
695
|
-
|
696
|
-
if (!
|
697
|
-
callback(
|
691
|
+
auto &entry = *kv.second.entry.get();
|
692
|
+
auto &entry_for_transaction = GetEntryForTransaction(transaction, entry);
|
693
|
+
if (!entry_for_transaction.deleted) {
|
694
|
+
callback(entry_for_transaction);
|
698
695
|
}
|
699
696
|
}
|
700
697
|
}
|
701
698
|
|
702
|
-
void CatalogSet::Scan(ClientContext &context, const std::function<void(CatalogEntry
|
699
|
+
void CatalogSet::Scan(ClientContext &context, const std::function<void(CatalogEntry &)> &callback) {
|
703
700
|
Scan(catalog.GetCatalogTransaction(context), callback);
|
704
701
|
}
|
705
702
|
|
706
|
-
void CatalogSet::Scan(const std::function<void(CatalogEntry
|
703
|
+
void CatalogSet::Scan(const std::function<void(CatalogEntry &)> &callback) {
|
707
704
|
// lock the catalog set
|
708
705
|
lock_guard<mutex> lock(catalog_lock);
|
709
706
|
for (auto &kv : entries) {
|
710
707
|
auto entry = kv.second.entry.get();
|
711
|
-
|
712
|
-
if (!
|
713
|
-
callback(
|
708
|
+
auto &commited_entry = GetCommittedEntry(*entry);
|
709
|
+
if (!commited_entry.deleted) {
|
710
|
+
callback(commited_entry);
|
714
711
|
}
|
715
712
|
}
|
716
713
|
}
|
717
714
|
|
718
715
|
void CatalogSet::Verify(Catalog &catalog_p) {
|
719
716
|
D_ASSERT(&catalog_p == &catalog);
|
720
|
-
vector<CatalogEntry
|
721
|
-
Scan([&](CatalogEntry
|
717
|
+
vector<reference<CatalogEntry>> entries;
|
718
|
+
Scan([&](CatalogEntry &entry) { entries.push_back(entry); });
|
722
719
|
for (auto &entry : entries) {
|
723
|
-
entry
|
720
|
+
entry.get().Verify(catalog_p);
|
724
721
|
}
|
725
722
|
}
|
726
723
|
|
@@ -12,7 +12,7 @@ CatalogTransaction::CatalogTransaction(Catalog &catalog, ClientContext &context)
|
|
12
12
|
this->transaction_id = transaction_t(-1);
|
13
13
|
this->start_time = transaction_t(-1);
|
14
14
|
} else {
|
15
|
-
auto &dtransaction = (
|
15
|
+
auto &dtransaction = transaction.Cast<DuckTransaction>();
|
16
16
|
this->transaction_id = dtransaction.transaction_id;
|
17
17
|
this->start_time = dtransaction.start_time;
|
18
18
|
}
|
@@ -194,7 +194,7 @@ unique_ptr<CatalogEntry> DefaultFunctionGenerator::CreateDefaultEntry(ClientCont
|
|
194
194
|
const string &entry_name) {
|
195
195
|
auto info = GetDefaultFunction(schema.name, entry_name);
|
196
196
|
if (info) {
|
197
|
-
return make_uniq_base<CatalogEntry, ScalarMacroCatalogEntry>(
|
197
|
+
return make_uniq_base<CatalogEntry, ScalarMacroCatalogEntry>(catalog, schema, info->Cast<CreateMacroInfo>());
|
198
198
|
}
|
199
199
|
return nullptr;
|
200
200
|
}
|
@@ -25,7 +25,7 @@ DefaultSchemaGenerator::DefaultSchemaGenerator(Catalog &catalog) : DefaultGenera
|
|
25
25
|
|
26
26
|
unique_ptr<CatalogEntry> DefaultSchemaGenerator::CreateDefaultEntry(ClientContext &context, const string &entry_name) {
|
27
27
|
if (GetDefaultSchema(entry_name)) {
|
28
|
-
return make_uniq_base<CatalogEntry, DuckSchemaEntry>(
|
28
|
+
return make_uniq_base<CatalogEntry, DuckSchemaEntry>(catalog, StringUtil::Lower(entry_name), true);
|
29
29
|
}
|
30
30
|
return nullptr;
|
31
31
|
}
|
@@ -111,7 +111,7 @@ unique_ptr<CatalogEntry> DefaultTypeGenerator::CreateDefaultEntry(ClientContext
|
|
111
111
|
info.type = LogicalType(type_id);
|
112
112
|
info.internal = true;
|
113
113
|
info.temporary = true;
|
114
|
-
return make_uniq_base<CatalogEntry, TypeCatalogEntry>(
|
114
|
+
return make_uniq_base<CatalogEntry, TypeCatalogEntry>(catalog, schema, info);
|
115
115
|
}
|
116
116
|
|
117
117
|
vector<string> DefaultTypeGenerator::GetDefaultEntries() {
|
@@ -76,7 +76,7 @@ DefaultViewGenerator::DefaultViewGenerator(Catalog &catalog, SchemaCatalogEntry
|
|
76
76
|
unique_ptr<CatalogEntry> DefaultViewGenerator::CreateDefaultEntry(ClientContext &context, const string &entry_name) {
|
77
77
|
auto info = GetDefaultView(context, schema.name, entry_name);
|
78
78
|
if (info) {
|
79
|
-
return make_uniq_base<CatalogEntry, ViewCatalogEntry>(
|
79
|
+
return make_uniq_base<CatalogEntry, ViewCatalogEntry>(catalog, schema, *info);
|
80
80
|
}
|
81
81
|
return nullptr;
|
82
82
|
}
|
@@ -14,11 +14,11 @@ void DependencyList::AddDependency(CatalogEntry &entry) {
|
|
14
14
|
void DependencyList::VerifyDependencies(Catalog &catalog, const string &name) {
|
15
15
|
for (auto &dep_entry : set) {
|
16
16
|
auto &dep = dep_entry.get();
|
17
|
-
if (dep.
|
17
|
+
if (&dep.ParentCatalog() != &catalog) {
|
18
18
|
throw DependencyException(
|
19
19
|
"Error adding dependency for object \"%s\" - dependency \"%s\" is in catalog "
|
20
20
|
"\"%s\", which does not match the catalog \"%s\".\nCross catalog dependencies are not supported.",
|
21
|
-
name, dep.name, dep.
|
21
|
+
name, dep.name, dep.ParentCatalog().GetName(), catalog.GetName());
|
22
22
|
}
|
23
23
|
}
|
24
24
|
}
|
@@ -18,17 +18,17 @@ void DependencyManager::AddObject(CatalogTransaction transaction, CatalogEntry &
|
|
18
18
|
// check for each object in the sources if they were not deleted yet
|
19
19
|
for (auto &dep : dependencies.set) {
|
20
20
|
auto &dependency = dep.get();
|
21
|
-
|
22
|
-
if (dependency.catalog != object.catalog) {
|
21
|
+
if (&dependency.ParentCatalog() != &object.ParentCatalog()) {
|
23
22
|
throw DependencyException(
|
24
23
|
"Error adding dependency for object \"%s\" - dependency \"%s\" is in catalog "
|
25
24
|
"\"%s\", which does not match the catalog \"%s\".\nCross catalog dependencies are not supported.",
|
26
|
-
object.name, dependency.name, dependency.
|
25
|
+
object.name, dependency.name, dependency.ParentCatalog().GetName(), object.ParentCatalog().GetName());
|
27
26
|
}
|
28
27
|
if (!dependency.set) {
|
29
28
|
throw InternalException("Dependency has no set");
|
30
29
|
}
|
31
|
-
|
30
|
+
auto catalog_entry = dependency.set->GetEntryInternal(transaction, dependency.name, nullptr);
|
31
|
+
if (!catalog_entry) {
|
32
32
|
throw InternalException("Dependency has already been deleted?");
|
33
33
|
}
|
34
34
|
}
|
@@ -58,9 +58,8 @@ void DependencyManager::DropObject(CatalogTransaction transaction, CatalogEntry
|
|
58
58
|
if (mapping_value == nullptr) {
|
59
59
|
continue;
|
60
60
|
}
|
61
|
-
|
62
|
-
|
63
|
-
if (!catalog_set.GetEntryInternal(transaction, mapping_value->index, dependency_entry)) {
|
61
|
+
auto dependency_entry = catalog_set.GetEntryInternal(transaction, mapping_value->index);
|
62
|
+
if (!dependency_entry) {
|
64
63
|
// the dependent object was already deleted, no conflict
|
65
64
|
continue;
|
66
65
|
}
|
@@ -89,8 +88,8 @@ void DependencyManager::AlterObject(CatalogTransaction transaction, CatalogEntry
|
|
89
88
|
// look up the entry in the catalog set
|
90
89
|
auto &entry = dep.entry.get();
|
91
90
|
auto &catalog_set = *entry.set;
|
92
|
-
|
93
|
-
if (!
|
91
|
+
auto dependency_entry = catalog_set.GetEntryInternal(transaction, entry.name, nullptr);
|
92
|
+
if (!dependency_entry) {
|
94
93
|
// the dependent object was already deleted, no conflict
|
95
94
|
continue;
|
96
95
|
}
|
@@ -138,7 +137,7 @@ void DependencyManager::AlterObject(CatalogTransaction transaction, CatalogEntry
|
|
138
137
|
if (new_obj.type == CatalogType::TABLE_ENTRY) {
|
139
138
|
auto &table = new_obj.Cast<TableCatalogEntry>();
|
140
139
|
for (auto &column : table.GetColumns().Logical()) {
|
141
|
-
auto user_type_catalog =
|
140
|
+
auto user_type_catalog = EnumType::GetCatalog(column.Type());
|
142
141
|
if (user_type_catalog) {
|
143
142
|
to_add.push_back(*user_type_catalog);
|
144
143
|
}
|
@@ -28,7 +28,7 @@ void DuckCatalog::Initialize(bool load_builtin) {
|
|
28
28
|
CreateSchemaInfo info;
|
29
29
|
info.schema = DEFAULT_SCHEMA;
|
30
30
|
info.internal = true;
|
31
|
-
CreateSchema(data,
|
31
|
+
CreateSchema(data, info);
|
32
32
|
|
33
33
|
if (load_builtin) {
|
34
34
|
// initialize default functions
|
@@ -46,29 +46,29 @@ bool DuckCatalog::IsDuckCatalog() {
|
|
46
46
|
//===--------------------------------------------------------------------===//
|
47
47
|
// Schema
|
48
48
|
//===--------------------------------------------------------------------===//
|
49
|
-
CatalogEntry
|
49
|
+
optional_ptr<CatalogEntry> DuckCatalog::CreateSchemaInternal(CatalogTransaction transaction, CreateSchemaInfo &info) {
|
50
50
|
DependencyList dependencies;
|
51
|
-
auto entry = make_uniq<DuckSchemaEntry>(this, info
|
51
|
+
auto entry = make_uniq<DuckSchemaEntry>(*this, info.schema, info.internal);
|
52
52
|
auto result = entry.get();
|
53
|
-
if (!schemas->CreateEntry(transaction, info
|
53
|
+
if (!schemas->CreateEntry(transaction, info.schema, std::move(entry), dependencies)) {
|
54
54
|
return nullptr;
|
55
55
|
}
|
56
56
|
return (CatalogEntry *)result;
|
57
57
|
}
|
58
58
|
|
59
|
-
CatalogEntry
|
60
|
-
D_ASSERT(!info
|
59
|
+
optional_ptr<CatalogEntry> DuckCatalog::CreateSchema(CatalogTransaction transaction, CreateSchemaInfo &info) {
|
60
|
+
D_ASSERT(!info.schema.empty());
|
61
61
|
auto result = CreateSchemaInternal(transaction, info);
|
62
62
|
if (!result) {
|
63
|
-
switch (info
|
63
|
+
switch (info.on_conflict) {
|
64
64
|
case OnCreateConflict::ERROR_ON_CONFLICT:
|
65
|
-
throw CatalogException("Schema with name %s already exists!", info
|
65
|
+
throw CatalogException("Schema with name %s already exists!", info.schema);
|
66
66
|
case OnCreateConflict::REPLACE_ON_CONFLICT: {
|
67
67
|
DropInfo drop_info;
|
68
68
|
drop_info.type = CatalogType::SCHEMA_ENTRY;
|
69
|
-
drop_info.catalog = info
|
70
|
-
drop_info.name = info
|
71
|
-
DropSchema(transaction,
|
69
|
+
drop_info.catalog = info.catalog;
|
70
|
+
drop_info.name = info.schema;
|
71
|
+
DropSchema(transaction, drop_info);
|
72
72
|
result = CreateSchemaInternal(transaction, info);
|
73
73
|
if (!result) {
|
74
74
|
throw InternalException("Failed to create schema entry in CREATE_OR_REPLACE");
|
@@ -85,36 +85,40 @@ CatalogEntry *DuckCatalog::CreateSchema(CatalogTransaction transaction, CreateSc
|
|
85
85
|
return result;
|
86
86
|
}
|
87
87
|
|
88
|
-
void DuckCatalog::DropSchema(CatalogTransaction transaction, DropInfo
|
89
|
-
D_ASSERT(!info
|
88
|
+
void DuckCatalog::DropSchema(CatalogTransaction transaction, DropInfo &info) {
|
89
|
+
D_ASSERT(!info.name.empty());
|
90
90
|
ModifyCatalog();
|
91
|
-
if (!schemas->DropEntry(transaction, info
|
92
|
-
if (
|
93
|
-
throw CatalogException("Schema with name \"%s\" does not exist!", info
|
91
|
+
if (!schemas->DropEntry(transaction, info.name, info.cascade)) {
|
92
|
+
if (info.if_not_found == OnEntryNotFound::THROW_EXCEPTION) {
|
93
|
+
throw CatalogException("Schema with name \"%s\" does not exist!", info.name);
|
94
94
|
}
|
95
95
|
}
|
96
96
|
}
|
97
97
|
|
98
|
-
void DuckCatalog::DropSchema(ClientContext &context, DropInfo
|
98
|
+
void DuckCatalog::DropSchema(ClientContext &context, DropInfo &info) {
|
99
99
|
DropSchema(GetCatalogTransaction(context), info);
|
100
100
|
}
|
101
101
|
|
102
|
-
void DuckCatalog::ScanSchemas(ClientContext &context, std::function<void(
|
103
|
-
schemas->Scan(GetCatalogTransaction(context),
|
102
|
+
void DuckCatalog::ScanSchemas(ClientContext &context, std::function<void(SchemaCatalogEntry &)> callback) {
|
103
|
+
schemas->Scan(GetCatalogTransaction(context),
|
104
|
+
[&](CatalogEntry &entry) { callback(entry.Cast<SchemaCatalogEntry>()); });
|
104
105
|
}
|
105
106
|
|
106
|
-
void DuckCatalog::ScanSchemas(std::function<void(
|
107
|
-
schemas->Scan([&](CatalogEntry
|
107
|
+
void DuckCatalog::ScanSchemas(std::function<void(SchemaCatalogEntry &)> callback) {
|
108
|
+
schemas->Scan([&](CatalogEntry &entry) { callback(entry.Cast<SchemaCatalogEntry>()); });
|
108
109
|
}
|
109
110
|
|
110
|
-
SchemaCatalogEntry
|
111
|
-
|
111
|
+
optional_ptr<SchemaCatalogEntry> DuckCatalog::GetSchema(CatalogTransaction transaction, const string &schema_name,
|
112
|
+
OnEntryNotFound if_not_found, QueryErrorContext error_context) {
|
112
113
|
D_ASSERT(!schema_name.empty());
|
113
114
|
auto entry = schemas->GetEntry(transaction, schema_name);
|
114
|
-
if (!entry
|
115
|
-
|
115
|
+
if (!entry) {
|
116
|
+
if (if_not_found == OnEntryNotFound::THROW_EXCEPTION) {
|
117
|
+
throw CatalogException(error_context.FormatError("Schema with name %s does not exist!", schema_name));
|
118
|
+
}
|
119
|
+
return nullptr;
|
116
120
|
}
|
117
|
-
return (
|
121
|
+
return &entry->Cast<SchemaCatalogEntry>();
|
118
122
|
}
|
119
123
|
|
120
124
|
DatabaseSize DuckCatalog::GetDatabaseSize(ClientContext &context) {
|
@@ -8,7 +8,7 @@ string SimilarCatalogEntry::GetQualifiedName(bool qualify_catalog, bool qualify_
|
|
8
8
|
D_ASSERT(Found());
|
9
9
|
string result;
|
10
10
|
if (qualify_catalog) {
|
11
|
-
result += schema->catalog
|
11
|
+
result += schema->catalog.GetName();
|
12
12
|
}
|
13
13
|
if (qualify_schema) {
|
14
14
|
if (!result.empty()) {
|