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
|
@@ -19,10 +19,20 @@
|
|
|
19
19
|
#include "duckdb/storage/table/standard_column_data.hpp"
|
|
20
20
|
#include "duckdb/transaction/transaction.hpp"
|
|
21
21
|
#include "duckdb/transaction/transaction_manager.hpp"
|
|
22
|
+
#include "duckdb/main/attached_database.hpp"
|
|
22
23
|
|
|
23
24
|
namespace duckdb {
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
DataTableInfo::DataTableInfo(AttachedDatabase &db, shared_ptr<TableIOManager> table_io_manager_p, string schema,
|
|
27
|
+
string table)
|
|
28
|
+
: db(db), table_io_manager(move(table_io_manager_p)), cardinality(0), schema(move(schema)), table(move(table)) {
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
bool DataTableInfo::IsTemporary() const {
|
|
32
|
+
return db.IsTemporary();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
DataTable::DataTable(AttachedDatabase &db, shared_ptr<TableIOManager> table_io_manager_p, const string &schema,
|
|
26
36
|
const string &table, vector<ColumnDefinition> column_definitions_p,
|
|
27
37
|
unique_ptr<PersistentTableData> data)
|
|
28
38
|
: info(make_shared<DataTableInfo>(db, move(table_io_manager_p), schema, table)),
|
|
@@ -53,7 +63,7 @@ DataTable::DataTable(ClientContext &context, DataTable &parent, ColumnDefinition
|
|
|
53
63
|
this->row_groups = parent.row_groups->AddColumn(context, new_column, default_value);
|
|
54
64
|
|
|
55
65
|
// also add this column to client local storage
|
|
56
|
-
auto &local_storage = LocalStorage::Get(context);
|
|
66
|
+
auto &local_storage = LocalStorage::Get(context, db);
|
|
57
67
|
local_storage.AddColumn(&parent, this, new_column, default_value);
|
|
58
68
|
|
|
59
69
|
// this table replaces the previous table, hence the parent is no longer the root DataTable
|
|
@@ -98,7 +108,7 @@ DataTable::DataTable(ClientContext &context, DataTable &parent, idx_t removed_co
|
|
|
98
108
|
this->row_groups = parent.row_groups->RemoveColumn(removed_column);
|
|
99
109
|
|
|
100
110
|
// scan the original table, and fill the new column with the transformed value
|
|
101
|
-
auto &local_storage = LocalStorage::Get(context);
|
|
111
|
+
auto &local_storage = LocalStorage::Get(context, db);
|
|
102
112
|
local_storage.DropColumn(&parent, this, removed_column);
|
|
103
113
|
|
|
104
114
|
// this table replaces the previous table, hence the parent is no longer the root DataTable
|
|
@@ -118,7 +128,7 @@ DataTable::DataTable(ClientContext &context, DataTable &parent, unique_ptr<Bound
|
|
|
118
128
|
VerifyNewConstraint(context, parent, constraint.get());
|
|
119
129
|
|
|
120
130
|
// Get the local data ownership from old dt
|
|
121
|
-
auto &local_storage = LocalStorage::Get(context);
|
|
131
|
+
auto &local_storage = LocalStorage::Get(context, db);
|
|
122
132
|
local_storage.MoveStorage(&parent, this);
|
|
123
133
|
// this table replaces the previous table, hence the parent is no longer the root DataTable
|
|
124
134
|
parent.is_root = false;
|
|
@@ -150,7 +160,7 @@ DataTable::DataTable(ClientContext &context, DataTable &parent, idx_t changed_id
|
|
|
150
160
|
this->row_groups = parent.row_groups->AlterType(context, changed_idx, target_type, bound_columns, cast_expr);
|
|
151
161
|
|
|
152
162
|
// scan the original table, and fill the new column with the transformed value
|
|
153
|
-
auto &local_storage = LocalStorage::Get(context);
|
|
163
|
+
auto &local_storage = LocalStorage::Get(context, db);
|
|
154
164
|
local_storage.ChangeType(&parent, this, changed_idx, target_type, bound_columns, cast_expr);
|
|
155
165
|
|
|
156
166
|
// this table replaces the previous table, hence the parent is no longer the root DataTable
|
|
@@ -203,7 +213,7 @@ idx_t DataTable::MaxThreads(ClientContext &context) {
|
|
|
203
213
|
void DataTable::InitializeParallelScan(ClientContext &context, ParallelTableScanState &state) {
|
|
204
214
|
row_groups->InitializeParallelScan(state.scan_state);
|
|
205
215
|
|
|
206
|
-
auto &local_storage = LocalStorage::Get(context);
|
|
216
|
+
auto &local_storage = LocalStorage::Get(context, db);
|
|
207
217
|
local_storage.InitializeParallelScan(this, state.local_state);
|
|
208
218
|
}
|
|
209
219
|
|
|
@@ -212,7 +222,7 @@ bool DataTable::NextParallelScan(ClientContext &context, ParallelTableScanState
|
|
|
212
222
|
return true;
|
|
213
223
|
}
|
|
214
224
|
scan_state.table_state.batch_index = state.scan_state.batch_index;
|
|
215
|
-
auto &local_storage = LocalStorage::Get(context);
|
|
225
|
+
auto &local_storage = LocalStorage::Get(context, db);
|
|
216
226
|
if (local_storage.NextParallelScan(context, this, state.local_state, scan_state.local_state)) {
|
|
217
227
|
return true;
|
|
218
228
|
} else {
|
|
@@ -315,8 +325,8 @@ bool DataTable::IsForeignKeyIndex(const vector<PhysicalIndex> &fk_keys, Index &i
|
|
|
315
325
|
return true;
|
|
316
326
|
}
|
|
317
327
|
|
|
318
|
-
|
|
319
|
-
|
|
328
|
+
void DataTable::VerifyForeignKeyConstraint(const BoundForeignKeyConstraint &bfk, ClientContext &context,
|
|
329
|
+
DataChunk &chunk, bool is_append) {
|
|
320
330
|
const vector<PhysicalIndex> *src_keys_ptr = &bfk.info.fk_keys;
|
|
321
331
|
const vector<PhysicalIndex> *dst_keys_ptr = &bfk.info.pk_keys;
|
|
322
332
|
if (!is_append) {
|
|
@@ -325,7 +335,7 @@ static void VerifyForeignKeyConstraint(const BoundForeignKeyConstraint &bfk, Cli
|
|
|
325
335
|
}
|
|
326
336
|
|
|
327
337
|
auto table_entry_ptr =
|
|
328
|
-
Catalog::
|
|
338
|
+
Catalog::GetEntry<TableCatalogEntry>(context, INVALID_CATALOG, bfk.info.schema, bfk.info.table);
|
|
329
339
|
if (table_entry_ptr == nullptr) {
|
|
330
340
|
throw InternalException("Can't find table \"%s\" in foreign key constraint", bfk.info.table);
|
|
331
341
|
}
|
|
@@ -355,7 +365,7 @@ static void VerifyForeignKeyConstraint(const BoundForeignKeyConstraint &bfk, Cli
|
|
|
355
365
|
|
|
356
366
|
data_table->info->indexes.VerifyForeignKey(*dst_keys_ptr, is_append, dst_chunk, err_msgs);
|
|
357
367
|
// check whether or not the chunk can be inserted or deleted into the referenced table' transaction local storage
|
|
358
|
-
auto &local_storage = LocalStorage::Get(context);
|
|
368
|
+
auto &local_storage = LocalStorage::Get(context, db);
|
|
359
369
|
bool transaction_check = local_storage.Find(data_table);
|
|
360
370
|
if (transaction_check) {
|
|
361
371
|
auto &transact_index = local_storage.GetIndexes(data_table);
|
|
@@ -394,13 +404,13 @@ static void VerifyForeignKeyConstraint(const BoundForeignKeyConstraint &bfk, Cli
|
|
|
394
404
|
}
|
|
395
405
|
}
|
|
396
406
|
|
|
397
|
-
|
|
398
|
-
|
|
407
|
+
void DataTable::VerifyAppendForeignKeyConstraint(const BoundForeignKeyConstraint &bfk, ClientContext &context,
|
|
408
|
+
DataChunk &chunk) {
|
|
399
409
|
VerifyForeignKeyConstraint(bfk, context, chunk, true);
|
|
400
410
|
}
|
|
401
411
|
|
|
402
|
-
|
|
403
|
-
|
|
412
|
+
void DataTable::VerifyDeleteForeignKeyConstraint(const BoundForeignKeyConstraint &bfk, ClientContext &context,
|
|
413
|
+
DataChunk &chunk) {
|
|
404
414
|
VerifyForeignKeyConstraint(bfk, context, chunk, false);
|
|
405
415
|
}
|
|
406
416
|
|
|
@@ -410,7 +420,7 @@ void DataTable::VerifyNewConstraint(ClientContext &context, DataTable &parent, c
|
|
|
410
420
|
}
|
|
411
421
|
|
|
412
422
|
parent.row_groups->VerifyNewConstraint(parent, *constraint);
|
|
413
|
-
auto &local_storage = LocalStorage::Get(context);
|
|
423
|
+
auto &local_storage = LocalStorage::Get(context, db);
|
|
414
424
|
local_storage.VerifyNewConstraint(parent, *constraint);
|
|
415
425
|
}
|
|
416
426
|
|
|
@@ -472,7 +482,7 @@ void DataTable::InitializeLocalAppend(LocalAppendState &state, ClientContext &co
|
|
|
472
482
|
if (!is_root) {
|
|
473
483
|
throw TransactionException("Transaction conflict: adding entries to a table that has been altered!");
|
|
474
484
|
}
|
|
475
|
-
auto &local_storage = LocalStorage::Get(context);
|
|
485
|
+
auto &local_storage = LocalStorage::Get(context, db);
|
|
476
486
|
local_storage.InitializeAppend(state, this);
|
|
477
487
|
}
|
|
478
488
|
|
|
@@ -500,12 +510,12 @@ void DataTable::FinalizeLocalAppend(LocalAppendState &state) {
|
|
|
500
510
|
}
|
|
501
511
|
|
|
502
512
|
OptimisticDataWriter *DataTable::CreateOptimisticWriter(ClientContext &context) {
|
|
503
|
-
auto &local_storage = LocalStorage::Get(context);
|
|
513
|
+
auto &local_storage = LocalStorage::Get(context, db);
|
|
504
514
|
return local_storage.CreateOptimisticWriter(this);
|
|
505
515
|
}
|
|
506
516
|
|
|
507
517
|
void DataTable::LocalMerge(ClientContext &context, RowGroupCollection &collection) {
|
|
508
|
-
auto &local_storage = LocalStorage::Get(context);
|
|
518
|
+
auto &local_storage = LocalStorage::Get(context, db);
|
|
509
519
|
local_storage.LocalMerge(this, collection);
|
|
510
520
|
}
|
|
511
521
|
|
|
@@ -751,8 +761,8 @@ idx_t DataTable::Delete(TableCatalogEntry &table, ClientContext &context, Vector
|
|
|
751
761
|
return 0;
|
|
752
762
|
}
|
|
753
763
|
|
|
754
|
-
auto &transaction = Transaction::
|
|
755
|
-
auto &local_storage = LocalStorage::Get(
|
|
764
|
+
auto &transaction = Transaction::Get(context, db);
|
|
765
|
+
auto &local_storage = LocalStorage::Get(transaction);
|
|
756
766
|
|
|
757
767
|
row_identifiers.Flatten(count);
|
|
758
768
|
auto ids = FlatVector::GetData<row_t>(row_identifiers);
|
|
@@ -887,7 +897,7 @@ void DataTable::Update(TableCatalogEntry &table, ClientContext &context, Vector
|
|
|
887
897
|
VerifyUpdateConstraints(context, table, updates, column_ids);
|
|
888
898
|
|
|
889
899
|
// now perform the actual update
|
|
890
|
-
auto &transaction = Transaction::
|
|
900
|
+
auto &transaction = Transaction::Get(context, db);
|
|
891
901
|
|
|
892
902
|
updates.Flatten();
|
|
893
903
|
row_ids.Flatten(count);
|
|
@@ -895,7 +905,7 @@ void DataTable::Update(TableCatalogEntry &table, ClientContext &context, Vector
|
|
|
895
905
|
auto first_id = FlatVector::GetValue<row_t>(row_ids, 0);
|
|
896
906
|
if (first_id >= MAX_ROW_ID) {
|
|
897
907
|
// update is in transaction-local storage: push update into local storage
|
|
898
|
-
auto &local_storage = LocalStorage::Get(context);
|
|
908
|
+
auto &local_storage = LocalStorage::Get(context, db);
|
|
899
909
|
local_storage.Update(this, row_ids, column_ids, updates);
|
|
900
910
|
return;
|
|
901
911
|
}
|
|
@@ -921,7 +931,7 @@ void DataTable::UpdateColumn(TableCatalogEntry &table, ClientContext &context, V
|
|
|
921
931
|
}
|
|
922
932
|
|
|
923
933
|
// now perform the actual update
|
|
924
|
-
auto &transaction = Transaction::
|
|
934
|
+
auto &transaction = Transaction::Get(context, db);
|
|
925
935
|
|
|
926
936
|
updates.Flatten();
|
|
927
937
|
row_ids.Flatten(updates.size());
|
|
@@ -32,7 +32,7 @@ OptimisticDataWriter::~OptimisticDataWriter() {
|
|
|
32
32
|
|
|
33
33
|
bool OptimisticDataWriter::PrepareWrite() {
|
|
34
34
|
// check if we should pre-emptively write the table to disk
|
|
35
|
-
if (table->info->IsTemporary() || StorageManager::
|
|
35
|
+
if (table->info->IsTemporary() || StorageManager::Get(table->info->db).InMemory()) {
|
|
36
36
|
return false;
|
|
37
37
|
}
|
|
38
38
|
// we should! write the second-to-last row group to disk
|
|
@@ -362,8 +362,12 @@ LocalStorage &LocalStorage::Get(Transaction &transaction) {
|
|
|
362
362
|
return transaction.GetLocalStorage();
|
|
363
363
|
}
|
|
364
364
|
|
|
365
|
-
LocalStorage &LocalStorage::Get(ClientContext &context) {
|
|
366
|
-
return Transaction::
|
|
365
|
+
LocalStorage &LocalStorage::Get(ClientContext &context, AttachedDatabase &db) {
|
|
366
|
+
return Transaction::Get(context, db).GetLocalStorage();
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
LocalStorage &LocalStorage::Get(ClientContext &context, Catalog &catalog) {
|
|
370
|
+
return LocalStorage::Get(context, catalog.GetAttached());
|
|
367
371
|
}
|
|
368
372
|
|
|
369
373
|
void LocalStorage::InitializeScan(DataTable *table, CollectionScanState &state, TableFilterSet *table_filters) {
|
|
@@ -106,7 +106,7 @@ T DeserializeHeaderStructure(data_ptr_t ptr) {
|
|
|
106
106
|
return T::Deserialize(source);
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
SingleFileBlockManager::SingleFileBlockManager(
|
|
109
|
+
SingleFileBlockManager::SingleFileBlockManager(AttachedDatabase &db, string path_p, bool read_only, bool create_new,
|
|
110
110
|
bool use_direct_io)
|
|
111
111
|
: BlockManager(BufferManager::GetBufferManager(db)), db(db), path(move(path_p)),
|
|
112
112
|
header_buffer(Allocator::Get(db), FileBufferType::MANAGED_BUFFER,
|
|
@@ -129,7 +129,7 @@ SingleFileBlockManager::SingleFileBlockManager(DatabaseInstance &db, string path
|
|
|
129
129
|
flags |= FileFlags::FILE_FLAGS_DIRECT_IO;
|
|
130
130
|
}
|
|
131
131
|
// open the RDBMS handle
|
|
132
|
-
auto &fs = FileSystem::
|
|
132
|
+
auto &fs = FileSystem::Get(db);
|
|
133
133
|
handle = fs.OpenFile(path, flags, lock);
|
|
134
134
|
if (create_new) {
|
|
135
135
|
// if we create a new file, we fill the metadata of the file
|
|
@@ -416,7 +416,7 @@ void SingleFileBlockManager::WriteHeader(DatabaseHeader header) {
|
|
|
416
416
|
}
|
|
417
417
|
header.block_count = max_block;
|
|
418
418
|
|
|
419
|
-
auto &config = DBConfig::
|
|
419
|
+
auto &config = DBConfig::Get(db);
|
|
420
420
|
if (config.options.checkpoint_abort == CheckpointAbort::DEBUG_ABORT_AFTER_FREE_LIST_WRITE) {
|
|
421
421
|
throw FatalException("Checkpoint aborted after free list write because of PRAGMA checkpoint_abort flag");
|
|
422
422
|
}
|
|
@@ -7,24 +7,33 @@
|
|
|
7
7
|
#include "duckdb/catalog/catalog.hpp"
|
|
8
8
|
#include "duckdb/common/file_system.hpp"
|
|
9
9
|
#include "duckdb/main/database.hpp"
|
|
10
|
-
#include "duckdb/main/connection.hpp"
|
|
11
10
|
#include "duckdb/main/client_context.hpp"
|
|
12
11
|
#include "duckdb/function/function.hpp"
|
|
13
|
-
#include "duckdb/parser/parsed_data/create_schema_info.hpp"
|
|
14
12
|
#include "duckdb/transaction/transaction_manager.hpp"
|
|
15
13
|
#include "duckdb/common/serializer/buffered_file_reader.hpp"
|
|
14
|
+
#include "duckdb/main/attached_database.hpp"
|
|
16
15
|
|
|
17
16
|
namespace duckdb {
|
|
18
17
|
|
|
19
|
-
StorageManager::StorageManager(
|
|
20
|
-
: db(db), path(move(
|
|
18
|
+
StorageManager::StorageManager(AttachedDatabase &db, string path_p, bool read_only)
|
|
19
|
+
: db(db), path(move(path_p)), read_only(read_only) {
|
|
20
|
+
if (path.empty()) {
|
|
21
|
+
path = ":memory:";
|
|
22
|
+
}
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
StorageManager::~StorageManager() {
|
|
24
26
|
}
|
|
25
27
|
|
|
26
|
-
StorageManager &StorageManager::
|
|
27
|
-
return
|
|
28
|
+
StorageManager &StorageManager::Get(AttachedDatabase &db) {
|
|
29
|
+
return db.GetStorageManager();
|
|
30
|
+
}
|
|
31
|
+
StorageManager &StorageManager::Get(Catalog &catalog) {
|
|
32
|
+
return StorageManager::Get(catalog.GetAttached());
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
DatabaseInstance &StorageManager::GetDatabase() {
|
|
36
|
+
return db.GetDatabase();
|
|
28
37
|
}
|
|
29
38
|
|
|
30
39
|
BufferManager &BufferManager::GetBufferManager(ClientContext &context) {
|
|
@@ -40,12 +49,8 @@ bool ObjectCache::ObjectCacheEnabled(ClientContext &context) {
|
|
|
40
49
|
}
|
|
41
50
|
|
|
42
51
|
bool StorageManager::InMemory() {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
void StorageManager::CreateBufferManager() {
|
|
47
|
-
auto &config = DBConfig::GetConfig(db);
|
|
48
|
-
buffer_manager = make_unique<BufferManager>(db, config.options.temporary_directory, config.options.maximum_memory);
|
|
52
|
+
D_ASSERT(!path.empty());
|
|
53
|
+
return path == ":memory:";
|
|
49
54
|
}
|
|
50
55
|
|
|
51
56
|
void StorageManager::Initialize() {
|
|
@@ -53,30 +58,6 @@ void StorageManager::Initialize() {
|
|
|
53
58
|
if (in_memory && read_only) {
|
|
54
59
|
throw CatalogException("Cannot launch in-memory database in read-only mode!");
|
|
55
60
|
}
|
|
56
|
-
CreateBufferManager();
|
|
57
|
-
|
|
58
|
-
auto &config = DBConfig::GetConfig(db);
|
|
59
|
-
auto &catalog = Catalog::GetCatalog(db);
|
|
60
|
-
|
|
61
|
-
// first initialize the base system catalogs
|
|
62
|
-
// these are never written to the WAL
|
|
63
|
-
Connection con(db);
|
|
64
|
-
con.BeginTransaction();
|
|
65
|
-
|
|
66
|
-
// create the default schema
|
|
67
|
-
CreateSchemaInfo info;
|
|
68
|
-
info.schema = DEFAULT_SCHEMA;
|
|
69
|
-
info.internal = true;
|
|
70
|
-
catalog.CreateSchema(*con.context, &info);
|
|
71
|
-
|
|
72
|
-
if (config.options.initialize_default_database) {
|
|
73
|
-
// initialize default functions
|
|
74
|
-
BuiltinFunctions builtin(*con.context, catalog);
|
|
75
|
-
builtin.Initialize();
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// commit transactions
|
|
79
|
-
con.Commit();
|
|
80
61
|
|
|
81
62
|
// create or load the database from disk, if not in-memory mode
|
|
82
63
|
LoadDatabase();
|
|
@@ -99,20 +80,20 @@ public:
|
|
|
99
80
|
}
|
|
100
81
|
};
|
|
101
82
|
|
|
102
|
-
SingleFileStorageManager::SingleFileStorageManager(
|
|
83
|
+
SingleFileStorageManager::SingleFileStorageManager(AttachedDatabase &db, string path, bool read_only)
|
|
103
84
|
: StorageManager(db, move(path), read_only) {
|
|
104
85
|
}
|
|
105
86
|
|
|
106
87
|
void SingleFileStorageManager::LoadDatabase() {
|
|
107
88
|
if (InMemory()) {
|
|
108
|
-
block_manager = make_unique<InMemoryBlockManager>(
|
|
89
|
+
block_manager = make_unique<InMemoryBlockManager>(BufferManager::GetBufferManager(db));
|
|
109
90
|
table_io_manager = make_unique<SingleFileTableIOManager>(*block_manager);
|
|
110
91
|
return;
|
|
111
92
|
}
|
|
112
93
|
|
|
113
94
|
string wal_path = path + ".wal";
|
|
114
|
-
auto &fs = db
|
|
115
|
-
auto &config = db
|
|
95
|
+
auto &fs = FileSystem::Get(db);
|
|
96
|
+
auto &config = DBConfig::Get(db);
|
|
116
97
|
bool truncate_wal = false;
|
|
117
98
|
// first check if the database exists
|
|
118
99
|
if (!fs.FileExists(path)) {
|
|
@@ -228,7 +209,8 @@ void SingleFileStorageManager::CreateCheckpoint(bool delete_wal, bool force_chec
|
|
|
228
209
|
if (InMemory() || read_only || !wal) {
|
|
229
210
|
return;
|
|
230
211
|
}
|
|
231
|
-
|
|
212
|
+
auto &config = DBConfig::Get(db);
|
|
213
|
+
if (wal->GetWALSize() > 0 || config.options.force_checkpoint || force_checkpoint) {
|
|
232
214
|
// we only need to checkpoint if there is anything in the WAL
|
|
233
215
|
SingleFileCheckpointWriter checkpointer(db, *block_manager);
|
|
234
216
|
checkpointer.CreateCheckpoint();
|
|
@@ -261,9 +243,10 @@ bool SingleFileStorageManager::AutomaticCheckpoint(idx_t estimated_wal_bytes) {
|
|
|
261
243
|
return false;
|
|
262
244
|
}
|
|
263
245
|
|
|
246
|
+
auto &config = DBConfig::Get(db);
|
|
264
247
|
auto initial_size = log->GetWALSize();
|
|
265
248
|
idx_t expected_wal_size = initial_size + estimated_wal_bytes;
|
|
266
|
-
return expected_wal_size >
|
|
249
|
+
return expected_wal_size > config.options.checkpoint_wal_size;
|
|
267
250
|
}
|
|
268
251
|
|
|
269
252
|
shared_ptr<TableIOManager> SingleFileStorageManager::GetTableIOManager(BoundCreateTableInfo *info /*info*/) {
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
#include "duckdb/storage/table/struct_column_data.hpp"
|
|
16
16
|
#include "duckdb/storage/table/update_segment.hpp"
|
|
17
|
+
#include "duckdb/main/attached_database.hpp"
|
|
17
18
|
|
|
18
19
|
namespace duckdb {
|
|
19
20
|
|
|
@@ -38,7 +39,7 @@ ColumnData::~ColumnData() {
|
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
DatabaseInstance &ColumnData::GetDatabase() const {
|
|
41
|
-
return info.db;
|
|
42
|
+
return info.db.GetDatabase();
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
DataTableInfo &ColumnData::GetTableInfo() const {
|
|
@@ -13,20 +13,21 @@
|
|
|
13
13
|
#include "duckdb/storage/meta_block_reader.hpp"
|
|
14
14
|
#include "duckdb/transaction/transaction_manager.hpp"
|
|
15
15
|
#include "duckdb/main/database.hpp"
|
|
16
|
+
#include "duckdb/main/attached_database.hpp"
|
|
16
17
|
|
|
17
18
|
namespace duckdb {
|
|
18
19
|
|
|
19
20
|
constexpr const idx_t RowGroup::ROW_GROUP_VECTOR_COUNT;
|
|
20
21
|
constexpr const idx_t RowGroup::ROW_GROUP_SIZE;
|
|
21
22
|
|
|
22
|
-
RowGroup::RowGroup(
|
|
23
|
+
RowGroup::RowGroup(AttachedDatabase &db, BlockManager &block_manager, DataTableInfo &table_info, idx_t start,
|
|
23
24
|
idx_t count)
|
|
24
25
|
: SegmentBase(start, count), db(db), block_manager(block_manager), table_info(table_info) {
|
|
25
26
|
|
|
26
27
|
Verify();
|
|
27
28
|
}
|
|
28
29
|
|
|
29
|
-
RowGroup::RowGroup(
|
|
30
|
+
RowGroup::RowGroup(AttachedDatabase &db, BlockManager &block_manager, DataTableInfo &table_info,
|
|
30
31
|
const vector<LogicalType> &types, RowGroupPointer &&pointer)
|
|
31
32
|
: SegmentBase(pointer.row_start, pointer.tuple_count), db(db), block_manager(block_manager),
|
|
32
33
|
table_info(table_info) {
|
|
@@ -77,6 +78,10 @@ void VersionNode::SetStart(idx_t start) {
|
|
|
77
78
|
RowGroup::~RowGroup() {
|
|
78
79
|
}
|
|
79
80
|
|
|
81
|
+
DatabaseInstance &RowGroup::GetDatabase() {
|
|
82
|
+
return db.GetDatabase();
|
|
83
|
+
}
|
|
84
|
+
|
|
80
85
|
void RowGroup::InitializeEmpty(const vector<LogicalType> &types) {
|
|
81
86
|
// set up the segment trees for the column segments
|
|
82
87
|
for (idx_t i = 0; i < types.size(); i++) {
|
|
@@ -17,16 +17,17 @@
|
|
|
17
17
|
#include "duckdb/storage/data_table.hpp"
|
|
18
18
|
#include "duckdb/storage/write_ahead_log.hpp"
|
|
19
19
|
#include "duckdb/storage/storage_manager.hpp"
|
|
20
|
+
#include "duckdb/main/attached_database.hpp"
|
|
20
21
|
|
|
21
22
|
namespace duckdb {
|
|
22
23
|
|
|
23
|
-
bool WriteAheadLog::Replay(
|
|
24
|
-
auto initial_reader = make_unique<BufferedFileReader>(database
|
|
24
|
+
bool WriteAheadLog::Replay(AttachedDatabase &database, string &path) {
|
|
25
|
+
auto initial_reader = make_unique<BufferedFileReader>(FileSystem::Get(database), path.c_str());
|
|
25
26
|
if (initial_reader->Finished()) {
|
|
26
27
|
// WAL is empty
|
|
27
28
|
return false;
|
|
28
29
|
}
|
|
29
|
-
Connection con(database);
|
|
30
|
+
Connection con(database.GetDatabase());
|
|
30
31
|
con.BeginTransaction();
|
|
31
32
|
|
|
32
33
|
// first deserialize the WAL to look for a checkpoint flag
|
|
@@ -58,7 +59,7 @@ bool WriteAheadLog::Replay(DatabaseInstance &database, string &path) {
|
|
|
58
59
|
initial_reader.reset();
|
|
59
60
|
if (checkpoint_state.checkpoint_id != INVALID_BLOCK) {
|
|
60
61
|
// there is a checkpoint flag: check if we need to deserialize the WAL
|
|
61
|
-
auto &manager =
|
|
62
|
+
auto &manager = database.GetStorageManager();
|
|
62
63
|
if (manager.IsCheckpointClean(checkpoint_state.checkpoint_id)) {
|
|
63
64
|
// the contents of the WAL have already been checkpointed
|
|
64
65
|
// we can safely truncate the WAL and ignore its contents
|
|
@@ -67,7 +68,7 @@ bool WriteAheadLog::Replay(DatabaseInstance &database, string &path) {
|
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
// we need to recover from the WAL: actually set up the replay state
|
|
70
|
-
BufferedFileReader reader(database
|
|
71
|
+
BufferedFileReader reader(FileSystem::Get(database), path.c_str());
|
|
71
72
|
ReplayState state(database, *con.context, reader);
|
|
72
73
|
|
|
73
74
|
// replay the WAL
|
|
@@ -192,7 +193,6 @@ void ReplayState::ReplayCreateTable() {
|
|
|
192
193
|
auto binder = Binder::CreateBinder(context);
|
|
193
194
|
auto bound_info = binder->BindCreateTableInfo(move(info));
|
|
194
195
|
|
|
195
|
-
auto &catalog = Catalog::GetCatalog(context);
|
|
196
196
|
catalog.CreateTable(context, bound_info.get());
|
|
197
197
|
}
|
|
198
198
|
|
|
@@ -206,7 +206,6 @@ void ReplayState::ReplayDropTable() {
|
|
|
206
206
|
return;
|
|
207
207
|
}
|
|
208
208
|
|
|
209
|
-
auto &catalog = Catalog::GetCatalog(context);
|
|
210
209
|
catalog.DropEntry(context, &info);
|
|
211
210
|
}
|
|
212
211
|
|
|
@@ -215,7 +214,6 @@ void ReplayState::ReplayAlter() {
|
|
|
215
214
|
if (deserialize_only) {
|
|
216
215
|
return;
|
|
217
216
|
}
|
|
218
|
-
auto &catalog = Catalog::GetCatalog(context);
|
|
219
217
|
catalog.Alter(context, info.get());
|
|
220
218
|
}
|
|
221
219
|
|
|
@@ -228,7 +226,6 @@ void ReplayState::ReplayCreateView() {
|
|
|
228
226
|
return;
|
|
229
227
|
}
|
|
230
228
|
|
|
231
|
-
auto &catalog = Catalog::GetCatalog(context);
|
|
232
229
|
catalog.CreateView(context, entry.get());
|
|
233
230
|
}
|
|
234
231
|
|
|
@@ -240,7 +237,6 @@ void ReplayState::ReplayDropView() {
|
|
|
240
237
|
if (deserialize_only) {
|
|
241
238
|
return;
|
|
242
239
|
}
|
|
243
|
-
auto &catalog = Catalog::GetCatalog(context);
|
|
244
240
|
catalog.DropEntry(context, &info);
|
|
245
241
|
}
|
|
246
242
|
|
|
@@ -254,7 +250,6 @@ void ReplayState::ReplayCreateSchema() {
|
|
|
254
250
|
return;
|
|
255
251
|
}
|
|
256
252
|
|
|
257
|
-
auto &catalog = Catalog::GetCatalog(context);
|
|
258
253
|
catalog.CreateSchema(context, &info);
|
|
259
254
|
}
|
|
260
255
|
|
|
@@ -267,7 +262,6 @@ void ReplayState::ReplayDropSchema() {
|
|
|
267
262
|
return;
|
|
268
263
|
}
|
|
269
264
|
|
|
270
|
-
auto &catalog = Catalog::GetCatalog(context);
|
|
271
265
|
catalog.DropEntry(context, &info);
|
|
272
266
|
}
|
|
273
267
|
|
|
@@ -280,7 +274,6 @@ void ReplayState::ReplayCreateType() {
|
|
|
280
274
|
return;
|
|
281
275
|
}
|
|
282
276
|
|
|
283
|
-
auto &catalog = Catalog::GetCatalog(context);
|
|
284
277
|
catalog.CreateType(context, info.get());
|
|
285
278
|
}
|
|
286
279
|
|
|
@@ -294,7 +287,6 @@ void ReplayState::ReplayDropType() {
|
|
|
294
287
|
return;
|
|
295
288
|
}
|
|
296
289
|
|
|
297
|
-
auto &catalog = Catalog::GetCatalog(context);
|
|
298
290
|
catalog.DropEntry(context, &info);
|
|
299
291
|
}
|
|
300
292
|
|
|
@@ -307,7 +299,6 @@ void ReplayState::ReplayCreateSequence() {
|
|
|
307
299
|
return;
|
|
308
300
|
}
|
|
309
301
|
|
|
310
|
-
auto &catalog = Catalog::GetCatalog(context);
|
|
311
302
|
catalog.CreateSequence(context, entry.get());
|
|
312
303
|
}
|
|
313
304
|
|
|
@@ -320,7 +311,6 @@ void ReplayState::ReplayDropSequence() {
|
|
|
320
311
|
return;
|
|
321
312
|
}
|
|
322
313
|
|
|
323
|
-
auto &catalog = Catalog::GetCatalog(context);
|
|
324
314
|
catalog.DropEntry(context, &info);
|
|
325
315
|
}
|
|
326
316
|
|
|
@@ -334,7 +324,6 @@ void ReplayState::ReplaySequenceValue() {
|
|
|
334
324
|
}
|
|
335
325
|
|
|
336
326
|
// fetch the sequence from the catalog
|
|
337
|
-
auto &catalog = Catalog::GetCatalog(context);
|
|
338
327
|
auto seq = catalog.GetEntry<SequenceCatalogEntry>(context, schema, name);
|
|
339
328
|
if (usage_count > seq->usage_count) {
|
|
340
329
|
seq->usage_count = usage_count;
|
|
@@ -351,7 +340,6 @@ void ReplayState::ReplayCreateMacro() {
|
|
|
351
340
|
return;
|
|
352
341
|
}
|
|
353
342
|
|
|
354
|
-
auto &catalog = Catalog::GetCatalog(context);
|
|
355
343
|
catalog.CreateFunction(context, entry.get());
|
|
356
344
|
}
|
|
357
345
|
|
|
@@ -364,7 +352,6 @@ void ReplayState::ReplayDropMacro() {
|
|
|
364
352
|
return;
|
|
365
353
|
}
|
|
366
354
|
|
|
367
|
-
auto &catalog = Catalog::GetCatalog(context);
|
|
368
355
|
catalog.DropEntry(context, &info);
|
|
369
356
|
}
|
|
370
357
|
|
|
@@ -377,7 +364,6 @@ void ReplayState::ReplayCreateTableMacro() {
|
|
|
377
364
|
return;
|
|
378
365
|
}
|
|
379
366
|
|
|
380
|
-
auto &catalog = Catalog::GetCatalog(context);
|
|
381
367
|
catalog.CreateFunction(context, entry.get());
|
|
382
368
|
}
|
|
383
369
|
|
|
@@ -390,7 +376,6 @@ void ReplayState::ReplayDropTableMacro() {
|
|
|
390
376
|
return;
|
|
391
377
|
}
|
|
392
378
|
|
|
393
|
-
auto &catalog = Catalog::GetCatalog(context);
|
|
394
379
|
catalog.DropEntry(context, &info);
|
|
395
380
|
}
|
|
396
381
|
|
|
@@ -403,7 +388,6 @@ void ReplayState::ReplayUseTable() {
|
|
|
403
388
|
if (deserialize_only) {
|
|
404
389
|
return;
|
|
405
390
|
}
|
|
406
|
-
auto &catalog = Catalog::GetCatalog(context);
|
|
407
391
|
current_table = catalog.GetEntry<TableCatalogEntry>(context, schema_name, table_name);
|
|
408
392
|
}
|
|
409
393
|
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
|
|
12
12
|
namespace duckdb {
|
|
13
13
|
|
|
14
|
-
WriteAheadLog::WriteAheadLog(
|
|
14
|
+
WriteAheadLog::WriteAheadLog(AttachedDatabase &database, const string &path) : skip_writing(false), database(database) {
|
|
15
15
|
wal_path = path;
|
|
16
|
-
writer = make_unique<BufferedFileWriter>(database
|
|
16
|
+
writer = make_unique<BufferedFileWriter>(FileSystem::Get(database), path.c_str(),
|
|
17
17
|
FileFlags::FILE_FLAGS_WRITE | FileFlags::FILE_FLAGS_FILE_CREATE |
|
|
18
18
|
FileFlags::FILE_FLAGS_APPEND);
|
|
19
19
|
}
|
|
@@ -41,7 +41,7 @@ void WriteAheadLog::Delete() {
|
|
|
41
41
|
}
|
|
42
42
|
writer.reset();
|
|
43
43
|
|
|
44
|
-
auto &fs = FileSystem::
|
|
44
|
+
auto &fs = FileSystem::Get(database);
|
|
45
45
|
fs.RemoveFile(wal_path);
|
|
46
46
|
}
|
|
47
47
|
|