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
@@ -773,7 +773,7 @@ struct ExtraTypeInfo {
|
|
773
773
|
|
774
774
|
ExtraTypeInfoType type;
|
775
775
|
string alias;
|
776
|
-
TypeCatalogEntry
|
776
|
+
optional_ptr<TypeCatalogEntry> catalog_entry;
|
777
777
|
|
778
778
|
public:
|
779
779
|
bool Equals(ExtraTypeInfo *other_p) const {
|
@@ -845,21 +845,6 @@ bool LogicalType::HasAlias() const {
|
|
845
845
|
return false;
|
846
846
|
}
|
847
847
|
|
848
|
-
void LogicalType::SetCatalog(LogicalType &type, TypeCatalogEntry *catalog_entry) {
|
849
|
-
auto info = type.AuxInfo();
|
850
|
-
if (!info) {
|
851
|
-
return;
|
852
|
-
}
|
853
|
-
((ExtraTypeInfo &)*info).catalog_entry = catalog_entry;
|
854
|
-
}
|
855
|
-
TypeCatalogEntry *LogicalType::GetCatalog(const LogicalType &type) {
|
856
|
-
auto info = type.AuxInfo();
|
857
|
-
if (!info) {
|
858
|
-
return nullptr;
|
859
|
-
}
|
860
|
-
return ((ExtraTypeInfo &)*info).catalog_entry;
|
861
|
-
}
|
862
|
-
|
863
848
|
ExtraTypeInfoType LogicalType::GetExtraTypeInfoType(const ExtraTypeInfo &type) {
|
864
849
|
return type.type;
|
865
850
|
}
|
@@ -1327,7 +1312,7 @@ struct EnumTypeInfo : public ExtraTypeInfo {
|
|
1327
1312
|
return enum_name;
|
1328
1313
|
};
|
1329
1314
|
const string GetSchemaName() const {
|
1330
|
-
return catalog_entry ? catalog_entry->schema
|
1315
|
+
return catalog_entry ? catalog_entry->schema.name : "";
|
1331
1316
|
};
|
1332
1317
|
const Vector &GetValuesInsertOrder() {
|
1333
1318
|
return values_insert_order;
|
@@ -1536,22 +1521,25 @@ idx_t EnumType::GetSize(const LogicalType &type) {
|
|
1536
1521
|
return ((EnumTypeInfo &)*info).GetDictSize();
|
1537
1522
|
}
|
1538
1523
|
|
1539
|
-
void EnumType::SetCatalog(LogicalType &type, TypeCatalogEntry
|
1540
|
-
D_ASSERT(type.id() == LogicalTypeId::ENUM);
|
1524
|
+
void EnumType::SetCatalog(LogicalType &type, optional_ptr<TypeCatalogEntry> catalog_entry) {
|
1541
1525
|
auto info = type.AuxInfo();
|
1542
|
-
|
1543
|
-
|
1526
|
+
if (!info) {
|
1527
|
+
return;
|
1528
|
+
}
|
1529
|
+
((ExtraTypeInfo &)*info).catalog_entry = catalog_entry;
|
1544
1530
|
}
|
1545
|
-
|
1546
|
-
|
1531
|
+
|
1532
|
+
optional_ptr<TypeCatalogEntry> EnumType::GetCatalog(const LogicalType &type) {
|
1547
1533
|
auto info = type.AuxInfo();
|
1548
|
-
|
1549
|
-
|
1534
|
+
if (!info) {
|
1535
|
+
return nullptr;
|
1536
|
+
}
|
1537
|
+
return ((ExtraTypeInfo &)*info).catalog_entry;
|
1550
1538
|
}
|
1551
1539
|
|
1552
1540
|
string EnumType::GetSchemaName(const LogicalType &type) {
|
1553
1541
|
auto catalog_entry = EnumType::GetCatalog(type);
|
1554
|
-
return catalog_entry ? catalog_entry->schema
|
1542
|
+
return catalog_entry ? catalog_entry->schema.name : "";
|
1555
1543
|
}
|
1556
1544
|
|
1557
1545
|
PhysicalType EnumType::GetPhysicalType(const LogicalType &type) {
|
@@ -1679,7 +1667,7 @@ shared_ptr<ExtraTypeInfo> ExtraTypeInfo::Deserialize(FieldReader &reader) {
|
|
1679
1667
|
// See if the serializer has a catalog
|
1680
1668
|
auto catalog = reader.GetSource().GetCatalog();
|
1681
1669
|
if (catalog) {
|
1682
|
-
auto enum_type = catalog->GetType(client_context, schema_name, enum_name,
|
1670
|
+
auto enum_type = catalog->GetType(client_context, schema_name, enum_name, OnEntryNotFound::RETURN_NULL);
|
1683
1671
|
if (enum_type != LogicalType::INVALID) {
|
1684
1672
|
extra_info = enum_type.GetAuxInfoShrPtr();
|
1685
1673
|
}
|
@@ -110,10 +110,10 @@ void PhysicalIndexJoin::Output(ExecutionContext &context, DataChunk &input, Data
|
|
110
110
|
OperatorState &state_p) const {
|
111
111
|
auto &phy_tbl_scan = (PhysicalTableScan &)*children[1];
|
112
112
|
auto &bind_tbl = phy_tbl_scan.bind_data->Cast<TableScanBindData>();
|
113
|
-
auto &transaction = DuckTransaction::Get(context.client,
|
113
|
+
auto &transaction = DuckTransaction::Get(context.client, bind_tbl.table.catalog);
|
114
114
|
auto &state = state_p.Cast<IndexJoinOperatorState>();
|
115
115
|
|
116
|
-
auto &tbl = bind_tbl.table
|
116
|
+
auto &tbl = bind_tbl.table.GetStorage();
|
117
117
|
idx_t output_sel_idx = 0;
|
118
118
|
vector<row_t> fetch_rows;
|
119
119
|
|
@@ -269,9 +269,10 @@ unique_ptr<GlobalSinkState> PhysicalBatchInsert::GetGlobalSinkState(ClientContex
|
|
269
269
|
if (info) {
|
270
270
|
// CREATE TABLE AS
|
271
271
|
D_ASSERT(!insert_table);
|
272
|
-
auto &catalog =
|
273
|
-
table = (TableCatalogEntry *)catalog
|
274
|
-
|
272
|
+
auto &catalog = schema->catalog;
|
273
|
+
table = (TableCatalogEntry *)catalog
|
274
|
+
.CreateTable(catalog.GetCatalogTransaction(context), *schema.get_mutable(), *info)
|
275
|
+
.get();
|
275
276
|
} else {
|
276
277
|
D_ASSERT(insert_table);
|
277
278
|
D_ASSERT(insert_table->IsDuckTable());
|
@@ -117,31 +117,32 @@ void PhysicalExport::GetData(ExecutionContext &context, DataChunk &chunk, Global
|
|
117
117
|
vector<reference<CatalogEntry>> macros;
|
118
118
|
|
119
119
|
auto schema_list = Catalog::GetSchemas(ccontext, info->catalog);
|
120
|
-
for (auto &
|
121
|
-
|
122
|
-
|
120
|
+
for (auto &schema_p : schema_list) {
|
121
|
+
auto &schema = schema_p.get();
|
122
|
+
if (!schema.internal) {
|
123
|
+
schemas.push_back(schema);
|
123
124
|
}
|
124
|
-
schema
|
125
|
-
if (entry
|
125
|
+
schema.Scan(context.client, CatalogType::TABLE_ENTRY, [&](CatalogEntry &entry) {
|
126
|
+
if (entry.internal) {
|
126
127
|
return;
|
127
128
|
}
|
128
|
-
if (entry
|
129
|
-
views.push_back(
|
129
|
+
if (entry.type != CatalogType::TABLE_ENTRY) {
|
130
|
+
views.push_back(entry);
|
130
131
|
}
|
131
132
|
});
|
132
|
-
schema
|
133
|
-
|
134
|
-
schema
|
135
|
-
|
136
|
-
schema
|
137
|
-
schema
|
138
|
-
if (!entry
|
139
|
-
macros.push_back(
|
133
|
+
schema.Scan(context.client, CatalogType::SEQUENCE_ENTRY,
|
134
|
+
[&](CatalogEntry &entry) { sequences.push_back(entry); });
|
135
|
+
schema.Scan(context.client, CatalogType::TYPE_ENTRY,
|
136
|
+
[&](CatalogEntry &entry) { custom_types.push_back(entry); });
|
137
|
+
schema.Scan(context.client, CatalogType::INDEX_ENTRY, [&](CatalogEntry &entry) { indexes.push_back(entry); });
|
138
|
+
schema.Scan(context.client, CatalogType::MACRO_ENTRY, [&](CatalogEntry &entry) {
|
139
|
+
if (!entry.internal && entry.type == CatalogType::MACRO_ENTRY) {
|
140
|
+
macros.push_back(entry);
|
140
141
|
}
|
141
142
|
});
|
142
|
-
schema
|
143
|
-
if (!entry
|
144
|
-
macros.push_back(
|
143
|
+
schema.Scan(context.client, CatalogType::TABLE_MACRO_ENTRY, [&](CatalogEntry &entry) {
|
144
|
+
if (!entry.internal && entry.type == CatalogType::TABLE_MACRO_ENTRY) {
|
145
|
+
macros.push_back(entry);
|
145
146
|
}
|
146
147
|
});
|
147
148
|
}
|
@@ -109,9 +109,9 @@ unique_ptr<GlobalSinkState> PhysicalInsert::GetGlobalSinkState(ClientContext &co
|
|
109
109
|
if (info) {
|
110
110
|
// CREATE TABLE AS
|
111
111
|
D_ASSERT(!insert_table);
|
112
|
-
auto &catalog =
|
113
|
-
table =
|
114
|
-
|
112
|
+
auto &catalog = schema->catalog;
|
113
|
+
table = &catalog.CreateTable(catalog.GetCatalogTransaction(context), *schema.get_mutable(), *info)
|
114
|
+
->Cast<TableCatalogEntry>();
|
115
115
|
} else {
|
116
116
|
D_ASSERT(insert_table);
|
117
117
|
D_ASSERT(insert_table->IsDuckTable());
|
@@ -313,7 +313,7 @@ void PhysicalInsert::OnConflictHandling(TableCatalogEntry &table, ExecutionConte
|
|
313
313
|
// then we scan the existing table for the conflicting tuples, using the rowids
|
314
314
|
scan_chunk.Initialize(context.client, types_to_fetch);
|
315
315
|
auto fetch_state = make_uniq<ColumnFetchState>();
|
316
|
-
auto &transaction = DuckTransaction::Get(context.client,
|
316
|
+
auto &transaction = DuckTransaction::Get(context.client, table.catalog);
|
317
317
|
data_table.Fetch(transaction, scan_chunk, columns_to_fetch, row_ids, conflicts.Count(), *fetch_state);
|
318
318
|
}
|
319
319
|
|
@@ -424,7 +424,7 @@ void PhysicalInsert::Combine(ExecutionContext &context, GlobalSinkState &gstate_
|
|
424
424
|
auto &table = gstate.table;
|
425
425
|
auto &storage = table.GetStorage();
|
426
426
|
storage.InitializeLocalAppend(gstate.append_state, context.client);
|
427
|
-
auto &transaction = DuckTransaction::Get(context.client,
|
427
|
+
auto &transaction = DuckTransaction::Get(context.client, table.catalog);
|
428
428
|
lstate.local_collection->Scan(transaction, [&](DataChunk &insert_chunk) {
|
429
429
|
storage.LocalAppend(gstate.append_state, table, context.client, insert_chunk);
|
430
430
|
return true;
|
@@ -26,7 +26,7 @@ void PhysicalAlter::GetData(ExecutionContext &context, DataChunk &chunk, GlobalS
|
|
26
26
|
return;
|
27
27
|
}
|
28
28
|
auto &catalog = Catalog::GetCatalog(context.client, info->catalog);
|
29
|
-
catalog.Alter(context.client, info
|
29
|
+
catalog.Alter(context.client, *info);
|
30
30
|
state.finished = true;
|
31
31
|
}
|
32
32
|
|
@@ -27,7 +27,7 @@ void PhysicalCreateFunction::GetData(ExecutionContext &context, DataChunk &chunk
|
|
27
27
|
return;
|
28
28
|
}
|
29
29
|
auto &catalog = Catalog::GetCatalog(context.client, info->catalog);
|
30
|
-
catalog.CreateFunction(context.client, info
|
30
|
+
catalog.CreateFunction(context.client, *info);
|
31
31
|
state.finished = true;
|
32
32
|
}
|
33
33
|
|
@@ -139,17 +139,18 @@ SinkFinalizeType PhysicalCreateIndex::Finalize(Pipeline &pipeline, Event &event,
|
|
139
139
|
state.global_index->buffer_manager.IncreaseUsedMemory(state.global_index->memory_size);
|
140
140
|
}
|
141
141
|
|
142
|
-
auto &schema =
|
143
|
-
auto index_entry =
|
142
|
+
auto &schema = table.schema;
|
143
|
+
auto index_entry = schema.CreateIndex(context, *info, table).get();
|
144
144
|
if (!index_entry) {
|
145
145
|
// index already exists, but error ignored because of IF NOT EXISTS
|
146
146
|
return SinkFinalizeType::READY;
|
147
147
|
}
|
148
|
+
auto &index = index_entry->Cast<DuckIndexEntry>();
|
148
149
|
|
149
|
-
|
150
|
-
|
150
|
+
index.index = state.global_index.get();
|
151
|
+
index.info = storage.info;
|
151
152
|
for (auto &parsed_expr : info->parsed_expressions) {
|
152
|
-
|
153
|
+
index.parsed_expressions.push_back(parsed_expr->Copy());
|
153
154
|
}
|
154
155
|
|
155
156
|
storage.info->indexes.AddIndex(std::move(state.global_index));
|
@@ -28,7 +28,7 @@ void PhysicalCreateSchema::GetData(ExecutionContext &context, DataChunk &chunk,
|
|
28
28
|
if (catalog.IsSystemCatalog()) {
|
29
29
|
throw BinderException("Cannot create schema in system catalog");
|
30
30
|
}
|
31
|
-
catalog.CreateSchema(context.client, info
|
31
|
+
catalog.CreateSchema(context.client, *info);
|
32
32
|
state.finished = true;
|
33
33
|
}
|
34
34
|
|
@@ -25,7 +25,7 @@ void PhysicalCreateSequence::GetData(ExecutionContext &context, DataChunk &chunk
|
|
25
25
|
return;
|
26
26
|
}
|
27
27
|
auto &catalog = Catalog::GetCatalog(context.client, info->catalog);
|
28
|
-
catalog.CreateSequence(context.client, info
|
28
|
+
catalog.CreateSequence(context.client, *info);
|
29
29
|
state.finished = true;
|
30
30
|
}
|
31
31
|
|
@@ -34,8 +34,8 @@ void PhysicalCreateTable::GetData(ExecutionContext &context, DataChunk &chunk, G
|
|
34
34
|
if (state.finished) {
|
35
35
|
return;
|
36
36
|
}
|
37
|
-
auto &catalog =
|
38
|
-
catalog.CreateTable(catalog.GetCatalogTransaction(context.client), schema, info
|
37
|
+
auto &catalog = schema.catalog;
|
38
|
+
catalog.CreateTable(catalog.GetCatalogTransaction(context.client), schema, *info);
|
39
39
|
state.finished = true;
|
40
40
|
}
|
41
41
|
|
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
#include "duckdb/catalog/catalog.hpp"
|
4
4
|
#include "duckdb/common/types/column/column_data_collection.hpp"
|
5
|
+
#include "duckdb/catalog/catalog_entry/type_catalog_entry.hpp"
|
5
6
|
|
6
7
|
namespace duckdb {
|
7
8
|
|
@@ -86,10 +87,10 @@ void PhysicalCreateType::GetData(ExecutionContext &context, DataChunk &chunk, Gl
|
|
86
87
|
}
|
87
88
|
|
88
89
|
auto &catalog = Catalog::GetCatalog(context.client, info->catalog);
|
89
|
-
auto catalog_entry = catalog.CreateType(context.client, info
|
90
|
+
auto catalog_entry = catalog.CreateType(context.client, *info);
|
90
91
|
D_ASSERT(catalog_entry->type == CatalogType::TYPE_ENTRY);
|
91
|
-
auto catalog_type = (
|
92
|
-
|
92
|
+
auto &catalog_type = catalog_entry->Cast<TypeCatalogEntry>();
|
93
|
+
EnumType::SetCatalog(info->type, &catalog_type);
|
93
94
|
state.finished = true;
|
94
95
|
}
|
95
96
|
|
@@ -25,7 +25,7 @@ void PhysicalCreateView::GetData(ExecutionContext &context, DataChunk &chunk, Gl
|
|
25
25
|
return;
|
26
26
|
}
|
27
27
|
auto &catalog = Catalog::GetCatalog(context.client, info->catalog);
|
28
|
-
catalog.CreateView(context.client, info
|
28
|
+
catalog.CreateView(context.client, *info);
|
29
29
|
state.finished = true;
|
30
30
|
}
|
31
31
|
|
@@ -30,7 +30,7 @@ void PhysicalDetach::GetData(ExecutionContext &context, DataChunk &chunk, Global
|
|
30
30
|
return;
|
31
31
|
}
|
32
32
|
auto &db_manager = DatabaseManager::Get(context.client);
|
33
|
-
db_manager.DetachDatabase(context.client, info->name, info->
|
33
|
+
db_manager.DetachDatabase(context.client, info->name, info->if_not_found);
|
34
34
|
state.finished = true;
|
35
35
|
}
|
36
36
|
|
@@ -40,7 +40,7 @@ void PhysicalDrop::GetData(ExecutionContext &context, DataChunk &chunk, GlobalSo
|
|
40
40
|
}
|
41
41
|
case CatalogType::SCHEMA_ENTRY: {
|
42
42
|
auto &catalog = Catalog::GetCatalog(context.client, info->catalog);
|
43
|
-
catalog.DropEntry(context.client, info
|
43
|
+
catalog.DropEntry(context.client, *info);
|
44
44
|
auto qualified_name = QualifiedName::Parse(info->name);
|
45
45
|
|
46
46
|
// Check if the dropped schema was set as the current schema
|
@@ -58,7 +58,7 @@ void PhysicalDrop::GetData(ExecutionContext &context, DataChunk &chunk, GlobalSo
|
|
58
58
|
}
|
59
59
|
default: {
|
60
60
|
auto &catalog = Catalog::GetCatalog(context.client, info->catalog);
|
61
|
-
catalog.DropEntry(context.client, info
|
61
|
+
catalog.DropEntry(context.client, *info);
|
62
62
|
break;
|
63
63
|
}
|
64
64
|
}
|
@@ -124,7 +124,7 @@ unique_ptr<PhysicalOperator> PhysicalPlanGenerator::CreatePlan(LogicalAggregate
|
|
124
124
|
|
125
125
|
plan = ExtractAggregateExpressions(std::move(plan), op.expressions, op.groups);
|
126
126
|
|
127
|
-
if (op.groups.empty()) {
|
127
|
+
if (op.groups.empty() && op.grouping_sets.size() <= 1) {
|
128
128
|
// no groups, check if we can use a simple aggregation
|
129
129
|
// special case: aggregate entire columns together
|
130
130
|
bool use_simple_aggregation = true;
|
@@ -20,10 +20,10 @@
|
|
20
20
|
namespace duckdb {
|
21
21
|
|
22
22
|
static bool CanPlanIndexJoin(ClientContext &context, TableScanBindData &bind_data, PhysicalTableScan &scan) {
|
23
|
-
auto table = bind_data.table;
|
24
|
-
auto &transaction = DuckTransaction::Get(context,
|
23
|
+
auto &table = bind_data.table;
|
24
|
+
auto &transaction = DuckTransaction::Get(context, table.catalog);
|
25
25
|
auto &local_storage = LocalStorage::Get(transaction);
|
26
|
-
if (local_storage.Find(table
|
26
|
+
if (local_storage.Find(table.GetStorage())) {
|
27
27
|
// transaction local appends: skip index join
|
28
28
|
return false;
|
29
29
|
}
|
@@ -137,7 +137,7 @@ void CheckForPerfectJoinOpt(LogicalComparisonJoin &op, PerfectHashJoinStats &joi
|
|
137
137
|
|
138
138
|
static optional_ptr<Index> CanUseIndexJoin(TableScanBindData &tbl, Expression &expr) {
|
139
139
|
optional_ptr<Index> result;
|
140
|
-
tbl.table
|
140
|
+
tbl.table.GetStorage().info->indexes.Scan([&](Index &index) {
|
141
141
|
if (index.unbound_expressions.size() != 1) {
|
142
142
|
return false;
|
143
143
|
}
|
@@ -35,12 +35,13 @@ unique_ptr<PhysicalOperator> DuckCatalog::PlanCreateTableAs(ClientContext &conte
|
|
35
35
|
|
36
36
|
unique_ptr<PhysicalOperator> PhysicalPlanGenerator::CreatePlan(LogicalCreateTable &op) {
|
37
37
|
const auto &create_info = (CreateTableInfo &)*op.info->base;
|
38
|
-
auto &catalog =
|
39
|
-
auto existing_entry = catalog.GetEntry<TableCatalogEntry>(context, create_info.schema, create_info.table,
|
38
|
+
auto &catalog = op.info->schema.catalog;
|
39
|
+
auto existing_entry = catalog.GetEntry<TableCatalogEntry>(context, create_info.schema, create_info.table,
|
40
|
+
OnEntryNotFound::RETURN_NULL);
|
40
41
|
bool replace = op.info->Base().on_conflict == OnCreateConflict::REPLACE_ON_CONFLICT;
|
41
42
|
if ((!existing_entry || replace) && !op.children.empty()) {
|
42
43
|
auto plan = CreatePlan(*op.children[0]);
|
43
|
-
return op.schema.catalog
|
44
|
+
return op.schema.catalog.PlanCreateTableAs(context, op, std::move(plan));
|
44
45
|
} else {
|
45
46
|
return make_uniq<PhysicalCreateTable>(op, op.schema, std::move(op.info), op.estimated_cardinality);
|
46
47
|
}
|
@@ -26,7 +26,7 @@ unique_ptr<PhysicalOperator> PhysicalPlanGenerator::CreatePlan(LogicalDelete &op
|
|
26
26
|
auto plan = CreatePlan(*op.children[0]);
|
27
27
|
|
28
28
|
dependencies.AddDependency(op.table);
|
29
|
-
return op.table.catalog
|
29
|
+
return op.table.catalog.PlanDelete(context, op, std::move(plan));
|
30
30
|
}
|
31
31
|
|
32
32
|
} // namespace duckdb
|
@@ -107,7 +107,7 @@ unique_ptr<PhysicalOperator> PhysicalPlanGenerator::CreatePlan(LogicalInsert &op
|
|
107
107
|
plan = CreatePlan(*op.children[0]);
|
108
108
|
}
|
109
109
|
dependencies.AddDependency(op.table);
|
110
|
-
return op.table.catalog
|
110
|
+
return op.table.catalog.PlanInsert(context, op, std::move(plan));
|
111
111
|
}
|
112
112
|
|
113
113
|
} // namespace duckdb
|
@@ -23,7 +23,7 @@ unique_ptr<PhysicalOperator> PhysicalPlanGenerator::CreatePlan(LogicalUpdate &op
|
|
23
23
|
auto plan = CreatePlan(*op.children[0]);
|
24
24
|
|
25
25
|
dependencies.AddDependency(op.table);
|
26
|
-
return op.table.catalog
|
26
|
+
return op.table.catalog.PlanUpdate(context, op, std::move(plan));
|
27
27
|
}
|
28
28
|
|
29
29
|
} // namespace duckdb
|
@@ -21,37 +21,37 @@ void BuiltinFunctions::AddCollation(string name, ScalarFunction function, bool c
|
|
21
21
|
bool not_required_for_equality) {
|
22
22
|
CreateCollationInfo info(std::move(name), std::move(function), combinable, not_required_for_equality);
|
23
23
|
info.internal = true;
|
24
|
-
catalog.CreateCollation(transaction,
|
24
|
+
catalog.CreateCollation(transaction, info);
|
25
25
|
}
|
26
26
|
|
27
27
|
void BuiltinFunctions::AddFunction(AggregateFunctionSet set) {
|
28
28
|
CreateAggregateFunctionInfo info(std::move(set));
|
29
29
|
info.internal = true;
|
30
|
-
catalog.CreateFunction(transaction,
|
30
|
+
catalog.CreateFunction(transaction, info);
|
31
31
|
}
|
32
32
|
|
33
33
|
void BuiltinFunctions::AddFunction(AggregateFunction function) {
|
34
34
|
CreateAggregateFunctionInfo info(std::move(function));
|
35
35
|
info.internal = true;
|
36
|
-
catalog.CreateFunction(transaction,
|
36
|
+
catalog.CreateFunction(transaction, info);
|
37
37
|
}
|
38
38
|
|
39
39
|
void BuiltinFunctions::AddFunction(PragmaFunction function) {
|
40
40
|
CreatePragmaFunctionInfo info(std::move(function));
|
41
41
|
info.internal = true;
|
42
|
-
catalog.CreatePragmaFunction(transaction,
|
42
|
+
catalog.CreatePragmaFunction(transaction, info);
|
43
43
|
}
|
44
44
|
|
45
45
|
void BuiltinFunctions::AddFunction(const string &name, PragmaFunctionSet functions) {
|
46
46
|
CreatePragmaFunctionInfo info(name, std::move(functions));
|
47
47
|
info.internal = true;
|
48
|
-
catalog.CreatePragmaFunction(transaction,
|
48
|
+
catalog.CreatePragmaFunction(transaction, info);
|
49
49
|
}
|
50
50
|
|
51
51
|
void BuiltinFunctions::AddFunction(ScalarFunction function) {
|
52
52
|
CreateScalarFunctionInfo info(std::move(function));
|
53
53
|
info.internal = true;
|
54
|
-
catalog.CreateFunction(transaction,
|
54
|
+
catalog.CreateFunction(transaction, info);
|
55
55
|
}
|
56
56
|
|
57
57
|
void BuiltinFunctions::AddFunction(const vector<string> &names, ScalarFunction function) { // NOLINT: false positive
|
@@ -64,25 +64,25 @@ void BuiltinFunctions::AddFunction(const vector<string> &names, ScalarFunction f
|
|
64
64
|
void BuiltinFunctions::AddFunction(ScalarFunctionSet set) {
|
65
65
|
CreateScalarFunctionInfo info(std::move(set));
|
66
66
|
info.internal = true;
|
67
|
-
catalog.CreateFunction(transaction,
|
67
|
+
catalog.CreateFunction(transaction, info);
|
68
68
|
}
|
69
69
|
|
70
70
|
void BuiltinFunctions::AddFunction(TableFunction function) {
|
71
71
|
CreateTableFunctionInfo info(std::move(function));
|
72
72
|
info.internal = true;
|
73
|
-
catalog.CreateTableFunction(transaction,
|
73
|
+
catalog.CreateTableFunction(transaction, info);
|
74
74
|
}
|
75
75
|
|
76
76
|
void BuiltinFunctions::AddFunction(TableFunctionSet set) {
|
77
77
|
CreateTableFunctionInfo info(std::move(set));
|
78
78
|
info.internal = true;
|
79
|
-
catalog.CreateTableFunction(transaction,
|
79
|
+
catalog.CreateTableFunction(transaction, info);
|
80
80
|
}
|
81
81
|
|
82
82
|
void BuiltinFunctions::AddFunction(CopyFunction function) {
|
83
83
|
CreateCopyFunctionInfo info(std::move(function));
|
84
84
|
info.internal = true;
|
85
|
-
catalog.CreateCopyFunction(transaction,
|
85
|
+
catalog.CreateCopyFunction(transaction, info);
|
86
86
|
}
|
87
87
|
|
88
88
|
} // namespace duckdb
|
@@ -247,10 +247,10 @@ unique_ptr<Expression> FunctionBinder::BindScalarFunction(const string &schema,
|
|
247
247
|
vector<unique_ptr<Expression>> children, string &error,
|
248
248
|
bool is_operator, Binder *binder) {
|
249
249
|
// bind the function
|
250
|
-
auto function =
|
250
|
+
auto &function =
|
251
251
|
Catalog::GetSystemCatalog(context).GetEntry(context, CatalogType::SCALAR_FUNCTION_ENTRY, schema, name);
|
252
|
-
D_ASSERT(function
|
253
|
-
return BindScalarFunction(function
|
252
|
+
D_ASSERT(function.type == CatalogType::SCALAR_FUNCTION_ENTRY);
|
253
|
+
return BindScalarFunction(function.Cast<ScalarFunctionCatalogEntry>(), std::move(children), error, is_operator,
|
254
254
|
binder);
|
255
255
|
}
|
256
256
|
|
@@ -418,10 +418,9 @@ static unique_ptr<FunctionData> ListAggregatesBind(ClientContext &context, Scala
|
|
418
418
|
|
419
419
|
// look up the aggregate function in the catalog
|
420
420
|
QueryErrorContext error_context(nullptr, 0);
|
421
|
-
auto func =
|
422
|
-
|
423
|
-
|
424
|
-
D_ASSERT(func->type == CatalogType::AGGREGATE_FUNCTION_ENTRY);
|
421
|
+
auto &func = Catalog::GetSystemCatalog(context).GetEntry<AggregateFunctionCatalogEntry>(
|
422
|
+
context, DEFAULT_SCHEMA, function_name, error_context);
|
423
|
+
D_ASSERT(func.type == CatalogType::AGGREGATE_FUNCTION_ENTRY);
|
425
424
|
|
426
425
|
if (is_parameter) {
|
427
426
|
bound_function.arguments[0] = LogicalTypeId::UNKNOWN;
|
@@ -439,13 +438,13 @@ static unique_ptr<FunctionData> ListAggregatesBind(ClientContext &context, Scala
|
|
439
438
|
}
|
440
439
|
|
441
440
|
FunctionBinder function_binder(context);
|
442
|
-
auto best_function_idx = function_binder.BindFunction(func
|
441
|
+
auto best_function_idx = function_binder.BindFunction(func.name, func.functions, types, error);
|
443
442
|
if (best_function_idx == DConstants::INVALID_INDEX) {
|
444
443
|
throw BinderException("No matching aggregate function\n%s", error);
|
445
444
|
}
|
446
445
|
|
447
446
|
// found a matching function, bind it as an aggregate
|
448
|
-
auto best_function = func
|
447
|
+
auto best_function = func.functions.GetFunctionByOffset(best_function_idx);
|
449
448
|
if (IS_AGGR) {
|
450
449
|
return ListAggregatesBindFunction<IS_AGGR>(context, bound_function, list_child_type, best_function, arguments);
|
451
450
|
}
|
@@ -167,8 +167,8 @@ static unique_ptr<BaseStatistics> PropagateNumericStats(ClientContext &context,
|
|
167
167
|
} else {
|
168
168
|
// no potential overflow: replace with non-overflowing operator
|
169
169
|
if (input.bind_data) {
|
170
|
-
auto bind_data =
|
171
|
-
bind_data
|
170
|
+
auto &bind_data = input.bind_data->Cast<DecimalArithmeticBindData>();
|
171
|
+
bind_data.check_overflow = false;
|
172
172
|
}
|
173
173
|
expr.function.function = GetScalarIntegerFunction<BASEOP>(expr.return_type.InternalType());
|
174
174
|
}
|
@@ -76,7 +76,7 @@ struct NextSequenceValueOperator {
|
|
76
76
|
}
|
77
77
|
};
|
78
78
|
|
79
|
-
SequenceCatalogEntry
|
79
|
+
SequenceCatalogEntry &BindSequence(ClientContext &context, const string &name) {
|
80
80
|
auto qname = QualifiedName::Parse(name);
|
81
81
|
// fetch the sequence from the catalog
|
82
82
|
Binder::BindSchemaOrCatalog(context, qname.catalog, qname.schema);
|
@@ -91,36 +91,37 @@ static void NextValFunction(DataChunk &args, ExpressionState &state, Vector &res
|
|
91
91
|
|
92
92
|
auto &context = state.GetContext();
|
93
93
|
if (info.sequence) {
|
94
|
-
auto &
|
94
|
+
auto &sequence = *info.sequence;
|
95
|
+
auto &transaction = DuckTransaction::Get(context, sequence.catalog);
|
95
96
|
// sequence to use is hard coded
|
96
97
|
// increment the sequence
|
97
98
|
result.SetVectorType(VectorType::FLAT_VECTOR);
|
98
99
|
auto result_data = FlatVector::GetData<int64_t>(result);
|
99
100
|
for (idx_t i = 0; i < args.size(); i++) {
|
100
101
|
// get the next value from the sequence
|
101
|
-
result_data[i] = OP::Operation(transaction,
|
102
|
+
result_data[i] = OP::Operation(transaction, sequence);
|
102
103
|
}
|
103
104
|
} else {
|
104
105
|
// sequence to use comes from the input
|
105
106
|
UnaryExecutor::Execute<string_t, int64_t>(input, result, args.size(), [&](string_t value) {
|
106
107
|
// fetch the sequence from the catalog
|
107
|
-
auto sequence = BindSequence(context, value.GetString());
|
108
|
+
auto &sequence = BindSequence(context, value.GetString());
|
108
109
|
// finally get the next value from the sequence
|
109
|
-
auto &transaction = DuckTransaction::Get(context,
|
110
|
-
return OP::Operation(transaction,
|
110
|
+
auto &transaction = DuckTransaction::Get(context, sequence.catalog);
|
111
|
+
return OP::Operation(transaction, sequence);
|
111
112
|
});
|
112
113
|
}
|
113
114
|
}
|
114
115
|
|
115
116
|
static unique_ptr<FunctionData> NextValBind(ClientContext &context, ScalarFunction &bound_function,
|
116
117
|
vector<unique_ptr<Expression>> &arguments) {
|
117
|
-
SequenceCatalogEntry
|
118
|
+
optional_ptr<SequenceCatalogEntry> sequence;
|
118
119
|
if (arguments[0]->IsFoldable()) {
|
119
120
|
// parameter to nextval function is a foldable constant
|
120
121
|
// evaluate the constant and perform the catalog lookup already
|
121
122
|
auto seqname = ExpressionExecutor::EvaluateScalar(context, *arguments[0]);
|
122
123
|
if (!seqname.IsNull()) {
|
123
|
-
sequence = BindSequence(context, seqname.ToString());
|
124
|
+
sequence = &BindSequence(context, seqname.ToString());
|
124
125
|
}
|
125
126
|
}
|
126
127
|
return make_uniq<NextvalBindData>(sequence);
|
@@ -197,22 +197,22 @@ static unique_ptr<FunctionData> BindAggregateState(ClientContext &context, Scala
|
|
197
197
|
auto state_type = AggregateStateType::GetStateType(arg_return_type);
|
198
198
|
|
199
199
|
// now we can look up the function in the catalog again and bind it
|
200
|
-
auto func = Catalog::GetSystemCatalog(context).GetEntry(context, CatalogType::SCALAR_FUNCTION_ENTRY,
|
201
|
-
|
202
|
-
if (func
|
200
|
+
auto &func = Catalog::GetSystemCatalog(context).GetEntry(context, CatalogType::SCALAR_FUNCTION_ENTRY,
|
201
|
+
DEFAULT_SCHEMA, state_type.function_name);
|
202
|
+
if (func.type != CatalogType::AGGREGATE_FUNCTION_ENTRY) {
|
203
203
|
throw InternalException("Could not find aggregate %s", state_type.function_name);
|
204
204
|
}
|
205
|
-
auto aggr = (
|
205
|
+
auto &aggr = func.Cast<AggregateFunctionCatalogEntry>();
|
206
206
|
|
207
207
|
string error;
|
208
208
|
|
209
209
|
FunctionBinder function_binder(context);
|
210
210
|
idx_t best_function =
|
211
|
-
function_binder.BindFunction(aggr
|
211
|
+
function_binder.BindFunction(aggr.name, aggr.functions, state_type.bound_argument_types, error);
|
212
212
|
if (best_function == DConstants::INVALID_INDEX) {
|
213
213
|
throw InternalException("Could not re-bind exported aggregate %s: %s", state_type.function_name, error);
|
214
214
|
}
|
215
|
-
auto bound_aggr = aggr
|
215
|
+
auto bound_aggr = aggr.functions.GetFunctionByOffset(best_function);
|
216
216
|
if (bound_aggr.bind) {
|
217
217
|
// FIXME: this is really hacky
|
218
218
|
// but the aggregate state export needs a rework around how it handles more complex aggregates anyway
|