duckdb 0.6.2-dev781.0 → 0.6.2-dev889.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/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
|
@@ -10,10 +10,12 @@
|
|
|
10
10
|
|
|
11
11
|
#include "duckdb/common/common.hpp"
|
|
12
12
|
#include "duckdb/common/assert.hpp"
|
|
13
|
+
#include "duckdb/common/exception.hpp"
|
|
13
14
|
|
|
14
15
|
namespace duckdb {
|
|
15
16
|
|
|
16
17
|
class ClientContext;
|
|
18
|
+
class MetaTransaction;
|
|
17
19
|
class Transaction;
|
|
18
20
|
class TransactionManager;
|
|
19
21
|
|
|
@@ -21,13 +23,13 @@ class TransactionManager;
|
|
|
21
23
|
//! current transaction
|
|
22
24
|
class TransactionContext {
|
|
23
25
|
public:
|
|
24
|
-
TransactionContext(
|
|
25
|
-
: transaction_manager(transaction_manager), context(context), auto_commit(true), current_transaction(nullptr) {
|
|
26
|
-
}
|
|
26
|
+
TransactionContext(ClientContext &context);
|
|
27
27
|
~TransactionContext();
|
|
28
28
|
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
MetaTransaction &ActiveTransaction() {
|
|
30
|
+
if (!current_transaction) {
|
|
31
|
+
throw InternalException("TransactionContext::ActiveTransaction called without active transaction");
|
|
32
|
+
}
|
|
31
33
|
return *current_transaction;
|
|
32
34
|
}
|
|
33
35
|
|
|
@@ -35,7 +37,6 @@ public:
|
|
|
35
37
|
return !!current_transaction;
|
|
36
38
|
}
|
|
37
39
|
|
|
38
|
-
void RecordQuery(string query);
|
|
39
40
|
void BeginTransaction();
|
|
40
41
|
void Commit();
|
|
41
42
|
void Rollback();
|
|
@@ -46,12 +47,15 @@ public:
|
|
|
46
47
|
return auto_commit;
|
|
47
48
|
}
|
|
48
49
|
|
|
50
|
+
idx_t GetActiveQuery();
|
|
51
|
+
void ResetActiveQuery();
|
|
52
|
+
void SetActiveQuery(transaction_t query_number);
|
|
53
|
+
|
|
49
54
|
private:
|
|
50
|
-
TransactionManager &transaction_manager;
|
|
51
55
|
ClientContext &context;
|
|
52
56
|
bool auto_commit;
|
|
53
57
|
|
|
54
|
-
|
|
58
|
+
unique_ptr<MetaTransaction> current_transaction;
|
|
55
59
|
|
|
56
60
|
TransactionContext(const TransactionContext &) = delete;
|
|
57
61
|
};
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
namespace duckdb {
|
|
19
19
|
|
|
20
|
+
class AttachedDatabase;
|
|
20
21
|
class ClientContext;
|
|
21
22
|
class Catalog;
|
|
22
23
|
struct ClientLockWrapper;
|
|
@@ -29,7 +30,7 @@ class TransactionManager {
|
|
|
29
30
|
friend struct CheckpointLock;
|
|
30
31
|
|
|
31
32
|
public:
|
|
32
|
-
explicit TransactionManager(
|
|
33
|
+
explicit TransactionManager(AttachedDatabase &db);
|
|
33
34
|
~TransactionManager();
|
|
34
35
|
|
|
35
36
|
//! Start a new transaction
|
|
@@ -39,9 +40,6 @@ public:
|
|
|
39
40
|
//! Rollback the given transaction
|
|
40
41
|
void RollbackTransaction(Transaction *transaction);
|
|
41
42
|
|
|
42
|
-
transaction_t GetQueryNumber() {
|
|
43
|
-
return current_query_number++;
|
|
44
|
-
}
|
|
45
43
|
transaction_t LowestActiveId() {
|
|
46
44
|
return lowest_active_id;
|
|
47
45
|
}
|
|
@@ -51,8 +49,7 @@ public:
|
|
|
51
49
|
|
|
52
50
|
void Checkpoint(ClientContext &context, bool force = false);
|
|
53
51
|
|
|
54
|
-
static TransactionManager &Get(
|
|
55
|
-
static TransactionManager &Get(DatabaseInstance &db);
|
|
52
|
+
static TransactionManager &Get(AttachedDatabase &db);
|
|
56
53
|
|
|
57
54
|
void SetBaseCommitId(transaction_t base) {
|
|
58
55
|
D_ASSERT(base >= TRANSACTION_ID_START);
|
|
@@ -65,10 +62,8 @@ private:
|
|
|
65
62
|
void RemoveTransaction(Transaction *transaction) noexcept;
|
|
66
63
|
void LockClients(vector<ClientLockWrapper> &client_locks, ClientContext &context);
|
|
67
64
|
|
|
68
|
-
//! The database
|
|
69
|
-
|
|
70
|
-
//! The current query number
|
|
71
|
-
atomic<transaction_t> current_query_number;
|
|
65
|
+
//! The attached database
|
|
66
|
+
AttachedDatabase &db;
|
|
72
67
|
//! The current start timestamp used by transactions
|
|
73
68
|
transaction_t current_start_timestamp;
|
|
74
69
|
//! The current transaction ID used by transactions
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
#include "duckdb/main/attached_database.hpp"
|
|
2
|
+
#include "duckdb/storage/storage_manager.hpp"
|
|
3
|
+
#include "duckdb/transaction/transaction_manager.hpp"
|
|
4
|
+
#include "duckdb/common/file_system.hpp"
|
|
5
|
+
|
|
6
|
+
namespace duckdb {
|
|
7
|
+
|
|
8
|
+
AttachedDatabase::AttachedDatabase(DatabaseInstance &db, AttachedDatabaseType type)
|
|
9
|
+
: CatalogEntry(CatalogType::DATABASE_ENTRY, nullptr,
|
|
10
|
+
type == AttachedDatabaseType::SYSTEM_DATABASE ? SYSTEM_CATALOG : TEMP_CATALOG),
|
|
11
|
+
db(db), type(type) {
|
|
12
|
+
D_ASSERT(type == AttachedDatabaseType::TEMP_DATABASE || type == AttachedDatabaseType::SYSTEM_DATABASE);
|
|
13
|
+
if (type == AttachedDatabaseType::TEMP_DATABASE) {
|
|
14
|
+
storage = make_unique<SingleFileStorageManager>(*this, ":memory:", false);
|
|
15
|
+
}
|
|
16
|
+
catalog = make_unique<Catalog>(*this);
|
|
17
|
+
transaction_manager = make_unique<TransactionManager>(*this);
|
|
18
|
+
internal = true;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
AttachedDatabase::AttachedDatabase(DatabaseInstance &db, Catalog &catalog_p, string name_p, string file_path_p,
|
|
22
|
+
AccessMode access_mode)
|
|
23
|
+
: CatalogEntry(CatalogType::DATABASE_ENTRY, &catalog_p, move(name_p)), db(db),
|
|
24
|
+
type(access_mode == AccessMode::READ_ONLY ? AttachedDatabaseType::READ_ONLY_DATABASE
|
|
25
|
+
: AttachedDatabaseType::READ_WRITE_DATABASE) {
|
|
26
|
+
storage = make_unique<SingleFileStorageManager>(*this, move(file_path_p), access_mode == AccessMode::READ_ONLY);
|
|
27
|
+
catalog = make_unique<Catalog>(*this);
|
|
28
|
+
transaction_manager = make_unique<TransactionManager>(*this);
|
|
29
|
+
internal = true;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
AttachedDatabase::~AttachedDatabase() {
|
|
33
|
+
if (Exception::UncaughtException()) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (IsSystem()) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// shutting down: attempt to checkpoint the database
|
|
41
|
+
// but only if we are not cleaning up as part of an exception unwind
|
|
42
|
+
try {
|
|
43
|
+
if (!storage->InMemory()) {
|
|
44
|
+
auto &config = DBConfig::GetConfig(db);
|
|
45
|
+
if (!config.options.checkpoint_on_shutdown) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
storage->CreateCheckpoint(true);
|
|
49
|
+
}
|
|
50
|
+
} catch (...) {
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
bool AttachedDatabase::IsSystem() const {
|
|
55
|
+
D_ASSERT(!storage || type != AttachedDatabaseType::SYSTEM_DATABASE);
|
|
56
|
+
return type == AttachedDatabaseType::SYSTEM_DATABASE;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
bool AttachedDatabase::IsTemporary() const {
|
|
60
|
+
return type == AttachedDatabaseType::TEMP_DATABASE;
|
|
61
|
+
}
|
|
62
|
+
bool AttachedDatabase::IsReadOnly() const {
|
|
63
|
+
return type == AttachedDatabaseType::READ_ONLY_DATABASE;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
string AttachedDatabase::ExtractDatabaseName(const string &dbpath) {
|
|
67
|
+
if (dbpath.empty() || dbpath == ":memory:") {
|
|
68
|
+
return "memory";
|
|
69
|
+
}
|
|
70
|
+
return FileSystem::ExtractBaseName(dbpath);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
void AttachedDatabase::Initialize() {
|
|
74
|
+
if (IsSystem()) {
|
|
75
|
+
catalog->Initialize(true);
|
|
76
|
+
} else {
|
|
77
|
+
catalog->Initialize(false);
|
|
78
|
+
storage->Initialize();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
StorageManager &AttachedDatabase::GetStorageManager() {
|
|
83
|
+
if (IsSystem()) {
|
|
84
|
+
throw InternalException("Internal system catalog does not have storage");
|
|
85
|
+
}
|
|
86
|
+
return *storage;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
Catalog &AttachedDatabase::GetCatalog() {
|
|
90
|
+
return *catalog;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
TransactionManager &AttachedDatabase::GetTransactionManager() {
|
|
94
|
+
return *transaction_manager;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
} // namespace duckdb
|
|
@@ -274,7 +274,7 @@ duckdb_state duckdb_register_table_function(duckdb_connection connection, duckdb
|
|
|
274
274
|
return DuckDBError;
|
|
275
275
|
}
|
|
276
276
|
con->context->RunFunctionInTransaction([&]() {
|
|
277
|
-
auto &catalog = duckdb::Catalog::
|
|
277
|
+
auto &catalog = duckdb::Catalog::GetSystemCatalog(*con->context);
|
|
278
278
|
duckdb::CreateTableFunctionInfo tf_info(*tf);
|
|
279
279
|
|
|
280
280
|
// create the function in the catalog
|
|
@@ -43,7 +43,10 @@
|
|
|
43
43
|
#include "duckdb/common/preserved_error.hpp"
|
|
44
44
|
#include "duckdb/common/progress_bar/progress_bar.hpp"
|
|
45
45
|
#include "duckdb/main/error_manager.hpp"
|
|
46
|
+
#include "duckdb/main/database_manager.hpp"
|
|
47
|
+
#include "duckdb/transaction/meta_transaction.hpp"
|
|
46
48
|
#include "duckdb/common/http_stats.hpp"
|
|
49
|
+
#include "duckdb/main/attached_database.hpp"
|
|
47
50
|
|
|
48
51
|
namespace duckdb {
|
|
49
52
|
|
|
@@ -61,8 +64,7 @@ struct ActiveQueryContext {
|
|
|
61
64
|
};
|
|
62
65
|
|
|
63
66
|
ClientContext::ClientContext(shared_ptr<DatabaseInstance> database)
|
|
64
|
-
: db(move(database)),
|
|
65
|
-
client_data(make_unique<ClientData>(*this)) {
|
|
67
|
+
: db(move(database)), interrupted(false), client_data(make_unique<ClientData>(*this)), transaction(*this) {
|
|
66
68
|
}
|
|
67
69
|
|
|
68
70
|
ClientContext::~ClientContext() {
|
|
@@ -81,7 +83,7 @@ unique_ptr<ClientContextLock> ClientContext::LockContext() {
|
|
|
81
83
|
void ClientContext::Destroy() {
|
|
82
84
|
auto lock = LockContext();
|
|
83
85
|
if (transaction.HasActiveTransaction()) {
|
|
84
|
-
|
|
86
|
+
transaction.ResetActiveQuery();
|
|
85
87
|
if (!transaction.IsAutoCommit()) {
|
|
86
88
|
transaction.Rollback();
|
|
87
89
|
}
|
|
@@ -148,7 +150,7 @@ void ClientContext::BeginQueryInternal(ClientContextLock &lock, const string &qu
|
|
|
148
150
|
LogQueryInternal(lock, query);
|
|
149
151
|
active_query->query = query;
|
|
150
152
|
query_progress = -1;
|
|
151
|
-
|
|
153
|
+
transaction.SetActiveQuery(db->GetDatabaseManager().GetNewQueryNumber());
|
|
152
154
|
}
|
|
153
155
|
|
|
154
156
|
PreservedError ClientContext::EndQueryInternal(ClientContextLock &lock, bool success, bool invalidate_transaction) {
|
|
@@ -169,7 +171,7 @@ PreservedError ClientContext::EndQueryInternal(ClientContextLock &lock, bool suc
|
|
|
169
171
|
if (transaction.HasActiveTransaction()) {
|
|
170
172
|
// Move the query profiler into the history
|
|
171
173
|
auto &prev_profilers = client_data->query_profiler_history->GetPrevProfilers();
|
|
172
|
-
prev_profilers.emplace_back(transaction.
|
|
174
|
+
prev_profilers.emplace_back(transaction.GetActiveQuery(), move(client_data->profiler));
|
|
173
175
|
// Reinitialize the query profiler
|
|
174
176
|
client_data->profiler = make_shared<QueryProfiler>(*this);
|
|
175
177
|
// Propagate settings of the saved query into the new profiler.
|
|
@@ -178,7 +180,7 @@ PreservedError ClientContext::EndQueryInternal(ClientContextLock &lock, bool suc
|
|
|
178
180
|
prev_profilers.pop_front();
|
|
179
181
|
}
|
|
180
182
|
|
|
181
|
-
|
|
183
|
+
transaction.ResetActiveQuery();
|
|
182
184
|
if (transaction.IsAutoCommit()) {
|
|
183
185
|
if (success) {
|
|
184
186
|
transaction.Commit();
|
|
@@ -234,10 +236,6 @@ FileOpener *FileOpener::Get(ClientContext &context) {
|
|
|
234
236
|
return ClientData::Get(context).file_opener.get();
|
|
235
237
|
}
|
|
236
238
|
|
|
237
|
-
SchemaCatalogEntry *SchemaCatalogEntry::GetTemporaryObjects(ClientContext &context) {
|
|
238
|
-
return context.client_data->temporary_objects.get();
|
|
239
|
-
}
|
|
240
|
-
|
|
241
239
|
const string &ClientContext::GetCurrentQuery() {
|
|
242
240
|
D_ASSERT(active_query);
|
|
243
241
|
return active_query->query;
|
|
@@ -333,7 +331,7 @@ shared_ptr<PreparedStatementData> ClientContext::CreatePreparedStatement(ClientC
|
|
|
333
331
|
result->names = planner.names;
|
|
334
332
|
result->types = planner.types;
|
|
335
333
|
result->value_map = move(planner.value_map);
|
|
336
|
-
result->catalog_version =
|
|
334
|
+
result->catalog_version = MetaTransaction::Get(*this).catalog_version;
|
|
337
335
|
|
|
338
336
|
if (!planner.properties.bound_all_parameters) {
|
|
339
337
|
return result;
|
|
@@ -378,10 +376,19 @@ unique_ptr<PendingQueryResult> ClientContext::PendingPreparedStatement(ClientCon
|
|
|
378
376
|
if (ValidChecker::IsInvalidated(ActiveTransaction()) && statement.properties.requires_valid_transaction) {
|
|
379
377
|
throw Exception(ErrorManager::FormatException(*this, ErrorType::INVALIDATED_TRANSACTION));
|
|
380
378
|
}
|
|
381
|
-
auto &
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
379
|
+
auto &transaction = MetaTransaction::Get(*this);
|
|
380
|
+
auto &manager = DatabaseManager::Get(*this);
|
|
381
|
+
for (auto &modified_database : statement.properties.modified_databases) {
|
|
382
|
+
auto entry = manager.GetDatabase(*this, modified_database);
|
|
383
|
+
if (!entry) {
|
|
384
|
+
throw InternalException("Database \"%s\" not found", modified_database);
|
|
385
|
+
}
|
|
386
|
+
if (entry->IsReadOnly()) {
|
|
387
|
+
throw Exception(StringUtil::Format(
|
|
388
|
+
"Cannot execute statement of type \"%s\" on database \"%s\" which is attached in read-only mode!",
|
|
389
|
+
StatementTypeToString(statement.statement_type), modified_database));
|
|
390
|
+
}
|
|
391
|
+
transaction.ModifyDatabase(entry);
|
|
385
392
|
}
|
|
386
393
|
|
|
387
394
|
// bind the bound values before execution
|
|
@@ -902,9 +909,8 @@ void ClientContext::DisableProfiling() {
|
|
|
902
909
|
|
|
903
910
|
void ClientContext::RegisterFunction(CreateFunctionInfo *info) {
|
|
904
911
|
RunFunctionInTransaction([&]() {
|
|
905
|
-
auto
|
|
906
|
-
|
|
907
|
-
*this, CatalogType::SCALAR_FUNCTION_ENTRY, info->schema, info->name, true);
|
|
912
|
+
auto existing_function =
|
|
913
|
+
Catalog::GetEntry<ScalarFunctionCatalogEntry>(*this, INVALID_CATALOG, info->schema, info->name, true);
|
|
908
914
|
if (existing_function) {
|
|
909
915
|
auto new_info = (CreateScalarFunctionInfo *)info;
|
|
910
916
|
if (new_info->functions.MergeFunctionSet(existing_function->functions)) {
|
|
@@ -913,6 +919,7 @@ void ClientContext::RegisterFunction(CreateFunctionInfo *info) {
|
|
|
913
919
|
}
|
|
914
920
|
}
|
|
915
921
|
// create function
|
|
922
|
+
auto &catalog = Catalog::GetSystemCatalog(*this);
|
|
916
923
|
catalog.CreateFunction(*this, info);
|
|
917
924
|
});
|
|
918
925
|
}
|
|
@@ -962,8 +969,7 @@ unique_ptr<TableDescription> ClientContext::TableInfo(const string &schema_name,
|
|
|
962
969
|
unique_ptr<TableDescription> result;
|
|
963
970
|
RunFunctionInTransaction([&]() {
|
|
964
971
|
// obtain the table info
|
|
965
|
-
auto
|
|
966
|
-
auto table = catalog.GetEntry<TableCatalogEntry>(*this, schema_name, table_name, true);
|
|
972
|
+
auto table = Catalog::GetEntry<TableCatalogEntry>(*this, INVALID_CATALOG, schema_name, table_name, true);
|
|
967
973
|
if (!table) {
|
|
968
974
|
return;
|
|
969
975
|
}
|
|
@@ -980,8 +986,8 @@ unique_ptr<TableDescription> ClientContext::TableInfo(const string &schema_name,
|
|
|
980
986
|
|
|
981
987
|
void ClientContext::Append(TableDescription &description, ColumnDataCollection &collection) {
|
|
982
988
|
RunFunctionInTransaction([&]() {
|
|
983
|
-
auto
|
|
984
|
-
|
|
989
|
+
auto table_entry =
|
|
990
|
+
Catalog::GetEntry<TableCatalogEntry>(*this, INVALID_CATALOG, description.schema, description.table);
|
|
985
991
|
// verify that the table columns and types match up
|
|
986
992
|
if (description.columns.size() != table_entry->columns.PhysicalColumnCount()) {
|
|
987
993
|
throw Exception("Failed to append: table entry has different number of columns!");
|
|
@@ -4,19 +4,22 @@
|
|
|
4
4
|
#include "duckdb/main/query_profiler.hpp"
|
|
5
5
|
#include "duckdb/common/http_stats.hpp"
|
|
6
6
|
#include "duckdb/common/random_engine.hpp"
|
|
7
|
-
#include "duckdb/catalog/catalog_entry/schema_catalog_entry.hpp"
|
|
8
7
|
#include "duckdb/catalog/catalog_search_path.hpp"
|
|
9
8
|
#include "duckdb/catalog/catalog.hpp"
|
|
10
9
|
#include "duckdb/common/serializer/buffered_file_writer.hpp"
|
|
10
|
+
#include "duckdb/main/attached_database.hpp"
|
|
11
|
+
#include "duckdb/main/database.hpp"
|
|
11
12
|
|
|
12
13
|
namespace duckdb {
|
|
13
14
|
|
|
14
15
|
ClientData::ClientData(ClientContext &context) : catalog_search_path(make_unique<CatalogSearchPath>(context)) {
|
|
16
|
+
auto &db = DatabaseInstance::GetDatabase(context);
|
|
15
17
|
profiler = make_shared<QueryProfiler>(context);
|
|
16
18
|
query_profiler_history = make_unique<QueryProfilerHistory>();
|
|
17
|
-
temporary_objects = make_shared<
|
|
19
|
+
temporary_objects = make_shared<AttachedDatabase>(db, AttachedDatabaseType::TEMP_DATABASE);
|
|
18
20
|
random_engine = make_unique<RandomEngine>();
|
|
19
21
|
file_opener = make_unique<ClientContextFileOpener>(context);
|
|
22
|
+
temporary_objects->Initialize();
|
|
20
23
|
}
|
|
21
24
|
ClientData::~ClientData() {
|
|
22
25
|
}
|
|
@@ -71,6 +71,7 @@ static ConfigurationOption internal_options[] = {DUCKDB_GLOBAL(AccessModeSetting
|
|
|
71
71
|
DUCKDB_GLOBAL(ForceBitpackingModeSetting),
|
|
72
72
|
DUCKDB_LOCAL(HomeDirectorySetting),
|
|
73
73
|
DUCKDB_LOCAL(LogQueryPathSetting),
|
|
74
|
+
DUCKDB_GLOBAL(ImmediateTransactionModeSetting),
|
|
74
75
|
DUCKDB_LOCAL(MaximumExpressionDepthSetting),
|
|
75
76
|
DUCKDB_GLOBAL(MaximumMemorySetting),
|
|
76
77
|
DUCKDB_GLOBAL_ALIAS("memory_limit", MaximumMemorySetting),
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#include "duckdb/main/database.hpp"
|
|
2
2
|
|
|
3
3
|
#include "duckdb/catalog/catalog.hpp"
|
|
4
|
+
#include "duckdb/main/database_manager.hpp"
|
|
4
5
|
#include "duckdb/common/virtual_file_system.hpp"
|
|
5
6
|
#include "duckdb/main/client_context.hpp"
|
|
6
7
|
#include "duckdb/parallel/task_scheduler.hpp"
|
|
@@ -13,6 +14,7 @@
|
|
|
13
14
|
#include "duckdb/main/replacement_opens.hpp"
|
|
14
15
|
#include "duckdb/function/cast/cast_function_set.hpp"
|
|
15
16
|
#include "duckdb/main/error_manager.hpp"
|
|
17
|
+
#include "duckdb/main/attached_database.hpp"
|
|
16
18
|
|
|
17
19
|
#ifndef DUCKDB_NO_THREADS
|
|
18
20
|
#include "duckdb/common/thread.hpp"
|
|
@@ -50,38 +52,32 @@ DatabaseInstance::DatabaseInstance() {
|
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
DatabaseInstance::~DatabaseInstance() {
|
|
53
|
-
if (Exception::UncaughtException()) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// shutting down: attempt to checkpoint the database
|
|
58
|
-
// but only if we are not cleaning up as part of an exception unwind
|
|
59
|
-
try {
|
|
60
|
-
auto &storage = StorageManager::GetStorageManager(*this);
|
|
61
|
-
if (!storage.InMemory()) {
|
|
62
|
-
auto &config = storage.db.config;
|
|
63
|
-
if (!config.options.checkpoint_on_shutdown) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
storage.CreateCheckpoint(true);
|
|
67
|
-
}
|
|
68
|
-
} catch (...) {
|
|
69
|
-
}
|
|
70
55
|
}
|
|
71
56
|
|
|
72
57
|
BufferManager &BufferManager::GetBufferManager(DatabaseInstance &db) {
|
|
73
|
-
return
|
|
58
|
+
return db.GetBufferManager();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
BufferManager &BufferManager::GetBufferManager(AttachedDatabase &db) {
|
|
62
|
+
return BufferManager::GetBufferManager(db.GetDatabase());
|
|
74
63
|
}
|
|
75
64
|
|
|
76
65
|
DatabaseInstance &DatabaseInstance::GetDatabase(ClientContext &context) {
|
|
77
66
|
return *context.db;
|
|
78
67
|
}
|
|
79
68
|
|
|
80
|
-
|
|
81
|
-
|
|
69
|
+
DatabaseManager &DatabaseInstance::GetDatabaseManager() {
|
|
70
|
+
if (!db_manager) {
|
|
71
|
+
throw InternalException("Missing DB manager");
|
|
72
|
+
}
|
|
73
|
+
return *db_manager;
|
|
82
74
|
}
|
|
83
75
|
|
|
84
|
-
Catalog &Catalog::
|
|
76
|
+
Catalog &Catalog::GetSystemCatalog(DatabaseInstance &db) {
|
|
77
|
+
return db.GetDatabaseManager().GetSystemCatalog();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
Catalog &Catalog::GetCatalog(AttachedDatabase &db) {
|
|
85
81
|
return db.GetCatalog();
|
|
86
82
|
}
|
|
87
83
|
|
|
@@ -89,6 +85,10 @@ FileSystem &FileSystem::GetFileSystem(DatabaseInstance &db) {
|
|
|
89
85
|
return db.GetFileSystem();
|
|
90
86
|
}
|
|
91
87
|
|
|
88
|
+
FileSystem &FileSystem::Get(AttachedDatabase &db) {
|
|
89
|
+
return FileSystem::GetFileSystem(db.GetDatabase());
|
|
90
|
+
}
|
|
91
|
+
|
|
92
92
|
DBConfig &DBConfig::GetConfig(DatabaseInstance &db) {
|
|
93
93
|
return db.config;
|
|
94
94
|
}
|
|
@@ -97,6 +97,10 @@ ClientConfig &ClientConfig::GetConfig(ClientContext &context) {
|
|
|
97
97
|
return context.config;
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
DBConfig &DBConfig::Get(AttachedDatabase &db) {
|
|
101
|
+
return DBConfig::GetConfig(db.GetDatabase());
|
|
102
|
+
}
|
|
103
|
+
|
|
100
104
|
const DBConfig &DBConfig::GetConfig(const DatabaseInstance &db) {
|
|
101
105
|
return db.config;
|
|
102
106
|
}
|
|
@@ -105,11 +109,7 @@ const ClientConfig &ClientConfig::GetConfig(const ClientContext &context) {
|
|
|
105
109
|
return context.config;
|
|
106
110
|
}
|
|
107
111
|
|
|
108
|
-
TransactionManager &TransactionManager::Get(
|
|
109
|
-
return TransactionManager::Get(DatabaseInstance::GetDatabase(context));
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
TransactionManager &TransactionManager::Get(DatabaseInstance &db) {
|
|
112
|
+
TransactionManager &TransactionManager::Get(AttachedDatabase &db) {
|
|
113
113
|
return db.GetTransactionManager();
|
|
114
114
|
}
|
|
115
115
|
|
|
@@ -159,19 +159,29 @@ void DatabaseInstance::Initialize(const char *database_path, DBConfig *user_conf
|
|
|
159
159
|
config.options.temporary_directory = string();
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
catalog = make_unique<Catalog>(*this);
|
|
168
|
-
transaction_manager = make_unique<TransactionManager>(*this);
|
|
162
|
+
auto &config = DBConfig::GetConfig(*this);
|
|
163
|
+
db_manager = make_unique<DatabaseManager>(*this);
|
|
164
|
+
buffer_manager =
|
|
165
|
+
make_unique<BufferManager>(*this, config.options.temporary_directory, config.options.maximum_memory);
|
|
169
166
|
scheduler = make_unique<TaskScheduler>(*this);
|
|
170
167
|
object_cache = make_unique<ObjectCache>();
|
|
171
168
|
connection_manager = make_unique<ConnectionManager>();
|
|
172
169
|
|
|
170
|
+
auto database_name = AttachedDatabase::ExtractDatabaseName(config.options.database_path);
|
|
171
|
+
auto attached_database = make_unique<AttachedDatabase>(*this, Catalog::GetSystemCatalog(*this), database_name,
|
|
172
|
+
config.options.database_path, config.options.access_mode);
|
|
173
|
+
auto initial_database = attached_database.get();
|
|
174
|
+
{
|
|
175
|
+
Connection con(*this);
|
|
176
|
+
con.BeginTransaction();
|
|
177
|
+
db_manager->AddDatabase(*con.context, move(attached_database));
|
|
178
|
+
con.Commit();
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// initialize the system catalog
|
|
182
|
+
db_manager->InitializeSystemCatalog();
|
|
173
183
|
// initialize the database
|
|
174
|
-
|
|
184
|
+
initial_database->Initialize();
|
|
175
185
|
|
|
176
186
|
// only increase thread count after storage init because we get races on catalog otherwise
|
|
177
187
|
scheduler->SetThreads(config.options.maximum_threads);
|
|
@@ -200,16 +210,16 @@ DuckDB::DuckDB(DatabaseInstance &instance_p) : instance(instance_p.shared_from_t
|
|
|
200
210
|
DuckDB::~DuckDB() {
|
|
201
211
|
}
|
|
202
212
|
|
|
203
|
-
|
|
204
|
-
return *
|
|
213
|
+
BufferManager &DatabaseInstance::GetBufferManager() {
|
|
214
|
+
return *buffer_manager;
|
|
205
215
|
}
|
|
206
216
|
|
|
207
|
-
|
|
208
|
-
return
|
|
217
|
+
DatabaseManager &DatabaseManager::Get(DatabaseInstance &db) {
|
|
218
|
+
return db.GetDatabaseManager();
|
|
209
219
|
}
|
|
210
220
|
|
|
211
|
-
|
|
212
|
-
return *
|
|
221
|
+
DatabaseManager &DatabaseManager::Get(ClientContext &db) {
|
|
222
|
+
return DatabaseManager::Get(*db.db);
|
|
213
223
|
}
|
|
214
224
|
|
|
215
225
|
TaskScheduler &DatabaseInstance::GetScheduler() {
|
|
@@ -240,6 +250,10 @@ Allocator &Allocator::Get(DatabaseInstance &db) {
|
|
|
240
250
|
return *db.config.allocator;
|
|
241
251
|
}
|
|
242
252
|
|
|
253
|
+
Allocator &Allocator::Get(AttachedDatabase &db) {
|
|
254
|
+
return Allocator::Get(db.GetDatabase());
|
|
255
|
+
}
|
|
256
|
+
|
|
243
257
|
void DatabaseInstance::Configure(DBConfig &new_config) {
|
|
244
258
|
config.options = new_config.options;
|
|
245
259
|
if (config.options.access_mode == AccessMode::UNDEFINED) {
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
#include "duckdb/main/database_manager.hpp"
|
|
2
|
+
#include "duckdb/catalog/catalog.hpp"
|
|
3
|
+
#include "duckdb/main/attached_database.hpp"
|
|
4
|
+
#include "duckdb/storage/storage_manager.hpp"
|
|
5
|
+
#include "duckdb/main/client_data.hpp"
|
|
6
|
+
#include "duckdb/catalog/catalog_search_path.hpp"
|
|
7
|
+
|
|
8
|
+
namespace duckdb {
|
|
9
|
+
|
|
10
|
+
DatabaseManager::DatabaseManager(DatabaseInstance &db) : catalog_version(0), current_query_number(1) {
|
|
11
|
+
system = make_unique<AttachedDatabase>(db);
|
|
12
|
+
databases = make_unique<CatalogSet>(system->GetCatalog());
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
DatabaseManager::~DatabaseManager() {
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
DatabaseManager &DatabaseManager::Get(AttachedDatabase &db) {
|
|
19
|
+
return DatabaseManager::Get(db.GetDatabase());
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
void DatabaseManager::InitializeSystemCatalog() {
|
|
23
|
+
system->Initialize();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
AttachedDatabase *DatabaseManager::GetDatabase(ClientContext &context, const string &name) {
|
|
27
|
+
if (StringUtil::Lower(name) == TEMP_CATALOG) {
|
|
28
|
+
return context.client_data->temporary_objects.get();
|
|
29
|
+
}
|
|
30
|
+
return (AttachedDatabase *)databases->GetEntry(context, name);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
void DatabaseManager::AddDatabase(ClientContext &context, unique_ptr<AttachedDatabase> db_instance) {
|
|
34
|
+
auto name = db_instance->GetName();
|
|
35
|
+
DependencyList dependencies;
|
|
36
|
+
if (default_database.empty()) {
|
|
37
|
+
default_database = name;
|
|
38
|
+
}
|
|
39
|
+
if (!databases->CreateEntry(context, name, move(db_instance), dependencies)) {
|
|
40
|
+
throw BinderException("Failed to attach database: database with name \"%s\" already exists", name);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
void DatabaseManager::DetachDatabase(ClientContext &context, const string &name, bool if_exists) {
|
|
45
|
+
if (!databases->DropEntry(context, name, false, true)) {
|
|
46
|
+
if (!if_exists) {
|
|
47
|
+
throw BinderException("Failed to detach database with name \"%s\": database not found", name);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
AttachedDatabase *DatabaseManager::GetDatabaseFromPath(ClientContext &context, const string &path) {
|
|
53
|
+
auto databases = GetDatabases(context);
|
|
54
|
+
for (auto db : databases) {
|
|
55
|
+
if (db->IsSystem()) {
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
auto &storage = db->GetStorageManager();
|
|
59
|
+
if (storage.InMemory()) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (StringUtil::CIEquals(path, storage.GetDBPath())) {
|
|
63
|
+
return db;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return nullptr;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const string &DatabaseManager::GetDefaultDatabase(ClientContext &context) {
|
|
70
|
+
auto &config = ClientData::Get(context);
|
|
71
|
+
auto &default_entry = config.catalog_search_path->GetDefault();
|
|
72
|
+
if (IsInvalidCatalog(default_entry.catalog)) {
|
|
73
|
+
auto &result = DatabaseManager::Get(context).default_database;
|
|
74
|
+
if (result.empty()) {
|
|
75
|
+
throw InternalException("Calling DatabaseManager::GetDefaultDatabase with no default database set");
|
|
76
|
+
}
|
|
77
|
+
return result;
|
|
78
|
+
}
|
|
79
|
+
return default_entry.catalog;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
vector<AttachedDatabase *> DatabaseManager::GetDatabases(ClientContext &context) {
|
|
83
|
+
vector<AttachedDatabase *> result;
|
|
84
|
+
databases->Scan(context, [&](CatalogEntry *entry) { result.push_back((AttachedDatabase *)entry); });
|
|
85
|
+
result.push_back(system.get());
|
|
86
|
+
result.push_back(context.client_data->temporary_objects.get());
|
|
87
|
+
return result;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
Catalog &DatabaseManager::GetSystemCatalog() {
|
|
91
|
+
D_ASSERT(system);
|
|
92
|
+
return system->GetCatalog();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
} // namespace duckdb
|
|
@@ -7,7 +7,7 @@ namespace duckdb {
|
|
|
7
7
|
MaterializedQueryResult::MaterializedQueryResult(StatementType statement_type, StatementProperties properties,
|
|
8
8
|
vector<string> names_p, unique_ptr<ColumnDataCollection> collection_p,
|
|
9
9
|
ClientProperties client_properties)
|
|
10
|
-
: QueryResult(QueryResultType::MATERIALIZED_RESULT, statement_type, properties, collection_p->Types(),
|
|
10
|
+
: QueryResult(QueryResultType::MATERIALIZED_RESULT, statement_type, move(properties), collection_p->Types(),
|
|
11
11
|
move(names_p), move(client_properties)),
|
|
12
12
|
collection(move(collection_p)), scan_initialized(false) {
|
|
13
13
|
}
|