duckdb 0.6.2-dev781.0 → 0.6.2-dev891.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 +1 -1
- package/package.json +1 -1
- package/src/connection.cpp +2 -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 +1 -1
- package/src/duckdb/extension/icu/icu-makedate.cpp +1 -1
- package/src/duckdb/extension/icu/icu-strptime.cpp +2 -2
- package/src/duckdb/extension/icu/icu-timezone.cpp +6 -5
- package/src/duckdb/extension/json/json-extension.cpp +1 -1
- package/src/duckdb/extension/parquet/column_reader.cpp +7 -0
- package/src/duckdb/extension/parquet/parquet-extension.cpp +1 -1
- package/src/duckdb/src/catalog/catalog.cpp +516 -177
- package/src/duckdb/src/catalog/catalog_entry/index_catalog_entry.cpp +1 -0
- package/src/duckdb/src/catalog/catalog_entry/schema_catalog_entry.cpp +66 -49
- package/src/duckdb/src/catalog/catalog_entry/table_catalog_entry.cpp +15 -16
- package/src/duckdb/src/catalog/catalog_entry/view_catalog_entry.cpp +1 -1
- package/src/duckdb/src/catalog/catalog_entry.cpp +6 -2
- package/src/duckdb/src/catalog/catalog_search_path.cpp +177 -22
- package/src/duckdb/src/catalog/catalog_set.cpp +134 -72
- package/src/duckdb/src/catalog/catalog_transaction.cpp +28 -0
- package/src/duckdb/src/catalog/default/default_views.cpp +4 -4
- package/src/duckdb/src/catalog/dependency_list.cpp +13 -0
- package/src/duckdb/src/catalog/dependency_manager.cpp +19 -13
- package/src/duckdb/src/common/constants.cpp +8 -0
- package/src/duckdb/src/common/enums/catalog_type.cpp +2 -0
- package/src/duckdb/src/common/enums/logical_operator_type.cpp +2 -0
- package/src/duckdb/src/common/enums/physical_operator_type.cpp +2 -0
- package/src/duckdb/src/common/enums/statement_type.cpp +2 -0
- package/src/duckdb/src/common/file_system.cpp +1 -1
- package/src/duckdb/src/common/string_util.cpp +5 -1
- package/src/duckdb/src/execution/index/art/art.cpp +1 -1
- package/src/duckdb/src/execution/operator/helper/physical_transaction.cpp +1 -0
- package/src/duckdb/src/execution/operator/join/physical_index_join.cpp +1 -1
- package/src/duckdb/src/execution/operator/persistent/physical_batch_insert.cpp +3 -2
- package/src/duckdb/src/execution/operator/persistent/physical_delete.cpp +1 -1
- package/src/duckdb/src/execution/operator/persistent/physical_export.cpp +1 -1
- package/src/duckdb/src/execution/operator/persistent/physical_insert.cpp +4 -3
- package/src/duckdb/src/execution/operator/schema/physical_alter.cpp +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_attach.cpp +72 -0
- package/src/duckdb/src/execution/operator/schema/physical_create_function.cpp +2 -1
- package/src/duckdb/src/execution/operator/schema/physical_create_index.cpp +3 -3
- package/src/duckdb/src/execution/operator/schema/physical_create_schema.cpp +5 -1
- package/src/duckdb/src/execution/operator/schema/physical_create_sequence.cpp +2 -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 +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_create_view.cpp +2 -1
- package/src/duckdb/src/execution/operator/schema/physical_drop.cpp +10 -2
- package/src/duckdb/src/execution/physical_plan/plan_comparison_join.cpp +4 -4
- package/src/duckdb/src/execution/physical_plan/plan_create_index.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_create_table.cpp +2 -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_simple.cpp +4 -0
- package/src/duckdb/src/execution/physical_plan/plan_update.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan_generator.cpp +3 -2
- package/src/duckdb/src/function/built_in_functions.cpp +88 -0
- package/src/duckdb/src/function/function.cpp +0 -79
- package/src/duckdb/src/function/function_binder.cpp +2 -1
- package/src/duckdb/src/function/pragma/pragma_queries.cpp +10 -1
- package/src/duckdb/src/function/scalar/date/current.cpp +2 -2
- package/src/duckdb/src/function/scalar/list/list_aggregates.cpp +3 -2
- package/src/duckdb/src/function/scalar/sequence/nextval.cpp +14 -17
- package/src/duckdb/src/function/scalar/system/aggregate_export.cpp +2 -2
- package/src/duckdb/src/function/scalar/system/system_functions.cpp +7 -4
- package/src/duckdb/src/function/table/checkpoint.cpp +37 -4
- package/src/duckdb/src/function/table/read_csv.cpp +1 -1
- package/src/duckdb/src/function/table/system/duckdb_columns.cpp +32 -25
- package/src/duckdb/src/function/table/system/duckdb_constraints.cpp +26 -22
- package/src/duckdb/src/function/table/system/duckdb_dependencies.cpp +1 -1
- package/src/duckdb/src/function/table/system/duckdb_extensions.cpp +1 -1
- package/src/duckdb/src/function/table/system/duckdb_functions.cpp +22 -15
- package/src/duckdb/src/function/table/system/duckdb_indexes.cpp +25 -18
- package/src/duckdb/src/function/table/system/duckdb_schemas.cpp +16 -8
- package/src/duckdb/src/function/table/system/duckdb_sequences.cpp +26 -19
- package/src/duckdb/src/function/table/system/duckdb_tables.cpp +24 -17
- package/src/duckdb/src/function/table/system/duckdb_types.cpp +22 -16
- package/src/duckdb/src/function/table/system/duckdb_views.cpp +20 -13
- package/src/duckdb/src/function/table/system/pragma_collations.cpp +3 -4
- package/src/duckdb/src/function/table/system/pragma_database_list.cpp +20 -12
- package/src/duckdb/src/function/table/system/pragma_database_size.cpp +39 -24
- package/src/duckdb/src/function/table/system/pragma_storage_info.cpp +1 -7
- package/src/duckdb/src/function/table/system/pragma_table_info.cpp +3 -2
- package/src/duckdb/src/function/table/system_functions.cpp +0 -1
- package/src/duckdb/src/function/table/table_scan.cpp +13 -10
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +102 -81
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/aggregate_function_catalog_entry.hpp +4 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/collate_catalog_entry.hpp +4 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/copy_function_catalog_entry.hpp +4 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/index_catalog_entry.hpp +4 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/pragma_function_catalog_entry.hpp +4 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/scalar_function_catalog_entry.hpp +4 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/scalar_macro_catalog_entry.hpp +4 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/schema_catalog_entry.hpp +21 -14
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/sequence_catalog_entry.hpp +4 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_catalog_entry.hpp +4 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_function_catalog_entry.hpp +4 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_macro_catalog_entry.hpp +4 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/type_catalog_entry.hpp +4 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/view_catalog_entry.hpp +4 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry.hpp +2 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_search_path.hpp +30 -11
- package/src/duckdb/src/include/duckdb/catalog/catalog_set.hpp +35 -20
- package/src/duckdb/src/include/duckdb/catalog/catalog_transaction.hpp +32 -0
- package/src/duckdb/src/include/duckdb/catalog/dependency_list.hpp +27 -0
- package/src/duckdb/src/include/duckdb/catalog/dependency_manager.hpp +6 -4
- package/src/duckdb/src/include/duckdb/common/allocator.hpp +3 -0
- package/src/duckdb/src/include/duckdb/common/constants.hpp +8 -3
- package/src/duckdb/src/include/duckdb/common/enums/catalog_type.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/enums/logical_operator_type.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/enums/physical_operator_type.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/enums/statement_type.hpp +10 -4
- package/src/duckdb/src/include/duckdb/common/file_system.hpp +2 -0
- package/src/duckdb/src/include/duckdb/common/string_util.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/index/art/art.hpp +2 -2
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_attach.hpp +33 -0
- package/src/duckdb/src/include/duckdb/execution/physical_plan_generator.hpp +2 -1
- package/src/duckdb/src/include/duckdb/function/aggregate/algebraic_functions.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/aggregate/distributive_functions.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/aggregate/holistic_functions.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/aggregate/nested_functions.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/aggregate/regression_functions.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/built_in_functions.hpp +78 -0
- package/src/duckdb/src/include/duckdb/function/function.hpp +0 -61
- package/src/duckdb/src/include/duckdb/function/function_serialization.hpp +1 -2
- package/src/duckdb/src/include/duckdb/function/pragma/pragma_functions.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/scalar/blob_functions.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/scalar/date_functions.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/scalar/enum_functions.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/scalar/generic_functions.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/scalar/math_functions.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/scalar/nested_functions.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/scalar/operators.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/scalar/regexp.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/scalar/sequence_functions.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/scalar/string_functions.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/scalar/trigonometric_functions.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/scalar/uuid_functions.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/scalar_function.hpp +2 -1
- package/src/duckdb/src/include/duckdb/function/table/arrow.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/table/range.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/table/read_csv.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/table/summary.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/table/system_functions.hpp +1 -4
- package/src/duckdb/src/include/duckdb/function/table/table_scan.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/table_function.hpp +2 -1
- package/src/duckdb/src/include/duckdb/main/attached_database.hpp +64 -0
- package/src/duckdb/src/include/duckdb/main/client_context.hpp +3 -3
- package/src/duckdb/src/include/duckdb/main/client_data.hpp +2 -1
- package/src/duckdb/src/include/duckdb/main/config.hpp +3 -0
- package/src/duckdb/src/include/duckdb/main/database.hpp +6 -6
- package/src/duckdb/src/include/duckdb/main/database_manager.hpp +69 -0
- package/src/duckdb/src/include/duckdb/main/settings.hpp +10 -0
- package/src/duckdb/src/include/duckdb/main/valid_checker.hpp +2 -2
- package/src/duckdb/src/include/duckdb/parser/expression/function_expression.hpp +3 -1
- package/src/duckdb/src/include/duckdb/parser/expression/window_expression.hpp +3 -1
- package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_function_info.hpp +2 -2
- package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_info.hpp +18 -1
- package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_table_info.hpp +53 -56
- package/src/duckdb/src/include/duckdb/parser/parsed_data/attach_info.hpp +39 -0
- package/src/duckdb/src/include/duckdb/parser/parsed_data/copy_info.hpp +4 -1
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_aggregate_function_info.hpp +3 -18
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_collation_info.hpp +4 -13
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_copy_function_info.hpp +3 -12
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_index_info.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_info.hpp +5 -3
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_pragma_function_info.hpp +3 -14
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_table_function_info.hpp +3 -19
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_table_info.hpp +3 -1
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_view_info.hpp +7 -34
- package/src/duckdb/src/include/duckdb/parser/parsed_data/drop_info.hpp +7 -1
- package/src/duckdb/src/include/duckdb/parser/parsed_data/exported_table_data.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/parser_extension.hpp +2 -2
- package/src/duckdb/src/include/duckdb/parser/qualified_name.hpp +10 -2
- package/src/duckdb/src/include/duckdb/parser/query_error_context.hpp +2 -2
- package/src/duckdb/src/include/duckdb/parser/statement/attach_statement.hpp +29 -0
- package/src/duckdb/src/include/duckdb/parser/statement/export_statement.hpp +1 -0
- package/src/duckdb/src/include/duckdb/parser/statement/insert_statement.hpp +2 -0
- package/src/duckdb/src/include/duckdb/parser/statement/list.hpp +1 -0
- package/src/duckdb/src/include/duckdb/parser/tableref/basetableref.hpp +4 -1
- package/src/duckdb/src/include/duckdb/parser/tokens.hpp +1 -0
- package/src/duckdb/src/include/duckdb/parser/transformer.hpp +2 -0
- package/src/duckdb/src/include/duckdb/planner/bind_context.hpp +2 -0
- package/src/duckdb/src/include/duckdb/planner/binder.hpp +11 -1
- package/src/duckdb/src/include/duckdb/planner/parsed_data/bound_create_table_info.hpp +2 -1
- package/src/duckdb/src/include/duckdb/storage/buffer_manager.hpp +1 -0
- package/src/duckdb/src/include/duckdb/storage/checkpoint_manager.hpp +13 -6
- package/src/duckdb/src/include/duckdb/storage/data_table.hpp +10 -2
- package/src/duckdb/src/include/duckdb/storage/single_file_block_manager.hpp +2 -2
- package/src/duckdb/src/include/duckdb/storage/statistics/base_statistics.hpp +2 -2
- package/src/duckdb/src/include/duckdb/storage/storage_manager.hpp +9 -12
- package/src/duckdb/src/include/duckdb/storage/table/data_table_info.hpp +3 -7
- package/src/duckdb/src/include/duckdb/storage/table/row_group.hpp +5 -6
- package/src/duckdb/src/include/duckdb/storage/write_ahead_log.hpp +9 -7
- package/src/duckdb/src/include/duckdb/transaction/local_storage.hpp +3 -1
- package/src/duckdb/src/include/duckdb/transaction/meta_transaction.hpp +64 -0
- package/src/duckdb/src/include/duckdb/transaction/transaction.hpp +14 -23
- package/src/duckdb/src/include/duckdb/transaction/transaction_context.hpp +12 -8
- package/src/duckdb/src/include/duckdb/transaction/transaction_manager.hpp +5 -10
- package/src/duckdb/src/include/duckdb/transaction/undo_buffer.hpp +1 -1
- package/src/duckdb/src/main/attached_database.cpp +97 -0
- package/src/duckdb/src/main/capi/table_function-c.cpp +1 -1
- package/src/duckdb/src/main/client_context.cpp +28 -22
- package/src/duckdb/src/main/client_data.cpp +5 -2
- package/src/duckdb/src/main/config.cpp +1 -0
- package/src/duckdb/src/main/database.cpp +54 -40
- package/src/duckdb/src/main/database_manager.cpp +95 -0
- package/src/duckdb/src/main/materialized_query_result.cpp +1 -1
- package/src/duckdb/src/main/prepared_statement_data.cpp +1 -2
- package/src/duckdb/src/main/query_result.cpp +4 -4
- package/src/duckdb/src/main/settings/settings.cpp +22 -6
- package/src/duckdb/src/main/stream_query_result.cpp +1 -1
- package/src/duckdb/src/parser/expression/columnref_expression.cpp +9 -3
- package/src/duckdb/src/parser/expression/function_expression.cpp +15 -13
- package/src/duckdb/src/parser/expression/window_expression.cpp +6 -4
- package/src/duckdb/src/parser/parsed_data/alter_function_info.cpp +7 -7
- package/src/duckdb/src/parser/parsed_data/alter_info.cpp +12 -2
- package/src/duckdb/src/parser/parsed_data/alter_table_info.cpp +96 -98
- package/src/duckdb/src/parser/parsed_data/create_aggregate_function_info.cpp +27 -0
- package/src/duckdb/src/parser/parsed_data/create_collation_info.cpp +23 -0
- package/src/duckdb/src/parser/parsed_data/create_copy_function_info.cpp +21 -0
- package/src/duckdb/src/parser/parsed_data/create_info.cpp +3 -0
- package/src/duckdb/src/parser/parsed_data/create_pragma_function_info.cpp +23 -0
- package/src/duckdb/src/parser/parsed_data/create_scalar_function_info.cpp +3 -1
- package/src/duckdb/src/parser/parsed_data/create_table_function_info.cpp +28 -0
- package/src/duckdb/src/parser/parsed_data/create_table_info.cpp +9 -3
- package/src/duckdb/src/parser/parsed_data/create_view_info.cpp +49 -0
- package/src/duckdb/src/parser/statement/attach_statement.cpp +15 -0
- package/src/duckdb/src/parser/statement/insert_statement.cpp +6 -2
- package/src/duckdb/src/parser/tableref/basetableref.cpp +9 -4
- package/src/duckdb/src/parser/transform/constraint/transform_constraint.cpp +15 -13
- package/src/duckdb/src/parser/transform/expression/transform_function.cpp +17 -7
- package/src/duckdb/src/parser/transform/expression/transform_operator.cpp +4 -9
- package/src/duckdb/src/parser/transform/helpers/nodetype_to_string.cpp +4 -0
- package/src/duckdb/src/parser/transform/statement/transform_alter_sequence.cpp +5 -4
- package/src/duckdb/src/parser/transform/statement/transform_alter_table.cpp +8 -10
- package/src/duckdb/src/parser/transform/statement/transform_attach.cpp +32 -0
- package/src/duckdb/src/parser/transform/statement/transform_checkpoint.cpp +7 -2
- package/src/duckdb/src/parser/transform/statement/transform_copy.cpp +1 -0
- package/src/duckdb/src/parser/transform/statement/transform_create_function.cpp +1 -0
- package/src/duckdb/src/parser/transform/statement/transform_create_schema.cpp +1 -0
- package/src/duckdb/src/parser/transform/statement/transform_create_sequence.cpp +1 -0
- package/src/duckdb/src/parser/transform/statement/transform_create_table.cpp +5 -5
- package/src/duckdb/src/parser/transform/statement/transform_create_table_as.cpp +1 -0
- package/src/duckdb/src/parser/transform/statement/transform_create_type.cpp +6 -13
- package/src/duckdb/src/parser/transform/statement/transform_create_view.cpp +6 -6
- package/src/duckdb/src/parser/transform/statement/transform_drop.cpp +11 -2
- package/src/duckdb/src/parser/transform/statement/transform_export.cpp +5 -1
- package/src/duckdb/src/parser/transform/statement/transform_insert.cpp +1 -0
- package/src/duckdb/src/parser/transform/statement/transform_rename.cpp +12 -36
- package/src/duckdb/src/parser/transform/statement/transform_show.cpp +3 -1
- package/src/duckdb/src/parser/transform/statement/transform_use.cpp +21 -0
- package/src/duckdb/src/parser/transform/tableref/transform_base_tableref.cpp +11 -3
- package/src/duckdb/src/parser/transformer.cpp +4 -0
- package/src/duckdb/src/planner/bind_context.cpp +11 -2
- package/src/duckdb/src/planner/binder/expression/bind_cast_expression.cpp +1 -1
- package/src/duckdb/src/planner/binder/expression/bind_columnref_expression.cpp +43 -13
- package/src/duckdb/src/planner/binder/expression/bind_comparison_expression.cpp +1 -1
- package/src/duckdb/src/planner/binder/expression/bind_function_expression.cpp +2 -3
- package/src/duckdb/src/planner/binder/expression/bind_window_expression.cpp +2 -3
- package/src/duckdb/src/planner/binder/statement/bind_attach.cpp +20 -0
- package/src/duckdb/src/planner/binder/statement/bind_copy.cpp +7 -4
- package/src/duckdb/src/planner/binder/statement/bind_create.cpp +79 -27
- package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +11 -7
- package/src/duckdb/src/planner/binder/statement/bind_delete.cpp +1 -1
- package/src/duckdb/src/planner/binder/statement/bind_drop.cpp +13 -5
- package/src/duckdb/src/planner/binder/statement/bind_export.cpp +6 -3
- package/src/duckdb/src/planner/binder/statement/bind_extension.cpp +1 -1
- package/src/duckdb/src/planner/binder/statement/bind_insert.cpp +3 -2
- package/src/duckdb/src/planner/binder/statement/bind_pragma.cpp +2 -2
- package/src/duckdb/src/planner/binder/statement/bind_prepare.cpp +0 -2
- package/src/duckdb/src/planner/binder/statement/bind_simple.cpp +11 -6
- package/src/duckdb/src/planner/binder/statement/bind_update.cpp +1 -1
- package/src/duckdb/src/planner/binder/tableref/bind_basetableref.cpp +10 -6
- package/src/duckdb/src/planner/binder/tableref/bind_table_function.cpp +2 -4
- package/src/duckdb/src/planner/binder.cpp +17 -2
- package/src/duckdb/src/planner/logical_operator.cpp +5 -12
- package/src/duckdb/src/planner/operator/logical_copy_to_file.cpp +3 -4
- package/src/duckdb/src/planner/operator/logical_create.cpp +1 -4
- package/src/duckdb/src/planner/operator/logical_create_index.cpp +2 -2
- package/src/duckdb/src/planner/operator/logical_delete.cpp +2 -3
- package/src/duckdb/src/planner/operator/logical_insert.cpp +1 -1
- package/src/duckdb/src/planner/operator/logical_update.cpp +1 -1
- package/src/duckdb/src/planner/parsed_data/bound_create_table_info.cpp +1 -1
- package/src/duckdb/src/planner/planner.cpp +3 -2
- package/src/duckdb/src/planner/pragma_handler.cpp +1 -1
- package/src/duckdb/src/storage/buffer_manager.cpp +5 -0
- package/src/duckdb/src/storage/checkpoint_manager.cpp +10 -17
- package/src/duckdb/src/storage/data_table.cpp +34 -24
- package/src/duckdb/src/storage/local_storage.cpp +7 -3
- package/src/duckdb/src/storage/single_file_block_manager.cpp +3 -3
- package/src/duckdb/src/storage/storage_manager.cpp +25 -42
- package/src/duckdb/src/storage/table/column_data.cpp +2 -1
- package/src/duckdb/src/storage/table/row_group.cpp +7 -2
- package/src/duckdb/src/storage/wal_replay.cpp +6 -22
- package/src/duckdb/src/storage/write_ahead_log.cpp +3 -3
- package/src/duckdb/src/transaction/meta_transaction.cpp +106 -0
- package/src/duckdb/src/transaction/transaction.cpp +21 -21
- package/src/duckdb/src/transaction/transaction_context.cpp +44 -8
- package/src/duckdb/src/transaction/transaction_manager.cpp +20 -20
- package/src/duckdb/src/transaction/undo_buffer.cpp +1 -3
- package/src/duckdb/third_party/libpg_query/include/nodes/nodes.hpp +2 -0
- package/src/duckdb/third_party/libpg_query/include/nodes/parsenodes.hpp +27 -1
- package/src/duckdb/third_party/libpg_query/include/parser/gram.hpp +99 -97
- package/src/duckdb/third_party/libpg_query/include/parser/kwlist.hpp +1 -0
- package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +15206 -14793
- package/src/duckdb/ub_src_catalog.cpp +4 -0
- package/src/duckdb/ub_src_execution_operator_schema.cpp +2 -0
- package/src/duckdb/ub_src_function.cpp +2 -0
- package/src/duckdb/ub_src_function_table_system.cpp +0 -2
- package/src/duckdb/ub_src_main.cpp +4 -0
- package/src/duckdb/ub_src_parser_parsed_data.cpp +12 -0
- package/src/duckdb/ub_src_parser_statement.cpp +2 -0
- package/src/duckdb/ub_src_parser_transform_statement.cpp +4 -0
- package/src/duckdb/ub_src_planner_binder_statement.cpp +2 -0
- package/src/duckdb/ub_src_transaction.cpp +2 -0
- package/src/duckdb/src/function/table/system/pragma_functions.cpp +0 -120
|
@@ -28,30 +28,120 @@
|
|
|
28
28
|
#include "duckdb/planner/binder.hpp"
|
|
29
29
|
#include "duckdb/catalog/default/default_types.hpp"
|
|
30
30
|
#include "duckdb/main/extension_functions.hpp"
|
|
31
|
+
#include "duckdb/main/connection.hpp"
|
|
32
|
+
#include "duckdb/main/attached_database.hpp"
|
|
33
|
+
#include "duckdb/main/database_manager.hpp"
|
|
34
|
+
#include "duckdb/function/built_in_functions.hpp"
|
|
31
35
|
#include <algorithm>
|
|
36
|
+
|
|
32
37
|
namespace duckdb {
|
|
33
38
|
|
|
34
|
-
|
|
35
|
-
|
|
39
|
+
Catalog::Catalog(AttachedDatabase &db)
|
|
40
|
+
: schemas(make_unique<CatalogSet>(*this, make_unique<DefaultSchemaGenerator>(*this))),
|
|
41
|
+
dependency_manager(make_unique<DependencyManager>(*this)), db(db) {
|
|
42
|
+
}
|
|
43
|
+
Catalog::~Catalog() {
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
void Catalog::Initialize(bool load_builtin) {
|
|
47
|
+
// first initialize the base system catalogs
|
|
48
|
+
// these are never written to the WAL
|
|
49
|
+
// we start these at 1 because deleted entries default to 0
|
|
50
|
+
CatalogTransaction data(GetDatabase(), 1, 1);
|
|
36
51
|
|
|
37
|
-
|
|
52
|
+
// create the default schema
|
|
53
|
+
CreateSchemaInfo info;
|
|
54
|
+
info.schema = DEFAULT_SCHEMA;
|
|
55
|
+
info.internal = true;
|
|
56
|
+
CreateSchema(data, &info);
|
|
57
|
+
|
|
58
|
+
if (load_builtin) {
|
|
59
|
+
// initialize default functions
|
|
60
|
+
BuiltinFunctions builtin(data, *this);
|
|
61
|
+
builtin.Initialize();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
Verify();
|
|
38
65
|
}
|
|
39
66
|
|
|
40
|
-
Catalog::
|
|
41
|
-
|
|
42
|
-
dependency_manager(make_unique<DependencyManager>(*this)) {
|
|
43
|
-
catalog_version = 0;
|
|
67
|
+
DatabaseInstance &Catalog::GetDatabase() {
|
|
68
|
+
return db.GetDatabase();
|
|
44
69
|
}
|
|
45
|
-
|
|
70
|
+
|
|
71
|
+
AttachedDatabase &Catalog::GetAttached() {
|
|
72
|
+
return db;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const string &Catalog::GetName() {
|
|
76
|
+
return GetAttached().GetName();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
idx_t Catalog::GetOid() {
|
|
80
|
+
return GetAttached().oid;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
Catalog &Catalog::GetSystemCatalog(ClientContext &context) {
|
|
84
|
+
return Catalog::GetSystemCatalog(*context.db);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
Catalog &Catalog::GetCatalog(ClientContext &context, const string &catalog_name) {
|
|
88
|
+
auto &db_manager = DatabaseManager::Get(context);
|
|
89
|
+
if (catalog_name == TEMP_CATALOG) {
|
|
90
|
+
return ClientData::Get(context).temporary_objects->GetCatalog();
|
|
91
|
+
}
|
|
92
|
+
if (catalog_name == SYSTEM_CATALOG) {
|
|
93
|
+
return GetSystemCatalog(context);
|
|
94
|
+
}
|
|
95
|
+
auto entry = db_manager.GetDatabase(
|
|
96
|
+
context, IsInvalidCatalog(catalog_name) ? DatabaseManager::GetDefaultDatabase(context) : catalog_name);
|
|
97
|
+
if (!entry) {
|
|
98
|
+
throw BinderException("Catalog \"%s\" does not exist!", catalog_name);
|
|
99
|
+
}
|
|
100
|
+
return entry->GetCatalog();
|
|
46
101
|
}
|
|
47
102
|
|
|
48
|
-
|
|
49
|
-
|
|
103
|
+
//===--------------------------------------------------------------------===//
|
|
104
|
+
// Schema
|
|
105
|
+
//===--------------------------------------------------------------------===//
|
|
106
|
+
CatalogEntry *Catalog::CreateSchema(CatalogTransaction transaction, CreateSchemaInfo *info) {
|
|
107
|
+
D_ASSERT(!info->schema.empty());
|
|
108
|
+
DependencyList dependencies;
|
|
109
|
+
auto entry = make_unique<SchemaCatalogEntry>(this, info->schema, info->internal);
|
|
110
|
+
auto result = entry.get();
|
|
111
|
+
if (!schemas->CreateEntry(transaction, info->schema, move(entry), dependencies)) {
|
|
112
|
+
if (info->on_conflict == OnCreateConflict::ERROR_ON_CONFLICT) {
|
|
113
|
+
throw CatalogException("Schema with name %s already exists!", info->schema);
|
|
114
|
+
} else {
|
|
115
|
+
D_ASSERT(info->on_conflict == OnCreateConflict::IGNORE_ON_CONFLICT);
|
|
116
|
+
}
|
|
117
|
+
return nullptr;
|
|
118
|
+
}
|
|
119
|
+
return result;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
CatalogEntry *Catalog::CreateSchema(ClientContext &context, CreateSchemaInfo *info) {
|
|
123
|
+
return CreateSchema(GetCatalogTransaction(context), info);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
CatalogTransaction Catalog::GetCatalogTransaction(ClientContext &context) {
|
|
127
|
+
return CatalogTransaction(*this, context);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
void Catalog::DropSchema(ClientContext &context, DropInfo *info) {
|
|
131
|
+
D_ASSERT(!info->name.empty());
|
|
132
|
+
ModifyCatalog();
|
|
133
|
+
if (!schemas->DropEntry(GetCatalogTransaction(context), info->name, info->cascade)) {
|
|
134
|
+
if (!info->if_exists) {
|
|
135
|
+
throw CatalogException("Schema with name \"%s\" does not exist!", info->name);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
50
138
|
}
|
|
51
139
|
|
|
140
|
+
//===--------------------------------------------------------------------===//
|
|
141
|
+
// Table
|
|
142
|
+
//===--------------------------------------------------------------------===//
|
|
52
143
|
CatalogEntry *Catalog::CreateTable(ClientContext &context, BoundCreateTableInfo *info) {
|
|
53
|
-
|
|
54
|
-
return CreateTable(context, schema, info);
|
|
144
|
+
return CreateTable(GetCatalogTransaction(context), info);
|
|
55
145
|
}
|
|
56
146
|
|
|
57
147
|
CatalogEntry *Catalog::CreateTable(ClientContext &context, unique_ptr<CreateTableInfo> info) {
|
|
@@ -60,115 +150,214 @@ CatalogEntry *Catalog::CreateTable(ClientContext &context, unique_ptr<CreateTabl
|
|
|
60
150
|
return CreateTable(context, bound_info.get());
|
|
61
151
|
}
|
|
62
152
|
|
|
63
|
-
CatalogEntry *Catalog::CreateTable(
|
|
64
|
-
|
|
153
|
+
CatalogEntry *Catalog::CreateTable(CatalogTransaction transaction, SchemaCatalogEntry *schema,
|
|
154
|
+
BoundCreateTableInfo *info) {
|
|
155
|
+
return schema->CreateTable(transaction, info);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
CatalogEntry *Catalog::CreateTable(CatalogTransaction transaction, BoundCreateTableInfo *info) {
|
|
159
|
+
auto schema = GetSchema(transaction, info->base->schema);
|
|
160
|
+
return CreateTable(transaction, schema, info);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
//===--------------------------------------------------------------------===//
|
|
164
|
+
// View
|
|
165
|
+
//===--------------------------------------------------------------------===//
|
|
166
|
+
CatalogEntry *Catalog::CreateView(CatalogTransaction transaction, CreateViewInfo *info) {
|
|
167
|
+
auto schema = GetSchema(transaction, info->schema);
|
|
168
|
+
return CreateView(transaction, schema, info);
|
|
65
169
|
}
|
|
66
170
|
|
|
67
171
|
CatalogEntry *Catalog::CreateView(ClientContext &context, CreateViewInfo *info) {
|
|
68
|
-
|
|
69
|
-
|
|
172
|
+
return CreateView(GetCatalogTransaction(context), info);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
CatalogEntry *Catalog::CreateView(CatalogTransaction transaction, SchemaCatalogEntry *schema, CreateViewInfo *info) {
|
|
176
|
+
return schema->CreateView(transaction, info);
|
|
70
177
|
}
|
|
71
178
|
|
|
72
|
-
|
|
73
|
-
|
|
179
|
+
//===--------------------------------------------------------------------===//
|
|
180
|
+
// Sequence
|
|
181
|
+
//===--------------------------------------------------------------------===//
|
|
182
|
+
CatalogEntry *Catalog::CreateSequence(CatalogTransaction transaction, CreateSequenceInfo *info) {
|
|
183
|
+
auto schema = GetSchema(transaction, info->schema);
|
|
184
|
+
return CreateSequence(transaction, schema, info);
|
|
74
185
|
}
|
|
75
186
|
|
|
76
187
|
CatalogEntry *Catalog::CreateSequence(ClientContext &context, CreateSequenceInfo *info) {
|
|
77
|
-
|
|
78
|
-
|
|
188
|
+
return CreateSequence(GetCatalogTransaction(context), info);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
CatalogEntry *Catalog::CreateSequence(CatalogTransaction transaction, SchemaCatalogEntry *schema,
|
|
192
|
+
CreateSequenceInfo *info) {
|
|
193
|
+
return schema->CreateSequence(transaction, info);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
//===--------------------------------------------------------------------===//
|
|
197
|
+
// Type
|
|
198
|
+
//===--------------------------------------------------------------------===//
|
|
199
|
+
CatalogEntry *Catalog::CreateType(CatalogTransaction transaction, CreateTypeInfo *info) {
|
|
200
|
+
auto schema = GetSchema(transaction, info->schema);
|
|
201
|
+
return CreateType(transaction, schema, info);
|
|
79
202
|
}
|
|
80
203
|
|
|
81
204
|
CatalogEntry *Catalog::CreateType(ClientContext &context, CreateTypeInfo *info) {
|
|
82
|
-
|
|
83
|
-
return CreateType(context, schema, info);
|
|
205
|
+
return CreateType(GetCatalogTransaction(context), info);
|
|
84
206
|
}
|
|
85
207
|
|
|
86
|
-
CatalogEntry *Catalog::
|
|
87
|
-
return schema->
|
|
208
|
+
CatalogEntry *Catalog::CreateType(CatalogTransaction transaction, SchemaCatalogEntry *schema, CreateTypeInfo *info) {
|
|
209
|
+
return schema->CreateType(transaction, info);
|
|
88
210
|
}
|
|
89
211
|
|
|
90
|
-
|
|
91
|
-
|
|
212
|
+
//===--------------------------------------------------------------------===//
|
|
213
|
+
// Table Function
|
|
214
|
+
//===--------------------------------------------------------------------===//
|
|
215
|
+
CatalogEntry *Catalog::CreateTableFunction(CatalogTransaction transaction, CreateTableFunctionInfo *info) {
|
|
216
|
+
auto schema = GetSchema(transaction, info->schema);
|
|
217
|
+
return CreateTableFunction(transaction, schema, info);
|
|
92
218
|
}
|
|
93
219
|
|
|
94
220
|
CatalogEntry *Catalog::CreateTableFunction(ClientContext &context, CreateTableFunctionInfo *info) {
|
|
95
|
-
|
|
96
|
-
return CreateTableFunction(context, schema, info);
|
|
221
|
+
return CreateTableFunction(GetCatalogTransaction(context), info);
|
|
97
222
|
}
|
|
98
223
|
|
|
99
|
-
CatalogEntry *Catalog::CreateTableFunction(
|
|
224
|
+
CatalogEntry *Catalog::CreateTableFunction(CatalogTransaction transaction, SchemaCatalogEntry *schema,
|
|
100
225
|
CreateTableFunctionInfo *info) {
|
|
101
|
-
return schema->CreateTableFunction(
|
|
226
|
+
return schema->CreateTableFunction(transaction, info);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
//===--------------------------------------------------------------------===//
|
|
230
|
+
// Copy Function
|
|
231
|
+
//===--------------------------------------------------------------------===//
|
|
232
|
+
CatalogEntry *Catalog::CreateCopyFunction(CatalogTransaction transaction, CreateCopyFunctionInfo *info) {
|
|
233
|
+
auto schema = GetSchema(transaction, info->schema);
|
|
234
|
+
return CreateCopyFunction(transaction, schema, info);
|
|
102
235
|
}
|
|
103
236
|
|
|
104
237
|
CatalogEntry *Catalog::CreateCopyFunction(ClientContext &context, CreateCopyFunctionInfo *info) {
|
|
105
|
-
|
|
106
|
-
return CreateCopyFunction(context, schema, info);
|
|
238
|
+
return CreateCopyFunction(GetCatalogTransaction(context), info);
|
|
107
239
|
}
|
|
108
240
|
|
|
109
|
-
CatalogEntry *Catalog::CreateCopyFunction(
|
|
241
|
+
CatalogEntry *Catalog::CreateCopyFunction(CatalogTransaction transaction, SchemaCatalogEntry *schema,
|
|
110
242
|
CreateCopyFunctionInfo *info) {
|
|
111
|
-
return schema->CreateCopyFunction(
|
|
243
|
+
return schema->CreateCopyFunction(transaction, info);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
//===--------------------------------------------------------------------===//
|
|
247
|
+
// Pragma Function
|
|
248
|
+
//===--------------------------------------------------------------------===//
|
|
249
|
+
CatalogEntry *Catalog::CreatePragmaFunction(CatalogTransaction transaction, CreatePragmaFunctionInfo *info) {
|
|
250
|
+
auto schema = GetSchema(transaction, info->schema);
|
|
251
|
+
return CreatePragmaFunction(transaction, schema, info);
|
|
112
252
|
}
|
|
113
253
|
|
|
114
254
|
CatalogEntry *Catalog::CreatePragmaFunction(ClientContext &context, CreatePragmaFunctionInfo *info) {
|
|
115
|
-
|
|
116
|
-
return CreatePragmaFunction(context, schema, info);
|
|
255
|
+
return CreatePragmaFunction(GetCatalogTransaction(context), info);
|
|
117
256
|
}
|
|
118
257
|
|
|
119
|
-
CatalogEntry *Catalog::CreatePragmaFunction(
|
|
258
|
+
CatalogEntry *Catalog::CreatePragmaFunction(CatalogTransaction transaction, SchemaCatalogEntry *schema,
|
|
120
259
|
CreatePragmaFunctionInfo *info) {
|
|
121
|
-
return schema->CreatePragmaFunction(
|
|
260
|
+
return schema->CreatePragmaFunction(transaction, info);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
//===--------------------------------------------------------------------===//
|
|
264
|
+
// Function
|
|
265
|
+
//===--------------------------------------------------------------------===//
|
|
266
|
+
CatalogEntry *Catalog::CreateFunction(CatalogTransaction transaction, CreateFunctionInfo *info) {
|
|
267
|
+
auto schema = GetSchema(transaction, info->schema);
|
|
268
|
+
return CreateFunction(transaction, schema, info);
|
|
122
269
|
}
|
|
123
270
|
|
|
124
271
|
CatalogEntry *Catalog::CreateFunction(ClientContext &context, CreateFunctionInfo *info) {
|
|
125
|
-
|
|
126
|
-
return CreateFunction(context, schema, info);
|
|
272
|
+
return CreateFunction(GetCatalogTransaction(context), info);
|
|
127
273
|
}
|
|
128
274
|
|
|
129
|
-
CatalogEntry *Catalog::CreateFunction(
|
|
130
|
-
|
|
275
|
+
CatalogEntry *Catalog::CreateFunction(CatalogTransaction transaction, SchemaCatalogEntry *schema,
|
|
276
|
+
CreateFunctionInfo *info) {
|
|
277
|
+
return schema->CreateFunction(transaction, info);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
CatalogEntry *Catalog::AddFunction(ClientContext &context, CreateFunctionInfo *info) {
|
|
281
|
+
info->on_conflict = OnCreateConflict::ALTER_ON_CONFLICT;
|
|
282
|
+
return CreateFunction(context, info);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
//===--------------------------------------------------------------------===//
|
|
286
|
+
// Collation
|
|
287
|
+
//===--------------------------------------------------------------------===//
|
|
288
|
+
CatalogEntry *Catalog::CreateCollation(CatalogTransaction transaction, CreateCollationInfo *info) {
|
|
289
|
+
auto schema = GetSchema(transaction, info->schema);
|
|
290
|
+
return CreateCollation(transaction, schema, info);
|
|
131
291
|
}
|
|
132
292
|
|
|
133
293
|
CatalogEntry *Catalog::CreateCollation(ClientContext &context, CreateCollationInfo *info) {
|
|
134
|
-
|
|
135
|
-
return CreateCollation(context, schema, info);
|
|
294
|
+
return CreateCollation(GetCatalogTransaction(context), info);
|
|
136
295
|
}
|
|
137
296
|
|
|
138
|
-
CatalogEntry *Catalog::CreateCollation(
|
|
139
|
-
|
|
297
|
+
CatalogEntry *Catalog::CreateCollation(CatalogTransaction transaction, SchemaCatalogEntry *schema,
|
|
298
|
+
CreateCollationInfo *info) {
|
|
299
|
+
return schema->CreateCollation(transaction, info);
|
|
140
300
|
}
|
|
141
301
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
302
|
+
//===--------------------------------------------------------------------===//
|
|
303
|
+
// Lookup Structures
|
|
304
|
+
//===--------------------------------------------------------------------===//
|
|
305
|
+
struct CatalogLookup {
|
|
306
|
+
CatalogLookup(Catalog &catalog, string schema_p) : catalog(catalog), schema(move(schema_p)) {
|
|
146
307
|
}
|
|
147
308
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
309
|
+
Catalog &catalog;
|
|
310
|
+
string schema;
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
//! Return value of Catalog::LookupEntry
|
|
314
|
+
struct CatalogEntryLookup {
|
|
315
|
+
SchemaCatalogEntry *schema;
|
|
316
|
+
CatalogEntry *entry;
|
|
317
|
+
|
|
318
|
+
DUCKDB_API bool Found() const {
|
|
319
|
+
return entry;
|
|
320
|
+
}
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
//! Return value of SimilarEntryInSchemas
|
|
324
|
+
struct SimilarCatalogEntry {
|
|
325
|
+
//! The entry name. Empty if absent
|
|
326
|
+
string name;
|
|
327
|
+
//! The distance to the given name.
|
|
328
|
+
idx_t distance;
|
|
329
|
+
//! The schema of the entry.
|
|
330
|
+
SchemaCatalogEntry *schema;
|
|
331
|
+
|
|
332
|
+
DUCKDB_API bool Found() const {
|
|
333
|
+
return !name.empty();
|
|
158
334
|
}
|
|
159
|
-
return result;
|
|
160
|
-
}
|
|
161
335
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
336
|
+
DUCKDB_API string GetQualifiedName(bool qualify_catalog, bool qualify_schema) const;
|
|
337
|
+
};
|
|
338
|
+
|
|
339
|
+
string SimilarCatalogEntry::GetQualifiedName(bool qualify_catalog, bool qualify_schema) const {
|
|
340
|
+
D_ASSERT(Found());
|
|
341
|
+
string result;
|
|
342
|
+
if (qualify_catalog) {
|
|
343
|
+
result += schema->catalog->GetName();
|
|
344
|
+
}
|
|
345
|
+
if (qualify_schema) {
|
|
346
|
+
if (!result.empty()) {
|
|
347
|
+
result += ".";
|
|
168
348
|
}
|
|
349
|
+
result += schema->name;
|
|
350
|
+
}
|
|
351
|
+
if (!result.empty()) {
|
|
352
|
+
result += ".";
|
|
169
353
|
}
|
|
354
|
+
result += name;
|
|
355
|
+
return result;
|
|
170
356
|
}
|
|
171
357
|
|
|
358
|
+
//===--------------------------------------------------------------------===//
|
|
359
|
+
// Generic
|
|
360
|
+
//===--------------------------------------------------------------------===//
|
|
172
361
|
void Catalog::DropEntry(ClientContext &context, DropInfo *info) {
|
|
173
362
|
ModifyCatalog();
|
|
174
363
|
if (info->type == CatalogType::SCHEMA_ENTRY) {
|
|
@@ -185,31 +374,31 @@ void Catalog::DropEntry(ClientContext &context, DropInfo *info) {
|
|
|
185
374
|
lookup.schema->DropEntry(context, info);
|
|
186
375
|
}
|
|
187
376
|
|
|
188
|
-
|
|
189
|
-
info->on_conflict = OnCreateConflict::ALTER_ON_CONFLICT;
|
|
190
|
-
return CreateFunction(context, info);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
SchemaCatalogEntry *Catalog::GetSchema(ClientContext &context, const string &schema_name, bool if_exists,
|
|
377
|
+
SchemaCatalogEntry *Catalog::GetSchema(CatalogTransaction transaction, const string &schema_name, bool if_exists,
|
|
194
378
|
QueryErrorContext error_context) {
|
|
195
379
|
D_ASSERT(!schema_name.empty());
|
|
196
|
-
|
|
197
|
-
return SchemaCatalogEntry::GetTemporaryObjects(context);
|
|
198
|
-
}
|
|
199
|
-
auto entry = schemas->GetEntry(context, schema_name);
|
|
380
|
+
auto entry = schemas->GetEntry(transaction, schema_name);
|
|
200
381
|
if (!entry && !if_exists) {
|
|
201
382
|
throw CatalogException(error_context.FormatError("Schema with name %s does not exist!", schema_name));
|
|
202
383
|
}
|
|
203
384
|
return (SchemaCatalogEntry *)entry;
|
|
204
385
|
}
|
|
205
386
|
|
|
387
|
+
SchemaCatalogEntry *Catalog::GetSchema(ClientContext &context, const string &schema_name, bool if_exists,
|
|
388
|
+
QueryErrorContext error_context) {
|
|
389
|
+
return GetSchema(GetCatalogTransaction(context), schema_name, if_exists, error_context);
|
|
390
|
+
}
|
|
391
|
+
|
|
206
392
|
void Catalog::ScanSchemas(ClientContext &context, std::function<void(CatalogEntry *)> callback) {
|
|
207
393
|
// create all default schemas first
|
|
208
|
-
schemas->Scan(context, [&](CatalogEntry *entry) { callback(entry); });
|
|
394
|
+
schemas->Scan(GetCatalogTransaction(context), [&](CatalogEntry *entry) { callback(entry); });
|
|
209
395
|
}
|
|
210
396
|
|
|
397
|
+
//===--------------------------------------------------------------------===//
|
|
398
|
+
// Lookup
|
|
399
|
+
//===--------------------------------------------------------------------===//
|
|
211
400
|
SimilarCatalogEntry Catalog::SimilarEntryInSchemas(ClientContext &context, const string &entry_name, CatalogType type,
|
|
212
|
-
const
|
|
401
|
+
const unordered_set<SchemaCatalogEntry *> &schemas) {
|
|
213
402
|
|
|
214
403
|
vector<CatalogSet *> sets;
|
|
215
404
|
std::transform(schemas.begin(), schemas.end(), std::back_inserter(sets),
|
|
@@ -217,7 +406,8 @@ SimilarCatalogEntry Catalog::SimilarEntryInSchemas(ClientContext &context, const
|
|
|
217
406
|
pair<string, idx_t> most_similar {"", (idx_t)-1};
|
|
218
407
|
SchemaCatalogEntry *schema_of_most_similar = nullptr;
|
|
219
408
|
for (auto schema : schemas) {
|
|
220
|
-
auto
|
|
409
|
+
auto transaction = schema->catalog->GetCatalogTransaction(context);
|
|
410
|
+
auto entry = schema->GetCatalogSet(type).SimilarEntry(transaction, entry_name);
|
|
221
411
|
if (!entry.first.empty() && (most_similar.first.empty() || most_similar.second > entry.second)) {
|
|
222
412
|
most_similar = entry;
|
|
223
413
|
schema_of_most_similar = schema;
|
|
@@ -237,18 +427,87 @@ string FindExtension(const string &function_name) {
|
|
|
237
427
|
}
|
|
238
428
|
return "";
|
|
239
429
|
}
|
|
430
|
+
|
|
431
|
+
vector<CatalogSearchEntry> GetCatalogEntries(ClientContext &context, const string &catalog, const string &schema) {
|
|
432
|
+
vector<CatalogSearchEntry> entries;
|
|
433
|
+
auto &search_path = *context.client_data->catalog_search_path;
|
|
434
|
+
if (IsInvalidCatalog(catalog) && IsInvalidSchema(schema)) {
|
|
435
|
+
// no catalog or schema provided - scan the entire search path
|
|
436
|
+
entries = search_path.Get();
|
|
437
|
+
} else if (IsInvalidCatalog(catalog)) {
|
|
438
|
+
auto catalogs = search_path.GetCatalogsForSchema(schema);
|
|
439
|
+
for (auto &catalog_name : catalogs) {
|
|
440
|
+
entries.emplace_back(catalog_name, schema);
|
|
441
|
+
}
|
|
442
|
+
if (entries.empty()) {
|
|
443
|
+
entries.emplace_back(DatabaseManager::GetDefaultDatabase(context), schema);
|
|
444
|
+
}
|
|
445
|
+
} else if (IsInvalidSchema(schema)) {
|
|
446
|
+
auto schemas = search_path.GetSchemasForCatalog(catalog);
|
|
447
|
+
for (auto &schema_name : schemas) {
|
|
448
|
+
entries.emplace_back(catalog, schema_name);
|
|
449
|
+
}
|
|
450
|
+
if (entries.empty()) {
|
|
451
|
+
entries.emplace_back(catalog, DEFAULT_SCHEMA);
|
|
452
|
+
}
|
|
453
|
+
} else {
|
|
454
|
+
// specific catalog and schema provided
|
|
455
|
+
entries.emplace_back(catalog, schema);
|
|
456
|
+
}
|
|
457
|
+
return entries;
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
void FindMinimalQualification(ClientContext &context, const string &catalog_name, const string &schema_name,
|
|
461
|
+
bool &qualify_database, bool &qualify_schema) {
|
|
462
|
+
// check if we can we qualify ONLY the schema
|
|
463
|
+
bool found = false;
|
|
464
|
+
auto entries = GetCatalogEntries(context, INVALID_CATALOG, schema_name);
|
|
465
|
+
for (auto &entry : entries) {
|
|
466
|
+
if (entry.catalog == catalog_name && entry.schema == schema_name) {
|
|
467
|
+
found = true;
|
|
468
|
+
break;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
if (found) {
|
|
472
|
+
qualify_database = false;
|
|
473
|
+
qualify_schema = true;
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
476
|
+
// check if we can qualify ONLY the catalog
|
|
477
|
+
found = false;
|
|
478
|
+
entries = GetCatalogEntries(context, catalog_name, INVALID_SCHEMA);
|
|
479
|
+
for (auto &entry : entries) {
|
|
480
|
+
if (entry.catalog == catalog_name && entry.schema == schema_name) {
|
|
481
|
+
found = true;
|
|
482
|
+
break;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
if (found) {
|
|
486
|
+
qualify_database = true;
|
|
487
|
+
qualify_schema = false;
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
490
|
+
// need to qualify both catalog and schema
|
|
491
|
+
qualify_database = true;
|
|
492
|
+
qualify_schema = true;
|
|
493
|
+
}
|
|
494
|
+
|
|
240
495
|
CatalogException Catalog::CreateMissingEntryException(ClientContext &context, const string &entry_name,
|
|
241
|
-
CatalogType type,
|
|
496
|
+
CatalogType type,
|
|
497
|
+
const unordered_set<SchemaCatalogEntry *> &schemas,
|
|
242
498
|
QueryErrorContext error_context) {
|
|
243
499
|
auto entry = SimilarEntryInSchemas(context, entry_name, type, schemas);
|
|
244
500
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
501
|
+
unordered_set<SchemaCatalogEntry *> unseen_schemas;
|
|
502
|
+
auto &db_manager = DatabaseManager::Get(context);
|
|
503
|
+
auto databases = db_manager.GetDatabases(context);
|
|
504
|
+
for (auto database : databases) {
|
|
505
|
+
auto &catalog = database->GetCatalog();
|
|
506
|
+
auto current_schemas = catalog.GetAllSchemas(context);
|
|
507
|
+
for (auto ¤t_schema : current_schemas) {
|
|
508
|
+
unseen_schemas.insert(current_schema);
|
|
250
509
|
}
|
|
251
|
-
}
|
|
510
|
+
}
|
|
252
511
|
auto unseen_entry = SimilarEntryInSchemas(context, entry_name, type, unseen_schemas);
|
|
253
512
|
auto extension_name = FindExtension(entry_name);
|
|
254
513
|
if (!extension_name.empty()) {
|
|
@@ -258,7 +517,14 @@ CatalogException Catalog::CreateMissingEntryException(ClientContext &context, co
|
|
|
258
517
|
}
|
|
259
518
|
string did_you_mean;
|
|
260
519
|
if (unseen_entry.Found() && unseen_entry.distance < entry.distance) {
|
|
261
|
-
|
|
520
|
+
// the closest matching entry requires qualification as it is not in the default search path
|
|
521
|
+
// check how to minimally qualify this entry
|
|
522
|
+
auto catalog_name = unseen_entry.schema->catalog->GetName();
|
|
523
|
+
auto schema_name = unseen_entry.schema->name;
|
|
524
|
+
bool qualify_database;
|
|
525
|
+
bool qualify_schema;
|
|
526
|
+
FindMinimalQualification(context, catalog_name, schema_name, qualify_database, qualify_schema);
|
|
527
|
+
did_you_mean = "\nDid you mean \"" + unseen_entry.GetQualifiedName(qualify_database, qualify_schema) + "\"?";
|
|
262
528
|
} else if (entry.Found()) {
|
|
263
529
|
did_you_mean = "\nDid you mean \"" + entry.name + "\"?";
|
|
264
530
|
}
|
|
@@ -267,44 +533,74 @@ CatalogException Catalog::CreateMissingEntryException(ClientContext &context, co
|
|
|
267
533
|
entry_name, did_you_mean));
|
|
268
534
|
}
|
|
269
535
|
|
|
270
|
-
CatalogEntryLookup Catalog::
|
|
271
|
-
|
|
272
|
-
if (!schema_name.empty()) {
|
|
273
|
-
auto schema = GetSchema(context, schema_name, if_exists, error_context);
|
|
274
|
-
if (!schema) {
|
|
275
|
-
D_ASSERT(if_exists);
|
|
276
|
-
return {nullptr, nullptr};
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
auto entry = schema->GetCatalogSet(type).GetEntry(context, name);
|
|
280
|
-
if (!entry && !if_exists) {
|
|
281
|
-
throw CreateMissingEntryException(context, name, type, {schema}, error_context);
|
|
282
|
-
}
|
|
536
|
+
CatalogEntryLookup Catalog::LookupEntryInternal(CatalogTransaction transaction, CatalogType type, const string &schema,
|
|
537
|
+
const string &name) {
|
|
283
538
|
|
|
284
|
-
|
|
539
|
+
auto schema_entry = (SchemaCatalogEntry *)GetSchema(transaction, schema, true);
|
|
540
|
+
if (!schema_entry) {
|
|
541
|
+
return {nullptr, nullptr};
|
|
285
542
|
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
auto lookup = LookupEntry(context, type, path, name, true, error_context);
|
|
290
|
-
if (lookup.Found()) {
|
|
291
|
-
return lookup;
|
|
292
|
-
}
|
|
543
|
+
auto entry = schema_entry->GetCatalogSet(type).GetEntry(transaction, name);
|
|
544
|
+
if (!entry) {
|
|
545
|
+
return {schema_entry, nullptr};
|
|
293
546
|
}
|
|
547
|
+
return {schema_entry, entry};
|
|
548
|
+
}
|
|
294
549
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
550
|
+
CatalogEntryLookup Catalog::LookupEntry(ClientContext &context, CatalogType type, const string &schema,
|
|
551
|
+
const string &name, bool if_exists, QueryErrorContext error_context) {
|
|
552
|
+
unordered_set<SchemaCatalogEntry *> schemas;
|
|
553
|
+
if (IsInvalidSchema(schema)) {
|
|
554
|
+
// try all schemas for this catalog
|
|
555
|
+
auto catalog_name = GetName();
|
|
556
|
+
if (catalog_name == DatabaseManager::GetDefaultDatabase(context)) {
|
|
557
|
+
catalog_name = INVALID_CATALOG;
|
|
558
|
+
}
|
|
559
|
+
auto entries = GetCatalogEntries(context, GetName(), INVALID_SCHEMA);
|
|
560
|
+
for (auto &entry : entries) {
|
|
561
|
+
auto &candidate_schema = entry.schema;
|
|
562
|
+
auto transaction = GetCatalogTransaction(context);
|
|
563
|
+
auto result = LookupEntryInternal(transaction, type, candidate_schema, name);
|
|
564
|
+
if (result.Found()) {
|
|
565
|
+
return result;
|
|
566
|
+
}
|
|
567
|
+
if (result.schema) {
|
|
568
|
+
schemas.insert(result.schema);
|
|
301
569
|
}
|
|
302
570
|
}
|
|
303
|
-
|
|
304
|
-
|
|
571
|
+
} else {
|
|
572
|
+
auto transaction = GetCatalogTransaction(context);
|
|
573
|
+
auto result = LookupEntryInternal(transaction, type, schema, name);
|
|
574
|
+
if (result.Found()) {
|
|
575
|
+
return result;
|
|
576
|
+
}
|
|
577
|
+
if (result.schema) {
|
|
578
|
+
schemas.insert(result.schema);
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
if (if_exists) {
|
|
582
|
+
return {nullptr, nullptr};
|
|
305
583
|
}
|
|
584
|
+
throw CreateMissingEntryException(context, name, type, schemas, error_context);
|
|
585
|
+
}
|
|
306
586
|
|
|
307
|
-
|
|
587
|
+
CatalogEntryLookup Catalog::LookupEntry(ClientContext &context, vector<CatalogLookup> &lookups, CatalogType type,
|
|
588
|
+
const string &name, bool if_exists, QueryErrorContext error_context) {
|
|
589
|
+
unordered_set<SchemaCatalogEntry *> schemas;
|
|
590
|
+
for (auto &lookup : lookups) {
|
|
591
|
+
auto transaction = lookup.catalog.GetCatalogTransaction(context);
|
|
592
|
+
auto result = lookup.catalog.LookupEntryInternal(transaction, type, lookup.schema, name);
|
|
593
|
+
if (result.Found()) {
|
|
594
|
+
return result;
|
|
595
|
+
}
|
|
596
|
+
if (result.schema) {
|
|
597
|
+
schemas.insert(result.schema);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
if (if_exists) {
|
|
601
|
+
return {nullptr, nullptr};
|
|
602
|
+
}
|
|
603
|
+
throw CreateMissingEntryException(context, name, type, schemas, error_context);
|
|
308
604
|
}
|
|
309
605
|
|
|
310
606
|
CatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema, const string &name) {
|
|
@@ -325,75 +621,101 @@ CatalogEntry *Catalog::GetEntry(ClientContext &context, CatalogType type, const
|
|
|
325
621
|
return LookupEntry(context, type, schema_name, name, if_exists, error_context).entry;
|
|
326
622
|
}
|
|
327
623
|
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
624
|
+
CatalogEntry *Catalog::GetEntry(ClientContext &context, CatalogType type, const string &catalog, const string &schema,
|
|
625
|
+
const string &name, bool if_exists_p, QueryErrorContext error_context) {
|
|
626
|
+
auto entries = GetCatalogEntries(context, catalog, schema);
|
|
627
|
+
vector<CatalogLookup> lookups;
|
|
628
|
+
lookups.reserve(entries.size());
|
|
629
|
+
for (auto &entry : entries) {
|
|
630
|
+
lookups.emplace_back(Catalog::GetCatalog(context, entry.catalog), entry.schema);
|
|
631
|
+
}
|
|
632
|
+
auto result = LookupEntry(context, lookups, type, name, if_exists_p, error_context);
|
|
633
|
+
if (!result.Found()) {
|
|
634
|
+
D_ASSERT(if_exists_p);
|
|
333
635
|
return nullptr;
|
|
334
636
|
}
|
|
335
|
-
|
|
336
|
-
|
|
637
|
+
return result.entry;
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
SchemaCatalogEntry *Catalog::GetSchema(ClientContext &context, const string &catalog_name, const string &schema_name,
|
|
641
|
+
bool if_exists_p, QueryErrorContext error_context) {
|
|
642
|
+
auto entries = GetCatalogEntries(context, catalog_name, schema_name);
|
|
643
|
+
SchemaCatalogEntry *result = nullptr;
|
|
644
|
+
for (idx_t i = 0; i < entries.size(); i++) {
|
|
645
|
+
auto if_exists = i + 1 == entries.size() ? if_exists_p : true;
|
|
646
|
+
auto &catalog = Catalog::GetCatalog(context, entries[i].catalog);
|
|
647
|
+
auto result = catalog.GetSchema(context, schema_name, if_exists, error_context);
|
|
648
|
+
if (result) {
|
|
649
|
+
return result;
|
|
650
|
+
}
|
|
337
651
|
}
|
|
338
|
-
return
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
template <>
|
|
342
|
-
SequenceCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name, const string &name,
|
|
343
|
-
bool if_exists, QueryErrorContext error_context) {
|
|
344
|
-
return (SequenceCatalogEntry *)GetEntry(context, CatalogType::SEQUENCE_ENTRY, schema_name, name, if_exists,
|
|
345
|
-
error_context);
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
template <>
|
|
349
|
-
TableFunctionCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name, const string &name,
|
|
350
|
-
bool if_exists, QueryErrorContext error_context) {
|
|
351
|
-
return (TableFunctionCatalogEntry *)GetEntry(context, CatalogType::TABLE_FUNCTION_ENTRY, schema_name, name,
|
|
352
|
-
if_exists, error_context);
|
|
652
|
+
return result;
|
|
353
653
|
}
|
|
354
654
|
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
655
|
+
LogicalType Catalog::GetType(ClientContext &context, const string &catalog_name, const string &schema,
|
|
656
|
+
const string &name) {
|
|
657
|
+
CatalogEntry *entry;
|
|
658
|
+
entry = GetEntry(context, CatalogType::TYPE_ENTRY, catalog_name, schema, name, true);
|
|
659
|
+
if (!entry) {
|
|
660
|
+
// look in the system catalog
|
|
661
|
+
entry = GetEntry(context, CatalogType::TYPE_ENTRY, SYSTEM_CATALOG, schema, name, true);
|
|
662
|
+
if (!entry) {
|
|
663
|
+
// repeat the search to get the error
|
|
664
|
+
GetEntry(context, CatalogType::TYPE_ENTRY, catalog_name, schema, name);
|
|
665
|
+
throw InternalException("Catalog::GetType - second type lookup somehow succeeded!?");
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
auto type_entry = (TypeCatalogEntry *)entry;
|
|
669
|
+
auto result_type = type_entry->user_type;
|
|
670
|
+
LogicalType::SetCatalog(result_type, type_entry);
|
|
671
|
+
return result_type;
|
|
360
672
|
}
|
|
361
673
|
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
if_exists, error_context);
|
|
367
|
-
}
|
|
674
|
+
vector<SchemaCatalogEntry *> Catalog::GetSchemas(ClientContext &context, const string &catalog_name) {
|
|
675
|
+
vector<Catalog *> catalogs;
|
|
676
|
+
if (IsInvalidCatalog(catalog_name)) {
|
|
677
|
+
unordered_set<string> name;
|
|
368
678
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
679
|
+
auto &search_path = *context.client_data->catalog_search_path;
|
|
680
|
+
for (auto &entry : search_path.Get()) {
|
|
681
|
+
if (name.find(entry.catalog) != name.end()) {
|
|
682
|
+
continue;
|
|
683
|
+
}
|
|
684
|
+
name.insert(entry.catalog);
|
|
685
|
+
catalogs.push_back(&Catalog::GetCatalog(context, entry.catalog));
|
|
686
|
+
}
|
|
687
|
+
} else {
|
|
688
|
+
catalogs.push_back(&Catalog::GetCatalog(context, catalog_name));
|
|
375
689
|
}
|
|
376
|
-
|
|
690
|
+
vector<SchemaCatalogEntry *> result;
|
|
691
|
+
for (auto catalog : catalogs) {
|
|
692
|
+
auto schemas = catalog->schemas->GetEntries<SchemaCatalogEntry>(catalog->GetCatalogTransaction(context));
|
|
693
|
+
result.insert(result.end(), schemas.begin(), schemas.end());
|
|
694
|
+
}
|
|
695
|
+
return result;
|
|
377
696
|
}
|
|
378
697
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
bool if_exists, QueryErrorContext error_context) {
|
|
382
|
-
return (CollateCatalogEntry *)GetEntry(context, CatalogType::COLLATION_ENTRY, schema_name, name, if_exists,
|
|
383
|
-
error_context);
|
|
384
|
-
}
|
|
698
|
+
vector<SchemaCatalogEntry *> Catalog::GetAllSchemas(ClientContext &context) {
|
|
699
|
+
vector<SchemaCatalogEntry *> result;
|
|
385
700
|
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
701
|
+
auto &db_manager = DatabaseManager::Get(context);
|
|
702
|
+
auto databases = db_manager.GetDatabases(context);
|
|
703
|
+
for (auto database : databases) {
|
|
704
|
+
auto &catalog = database->GetCatalog();
|
|
705
|
+
auto new_schemas = catalog.schemas->GetEntries<SchemaCatalogEntry>(catalog.GetCatalogTransaction(context));
|
|
706
|
+
result.insert(result.end(), new_schemas.begin(), new_schemas.end());
|
|
707
|
+
}
|
|
708
|
+
sort(result.begin(), result.end(), [&](SchemaCatalogEntry *x, SchemaCatalogEntry *y) {
|
|
709
|
+
if (x->catalog->GetName() < y->catalog->GetName()) {
|
|
710
|
+
return true;
|
|
711
|
+
}
|
|
712
|
+
if (x->catalog->GetName() == y->catalog->GetName()) {
|
|
713
|
+
return x->name < y->name;
|
|
714
|
+
}
|
|
715
|
+
return false;
|
|
716
|
+
});
|
|
391
717
|
|
|
392
|
-
|
|
393
|
-
auto user_type_catalog = GetEntry<TypeCatalogEntry>(context, schema, name);
|
|
394
|
-
auto result_type = user_type_catalog->user_type;
|
|
395
|
-
LogicalType::SetCatalog(result_type, user_type_catalog);
|
|
396
|
-
return result_type;
|
|
718
|
+
return result;
|
|
397
719
|
}
|
|
398
720
|
|
|
399
721
|
void Catalog::Alter(ClientContext &context, AlterInfo *info) {
|
|
@@ -405,12 +727,29 @@ void Catalog::Alter(ClientContext &context, AlterInfo *info) {
|
|
|
405
727
|
return lookup.schema->Alter(context, info);
|
|
406
728
|
}
|
|
407
729
|
|
|
730
|
+
void Catalog::Verify() {
|
|
731
|
+
#ifdef DEBUG
|
|
732
|
+
schemas->Verify(*this);
|
|
733
|
+
#endif
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
//===--------------------------------------------------------------------===//
|
|
737
|
+
// Catalog Version
|
|
738
|
+
//===--------------------------------------------------------------------===//
|
|
408
739
|
idx_t Catalog::GetCatalogVersion() {
|
|
409
|
-
return catalog_version;
|
|
740
|
+
return GetDatabase().GetDatabaseManager().catalog_version;
|
|
410
741
|
}
|
|
411
742
|
|
|
412
743
|
idx_t Catalog::ModifyCatalog() {
|
|
413
|
-
return catalog_version++;
|
|
744
|
+
return GetDatabase().GetDatabaseManager().catalog_version++;
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
bool Catalog::IsSystemCatalog() const {
|
|
748
|
+
return db.IsSystem();
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
bool Catalog::IsTemporaryCatalog() const {
|
|
752
|
+
return db.IsTemporary();
|
|
414
753
|
}
|
|
415
754
|
|
|
416
755
|
} // namespace duckdb
|