duckdb 0.7.2-dev2507.0 → 0.7.2-dev2675.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/binding.gyp +7 -7
- package/package.json +2 -2
- 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/extension/parquet/parquet_statistics.cpp +3 -0
- 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/radix_partitioning.cpp +1 -1
- package/src/duckdb/src/common/types.cpp +15 -27
- package/src/duckdb/src/execution/index/art/art.cpp +286 -269
- package/src/duckdb/src/execution/index/art/art_key.cpp +22 -32
- package/src/duckdb/src/execution/index/art/fixed_size_allocator.cpp +224 -0
- package/src/duckdb/src/execution/index/art/iterator.cpp +142 -123
- package/src/duckdb/src/execution/index/art/leaf.cpp +319 -170
- package/src/duckdb/src/execution/index/art/leaf_segment.cpp +42 -0
- package/src/duckdb/src/execution/index/art/node.cpp +444 -379
- package/src/duckdb/src/execution/index/art/node16.cpp +178 -114
- package/src/duckdb/src/execution/index/art/node256.cpp +117 -79
- package/src/duckdb/src/execution/index/art/node4.cpp +169 -114
- package/src/duckdb/src/execution/index/art/node48.cpp +175 -105
- package/src/duckdb/src/execution/index/art/prefix.cpp +405 -127
- package/src/duckdb/src/execution/index/art/prefix_segment.cpp +42 -0
- package/src/duckdb/src/execution/index/art/swizzleable_pointer.cpp +10 -85
- package/src/duckdb/src/execution/operator/join/physical_index_join.cpp +4 -3
- package/src/duckdb/src/execution/operator/persistent/base_csv_reader.cpp +2 -2
- package/src/duckdb/src/execution/operator/persistent/csv_reader_options.cpp +2 -0
- 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 +17 -17
- 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/read_csv.cpp +5 -1
- 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/queue.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/types.hpp +3 -4
- package/src/duckdb/src/include/duckdb/execution/index/art/art.hpp +53 -45
- package/src/duckdb/src/include/duckdb/execution/index/art/art_key.hpp +29 -24
- package/src/duckdb/src/include/duckdb/execution/index/art/fixed_size_allocator.hpp +114 -0
- package/src/duckdb/src/include/duckdb/execution/index/art/iterator.hpp +26 -20
- package/src/duckdb/src/include/duckdb/execution/index/art/leaf.hpp +63 -39
- package/src/duckdb/src/include/duckdb/execution/index/art/leaf_segment.hpp +36 -0
- package/src/duckdb/src/include/duckdb/execution/index/art/node.hpp +98 -116
- package/src/duckdb/src/include/duckdb/execution/index/art/node16.hpp +48 -36
- package/src/duckdb/src/include/duckdb/execution/index/art/node256.hpp +52 -35
- package/src/duckdb/src/include/duckdb/execution/index/art/node4.hpp +46 -36
- package/src/duckdb/src/include/duckdb/execution/index/art/node48.hpp +57 -35
- package/src/duckdb/src/include/duckdb/execution/index/art/prefix.hpp +57 -50
- package/src/duckdb/src/include/duckdb/execution/index/art/prefix_segment.hpp +40 -0
- package/src/duckdb/src/include/duckdb/execution/index/art/swizzleable_pointer.hpp +38 -31
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_file_handle.hpp +2 -1
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_reader_options.hpp +2 -0
- 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/statement/insert_statement.hpp +4 -1
- package/src/duckdb/src/include/duckdb/parser/tableref.hpp +5 -2
- package/src/duckdb/src/include/duckdb/parser/transformer.hpp +4 -1
- 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/storage/buffer_manager.hpp +0 -5
- package/src/duckdb/src/include/duckdb/storage/index.hpp +13 -28
- package/src/duckdb/src/include/duckdb/storage/standard_buffer_manager.hpp +0 -2
- package/src/duckdb/src/include/duckdb/transaction/cleanup_state.hpp +5 -0
- package/src/duckdb/src/include/duckdb/transaction/transaction.hpp +12 -0
- package/src/duckdb/src/include/duckdb.h +26 -0
- package/src/duckdb/src/main/attached_database.cpp +12 -6
- package/src/duckdb/src/main/capi/helper-c.cpp +7 -0
- 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/statement/insert_statement.cpp +15 -6
- package/src/duckdb/src/parser/transform/constraint/transform_constraint.cpp +1 -1
- package/src/duckdb/src/parser/transform/expression/transform_function.cpp +18 -5
- 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_insert.cpp +5 -7
- 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 +56 -42
- 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 +16 -11
- 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 +57 -55
- package/src/duckdb/src/storage/data_table.cpp +9 -9
- package/src/duckdb/src/storage/index.cpp +18 -6
- package/src/duckdb/src/storage/local_storage.cpp +8 -2
- package/src/duckdb/src/storage/standard_buffer_manager.cpp +0 -9
- package/src/duckdb/src/storage/table/update_segment.cpp +1 -1
- package/src/duckdb/src/storage/wal_replay.cpp +29 -31
- package/src/duckdb/src/storage/write_ahead_log.cpp +8 -8
- package/src/duckdb/src/transaction/cleanup_state.cpp +7 -1
- package/src/duckdb/src/transaction/commit_state.cpp +3 -4
- package/src/duckdb/src/transaction/transaction_context.cpp +1 -1
- package/src/duckdb/src/transaction/undo_buffer.cpp +8 -0
- package/src/duckdb/ub_extension_icu_third_party_icu_i18n.cpp +4 -4
- package/src/duckdb/ub_src_execution_index_art.cpp +7 -1
@@ -50,7 +50,8 @@ void FindForeignKeyInformation(CatalogEntry &entry, AlterForeignKeyType alter_fk
|
|
50
50
|
}
|
51
51
|
auto &fk = cond->Cast<ForeignKeyConstraint>();
|
52
52
|
if (fk.info.type == ForeignKeyType::FK_TYPE_FOREIGN_KEY_TABLE) {
|
53
|
-
AlterEntryData alter_data(entry.
|
53
|
+
AlterEntryData alter_data(entry.ParentCatalog().GetName(), fk.info.schema, fk.info.table,
|
54
|
+
OnEntryNotFound::THROW_EXCEPTION);
|
54
55
|
fk_arrays.push_back(make_uniq<AlterForeignKeyInfo>(std::move(alter_data), entry.name, fk.pk_columns,
|
55
56
|
fk.fk_columns, fk.info.pk_keys, fk.info.fk_keys,
|
56
57
|
alter_fk_type));
|
@@ -62,16 +63,18 @@ void FindForeignKeyInformation(CatalogEntry &entry, AlterForeignKeyType alter_fk
|
|
62
63
|
}
|
63
64
|
}
|
64
65
|
|
65
|
-
DuckSchemaEntry::DuckSchemaEntry(Catalog
|
66
|
+
DuckSchemaEntry::DuckSchemaEntry(Catalog &catalog, string name_p, bool is_internal)
|
66
67
|
: SchemaCatalogEntry(catalog, std::move(name_p), is_internal),
|
67
|
-
tables(
|
68
|
-
copy_functions(
|
69
|
-
functions(
|
70
|
-
|
68
|
+
tables(catalog, make_uniq<DefaultViewGenerator>(catalog, *this)), indexes(catalog), table_functions(catalog),
|
69
|
+
copy_functions(catalog), pragma_functions(catalog),
|
70
|
+
functions(catalog, make_uniq<DefaultFunctionGenerator>(catalog, *this)), sequences(catalog), collations(catalog),
|
71
|
+
types(catalog, make_uniq<DefaultTypeGenerator>(catalog, *this)) {
|
71
72
|
}
|
72
73
|
|
73
|
-
CatalogEntry
|
74
|
-
|
74
|
+
optional_ptr<CatalogEntry> DuckSchemaEntry::AddEntryInternal(CatalogTransaction transaction,
|
75
|
+
unique_ptr<StandardEntry> entry,
|
76
|
+
OnCreateConflict on_conflict,
|
77
|
+
DependencyList dependencies) {
|
75
78
|
auto entry_name = entry->name;
|
76
79
|
auto entry_type = entry->type;
|
77
80
|
auto result = entry.get();
|
@@ -102,12 +105,12 @@ CatalogEntry *DuckSchemaEntry::AddEntryInternal(CatalogTransaction transaction,
|
|
102
105
|
return result;
|
103
106
|
}
|
104
107
|
|
105
|
-
CatalogEntry
|
106
|
-
auto table = make_uniq<DuckTableEntry>(catalog, this, info);
|
108
|
+
optional_ptr<CatalogEntry> DuckSchemaEntry::CreateTable(CatalogTransaction transaction, BoundCreateTableInfo &info) {
|
109
|
+
auto table = make_uniq<DuckTableEntry>(catalog, *this, info);
|
107
110
|
auto &storage = table->GetStorage();
|
108
111
|
storage.info->cardinality = storage.GetTotalRows();
|
109
112
|
|
110
|
-
|
113
|
+
auto entry = AddEntryInternal(transaction, std::move(table), info.Base().on_conflict, info.dependencies);
|
111
114
|
if (!entry) {
|
112
115
|
return nullptr;
|
113
116
|
}
|
@@ -117,122 +120,126 @@ CatalogEntry *DuckSchemaEntry::CreateTable(CatalogTransaction transaction, Bound
|
|
117
120
|
FindForeignKeyInformation(*entry, AlterForeignKeyType::AFT_ADD, fk_arrays);
|
118
121
|
for (idx_t i = 0; i < fk_arrays.size(); i++) {
|
119
122
|
// alter primary key table
|
120
|
-
|
121
|
-
catalog
|
123
|
+
auto &fk_info = *fk_arrays[i];
|
124
|
+
catalog.Alter(transaction.GetContext(), fk_info);
|
122
125
|
|
123
126
|
// make a dependency between this table and referenced table
|
124
127
|
auto &set = GetCatalogSet(CatalogType::TABLE_ENTRY);
|
125
|
-
info
|
128
|
+
info.dependencies.AddDependency(*set.GetEntry(transaction, fk_info.name));
|
126
129
|
}
|
127
130
|
return entry;
|
128
131
|
}
|
129
132
|
|
130
|
-
CatalogEntry
|
131
|
-
if (info
|
133
|
+
optional_ptr<CatalogEntry> DuckSchemaEntry::CreateFunction(CatalogTransaction transaction, CreateFunctionInfo &info) {
|
134
|
+
if (info.on_conflict == OnCreateConflict::ALTER_ON_CONFLICT) {
|
132
135
|
// check if the original entry exists
|
133
|
-
auto &catalog_set = GetCatalogSet(info
|
134
|
-
auto current_entry = catalog_set.GetEntry(transaction, info
|
136
|
+
auto &catalog_set = GetCatalogSet(info.type);
|
137
|
+
auto current_entry = catalog_set.GetEntry(transaction, info.name);
|
135
138
|
if (current_entry) {
|
136
139
|
// the current entry exists - alter it instead
|
137
|
-
auto alter_info = info
|
138
|
-
Alter(transaction.GetContext(), alter_info
|
140
|
+
auto alter_info = info.GetAlterInfo();
|
141
|
+
Alter(transaction.GetContext(), *alter_info);
|
139
142
|
return nullptr;
|
140
143
|
}
|
141
144
|
}
|
142
145
|
unique_ptr<StandardEntry> function;
|
143
|
-
switch (info
|
146
|
+
switch (info.type) {
|
144
147
|
case CatalogType::SCALAR_FUNCTION_ENTRY:
|
145
|
-
function =
|
146
|
-
|
148
|
+
function = make_uniq_base<StandardEntry, ScalarFunctionCatalogEntry>(catalog, *this,
|
149
|
+
info.Cast<CreateScalarFunctionInfo>());
|
147
150
|
break;
|
148
151
|
case CatalogType::TABLE_FUNCTION_ENTRY:
|
149
|
-
function =
|
150
|
-
|
152
|
+
function = make_uniq_base<StandardEntry, TableFunctionCatalogEntry>(catalog, *this,
|
153
|
+
info.Cast<CreateTableFunctionInfo>());
|
151
154
|
break;
|
152
155
|
case CatalogType::MACRO_ENTRY:
|
153
156
|
// create a macro function
|
154
|
-
function = make_uniq_base<StandardEntry, ScalarMacroCatalogEntry>(catalog, this, (
|
157
|
+
function = make_uniq_base<StandardEntry, ScalarMacroCatalogEntry>(catalog, *this, info.Cast<CreateMacroInfo>());
|
155
158
|
break;
|
156
159
|
|
157
160
|
case CatalogType::TABLE_MACRO_ENTRY:
|
158
161
|
// create a macro table function
|
159
|
-
function = make_uniq_base<StandardEntry, TableMacroCatalogEntry>(catalog, this, (
|
162
|
+
function = make_uniq_base<StandardEntry, TableMacroCatalogEntry>(catalog, *this, info.Cast<CreateMacroInfo>());
|
160
163
|
break;
|
161
164
|
case CatalogType::AGGREGATE_FUNCTION_ENTRY:
|
162
|
-
D_ASSERT(info
|
165
|
+
D_ASSERT(info.type == CatalogType::AGGREGATE_FUNCTION_ENTRY);
|
163
166
|
// create an aggregate function
|
164
|
-
function = make_uniq_base<StandardEntry, AggregateFunctionCatalogEntry>(
|
165
|
-
|
167
|
+
function = make_uniq_base<StandardEntry, AggregateFunctionCatalogEntry>(
|
168
|
+
catalog, *this, info.Cast<CreateAggregateFunctionInfo>());
|
166
169
|
break;
|
167
170
|
default:
|
168
|
-
throw InternalException("Unknown function type \"%s\"", CatalogTypeToString(info
|
171
|
+
throw InternalException("Unknown function type \"%s\"", CatalogTypeToString(info.type));
|
169
172
|
}
|
170
|
-
function->internal = info
|
171
|
-
return AddEntry(transaction, std::move(function), info
|
173
|
+
function->internal = info.internal;
|
174
|
+
return AddEntry(transaction, std::move(function), info.on_conflict);
|
172
175
|
}
|
173
176
|
|
174
|
-
CatalogEntry
|
175
|
-
|
177
|
+
optional_ptr<CatalogEntry> DuckSchemaEntry::AddEntry(CatalogTransaction transaction, unique_ptr<StandardEntry> entry,
|
178
|
+
OnCreateConflict on_conflict) {
|
176
179
|
DependencyList dependencies;
|
177
180
|
return AddEntryInternal(transaction, std::move(entry), on_conflict, dependencies);
|
178
181
|
}
|
179
182
|
|
180
|
-
CatalogEntry
|
181
|
-
auto sequence = make_uniq<SequenceCatalogEntry>(catalog, this, info);
|
182
|
-
return AddEntry(transaction, std::move(sequence), info
|
183
|
+
optional_ptr<CatalogEntry> DuckSchemaEntry::CreateSequence(CatalogTransaction transaction, CreateSequenceInfo &info) {
|
184
|
+
auto sequence = make_uniq<SequenceCatalogEntry>(catalog, *this, info);
|
185
|
+
return AddEntry(transaction, std::move(sequence), info.on_conflict);
|
183
186
|
}
|
184
187
|
|
185
|
-
CatalogEntry
|
186
|
-
auto type_entry = make_uniq<TypeCatalogEntry>(catalog, this, info);
|
187
|
-
return AddEntry(transaction, std::move(type_entry), info
|
188
|
+
optional_ptr<CatalogEntry> DuckSchemaEntry::CreateType(CatalogTransaction transaction, CreateTypeInfo &info) {
|
189
|
+
auto type_entry = make_uniq<TypeCatalogEntry>(catalog, *this, info);
|
190
|
+
return AddEntry(transaction, std::move(type_entry), info.on_conflict);
|
188
191
|
}
|
189
192
|
|
190
|
-
CatalogEntry
|
191
|
-
auto view = make_uniq<ViewCatalogEntry>(catalog, this, info);
|
192
|
-
return AddEntry(transaction, std::move(view), info
|
193
|
+
optional_ptr<CatalogEntry> DuckSchemaEntry::CreateView(CatalogTransaction transaction, CreateViewInfo &info) {
|
194
|
+
auto view = make_uniq<ViewCatalogEntry>(catalog, *this, info);
|
195
|
+
return AddEntry(transaction, std::move(view), info.on_conflict);
|
193
196
|
}
|
194
197
|
|
195
|
-
CatalogEntry
|
198
|
+
optional_ptr<CatalogEntry> DuckSchemaEntry::CreateIndex(ClientContext &context, CreateIndexInfo &info,
|
199
|
+
TableCatalogEntry &table) {
|
196
200
|
DependencyList dependencies;
|
197
|
-
dependencies.AddDependency(
|
198
|
-
auto index = make_uniq<DuckIndexEntry>(catalog, this, info);
|
199
|
-
return AddEntryInternal(GetCatalogTransaction(context), std::move(index), info
|
201
|
+
dependencies.AddDependency(table);
|
202
|
+
auto index = make_uniq<DuckIndexEntry>(catalog, *this, info);
|
203
|
+
return AddEntryInternal(GetCatalogTransaction(context), std::move(index), info.on_conflict, dependencies);
|
200
204
|
}
|
201
205
|
|
202
|
-
CatalogEntry
|
203
|
-
auto collation = make_uniq<CollateCatalogEntry>(catalog, this, info);
|
204
|
-
collation->internal = info
|
205
|
-
return AddEntry(transaction, std::move(collation), info
|
206
|
+
optional_ptr<CatalogEntry> DuckSchemaEntry::CreateCollation(CatalogTransaction transaction, CreateCollationInfo &info) {
|
207
|
+
auto collation = make_uniq<CollateCatalogEntry>(catalog, *this, info);
|
208
|
+
collation->internal = info.internal;
|
209
|
+
return AddEntry(transaction, std::move(collation), info.on_conflict);
|
206
210
|
}
|
207
211
|
|
208
|
-
CatalogEntry
|
209
|
-
|
210
|
-
table_function
|
211
|
-
|
212
|
+
optional_ptr<CatalogEntry> DuckSchemaEntry::CreateTableFunction(CatalogTransaction transaction,
|
213
|
+
CreateTableFunctionInfo &info) {
|
214
|
+
auto table_function = make_uniq<TableFunctionCatalogEntry>(catalog, *this, info);
|
215
|
+
table_function->internal = info.internal;
|
216
|
+
return AddEntry(transaction, std::move(table_function), info.on_conflict);
|
212
217
|
}
|
213
218
|
|
214
|
-
CatalogEntry
|
215
|
-
|
216
|
-
copy_function
|
217
|
-
|
219
|
+
optional_ptr<CatalogEntry> DuckSchemaEntry::CreateCopyFunction(CatalogTransaction transaction,
|
220
|
+
CreateCopyFunctionInfo &info) {
|
221
|
+
auto copy_function = make_uniq<CopyFunctionCatalogEntry>(catalog, *this, info);
|
222
|
+
copy_function->internal = info.internal;
|
223
|
+
return AddEntry(transaction, std::move(copy_function), info.on_conflict);
|
218
224
|
}
|
219
225
|
|
220
|
-
CatalogEntry
|
221
|
-
|
222
|
-
pragma_function
|
223
|
-
|
226
|
+
optional_ptr<CatalogEntry> DuckSchemaEntry::CreatePragmaFunction(CatalogTransaction transaction,
|
227
|
+
CreatePragmaFunctionInfo &info) {
|
228
|
+
auto pragma_function = make_uniq<PragmaFunctionCatalogEntry>(catalog, *this, info);
|
229
|
+
pragma_function->internal = info.internal;
|
230
|
+
return AddEntry(transaction, std::move(pragma_function), info.on_conflict);
|
224
231
|
}
|
225
232
|
|
226
|
-
void DuckSchemaEntry::Alter(ClientContext &context, AlterInfo
|
227
|
-
CatalogType type = info
|
233
|
+
void DuckSchemaEntry::Alter(ClientContext &context, AlterInfo &info) {
|
234
|
+
CatalogType type = info.GetCatalogType();
|
228
235
|
auto &set = GetCatalogSet(type);
|
229
236
|
auto transaction = GetCatalogTransaction(context);
|
230
|
-
if (info
|
231
|
-
if (!set.AlterOwnership(transaction, (
|
237
|
+
if (info.type == AlterType::CHANGE_OWNERSHIP) {
|
238
|
+
if (!set.AlterOwnership(transaction, info.Cast<ChangeOwnershipInfo>())) {
|
232
239
|
throw CatalogException("Couldn't change ownership!");
|
233
240
|
}
|
234
241
|
} else {
|
235
|
-
string name = info
|
242
|
+
string name = info.name;
|
236
243
|
if (!set.AlterEntry(transaction, name, info)) {
|
237
244
|
throw CatalogException("Entry with name \"%s\" does not exist!", name);
|
238
245
|
}
|
@@ -240,46 +247,47 @@ void DuckSchemaEntry::Alter(ClientContext &context, AlterInfo *info) {
|
|
240
247
|
}
|
241
248
|
|
242
249
|
void DuckSchemaEntry::Scan(ClientContext &context, CatalogType type,
|
243
|
-
const std::function<void(CatalogEntry
|
250
|
+
const std::function<void(CatalogEntry &)> &callback) {
|
244
251
|
auto &set = GetCatalogSet(type);
|
245
252
|
set.Scan(GetCatalogTransaction(context), callback);
|
246
253
|
}
|
247
254
|
|
248
|
-
void DuckSchemaEntry::Scan(CatalogType type, const std::function<void(CatalogEntry
|
255
|
+
void DuckSchemaEntry::Scan(CatalogType type, const std::function<void(CatalogEntry &)> &callback) {
|
249
256
|
auto &set = GetCatalogSet(type);
|
250
257
|
set.Scan(callback);
|
251
258
|
}
|
252
259
|
|
253
|
-
void DuckSchemaEntry::DropEntry(ClientContext &context, DropInfo
|
254
|
-
auto &set = GetCatalogSet(info
|
260
|
+
void DuckSchemaEntry::DropEntry(ClientContext &context, DropInfo &info) {
|
261
|
+
auto &set = GetCatalogSet(info.type);
|
255
262
|
|
256
263
|
// first find the entry
|
257
264
|
auto transaction = GetCatalogTransaction(context);
|
258
|
-
auto existing_entry = set.GetEntry(transaction, info
|
265
|
+
auto existing_entry = set.GetEntry(transaction, info.name);
|
259
266
|
if (!existing_entry) {
|
260
|
-
throw InternalException("Failed to drop entry \"%s\" - entry could not be found", info
|
267
|
+
throw InternalException("Failed to drop entry \"%s\" - entry could not be found", info.name);
|
261
268
|
}
|
262
|
-
if (existing_entry->type != info
|
263
|
-
throw CatalogException("Existing object %s is of type %s, trying to replace with type %s", info
|
264
|
-
CatalogTypeToString(existing_entry->type), CatalogTypeToString(info
|
269
|
+
if (existing_entry->type != info.type) {
|
270
|
+
throw CatalogException("Existing object %s is of type %s, trying to replace with type %s", info.name,
|
271
|
+
CatalogTypeToString(existing_entry->type), CatalogTypeToString(info.type));
|
265
272
|
}
|
266
273
|
|
267
274
|
// if there is a foreign key constraint, get that information
|
268
275
|
vector<unique_ptr<AlterForeignKeyInfo>> fk_arrays;
|
269
276
|
FindForeignKeyInformation(*existing_entry, AlterForeignKeyType::AFT_DELETE, fk_arrays);
|
270
277
|
|
271
|
-
if (!set.DropEntry(transaction, info
|
278
|
+
if (!set.DropEntry(transaction, info.name, info.cascade, info.allow_drop_internal)) {
|
272
279
|
throw InternalException("Could not drop element because of an internal error");
|
273
280
|
}
|
274
281
|
|
275
282
|
// remove the foreign key constraint in main key table if main key table's name is valid
|
276
283
|
for (idx_t i = 0; i < fk_arrays.size(); i++) {
|
277
284
|
// alter primary key table
|
278
|
-
catalog
|
285
|
+
catalog.Alter(context, *fk_arrays[i]);
|
279
286
|
}
|
280
287
|
}
|
281
288
|
|
282
|
-
CatalogEntry
|
289
|
+
optional_ptr<CatalogEntry> DuckSchemaEntry::GetEntry(CatalogTransaction transaction, CatalogType type,
|
290
|
+
const string &name) {
|
283
291
|
return GetCatalogSet(type).GetEntry(transaction, name);
|
284
292
|
}
|
285
293
|
|
@@ -318,7 +326,7 @@ CatalogSet &DuckSchemaEntry::GetCatalogSet(CatalogType type) {
|
|
318
326
|
}
|
319
327
|
|
320
328
|
void DuckSchemaEntry::Verify(Catalog &catalog) {
|
321
|
-
|
329
|
+
InCatalogEntry::Verify(catalog);
|
322
330
|
|
323
331
|
tables.Verify(catalog);
|
324
332
|
indexes.Verify(catalog);
|
@@ -19,7 +19,7 @@
|
|
19
19
|
|
20
20
|
namespace duckdb {
|
21
21
|
|
22
|
-
void AddDataTableIndex(DataTable
|
22
|
+
void AddDataTableIndex(DataTable &storage, const ColumnList &columns, const vector<PhysicalIndex> &keys,
|
23
23
|
IndexConstraintType constraint_type, BlockPointer *index_block = nullptr) {
|
24
24
|
// fetch types and create expressions for the index from the columns
|
25
25
|
vector<column_t> column_ids;
|
@@ -39,19 +39,19 @@ void AddDataTableIndex(DataTable *storage, const ColumnList &columns, const vect
|
|
39
39
|
unique_ptr<ART> art;
|
40
40
|
// create an adaptive radix tree around the expressions
|
41
41
|
if (index_block) {
|
42
|
-
art = make_uniq<ART>(column_ids, TableIOManager::Get(
|
43
|
-
storage
|
42
|
+
art = make_uniq<ART>(column_ids, TableIOManager::Get(storage), std::move(unbound_expressions), constraint_type,
|
43
|
+
storage.db, index_block->block_id, index_block->offset);
|
44
44
|
} else {
|
45
|
-
art = make_uniq<ART>(column_ids, TableIOManager::Get(
|
46
|
-
storage
|
47
|
-
if (!storage
|
45
|
+
art = make_uniq<ART>(column_ids, TableIOManager::Get(storage), std::move(unbound_expressions), constraint_type,
|
46
|
+
storage.db);
|
47
|
+
if (!storage.IsRoot()) {
|
48
48
|
throw TransactionException("Transaction conflict: cannot add an index to a table that has been altered!");
|
49
49
|
}
|
50
50
|
}
|
51
|
-
storage
|
51
|
+
storage.info->indexes.AddIndex(std::move(art));
|
52
52
|
}
|
53
53
|
|
54
|
-
void AddDataTableIndex(DataTable
|
54
|
+
void AddDataTableIndex(DataTable &storage, const ColumnList &columns, vector<LogicalIndex> &keys,
|
55
55
|
IndexConstraintType constraint_type, BlockPointer *index_block = nullptr) {
|
56
56
|
vector<PhysicalIndex> new_keys;
|
57
57
|
new_keys.reserve(keys.size());
|
@@ -61,19 +61,19 @@ void AddDataTableIndex(DataTable *storage, const ColumnList &columns, vector<Log
|
|
61
61
|
AddDataTableIndex(storage, columns, new_keys, constraint_type, index_block);
|
62
62
|
}
|
63
63
|
|
64
|
-
DuckTableEntry::DuckTableEntry(Catalog
|
64
|
+
DuckTableEntry::DuckTableEntry(Catalog &catalog, SchemaCatalogEntry &schema, BoundCreateTableInfo &info,
|
65
65
|
std::shared_ptr<DataTable> inherited_storage)
|
66
|
-
: TableCatalogEntry(catalog, schema, info
|
67
|
-
bound_constraints(std::move(info
|
68
|
-
column_dependency_manager(std::move(info
|
66
|
+
: TableCatalogEntry(catalog, schema, info.Base()), storage(std::move(inherited_storage)),
|
67
|
+
bound_constraints(std::move(info.bound_constraints)),
|
68
|
+
column_dependency_manager(std::move(info.column_dependency_manager)) {
|
69
69
|
if (!storage) {
|
70
70
|
// create the physical storage
|
71
71
|
vector<ColumnDefinition> storage_columns;
|
72
72
|
for (auto &col_def : columns.Physical()) {
|
73
73
|
storage_columns.push_back(col_def.Copy());
|
74
74
|
}
|
75
|
-
storage = make_shared<DataTable>(catalog
|
76
|
-
schema
|
75
|
+
storage = make_shared<DataTable>(catalog.GetAttached(), StorageManager::Get(catalog).GetTableIOManager(&info),
|
76
|
+
schema.name, name, std::move(storage_columns), std::move(info.data));
|
77
77
|
|
78
78
|
// create the unique indexes for the UNIQUE and PRIMARY KEY and FOREIGN KEY constraints
|
79
79
|
idx_t indexes_idx = 0;
|
@@ -86,22 +86,21 @@ DuckTableEntry::DuckTableEntry(Catalog *catalog, SchemaCatalogEntry *schema, Bou
|
|
86
86
|
if (unique.is_primary_key) {
|
87
87
|
constraint_type = IndexConstraintType::PRIMARY;
|
88
88
|
}
|
89
|
-
if (info
|
90
|
-
AddDataTableIndex(storage
|
89
|
+
if (info.indexes.empty()) {
|
90
|
+
AddDataTableIndex(*storage, columns, unique.keys, constraint_type);
|
91
91
|
} else {
|
92
|
-
AddDataTableIndex(storage
|
93
|
-
&info->indexes[indexes_idx++]);
|
92
|
+
AddDataTableIndex(*storage, columns, unique.keys, constraint_type, &info.indexes[indexes_idx++]);
|
94
93
|
}
|
95
94
|
} else if (constraint->type == ConstraintType::FOREIGN_KEY) {
|
96
95
|
// foreign key constraint: create a foreign key index
|
97
96
|
auto &bfk = constraint->Cast<BoundForeignKeyConstraint>();
|
98
97
|
if (bfk.info.type == ForeignKeyType::FK_TYPE_FOREIGN_KEY_TABLE ||
|
99
98
|
bfk.info.type == ForeignKeyType::FK_TYPE_SELF_REFERENCE_TABLE) {
|
100
|
-
if (info
|
101
|
-
AddDataTableIndex(storage
|
99
|
+
if (info.indexes.empty()) {
|
100
|
+
AddDataTableIndex(*storage, columns, bfk.info.fk_keys, IndexConstraintType::FOREIGN);
|
102
101
|
} else {
|
103
|
-
AddDataTableIndex(storage
|
104
|
-
&info
|
102
|
+
AddDataTableIndex(*storage, columns, bfk.info.fk_keys, IndexConstraintType::FOREIGN,
|
103
|
+
&info.indexes[indexes_idx++]);
|
105
104
|
}
|
106
105
|
}
|
107
106
|
}
|
@@ -120,66 +119,66 @@ unique_ptr<BaseStatistics> DuckTableEntry::GetStatistics(ClientContext &context,
|
|
120
119
|
return storage->GetStatistics(context, column.StorageOid());
|
121
120
|
}
|
122
121
|
|
123
|
-
unique_ptr<CatalogEntry> DuckTableEntry::AlterEntry(ClientContext &context, AlterInfo
|
122
|
+
unique_ptr<CatalogEntry> DuckTableEntry::AlterEntry(ClientContext &context, AlterInfo &info) {
|
124
123
|
D_ASSERT(!internal);
|
125
|
-
if (info
|
124
|
+
if (info.type != AlterType::ALTER_TABLE) {
|
126
125
|
throw CatalogException("Can only modify table with ALTER TABLE statement");
|
127
126
|
}
|
128
|
-
auto table_info = (
|
129
|
-
switch (table_info
|
127
|
+
auto &table_info = info.Cast<AlterTableInfo>();
|
128
|
+
switch (table_info.alter_table_type) {
|
130
129
|
case AlterTableType::RENAME_COLUMN: {
|
131
|
-
auto rename_info = (
|
132
|
-
return RenameColumn(context,
|
130
|
+
auto &rename_info = table_info.Cast<RenameColumnInfo>();
|
131
|
+
return RenameColumn(context, rename_info);
|
133
132
|
}
|
134
133
|
case AlterTableType::RENAME_TABLE: {
|
135
|
-
auto rename_info = (
|
134
|
+
auto &rename_info = table_info.Cast<RenameTableInfo>();
|
136
135
|
auto copied_table = Copy(context);
|
137
|
-
copied_table->name = rename_info
|
138
|
-
storage->info->table = rename_info
|
136
|
+
copied_table->name = rename_info.new_table_name;
|
137
|
+
storage->info->table = rename_info.new_table_name;
|
139
138
|
return copied_table;
|
140
139
|
}
|
141
140
|
case AlterTableType::ADD_COLUMN: {
|
142
|
-
auto add_info = (
|
143
|
-
return AddColumn(context,
|
141
|
+
auto &add_info = table_info.Cast<AddColumnInfo>();
|
142
|
+
return AddColumn(context, add_info);
|
144
143
|
}
|
145
144
|
case AlterTableType::REMOVE_COLUMN: {
|
146
|
-
auto remove_info = (
|
147
|
-
return RemoveColumn(context,
|
145
|
+
auto &remove_info = table_info.Cast<RemoveColumnInfo>();
|
146
|
+
return RemoveColumn(context, remove_info);
|
148
147
|
}
|
149
148
|
case AlterTableType::SET_DEFAULT: {
|
150
|
-
auto set_default_info = (
|
151
|
-
return SetDefault(context,
|
149
|
+
auto &set_default_info = table_info.Cast<SetDefaultInfo>();
|
150
|
+
return SetDefault(context, set_default_info);
|
152
151
|
}
|
153
152
|
case AlterTableType::ALTER_COLUMN_TYPE: {
|
154
|
-
auto change_type_info = (
|
155
|
-
return ChangeColumnType(context,
|
153
|
+
auto &change_type_info = table_info.Cast<ChangeColumnTypeInfo>();
|
154
|
+
return ChangeColumnType(context, change_type_info);
|
156
155
|
}
|
157
156
|
case AlterTableType::FOREIGN_KEY_CONSTRAINT: {
|
158
|
-
auto foreign_key_constraint_info = (
|
159
|
-
if (foreign_key_constraint_info
|
160
|
-
return AddForeignKeyConstraint(context,
|
157
|
+
auto &foreign_key_constraint_info = table_info.Cast<AlterForeignKeyInfo>();
|
158
|
+
if (foreign_key_constraint_info.type == AlterForeignKeyType::AFT_ADD) {
|
159
|
+
return AddForeignKeyConstraint(context, foreign_key_constraint_info);
|
161
160
|
} else {
|
162
|
-
return DropForeignKeyConstraint(context,
|
161
|
+
return DropForeignKeyConstraint(context, foreign_key_constraint_info);
|
163
162
|
}
|
164
163
|
}
|
165
164
|
case AlterTableType::SET_NOT_NULL: {
|
166
|
-
auto set_not_null_info = (
|
167
|
-
return SetNotNull(context,
|
165
|
+
auto &set_not_null_info = table_info.Cast<SetNotNullInfo>();
|
166
|
+
return SetNotNull(context, set_not_null_info);
|
168
167
|
}
|
169
168
|
case AlterTableType::DROP_NOT_NULL: {
|
170
|
-
auto drop_not_null_info = (
|
171
|
-
return DropNotNull(context,
|
169
|
+
auto &drop_not_null_info = table_info.Cast<DropNotNullInfo>();
|
170
|
+
return DropNotNull(context, drop_not_null_info);
|
172
171
|
}
|
173
172
|
default:
|
174
173
|
throw InternalException("Unrecognized alter table type!");
|
175
174
|
}
|
176
175
|
}
|
177
176
|
|
178
|
-
void DuckTableEntry::UndoAlter(ClientContext &context, AlterInfo
|
177
|
+
void DuckTableEntry::UndoAlter(ClientContext &context, AlterInfo &info) {
|
179
178
|
D_ASSERT(!internal);
|
180
|
-
D_ASSERT(info
|
181
|
-
auto table_info = (
|
182
|
-
switch (table_info
|
179
|
+
D_ASSERT(info.type == AlterType::ALTER_TABLE);
|
180
|
+
auto &table_info = info.Cast<AlterTableInfo>();
|
181
|
+
switch (table_info.alter_table_type) {
|
183
182
|
case AlterTableType::RENAME_TABLE: {
|
184
183
|
storage->info->table = this->name;
|
185
184
|
break;
|
@@ -266,7 +265,7 @@ unique_ptr<CatalogEntry> DuckTableEntry::RenameColumn(ClientContext &context, Re
|
|
266
265
|
}
|
267
266
|
auto binder = Binder::CreateBinder(context);
|
268
267
|
auto bound_create_info = binder->BindCreateTableInfo(std::move(create_info));
|
269
|
-
return make_uniq<DuckTableEntry>(catalog, schema,
|
268
|
+
return make_uniq<DuckTableEntry>(catalog, schema, *bound_create_info, storage);
|
270
269
|
}
|
271
270
|
|
272
271
|
unique_ptr<CatalogEntry> DuckTableEntry::AddColumn(ClientContext &context, AddColumnInfo &info) {
|
@@ -286,7 +285,7 @@ unique_ptr<CatalogEntry> DuckTableEntry::AddColumn(ClientContext &context, AddCo
|
|
286
285
|
for (auto &constraint : constraints) {
|
287
286
|
create_info->constraints.push_back(constraint->Copy());
|
288
287
|
}
|
289
|
-
Binder::BindLogicalType(context, info.new_column.TypeMutable(), catalog, schema
|
288
|
+
Binder::BindLogicalType(context, info.new_column.TypeMutable(), &catalog, schema.name);
|
290
289
|
info.new_column.SetOid(columns.LogicalColumnCount());
|
291
290
|
info.new_column.SetStorageOid(columns.PhysicalColumnCount());
|
292
291
|
auto col = info.new_column.Copy();
|
@@ -297,7 +296,7 @@ unique_ptr<CatalogEntry> DuckTableEntry::AddColumn(ClientContext &context, AddCo
|
|
297
296
|
auto bound_create_info = binder->BindCreateTableInfo(std::move(create_info));
|
298
297
|
auto new_storage =
|
299
298
|
make_shared<DataTable>(context, *storage, info.new_column, bound_create_info->bound_defaults.back().get());
|
300
|
-
return make_uniq<DuckTableEntry>(catalog, schema,
|
299
|
+
return make_uniq<DuckTableEntry>(catalog, schema, *bound_create_info, new_storage);
|
301
300
|
}
|
302
301
|
|
303
302
|
void DuckTableEntry::UpdateConstraintsOnColumnDrop(const LogicalIndex &removed_index,
|
@@ -428,11 +427,11 @@ unique_ptr<CatalogEntry> DuckTableEntry::RemoveColumn(ClientContext &context, Re
|
|
428
427
|
auto binder = Binder::CreateBinder(context);
|
429
428
|
auto bound_create_info = binder->BindCreateTableInfo(std::move(create_info));
|
430
429
|
if (columns.GetColumn(LogicalIndex(removed_index)).Generated()) {
|
431
|
-
return make_uniq<DuckTableEntry>(catalog, schema,
|
430
|
+
return make_uniq<DuckTableEntry>(catalog, schema, *bound_create_info, storage);
|
432
431
|
}
|
433
432
|
auto new_storage =
|
434
433
|
make_shared<DataTable>(context, *storage, columns.LogicalToPhysical(LogicalIndex(removed_index)).index);
|
435
|
-
return make_uniq<DuckTableEntry>(catalog, schema,
|
434
|
+
return make_uniq<DuckTableEntry>(catalog, schema, *bound_create_info, new_storage);
|
436
435
|
}
|
437
436
|
|
438
437
|
unique_ptr<CatalogEntry> DuckTableEntry::SetDefault(ClientContext &context, SetDefaultInfo &info) {
|
@@ -462,7 +461,7 @@ unique_ptr<CatalogEntry> DuckTableEntry::SetDefault(ClientContext &context, SetD
|
|
462
461
|
|
463
462
|
auto binder = Binder::CreateBinder(context);
|
464
463
|
auto bound_create_info = binder->BindCreateTableInfo(std::move(create_info));
|
465
|
-
return make_uniq<DuckTableEntry>(catalog, schema,
|
464
|
+
return make_uniq<DuckTableEntry>(catalog, schema, *bound_create_info, storage);
|
466
465
|
}
|
467
466
|
|
468
467
|
unique_ptr<CatalogEntry> DuckTableEntry::SetNotNull(ClientContext &context, SetNotNullInfo &info) {
|
@@ -493,13 +492,13 @@ unique_ptr<CatalogEntry> DuckTableEntry::SetNotNull(ClientContext &context, SetN
|
|
493
492
|
|
494
493
|
// Early return
|
495
494
|
if (has_not_null) {
|
496
|
-
return make_uniq<DuckTableEntry>(catalog, schema,
|
495
|
+
return make_uniq<DuckTableEntry>(catalog, schema, *bound_create_info, storage);
|
497
496
|
}
|
498
497
|
|
499
498
|
// Return with new storage info. Note that we need the bound column index here.
|
500
499
|
auto new_storage = make_shared<DataTable>(
|
501
500
|
context, *storage, make_uniq<BoundNotNullConstraint>(columns.LogicalToPhysical(LogicalIndex(not_null_idx))));
|
502
|
-
return make_uniq<DuckTableEntry>(catalog, schema,
|
501
|
+
return make_uniq<DuckTableEntry>(catalog, schema, *bound_create_info, new_storage);
|
503
502
|
}
|
504
503
|
|
505
504
|
unique_ptr<CatalogEntry> DuckTableEntry::DropNotNull(ClientContext &context, DropNotNullInfo &info) {
|
@@ -521,13 +520,13 @@ unique_ptr<CatalogEntry> DuckTableEntry::DropNotNull(ClientContext &context, Dro
|
|
521
520
|
|
522
521
|
auto binder = Binder::CreateBinder(context);
|
523
522
|
auto bound_create_info = binder->BindCreateTableInfo(std::move(create_info));
|
524
|
-
return make_uniq<DuckTableEntry>(catalog, schema,
|
523
|
+
return make_uniq<DuckTableEntry>(catalog, schema, *bound_create_info, storage);
|
525
524
|
}
|
526
525
|
|
527
526
|
unique_ptr<CatalogEntry> DuckTableEntry::ChangeColumnType(ClientContext &context, ChangeColumnTypeInfo &info) {
|
528
527
|
if (info.target_type.id() == LogicalTypeId::USER) {
|
529
528
|
info.target_type =
|
530
|
-
Catalog::GetType(context, catalog
|
529
|
+
Catalog::GetType(context, catalog.GetName(), schema.name, UserType::GetTypeName(info.target_type));
|
531
530
|
}
|
532
531
|
auto change_idx = GetColumnIndex(info.column_name);
|
533
532
|
auto create_info = make_uniq<CreateTableInfo>(schema, name);
|
@@ -611,8 +610,7 @@ unique_ptr<CatalogEntry> DuckTableEntry::ChangeColumnType(ClientContext &context
|
|
611
610
|
auto new_storage =
|
612
611
|
make_shared<DataTable>(context, *storage, columns.LogicalToPhysical(LogicalIndex(change_idx)).index,
|
613
612
|
info.target_type, std::move(storage_oids), *bound_expression);
|
614
|
-
auto result =
|
615
|
-
make_uniq<DuckTableEntry>(catalog, schema, (BoundCreateTableInfo *)bound_create_info.get(), new_storage);
|
613
|
+
auto result = make_uniq<DuckTableEntry>(catalog, schema, *bound_create_info, new_storage);
|
616
614
|
return std::move(result);
|
617
615
|
}
|
618
616
|
|
@@ -637,7 +635,7 @@ unique_ptr<CatalogEntry> DuckTableEntry::AddForeignKeyConstraint(ClientContext &
|
|
637
635
|
auto binder = Binder::CreateBinder(context);
|
638
636
|
auto bound_create_info = binder->BindCreateTableInfo(std::move(create_info));
|
639
637
|
|
640
|
-
return make_uniq<DuckTableEntry>(catalog, schema,
|
638
|
+
return make_uniq<DuckTableEntry>(catalog, schema, *bound_create_info, storage);
|
641
639
|
}
|
642
640
|
|
643
641
|
unique_ptr<CatalogEntry> DuckTableEntry::DropForeignKeyConstraint(ClientContext &context, AlterForeignKeyInfo &info) {
|
@@ -660,7 +658,7 @@ unique_ptr<CatalogEntry> DuckTableEntry::DropForeignKeyConstraint(ClientContext
|
|
660
658
|
auto binder = Binder::CreateBinder(context);
|
661
659
|
auto bound_create_info = binder->BindCreateTableInfo(std::move(create_info));
|
662
660
|
|
663
|
-
return make_uniq<DuckTableEntry>(catalog, schema,
|
661
|
+
return make_uniq<DuckTableEntry>(catalog, schema, *bound_create_info, storage);
|
664
662
|
}
|
665
663
|
|
666
664
|
unique_ptr<CatalogEntry> DuckTableEntry::Copy(ClientContext &context) const {
|
@@ -674,7 +672,7 @@ unique_ptr<CatalogEntry> DuckTableEntry::Copy(ClientContext &context) const {
|
|
674
672
|
|
675
673
|
auto binder = Binder::CreateBinder(context);
|
676
674
|
auto bound_create_info = binder->BindCreateTableInfo(std::move(create_info));
|
677
|
-
return make_uniq<DuckTableEntry>(catalog, schema,
|
675
|
+
return make_uniq<DuckTableEntry>(catalog, schema, *bound_create_info, storage);
|
678
676
|
}
|
679
677
|
|
680
678
|
void DuckTableEntry::SetAsRoot() {
|
@@ -712,7 +710,7 @@ const vector<unique_ptr<BoundConstraint>> &DuckTableEntry::GetBoundConstraints()
|
|
712
710
|
}
|
713
711
|
|
714
712
|
TableFunction DuckTableEntry::GetScanFunction(ClientContext &context, unique_ptr<FunctionData> &bind_data) {
|
715
|
-
bind_data = make_uniq<TableScanBindData>(this);
|
713
|
+
bind_data = make_uniq<TableScanBindData>(*this);
|
716
714
|
return TableScanFunction::GetFunction();
|
717
715
|
}
|
718
716
|
|
@@ -4,9 +4,9 @@
|
|
4
4
|
|
5
5
|
namespace duckdb {
|
6
6
|
|
7
|
-
IndexCatalogEntry::IndexCatalogEntry(Catalog
|
8
|
-
: StandardEntry(CatalogType::INDEX_ENTRY, schema, catalog, info
|
9
|
-
this->temporary = info
|
7
|
+
IndexCatalogEntry::IndexCatalogEntry(Catalog &catalog, SchemaCatalogEntry &schema, CreateIndexInfo &info)
|
8
|
+
: StandardEntry(CatalogType::INDEX_ENTRY, schema, catalog, info.index_name), index(nullptr), sql(info.sql) {
|
9
|
+
this->temporary = info.temporary;
|
10
10
|
}
|
11
11
|
|
12
12
|
string IndexCatalogEntry::ToSQL() const {
|