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
|
@@ -7,21 +7,27 @@
|
|
|
7
7
|
#include "duckdb/main/database.hpp"
|
|
8
8
|
#include "duckdb/parser/expression/constant_expression.hpp"
|
|
9
9
|
#include "duckdb/catalog/mapping_value.hpp"
|
|
10
|
+
#include "duckdb/catalog/dependency_list.hpp"
|
|
10
11
|
|
|
11
12
|
namespace duckdb {
|
|
12
13
|
|
|
13
14
|
DependencyManager::DependencyManager(Catalog &catalog) : catalog(catalog) {
|
|
14
15
|
}
|
|
15
16
|
|
|
16
|
-
void DependencyManager::AddObject(
|
|
17
|
-
unordered_set<CatalogEntry *> &dependencies) {
|
|
17
|
+
void DependencyManager::AddObject(CatalogTransaction transaction, CatalogEntry *object, DependencyList &dependencies) {
|
|
18
18
|
// check for each object in the sources if they were not deleted yet
|
|
19
|
-
for (auto &dependency : dependencies) {
|
|
19
|
+
for (auto &dependency : dependencies.set) {
|
|
20
20
|
CatalogEntry *catalog_entry;
|
|
21
|
+
if (dependency->catalog != object->catalog) {
|
|
22
|
+
throw DependencyException(
|
|
23
|
+
"Error adding dependency for object \"%s\" - dependency \"%s\" is in catalog "
|
|
24
|
+
"\"%s\", which does not match the catalog \"%s\".\nCross catalog dependencies are not supported.",
|
|
25
|
+
object->name, dependency->name, dependency->catalog->GetName(), object->catalog->GetName());
|
|
26
|
+
}
|
|
21
27
|
if (!dependency->set) {
|
|
22
28
|
throw InternalException("Dependency has no set");
|
|
23
29
|
}
|
|
24
|
-
if (!dependency->set->GetEntryInternal(
|
|
30
|
+
if (!dependency->set->GetEntryInternal(transaction, dependency->name, nullptr, catalog_entry)) {
|
|
25
31
|
throw InternalException("Dependency has already been deleted?");
|
|
26
32
|
}
|
|
27
33
|
}
|
|
@@ -29,15 +35,15 @@ void DependencyManager::AddObject(ClientContext &context, CatalogEntry *object,
|
|
|
29
35
|
auto dependency_type = object->type == CatalogType::INDEX_ENTRY ? DependencyType::DEPENDENCY_AUTOMATIC
|
|
30
36
|
: DependencyType::DEPENDENCY_REGULAR;
|
|
31
37
|
// add the object to the dependents_map of each object that it depends on
|
|
32
|
-
for (auto &dependency : dependencies) {
|
|
38
|
+
for (auto &dependency : dependencies.set) {
|
|
33
39
|
dependents_map[dependency].insert(Dependency(object, dependency_type));
|
|
34
40
|
}
|
|
35
41
|
// create the dependents map for this object: it starts out empty
|
|
36
42
|
dependents_map[object] = dependency_set_t();
|
|
37
|
-
dependencies_map[object] = dependencies;
|
|
43
|
+
dependencies_map[object] = dependencies.set;
|
|
38
44
|
}
|
|
39
45
|
|
|
40
|
-
void DependencyManager::DropObject(
|
|
46
|
+
void DependencyManager::DropObject(CatalogTransaction transaction, CatalogEntry *object, bool cascade) {
|
|
41
47
|
D_ASSERT(dependents_map.find(object) != dependents_map.end());
|
|
42
48
|
|
|
43
49
|
// first check the objects that depend on this object
|
|
@@ -45,13 +51,13 @@ void DependencyManager::DropObject(ClientContext &context, CatalogEntry *object,
|
|
|
45
51
|
for (auto &dep : dependent_objects) {
|
|
46
52
|
// look up the entry in the catalog set
|
|
47
53
|
auto &catalog_set = *dep.entry->set;
|
|
48
|
-
auto mapping_value = catalog_set.GetMapping(
|
|
54
|
+
auto mapping_value = catalog_set.GetMapping(transaction, dep.entry->name, true /* get_latest */);
|
|
49
55
|
if (mapping_value == nullptr) {
|
|
50
56
|
continue;
|
|
51
57
|
}
|
|
52
58
|
CatalogEntry *dependency_entry;
|
|
53
59
|
|
|
54
|
-
if (!catalog_set.GetEntryInternal(
|
|
60
|
+
if (!catalog_set.GetEntryInternal(transaction, mapping_value->index, dependency_entry)) {
|
|
55
61
|
// the dependent object was already deleted, no conflict
|
|
56
62
|
continue;
|
|
57
63
|
}
|
|
@@ -59,7 +65,7 @@ void DependencyManager::DropObject(ClientContext &context, CatalogEntry *object,
|
|
|
59
65
|
if (cascade || dep.dependency_type == DependencyType::DEPENDENCY_AUTOMATIC ||
|
|
60
66
|
dep.dependency_type == DependencyType::DEPENDENCY_OWNS) {
|
|
61
67
|
// cascade: drop the dependent object
|
|
62
|
-
catalog_set.DropEntryInternal(
|
|
68
|
+
catalog_set.DropEntryInternal(transaction, mapping_value->index.Copy(), *dependency_entry, cascade);
|
|
63
69
|
} else {
|
|
64
70
|
// no cascade and there are objects that depend on this object: throw error
|
|
65
71
|
throw DependencyException("Cannot drop entry \"%s\" because there are entries that "
|
|
@@ -69,7 +75,7 @@ void DependencyManager::DropObject(ClientContext &context, CatalogEntry *object,
|
|
|
69
75
|
}
|
|
70
76
|
}
|
|
71
77
|
|
|
72
|
-
void DependencyManager::AlterObject(
|
|
78
|
+
void DependencyManager::AlterObject(CatalogTransaction transaction, CatalogEntry *old_obj, CatalogEntry *new_obj) {
|
|
73
79
|
D_ASSERT(dependents_map.find(old_obj) != dependents_map.end());
|
|
74
80
|
D_ASSERT(dependencies_map.find(old_obj) != dependencies_map.end());
|
|
75
81
|
|
|
@@ -80,7 +86,7 @@ void DependencyManager::AlterObject(ClientContext &context, CatalogEntry *old_ob
|
|
|
80
86
|
// look up the entry in the catalog set
|
|
81
87
|
auto &catalog_set = *dep.entry->set;
|
|
82
88
|
CatalogEntry *dependency_entry;
|
|
83
|
-
if (!catalog_set.GetEntryInternal(
|
|
89
|
+
if (!catalog_set.GetEntryInternal(transaction, dep.entry->name, nullptr, dependency_entry)) {
|
|
84
90
|
// the dependent object was already deleted, no conflict
|
|
85
91
|
continue;
|
|
86
92
|
}
|
|
@@ -182,7 +188,7 @@ void DependencyManager::Scan(const std::function<void(CatalogEntry *, CatalogEnt
|
|
|
182
188
|
}
|
|
183
189
|
}
|
|
184
190
|
|
|
185
|
-
void DependencyManager::AddOwnership(
|
|
191
|
+
void DependencyManager::AddOwnership(CatalogTransaction transaction, CatalogEntry *owner, CatalogEntry *entry) {
|
|
186
192
|
// lock the catalog for writing
|
|
187
193
|
lock_guard<mutex> write_lock(catalog.write_lock);
|
|
188
194
|
|
|
@@ -27,6 +27,14 @@ uint64_t NextPowerOfTwo(uint64_t v) {
|
|
|
27
27
|
return v;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
bool IsInvalidSchema(const string &str) {
|
|
31
|
+
return str.empty();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
bool IsInvalidCatalog(const string &str) {
|
|
35
|
+
return str.empty();
|
|
36
|
+
}
|
|
37
|
+
|
|
30
38
|
bool IsRowIdColumnId(column_t column_id) {
|
|
31
39
|
return column_id == COLUMN_IDENTIFIER_ROW_ID;
|
|
32
40
|
}
|
|
@@ -15,6 +15,8 @@ string CatalogTypeToString(CatalogType type) {
|
|
|
15
15
|
return "Table";
|
|
16
16
|
case CatalogType::SCHEMA_ENTRY:
|
|
17
17
|
return "Schema";
|
|
18
|
+
case CatalogType::DATABASE_ENTRY:
|
|
19
|
+
return "Database";
|
|
18
20
|
case CatalogType::TABLE_FUNCTION_ENTRY:
|
|
19
21
|
return "Table Function";
|
|
20
22
|
case CatalogType::SCALAR_FUNCTION_ENTRY:
|
|
@@ -96,6 +96,8 @@ string LogicalOperatorToString(LogicalOperatorType type) {
|
|
|
96
96
|
return "CREATE_VIEW";
|
|
97
97
|
case LogicalOperatorType::LOGICAL_CREATE_SCHEMA:
|
|
98
98
|
return "CREATE_SCHEMA";
|
|
99
|
+
case LogicalOperatorType::LOGICAL_ATTACH:
|
|
100
|
+
return "ATTACH";
|
|
99
101
|
case LogicalOperatorType::LOGICAL_DROP:
|
|
100
102
|
return "DROP";
|
|
101
103
|
case LogicalOperatorType::LOGICAL_PRAGMA:
|
|
@@ -127,6 +127,8 @@ string PhysicalOperatorToString(PhysicalOperatorType type) {
|
|
|
127
127
|
return "INOUT_FUNCTION";
|
|
128
128
|
case PhysicalOperatorType::CREATE_TYPE:
|
|
129
129
|
return "CREATE_TYPE";
|
|
130
|
+
case PhysicalOperatorType::ATTACH:
|
|
131
|
+
return "ATTACH";
|
|
130
132
|
case PhysicalOperatorType::RESULT_COLLECTOR:
|
|
131
133
|
return "RESULT_COLLECTOR";
|
|
132
134
|
case PhysicalOperatorType::INVALID:
|
|
@@ -55,6 +55,8 @@ string StatementTypeToString(StatementType type) {
|
|
|
55
55
|
return "EXTENSION";
|
|
56
56
|
case StatementType::LOGICAL_PLAN_STATEMENT:
|
|
57
57
|
return "LOGICAL_PLAN";
|
|
58
|
+
case StatementType::ATTACH_STATEMENT:
|
|
59
|
+
return "ATTACH";
|
|
58
60
|
case StatementType::INVALID_STATEMENT:
|
|
59
61
|
break;
|
|
60
62
|
}
|
|
@@ -39,7 +39,7 @@ FileSystem::~FileSystem() {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
FileSystem &FileSystem::GetFileSystem(ClientContext &context) {
|
|
42
|
-
return *context.db
|
|
42
|
+
return FileSystem::GetFileSystem(*context.db);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
FileOpener *FileSystem::GetFileOpener(ClientContext &context) {
|
|
@@ -19,7 +19,7 @@ bool StringUtil::Contains(const string &haystack, const string &needle) {
|
|
|
19
19
|
|
|
20
20
|
void StringUtil::LTrim(string &str) {
|
|
21
21
|
auto it = str.begin();
|
|
22
|
-
while (CharacterIsSpace(*it)) {
|
|
22
|
+
while (it != str.end() && CharacterIsSpace(*it)) {
|
|
23
23
|
it++;
|
|
24
24
|
}
|
|
25
25
|
str.erase(str.begin(), it);
|
|
@@ -165,6 +165,10 @@ string StringUtil::Lower(const string &str) {
|
|
|
165
165
|
return (copy);
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
+
bool StringUtil::CIEquals(const string &l1, const string &l2) {
|
|
169
|
+
return StringUtil::Lower(l1) == StringUtil::Lower(l2);
|
|
170
|
+
}
|
|
171
|
+
|
|
168
172
|
vector<string> StringUtil::Split(const string &input, const string &split) {
|
|
169
173
|
vector<string> splits;
|
|
170
174
|
|
|
@@ -14,7 +14,7 @@ namespace duckdb {
|
|
|
14
14
|
|
|
15
15
|
ART::ART(const vector<column_t> &column_ids, TableIOManager &table_io_manager,
|
|
16
16
|
const vector<unique_ptr<Expression>> &unbound_expressions, IndexConstraintType constraint_type,
|
|
17
|
-
|
|
17
|
+
AttachedDatabase &db, idx_t block_id, idx_t block_offset)
|
|
18
18
|
: Index(IndexType::ART, table_io_manager, column_ids, unbound_expressions, constraint_type), db(db),
|
|
19
19
|
estimated_art_size(0), estimated_key_size(16) {
|
|
20
20
|
if (!Radix::IsLittleEndian()) {
|
|
@@ -98,9 +98,9 @@ unique_ptr<OperatorState> PhysicalIndexJoin::GetOperatorState(ExecutionContext &
|
|
|
98
98
|
|
|
99
99
|
void PhysicalIndexJoin::Output(ExecutionContext &context, DataChunk &input, DataChunk &chunk,
|
|
100
100
|
OperatorState &state_p) const {
|
|
101
|
-
auto &transaction = Transaction::GetTransaction(context.client);
|
|
102
101
|
auto &phy_tbl_scan = (PhysicalTableScan &)*children[1];
|
|
103
102
|
auto &bind_tbl = (TableScanBindData &)*phy_tbl_scan.bind_data;
|
|
103
|
+
auto &transaction = Transaction::Get(context.client, *bind_tbl.table->catalog);
|
|
104
104
|
auto &state = (IndexJoinOperatorState &)state_p;
|
|
105
105
|
|
|
106
106
|
auto tbl = bind_tbl.table->storage.get();
|
|
@@ -264,8 +264,9 @@ unique_ptr<GlobalSinkState> PhysicalBatchInsert::GetGlobalSinkState(ClientContex
|
|
|
264
264
|
if (info) {
|
|
265
265
|
// CREATE TABLE AS
|
|
266
266
|
D_ASSERT(!insert_table);
|
|
267
|
-
auto &catalog =
|
|
268
|
-
result->table =
|
|
267
|
+
auto &catalog = *schema->catalog;
|
|
268
|
+
result->table =
|
|
269
|
+
(TableCatalogEntry *)catalog.CreateTable(catalog.GetCatalogTransaction(context), schema, info.get());
|
|
269
270
|
} else {
|
|
270
271
|
D_ASSERT(insert_table);
|
|
271
272
|
result->table = insert_table;
|
|
@@ -37,7 +37,7 @@ SinkResultType PhysicalDelete::Sink(ExecutionContext &context, GlobalSinkState &
|
|
|
37
37
|
auto &ustate = (DeleteLocalState &)lstate;
|
|
38
38
|
|
|
39
39
|
// get rows and
|
|
40
|
-
auto &transaction = Transaction::
|
|
40
|
+
auto &transaction = Transaction::Get(context.client, table.db);
|
|
41
41
|
auto &row_identifiers = input.data[row_id_index];
|
|
42
42
|
|
|
43
43
|
vector<column_t> column_ids;
|
|
@@ -115,7 +115,7 @@ void PhysicalExport::GetData(ExecutionContext &context, DataChunk &chunk, Global
|
|
|
115
115
|
vector<CatalogEntry *> indexes;
|
|
116
116
|
vector<CatalogEntry *> macros;
|
|
117
117
|
|
|
118
|
-
auto schema_list = Catalog::
|
|
118
|
+
auto schema_list = Catalog::GetSchemas(ccontext, info->catalog);
|
|
119
119
|
for (auto &schema : schema_list) {
|
|
120
120
|
if (!schema->internal) {
|
|
121
121
|
schemas.push_back(schema);
|
|
@@ -75,8 +75,9 @@ unique_ptr<GlobalSinkState> PhysicalInsert::GetGlobalSinkState(ClientContext &co
|
|
|
75
75
|
if (info) {
|
|
76
76
|
// CREATE TABLE AS
|
|
77
77
|
D_ASSERT(!insert_table);
|
|
78
|
-
auto &catalog =
|
|
79
|
-
result->table =
|
|
78
|
+
auto &catalog = *schema->catalog;
|
|
79
|
+
result->table =
|
|
80
|
+
(TableCatalogEntry *)catalog.CreateTable(catalog.GetCatalogTransaction(context), schema, info.get());
|
|
80
81
|
} else {
|
|
81
82
|
D_ASSERT(insert_table);
|
|
82
83
|
result->table = insert_table;
|
|
@@ -188,7 +189,7 @@ void PhysicalInsert::Combine(ExecutionContext &context, GlobalSinkState &gstate_
|
|
|
188
189
|
gstate.insert_count += append_count;
|
|
189
190
|
auto table = gstate.table;
|
|
190
191
|
table->storage->InitializeLocalAppend(gstate.append_state, context.client);
|
|
191
|
-
auto &transaction = Transaction::
|
|
192
|
+
auto &transaction = Transaction::Get(context.client, *table->catalog);
|
|
192
193
|
lstate.local_collection->Scan(transaction, [&](DataChunk &insert_chunk) {
|
|
193
194
|
table->storage->LocalAppend(gstate.append_state, *table, context.client, insert_chunk);
|
|
194
195
|
return true;
|
|
@@ -25,7 +25,7 @@ void PhysicalAlter::GetData(ExecutionContext &context, DataChunk &chunk, GlobalS
|
|
|
25
25
|
if (state.finished) {
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
|
-
auto &catalog = Catalog::GetCatalog(context.client);
|
|
28
|
+
auto &catalog = Catalog::GetCatalog(context.client, info->catalog);
|
|
29
29
|
catalog.Alter(context.client, info.get());
|
|
30
30
|
state.finished = true;
|
|
31
31
|
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
#include "duckdb/execution/operator/schema/physical_attach.hpp"
|
|
2
|
+
#include "duckdb/parser/parsed_data/attach_info.hpp"
|
|
3
|
+
#include "duckdb/catalog/catalog.hpp"
|
|
4
|
+
#include "duckdb/main/database_manager.hpp"
|
|
5
|
+
#include "duckdb/main/attached_database.hpp"
|
|
6
|
+
#include "duckdb/main/database.hpp"
|
|
7
|
+
|
|
8
|
+
namespace duckdb {
|
|
9
|
+
|
|
10
|
+
//===--------------------------------------------------------------------===//
|
|
11
|
+
// Source
|
|
12
|
+
//===--------------------------------------------------------------------===//
|
|
13
|
+
class AttachSourceState : public GlobalSourceState {
|
|
14
|
+
public:
|
|
15
|
+
AttachSourceState() : finished(false) {
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
bool finished;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
unique_ptr<GlobalSourceState> PhysicalAttach::GetGlobalSourceState(ClientContext &context) const {
|
|
22
|
+
return make_unique<AttachSourceState>();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
void PhysicalAttach::GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
|
|
26
|
+
LocalSourceState &lstate) const {
|
|
27
|
+
auto &state = (AttachSourceState &)gstate;
|
|
28
|
+
if (state.finished) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
// parse the options
|
|
32
|
+
auto &config = DBConfig::GetConfig(context.client);
|
|
33
|
+
AccessMode access_mode = config.options.access_mode;
|
|
34
|
+
for (auto &entry : info->options) {
|
|
35
|
+
if (entry.first == "readonly" || entry.first == "read_only") {
|
|
36
|
+
auto read_only = BooleanValue::Get(entry.second.DefaultCastAs(LogicalType::BOOLEAN));
|
|
37
|
+
if (read_only) {
|
|
38
|
+
access_mode = AccessMode::READ_ONLY;
|
|
39
|
+
} else {
|
|
40
|
+
access_mode = AccessMode::READ_WRITE;
|
|
41
|
+
}
|
|
42
|
+
} else if (entry.first == "read_write" || entry.first == "read_write") {
|
|
43
|
+
auto read_only = !BooleanValue::Get(entry.second.DefaultCastAs(LogicalType::BOOLEAN));
|
|
44
|
+
if (read_only) {
|
|
45
|
+
access_mode = AccessMode::READ_ONLY;
|
|
46
|
+
} else {
|
|
47
|
+
access_mode = AccessMode::READ_WRITE;
|
|
48
|
+
}
|
|
49
|
+
} else {
|
|
50
|
+
throw BinderException("Unrecognized option for attach \"%s\"", entry.first);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
// attach the database
|
|
54
|
+
auto name = info->name;
|
|
55
|
+
auto path = info->path;
|
|
56
|
+
auto &db = DatabaseInstance::GetDatabase(context.client);
|
|
57
|
+
if (name.empty()) {
|
|
58
|
+
name = AttachedDatabase::ExtractDatabaseName(path);
|
|
59
|
+
}
|
|
60
|
+
auto &db_manager = DatabaseManager::Get(context.client);
|
|
61
|
+
auto existing_db = db_manager.GetDatabaseFromPath(context.client, path);
|
|
62
|
+
if (existing_db) {
|
|
63
|
+
throw BinderException("Database \"%s\" is already attached with alias \"%s\"", path, existing_db->GetName());
|
|
64
|
+
}
|
|
65
|
+
auto new_db = make_unique<AttachedDatabase>(db, Catalog::GetSystemCatalog(context.client), name, path, access_mode);
|
|
66
|
+
new_db->Initialize();
|
|
67
|
+
|
|
68
|
+
db_manager.AddDatabase(context.client, move(new_db));
|
|
69
|
+
state.finished = true;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
} // namespace duckdb
|
|
@@ -26,7 +26,8 @@ void PhysicalCreateFunction::GetData(ExecutionContext &context, DataChunk &chunk
|
|
|
26
26
|
if (state.finished) {
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
|
-
Catalog::GetCatalog(context.client
|
|
29
|
+
auto &catalog = Catalog::GetCatalog(context.client, info->catalog);
|
|
30
|
+
catalog.CreateFunction(context.client, info.get());
|
|
30
31
|
state.finished = true;
|
|
31
32
|
}
|
|
32
33
|
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
#include "duckdb/execution/expression_executor.hpp"
|
|
7
7
|
#include "duckdb/main/client_context.hpp"
|
|
8
8
|
#include "duckdb/storage/storage_manager.hpp"
|
|
9
|
+
#include "duckdb/main/database_manager.hpp"
|
|
9
10
|
|
|
10
11
|
namespace duckdb {
|
|
11
12
|
|
|
@@ -38,14 +39,13 @@ public:
|
|
|
38
39
|
};
|
|
39
40
|
|
|
40
41
|
unique_ptr<GlobalSinkState> PhysicalCreateIndex::GetGlobalSinkState(ClientContext &context) const {
|
|
41
|
-
|
|
42
42
|
auto state = make_unique<CreateIndexGlobalSinkState>();
|
|
43
43
|
|
|
44
44
|
// create the global index
|
|
45
45
|
switch (info->index_type) {
|
|
46
46
|
case IndexType::ART: {
|
|
47
47
|
state->global_index = make_unique<ART>(storage_ids, TableIOManager::Get(*table.storage), unbound_expressions,
|
|
48
|
-
info->constraint_type,
|
|
48
|
+
info->constraint_type, table.storage->db);
|
|
49
49
|
break;
|
|
50
50
|
}
|
|
51
51
|
default:
|
|
@@ -64,7 +64,7 @@ unique_ptr<LocalSinkState> PhysicalCreateIndex::GetLocalSinkState(ExecutionConte
|
|
|
64
64
|
switch (info->index_type) {
|
|
65
65
|
case IndexType::ART: {
|
|
66
66
|
state->local_index = make_unique<ART>(storage_ids, TableIOManager::Get(*table.storage), unbound_expressions,
|
|
67
|
-
info->constraint_type,
|
|
67
|
+
info->constraint_type, table.storage->db);
|
|
68
68
|
break;
|
|
69
69
|
}
|
|
70
70
|
default:
|
|
@@ -24,7 +24,11 @@ void PhysicalCreateSchema::GetData(ExecutionContext &context, DataChunk &chunk,
|
|
|
24
24
|
if (state.finished) {
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
|
-
Catalog::GetCatalog(context.client
|
|
27
|
+
auto &catalog = Catalog::GetCatalog(context.client, info->catalog);
|
|
28
|
+
if (catalog.IsSystemCatalog()) {
|
|
29
|
+
throw BinderException("Cannot create schema in system catalog");
|
|
30
|
+
}
|
|
31
|
+
catalog.CreateSchema(context.client, info.get());
|
|
28
32
|
state.finished = true;
|
|
29
33
|
}
|
|
30
34
|
|
|
@@ -24,7 +24,8 @@ void PhysicalCreateSequence::GetData(ExecutionContext &context, DataChunk &chunk
|
|
|
24
24
|
if (state.finished) {
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
|
-
Catalog::GetCatalog(context.client
|
|
27
|
+
auto &catalog = Catalog::GetCatalog(context.client, info->catalog);
|
|
28
|
+
catalog.CreateSequence(context.client, info.get());
|
|
28
29
|
state.finished = true;
|
|
29
30
|
}
|
|
30
31
|
|
|
@@ -34,8 +34,8 @@ void PhysicalCreateTable::GetData(ExecutionContext &context, DataChunk &chunk, G
|
|
|
34
34
|
if (state.finished) {
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
|
-
auto &catalog =
|
|
38
|
-
catalog.CreateTable(context.client, schema, info.get());
|
|
37
|
+
auto &catalog = *schema->catalog;
|
|
38
|
+
catalog.CreateTable(catalog.GetCatalogTransaction(context.client), schema, info.get());
|
|
39
39
|
state.finished = true;
|
|
40
40
|
}
|
|
41
41
|
|
|
@@ -108,7 +108,7 @@ void PhysicalCreateType::GetData(ExecutionContext &context, DataChunk &chunk, Gl
|
|
|
108
108
|
info->type = LogicalType::ENUM(info->name, result, total_row_count);
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
auto &catalog = Catalog::GetCatalog(context.client);
|
|
111
|
+
auto &catalog = Catalog::GetCatalog(context.client, info->catalog);
|
|
112
112
|
catalog.CreateType(context.client, info.get());
|
|
113
113
|
state.finished = true;
|
|
114
114
|
}
|
|
@@ -24,7 +24,8 @@ void PhysicalCreateView::GetData(ExecutionContext &context, DataChunk &chunk, Gl
|
|
|
24
24
|
if (state.finished) {
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
|
-
Catalog::GetCatalog(context.client
|
|
27
|
+
auto &catalog = Catalog::GetCatalog(context.client, info->catalog);
|
|
28
|
+
catalog.CreateView(context.client, info.get());
|
|
28
29
|
state.finished = true;
|
|
29
30
|
}
|
|
30
31
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#include "duckdb/execution/operator/schema/physical_drop.hpp"
|
|
2
2
|
#include "duckdb/main/client_data.hpp"
|
|
3
|
+
#include "duckdb/main/database_manager.hpp"
|
|
3
4
|
|
|
4
5
|
namespace duckdb {
|
|
5
6
|
|
|
@@ -33,10 +34,17 @@ void PhysicalDrop::GetData(ExecutionContext &context, DataChunk &chunk, GlobalSo
|
|
|
33
34
|
}
|
|
34
35
|
break;
|
|
35
36
|
}
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
case CatalogType::DATABASE_ENTRY: {
|
|
38
|
+
auto &db_manager = DatabaseManager::Get(context.client);
|
|
39
|
+
db_manager.DetachDatabase(context.client, info->name, info->if_exists);
|
|
38
40
|
break;
|
|
39
41
|
}
|
|
42
|
+
default: {
|
|
43
|
+
auto &catalog = Catalog::GetCatalog(context.client, info->catalog);
|
|
44
|
+
catalog.DropEntry(context.client, info.get());
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
40
48
|
state.finished = true;
|
|
41
49
|
}
|
|
42
50
|
|
|
@@ -18,12 +18,13 @@
|
|
|
18
18
|
|
|
19
19
|
namespace duckdb {
|
|
20
20
|
|
|
21
|
-
static bool CanPlanIndexJoin(
|
|
21
|
+
static bool CanPlanIndexJoin(ClientContext &context, TableScanBindData *bind_data, PhysicalTableScan &scan) {
|
|
22
22
|
if (!bind_data) {
|
|
23
23
|
// not a table scan
|
|
24
24
|
return false;
|
|
25
25
|
}
|
|
26
26
|
auto table = bind_data->table;
|
|
27
|
+
auto &transaction = Transaction::Get(context, *table->catalog);
|
|
27
28
|
auto &local_storage = LocalStorage::Get(transaction);
|
|
28
29
|
if (local_storage.Find(table->storage.get())) {
|
|
29
30
|
// transaction local appends: skip index join
|
|
@@ -146,7 +147,6 @@ static void CanUseIndexJoin(TableScanBindData *tbl, Expression &expr, Index **re
|
|
|
146
147
|
|
|
147
148
|
void TransformIndexJoin(ClientContext &context, LogicalComparisonJoin &op, Index **left_index, Index **right_index,
|
|
148
149
|
PhysicalOperator *left, PhysicalOperator *right) {
|
|
149
|
-
auto &transaction = Transaction::GetTransaction(context);
|
|
150
150
|
// check if one of the tables has an index on column
|
|
151
151
|
if (op.join_type == JoinType::INNER && op.conditions.size() == 1) {
|
|
152
152
|
// check if one of the children are table scans and if they have an index in the join attribute
|
|
@@ -154,14 +154,14 @@ void TransformIndexJoin(ClientContext &context, LogicalComparisonJoin &op, Index
|
|
|
154
154
|
if (left->type == PhysicalOperatorType::TABLE_SCAN) {
|
|
155
155
|
auto &tbl_scan = (PhysicalTableScan &)*left;
|
|
156
156
|
auto tbl = dynamic_cast<TableScanBindData *>(tbl_scan.bind_data.get());
|
|
157
|
-
if (CanPlanIndexJoin(
|
|
157
|
+
if (CanPlanIndexJoin(context, tbl, tbl_scan)) {
|
|
158
158
|
CanUseIndexJoin(tbl, *op.conditions[0].left, left_index);
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
161
|
if (right->type == PhysicalOperatorType::TABLE_SCAN) {
|
|
162
162
|
auto &tbl_scan = (PhysicalTableScan &)*right;
|
|
163
163
|
auto tbl = dynamic_cast<TableScanBindData *>(tbl_scan.bind_data.get());
|
|
164
|
-
if (CanPlanIndexJoin(
|
|
164
|
+
if (CanPlanIndexJoin(context, tbl, tbl_scan)) {
|
|
165
165
|
CanUseIndexJoin(tbl, *op.conditions[0].right, right_index);
|
|
166
166
|
}
|
|
167
167
|
}
|
|
@@ -25,7 +25,7 @@ unique_ptr<PhysicalOperator> PhysicalPlanGenerator::CreatePlan(LogicalCreateInde
|
|
|
25
25
|
make_unique<PhysicalTableScan>(op.info->scan_types, op.function, move(op.bind_data), op.info->column_ids,
|
|
26
26
|
op.info->names, move(table_filters), op.estimated_cardinality);
|
|
27
27
|
|
|
28
|
-
dependencies.
|
|
28
|
+
dependencies.AddDependency(&op.table);
|
|
29
29
|
op.info->column_ids.pop_back();
|
|
30
30
|
|
|
31
31
|
D_ASSERT(op.info->scan_types.size() - 1 <= op.info->names.size());
|
|
@@ -14,9 +14,8 @@ namespace duckdb {
|
|
|
14
14
|
|
|
15
15
|
unique_ptr<PhysicalOperator> PhysicalPlanGenerator::CreatePlan(LogicalCreateTable &op) {
|
|
16
16
|
auto &create_info = (CreateTableInfo &)*op.info->base;
|
|
17
|
-
auto &catalog =
|
|
18
|
-
auto existing_entry =
|
|
19
|
-
catalog.GetEntry(context, CatalogType::TABLE_ENTRY, create_info.schema, create_info.table, true);
|
|
17
|
+
auto &catalog = *op.info->schema->catalog;
|
|
18
|
+
auto existing_entry = catalog.GetEntry<TableCatalogEntry>(context, create_info.schema, create_info.table, true);
|
|
20
19
|
bool replace = op.info->Base().on_conflict == OnCreateConflict::REPLACE_ON_CONFLICT;
|
|
21
20
|
if ((!existing_entry || replace) && !op.children.empty()) {
|
|
22
21
|
auto plan = CreatePlan(*op.children[0]);
|
|
@@ -16,7 +16,7 @@ unique_ptr<PhysicalOperator> PhysicalPlanGenerator::CreatePlan(LogicalDelete &op
|
|
|
16
16
|
// get the index of the row_id column
|
|
17
17
|
auto &bound_ref = (BoundReferenceExpression &)*op.expressions[0];
|
|
18
18
|
|
|
19
|
-
dependencies.
|
|
19
|
+
dependencies.AddDependency(op.table);
|
|
20
20
|
auto del = make_unique<PhysicalDelete>(op.types, *op.table, *op.table->storage, bound_ref.index,
|
|
21
21
|
op.estimated_cardinality, op.return_chunk);
|
|
22
22
|
del->children.push_back(move(plan));
|
|
@@ -50,7 +50,7 @@ unique_ptr<PhysicalOperator> PhysicalPlanGenerator::CreatePlan(LogicalInsert &op
|
|
|
50
50
|
D_ASSERT(op.children.size() == 1);
|
|
51
51
|
plan = CreatePlan(*op.children[0]);
|
|
52
52
|
}
|
|
53
|
-
dependencies.
|
|
53
|
+
dependencies.AddDependency(op.table);
|
|
54
54
|
|
|
55
55
|
bool parallel_streaming_insert = !PreserveInsertionOrder(*plan);
|
|
56
56
|
bool use_batch_index = UseBatchIndex(*plan);
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
#include "duckdb/execution/operator/helper/physical_transaction.hpp"
|
|
3
3
|
#include "duckdb/execution/operator/helper/physical_vacuum.hpp"
|
|
4
4
|
#include "duckdb/execution/operator/schema/physical_alter.hpp"
|
|
5
|
+
#include "duckdb/execution/operator/schema/physical_attach.hpp"
|
|
5
6
|
#include "duckdb/execution/operator/schema/physical_create_schema.hpp"
|
|
6
7
|
#include "duckdb/execution/operator/schema/physical_create_sequence.hpp"
|
|
7
8
|
#include "duckdb/execution/operator/schema/physical_create_view.hpp"
|
|
@@ -33,6 +34,9 @@ unique_ptr<PhysicalOperator> PhysicalPlanGenerator::CreatePlan(LogicalSimple &op
|
|
|
33
34
|
}
|
|
34
35
|
case LogicalOperatorType::LOGICAL_LOAD:
|
|
35
36
|
return make_unique<PhysicalLoad>(unique_ptr_cast<ParseInfo, LoadInfo>(move(op.info)), op.estimated_cardinality);
|
|
37
|
+
case LogicalOperatorType::LOGICAL_ATTACH:
|
|
38
|
+
return make_unique<PhysicalAttach>(unique_ptr_cast<ParseInfo, AttachInfo>(move(op.info)),
|
|
39
|
+
op.estimated_cardinality);
|
|
36
40
|
default:
|
|
37
41
|
throw NotImplementedException("Unimplemented type for logical simple operator");
|
|
38
42
|
}
|
|
@@ -10,7 +10,7 @@ unique_ptr<PhysicalOperator> PhysicalPlanGenerator::CreatePlan(LogicalUpdate &op
|
|
|
10
10
|
|
|
11
11
|
auto plan = CreatePlan(*op.children[0]);
|
|
12
12
|
|
|
13
|
-
dependencies.
|
|
13
|
+
dependencies.AddDependency(op.table);
|
|
14
14
|
auto update = make_unique<PhysicalUpdate>(op.types, *op.table, *op.table->storage, op.columns, move(op.expressions),
|
|
15
15
|
move(op.bound_defaults), op.estimated_cardinality, op.return_chunk);
|
|
16
16
|
|
|
@@ -13,7 +13,7 @@ namespace duckdb {
|
|
|
13
13
|
|
|
14
14
|
class DependencyExtractor : public LogicalOperatorVisitor {
|
|
15
15
|
public:
|
|
16
|
-
explicit DependencyExtractor(
|
|
16
|
+
explicit DependencyExtractor(DependencyList &dependencies) : dependencies(dependencies) {
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
protected:
|
|
@@ -26,7 +26,7 @@ protected:
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
private:
|
|
29
|
-
|
|
29
|
+
DependencyList &dependencies;
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
PhysicalPlanGenerator::PhysicalPlanGenerator(ClientContext &context) : context(context) {
|
|
@@ -180,6 +180,7 @@ unique_ptr<PhysicalOperator> PhysicalPlanGenerator::CreatePlan(LogicalOperator &
|
|
|
180
180
|
case LogicalOperatorType::LOGICAL_DROP:
|
|
181
181
|
case LogicalOperatorType::LOGICAL_VACUUM:
|
|
182
182
|
case LogicalOperatorType::LOGICAL_LOAD:
|
|
183
|
+
case LogicalOperatorType::LOGICAL_ATTACH:
|
|
183
184
|
plan = CreatePlan((LogicalSimple &)op);
|
|
184
185
|
break;
|
|
185
186
|
case LogicalOperatorType::LOGICAL_RECURSIVE_CTE:
|