duckdb 0.6.2-dev772.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/connection.cpp +1 -1
- 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
|
@@ -27,9 +27,9 @@ public:
|
|
|
27
27
|
idx_t query_location;
|
|
28
28
|
|
|
29
29
|
public:
|
|
30
|
-
static string Format(const string &query, const string &error_message, int error_location);
|
|
30
|
+
DUCKDB_API static string Format(const string &query, const string &error_message, int error_location);
|
|
31
31
|
|
|
32
|
-
string FormatErrorRecursive(const string &msg, vector<ExceptionFormatValue> &values);
|
|
32
|
+
DUCKDB_API string FormatErrorRecursive(const string &msg, vector<ExceptionFormatValue> &values);
|
|
33
33
|
template <class T, typename... Args>
|
|
34
34
|
string FormatErrorRecursive(const string &msg, vector<ExceptionFormatValue> &values, T param, Args... params) {
|
|
35
35
|
values.push_back(ExceptionFormatValue::CreateFormatValue<T>(param));
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//===----------------------------------------------------------------------===//
|
|
2
|
+
// DuckDB
|
|
3
|
+
//
|
|
4
|
+
// duckdb/parser/statement/attach_statement.hpp
|
|
5
|
+
//
|
|
6
|
+
//
|
|
7
|
+
//===----------------------------------------------------------------------===//
|
|
8
|
+
|
|
9
|
+
#pragma once
|
|
10
|
+
|
|
11
|
+
#include "duckdb/parser/parsed_data/attach_info.hpp"
|
|
12
|
+
#include "duckdb/parser/sql_statement.hpp"
|
|
13
|
+
|
|
14
|
+
namespace duckdb {
|
|
15
|
+
|
|
16
|
+
class AttachStatement : public SQLStatement {
|
|
17
|
+
public:
|
|
18
|
+
AttachStatement();
|
|
19
|
+
|
|
20
|
+
unique_ptr<AttachInfo> info;
|
|
21
|
+
|
|
22
|
+
protected:
|
|
23
|
+
AttachStatement(const AttachStatement &other);
|
|
24
|
+
|
|
25
|
+
public:
|
|
26
|
+
unique_ptr<SQLStatement> Copy() const override;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
} // namespace duckdb
|
|
@@ -28,6 +28,8 @@ public:
|
|
|
28
28
|
string table;
|
|
29
29
|
//! Schema name to insert to
|
|
30
30
|
string schema;
|
|
31
|
+
//! The catalog name to insert to
|
|
32
|
+
string catalog;
|
|
31
33
|
|
|
32
34
|
//! keep track of optional returningList if statement contains a RETURNING keyword
|
|
33
35
|
vector<unique_ptr<ParsedExpression>> returning_list;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#include "duckdb/parser/statement/alter_statement.hpp"
|
|
2
|
+
#include "duckdb/parser/statement/attach_statement.hpp"
|
|
2
3
|
#include "duckdb/parser/statement/call_statement.hpp"
|
|
3
4
|
#include "duckdb/parser/statement/copy_statement.hpp"
|
|
4
5
|
#include "duckdb/parser/statement/create_statement.hpp"
|
|
@@ -15,9 +15,12 @@ namespace duckdb {
|
|
|
15
15
|
//! Represents a TableReference to a base table in the schema
|
|
16
16
|
class BaseTableRef : public TableRef {
|
|
17
17
|
public:
|
|
18
|
-
BaseTableRef()
|
|
18
|
+
BaseTableRef()
|
|
19
|
+
: TableRef(TableReferenceType::BASE_TABLE), catalog_name(INVALID_CATALOG), schema_name(INVALID_SCHEMA) {
|
|
19
20
|
}
|
|
20
21
|
|
|
22
|
+
//! The catalog name
|
|
23
|
+
string catalog_name;
|
|
21
24
|
//! Schema name
|
|
22
25
|
string schema_name;
|
|
23
26
|
//! Table name
|
|
@@ -144,6 +144,8 @@ private:
|
|
|
144
144
|
unique_ptr<SQLStatement> TransformVacuum(duckdb_libpgquery::PGNode *node);
|
|
145
145
|
unique_ptr<SQLStatement> TransformShow(duckdb_libpgquery::PGNode *node);
|
|
146
146
|
unique_ptr<ShowStatement> TransformShowSelect(duckdb_libpgquery::PGNode *node);
|
|
147
|
+
unique_ptr<AttachStatement> TransformAttach(duckdb_libpgquery::PGNode *node);
|
|
148
|
+
unique_ptr<SetStatement> TransformUse(duckdb_libpgquery::PGNode *node);
|
|
147
149
|
|
|
148
150
|
unique_ptr<PrepareStatement> TransformPrepare(duckdb_libpgquery::PGNode *node);
|
|
149
151
|
unique_ptr<ExecuteStatement> TransformExecute(duckdb_libpgquery::PGNode *node);
|
|
@@ -63,6 +63,8 @@ public:
|
|
|
63
63
|
unique_ptr<ParsedExpression> CreateColumnReference(const string &table_name, const string &column_name);
|
|
64
64
|
unique_ptr<ParsedExpression> CreateColumnReference(const string &schema_name, const string &table_name,
|
|
65
65
|
const string &column_name);
|
|
66
|
+
unique_ptr<ParsedExpression> CreateColumnReference(const string &catalog_name, const string &schema_name,
|
|
67
|
+
const string &table_name, const string &column_name);
|
|
66
68
|
|
|
67
69
|
//! Generate column expressions for all columns that are present in the
|
|
68
70
|
//! referenced tables. This is used to resolve the * expression in a
|
|
@@ -100,6 +100,7 @@ public:
|
|
|
100
100
|
BoundStatement Bind(QueryNode &node);
|
|
101
101
|
|
|
102
102
|
unique_ptr<BoundCreateTableInfo> BindCreateTableInfo(unique_ptr<CreateInfo> info);
|
|
103
|
+
unique_ptr<BoundCreateTableInfo> BindCreateTableInfo(unique_ptr<CreateInfo> info, SchemaCatalogEntry *schema);
|
|
103
104
|
void BindCreateViewInfo(CreateViewInfo &base);
|
|
104
105
|
SchemaCatalogEntry *BindSchema(CreateInfo &info);
|
|
105
106
|
SchemaCatalogEntry *BindCreateFunctionInfo(CreateInfo &info);
|
|
@@ -153,11 +154,15 @@ public:
|
|
|
153
154
|
return FormatErrorRecursive(query_location, msg, values, params...);
|
|
154
155
|
}
|
|
155
156
|
|
|
156
|
-
static void
|
|
157
|
+
static void BindSchemaOrCatalog(ClientContext &context, string &catalog, string &schema);
|
|
158
|
+
static void BindLogicalType(ClientContext &context, LogicalType &type, const string &catalog = INVALID_CATALOG,
|
|
159
|
+
const string &schema = INVALID_SCHEMA);
|
|
157
160
|
|
|
158
161
|
bool HasMatchingBinding(const string &table_name, const string &column_name, string &error_message);
|
|
159
162
|
bool HasMatchingBinding(const string &schema_name, const string &table_name, const string &column_name,
|
|
160
163
|
string &error_message);
|
|
164
|
+
bool HasMatchingBinding(const string &catalog_name, const string &schema_name, const string &table_name,
|
|
165
|
+
const string &column_name, string &error_message);
|
|
161
166
|
|
|
162
167
|
void SetBindingMode(BindingMode mode);
|
|
163
168
|
BindingMode GetBindingMode();
|
|
@@ -227,6 +232,7 @@ private:
|
|
|
227
232
|
BoundStatement Bind(ResetVariableStatement &stmt);
|
|
228
233
|
BoundStatement Bind(LoadStatement &stmt);
|
|
229
234
|
BoundStatement Bind(LogicalPlanStatement &stmt);
|
|
235
|
+
BoundStatement Bind(AttachStatement &stmt);
|
|
230
236
|
|
|
231
237
|
BoundStatement BindReturning(vector<unique_ptr<ParsedExpression>> returning_list, TableCatalogEntry *table,
|
|
232
238
|
idx_t update_table_index, unique_ptr<LogicalOperator> child_operator,
|
|
@@ -314,6 +320,10 @@ private:
|
|
|
314
320
|
bool FindStarExpression(ParsedExpression &expr, StarExpression **star);
|
|
315
321
|
void ReplaceStarExpression(unique_ptr<ParsedExpression> &expr, unique_ptr<ParsedExpression> &replacement);
|
|
316
322
|
|
|
323
|
+
//! If only a schema name is provided (e.g. "a.b") then figure out if "a" is a schema or a catalog name
|
|
324
|
+
void BindSchemaOrCatalog(string &catalog_name, string &schema_name);
|
|
325
|
+
SchemaCatalogEntry *BindCreateSchema(CreateInfo &info);
|
|
326
|
+
|
|
317
327
|
public:
|
|
318
328
|
// This should really be a private constructor, but make_shared does not allow it...
|
|
319
329
|
// If you are thinking about calling this, you should probably call Binder::CreateBinder
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
#include "duckdb/catalog/catalog_entry/table_column_type.hpp"
|
|
18
18
|
#include "duckdb/catalog/catalog_entry/column_dependency_manager.hpp"
|
|
19
19
|
#include "duckdb/storage/table/table_index_list.hpp"
|
|
20
|
+
#include "duckdb/catalog/dependency_list.hpp"
|
|
20
21
|
|
|
21
22
|
namespace duckdb {
|
|
22
23
|
class CatalogEntry;
|
|
@@ -39,7 +40,7 @@ struct BoundCreateTableInfo {
|
|
|
39
40
|
//! Bound default values
|
|
40
41
|
vector<unique_ptr<Expression>> bound_defaults;
|
|
41
42
|
//! Dependents of the table (in e.g. default values)
|
|
42
|
-
|
|
43
|
+
DependencyList dependencies;
|
|
43
44
|
//! The existing table data on disk (if any)
|
|
44
45
|
unique_ptr<PersistentTableData> data;
|
|
45
46
|
//! CREATE TABLE from QUERY
|
|
@@ -59,6 +59,7 @@ public:
|
|
|
59
59
|
|
|
60
60
|
static BufferManager &GetBufferManager(ClientContext &context);
|
|
61
61
|
DUCKDB_API static BufferManager &GetBufferManager(DatabaseInstance &db);
|
|
62
|
+
DUCKDB_API static BufferManager &GetBufferManager(AttachedDatabase &db);
|
|
62
63
|
|
|
63
64
|
idx_t GetUsedMemory() {
|
|
64
65
|
return current_memory;
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
#include "duckdb/storage/partial_block_manager.hpp"
|
|
12
12
|
#include "duckdb/catalog/catalog_entry/index_catalog_entry.hpp"
|
|
13
|
+
#include "duckdb/catalog/catalog.hpp"
|
|
13
14
|
|
|
14
15
|
namespace duckdb {
|
|
15
16
|
class DatabaseInstance;
|
|
@@ -24,13 +25,15 @@ class TypeCatalogEntry;
|
|
|
24
25
|
|
|
25
26
|
class CheckpointWriter {
|
|
26
27
|
public:
|
|
27
|
-
explicit CheckpointWriter(
|
|
28
|
+
explicit CheckpointWriter(AttachedDatabase &db) : db(db), catalog(Catalog::GetCatalog(db)) {
|
|
28
29
|
}
|
|
29
30
|
virtual ~CheckpointWriter() {
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
//! The database
|
|
33
|
-
|
|
34
|
+
AttachedDatabase &db;
|
|
35
|
+
//! The catalog
|
|
36
|
+
Catalog &catalog;
|
|
34
37
|
|
|
35
38
|
virtual MetaBlockWriter &GetMetaBlockWriter() = 0;
|
|
36
39
|
virtual unique_ptr<TableDataWriter> GetTableDataWriter(TableCatalogEntry &table) = 0;
|
|
@@ -48,9 +51,14 @@ protected:
|
|
|
48
51
|
|
|
49
52
|
class CheckpointReader {
|
|
50
53
|
public:
|
|
54
|
+
CheckpointReader(Catalog &catalog) : catalog(catalog) {
|
|
55
|
+
}
|
|
51
56
|
virtual ~CheckpointReader() {
|
|
52
57
|
}
|
|
53
58
|
|
|
59
|
+
protected:
|
|
60
|
+
Catalog &catalog;
|
|
61
|
+
|
|
54
62
|
protected:
|
|
55
63
|
virtual void LoadCheckpoint(ClientContext &context, MetaBlockReader &reader);
|
|
56
64
|
virtual void ReadSchema(ClientContext &context, MetaBlockReader &reader);
|
|
@@ -67,7 +75,8 @@ protected:
|
|
|
67
75
|
|
|
68
76
|
class SingleFileCheckpointReader final : public CheckpointReader {
|
|
69
77
|
public:
|
|
70
|
-
explicit SingleFileCheckpointReader(SingleFileStorageManager &storage)
|
|
78
|
+
explicit SingleFileCheckpointReader(SingleFileStorageManager &storage)
|
|
79
|
+
: CheckpointReader(Catalog::GetCatalog(storage.GetAttached())), storage(storage) {
|
|
71
80
|
}
|
|
72
81
|
|
|
73
82
|
void LoadFromStorage();
|
|
@@ -85,9 +94,7 @@ class SingleFileCheckpointWriter final : public CheckpointWriter {
|
|
|
85
94
|
friend class SingleFileTableDataWriter;
|
|
86
95
|
|
|
87
96
|
public:
|
|
88
|
-
|
|
89
|
-
: CheckpointWriter(db), partial_block_manager(block_manager) {
|
|
90
|
-
}
|
|
97
|
+
SingleFileCheckpointWriter(AttachedDatabase &db, BlockManager &block_manager);
|
|
91
98
|
|
|
92
99
|
//! Checkpoint the current state of the WAL and flush it to the main storage. This should be called BEFORE any
|
|
93
100
|
//! connection is available because right now the checkpointing cannot be done online. (TODO)
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
#include "duckdb/storage/table/data_table_info.hpp"
|
|
25
25
|
|
|
26
26
|
namespace duckdb {
|
|
27
|
+
class BoundForeignKeyConstraint;
|
|
27
28
|
class ClientContext;
|
|
28
29
|
class ColumnDataCollection;
|
|
29
30
|
class ColumnDefinition;
|
|
@@ -41,7 +42,7 @@ class TableDataWriter;
|
|
|
41
42
|
class DataTable {
|
|
42
43
|
public:
|
|
43
44
|
//! Constructs a new data table from an (optional) set of persistent segments
|
|
44
|
-
DataTable(
|
|
45
|
+
DataTable(AttachedDatabase &db, shared_ptr<TableIOManager> table_io_manager, const string &schema,
|
|
45
46
|
const string &table, vector<ColumnDefinition> column_definitions_p,
|
|
46
47
|
unique_ptr<PersistentTableData> data = nullptr);
|
|
47
48
|
//! Constructs a DataTable as a delta on an existing data table with a newly added column
|
|
@@ -59,7 +60,7 @@ public:
|
|
|
59
60
|
//! The set of physical columns stored by this DataTable
|
|
60
61
|
vector<ColumnDefinition> column_definitions;
|
|
61
62
|
//! A reference to the database instance
|
|
62
|
-
|
|
63
|
+
AttachedDatabase &db;
|
|
63
64
|
|
|
64
65
|
public:
|
|
65
66
|
//! Returns a list of types of the table
|
|
@@ -190,6 +191,13 @@ private:
|
|
|
190
191
|
void InitializeScanWithOffset(TableScanState &state, const vector<column_t> &column_ids, idx_t start_row,
|
|
191
192
|
idx_t end_row);
|
|
192
193
|
|
|
194
|
+
void VerifyForeignKeyConstraint(const BoundForeignKeyConstraint &bfk, ClientContext &context, DataChunk &chunk,
|
|
195
|
+
bool is_append);
|
|
196
|
+
void VerifyAppendForeignKeyConstraint(const BoundForeignKeyConstraint &bfk, ClientContext &context,
|
|
197
|
+
DataChunk &chunk);
|
|
198
|
+
void VerifyDeleteForeignKeyConstraint(const BoundForeignKeyConstraint &bfk, ClientContext &context,
|
|
199
|
+
DataChunk &chunk);
|
|
200
|
+
|
|
193
201
|
private:
|
|
194
202
|
//! Lock for appending entries to the table
|
|
195
203
|
mutex append_lock;
|
|
@@ -25,7 +25,7 @@ class SingleFileBlockManager : public BlockManager {
|
|
|
25
25
|
static constexpr uint64_t BLOCK_START = Storage::FILE_HEADER_SIZE * 3;
|
|
26
26
|
|
|
27
27
|
public:
|
|
28
|
-
SingleFileBlockManager(
|
|
28
|
+
SingleFileBlockManager(AttachedDatabase &db, string path, bool read_only, bool create_new, bool use_direct_io);
|
|
29
29
|
|
|
30
30
|
//! Creates a new Block using the specified block_id and returns a pointer
|
|
31
31
|
unique_ptr<Block> CreateBlock(block_id_t block_id, FileBuffer *source_buffer) override;
|
|
@@ -63,7 +63,7 @@ private:
|
|
|
63
63
|
vector<block_id_t> GetFreeListBlocks();
|
|
64
64
|
|
|
65
65
|
private:
|
|
66
|
-
|
|
66
|
+
AttachedDatabase &db;
|
|
67
67
|
//! The active DatabaseHeader, either 0 (h1) or 1 (h2)
|
|
68
68
|
uint8_t active_header;
|
|
69
69
|
//! The path where the file is stored
|
|
@@ -46,8 +46,8 @@ public:
|
|
|
46
46
|
public:
|
|
47
47
|
static unique_ptr<BaseStatistics> CreateEmpty(LogicalType type, StatisticsType stats_type);
|
|
48
48
|
|
|
49
|
-
bool CanHaveNull() const;
|
|
50
|
-
bool CanHaveNoNull() const;
|
|
49
|
+
DUCKDB_API bool CanHaveNull() const;
|
|
50
|
+
DUCKDB_API bool CanHaveNoNull() const;
|
|
51
51
|
|
|
52
52
|
void UpdateDistinctStatistics(Vector &v, idx_t count);
|
|
53
53
|
|
|
@@ -46,22 +46,18 @@ public:
|
|
|
46
46
|
//! database on disk
|
|
47
47
|
class StorageManager {
|
|
48
48
|
public:
|
|
49
|
-
StorageManager(
|
|
49
|
+
StorageManager(AttachedDatabase &db, string path, bool read_only);
|
|
50
50
|
virtual ~StorageManager();
|
|
51
51
|
|
|
52
|
-
//! The BufferManager of the database
|
|
53
|
-
unique_ptr<BufferManager> buffer_manager;
|
|
54
|
-
//! The database this storagemanager belongs to
|
|
55
|
-
DatabaseInstance &db;
|
|
56
|
-
|
|
57
52
|
public:
|
|
58
|
-
static StorageManager &
|
|
59
|
-
static StorageManager &
|
|
53
|
+
static StorageManager &Get(AttachedDatabase &db);
|
|
54
|
+
static StorageManager &Get(Catalog &catalog);
|
|
60
55
|
|
|
61
56
|
//! Initialize a database or load an existing database from the given path
|
|
62
57
|
void Initialize();
|
|
63
58
|
|
|
64
|
-
DatabaseInstance &GetDatabase()
|
|
59
|
+
DatabaseInstance &GetDatabase();
|
|
60
|
+
AttachedDatabase &GetAttached() {
|
|
65
61
|
return db;
|
|
66
62
|
}
|
|
67
63
|
|
|
@@ -84,13 +80,14 @@ public:
|
|
|
84
80
|
|
|
85
81
|
protected:
|
|
86
82
|
virtual void LoadDatabase() = 0;
|
|
87
|
-
virtual void CreateBufferManager();
|
|
88
83
|
|
|
84
|
+
protected:
|
|
85
|
+
//! The database this storagemanager belongs to
|
|
86
|
+
AttachedDatabase &db;
|
|
89
87
|
//! The path of the database
|
|
90
88
|
string path;
|
|
91
89
|
//! The WriteAheadLog of the storage manager
|
|
92
90
|
unique_ptr<WriteAheadLog> wal;
|
|
93
|
-
|
|
94
91
|
//! Whether or not the database is opened in read-only mode
|
|
95
92
|
bool read_only;
|
|
96
93
|
};
|
|
@@ -98,7 +95,7 @@ protected:
|
|
|
98
95
|
//! Stores database in a single file.
|
|
99
96
|
class SingleFileStorageManager : public StorageManager {
|
|
100
97
|
public:
|
|
101
|
-
SingleFileStorageManager(
|
|
98
|
+
SingleFileStorageManager(AttachedDatabase &db, string path, bool read_only);
|
|
102
99
|
|
|
103
100
|
//! The BlockManager to read/store meta information and data in blocks
|
|
104
101
|
unique_ptr<BlockManager> block_manager;
|
|
@@ -17,12 +17,10 @@ class DatabaseInstance;
|
|
|
17
17
|
class TableIOManager;
|
|
18
18
|
|
|
19
19
|
struct DataTableInfo {
|
|
20
|
-
DataTableInfo(
|
|
21
|
-
: db(db), table_io_manager(move(table_io_manager_p)), cardinality(0), schema(move(schema)), table(move(table)) {
|
|
22
|
-
}
|
|
20
|
+
DataTableInfo(AttachedDatabase &db, shared_ptr<TableIOManager> table_io_manager_p, string schema, string table);
|
|
23
21
|
|
|
24
22
|
//! The database instance of the table
|
|
25
|
-
|
|
23
|
+
AttachedDatabase &db;
|
|
26
24
|
//! The table IO manager
|
|
27
25
|
shared_ptr<TableIOManager> table_io_manager;
|
|
28
26
|
//! The amount of elements in the table. Note that this number signifies the amount of COMMITTED entries in the
|
|
@@ -35,9 +33,7 @@ struct DataTableInfo {
|
|
|
35
33
|
|
|
36
34
|
TableIndexList indexes;
|
|
37
35
|
|
|
38
|
-
bool IsTemporary()
|
|
39
|
-
return schema == TEMP_SCHEMA;
|
|
40
|
-
}
|
|
36
|
+
bool IsTemporary() const;
|
|
41
37
|
};
|
|
42
38
|
|
|
43
39
|
} // namespace duckdb
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
#include "duckdb/parser/column_list.hpp"
|
|
20
20
|
|
|
21
21
|
namespace duckdb {
|
|
22
|
+
class AttachedDatabase;
|
|
22
23
|
class BlockManager;
|
|
23
24
|
class ColumnData;
|
|
24
25
|
class DatabaseInstance;
|
|
@@ -49,15 +50,15 @@ public:
|
|
|
49
50
|
static constexpr const idx_t ROW_GROUP_VECTOR_COUNT = ROW_GROUP_SIZE / STANDARD_VECTOR_SIZE;
|
|
50
51
|
|
|
51
52
|
public:
|
|
52
|
-
RowGroup(
|
|
53
|
-
RowGroup(
|
|
53
|
+
RowGroup(AttachedDatabase &db, BlockManager &block_manager, DataTableInfo &table_info, idx_t start, idx_t count);
|
|
54
|
+
RowGroup(AttachedDatabase &db, BlockManager &block_manager, DataTableInfo &table_info,
|
|
54
55
|
const vector<LogicalType> &types, RowGroupPointer &&pointer);
|
|
55
56
|
RowGroup(RowGroup &row_group, idx_t start);
|
|
56
57
|
~RowGroup();
|
|
57
58
|
|
|
58
59
|
private:
|
|
59
60
|
//! The database instance
|
|
60
|
-
|
|
61
|
+
AttachedDatabase &db;
|
|
61
62
|
//! The block manager
|
|
62
63
|
BlockManager &block_manager;
|
|
63
64
|
//! The table info of this row_group
|
|
@@ -70,9 +71,7 @@ private:
|
|
|
70
71
|
vector<shared_ptr<SegmentStatistics>> stats;
|
|
71
72
|
|
|
72
73
|
public:
|
|
73
|
-
DatabaseInstance &GetDatabase()
|
|
74
|
-
return db;
|
|
75
|
-
}
|
|
74
|
+
DatabaseInstance &GetDatabase();
|
|
76
75
|
BlockManager &GetBlockManager() {
|
|
77
76
|
return block_manager;
|
|
78
77
|
}
|
|
@@ -22,6 +22,7 @@ namespace duckdb {
|
|
|
22
22
|
|
|
23
23
|
struct AlterInfo;
|
|
24
24
|
|
|
25
|
+
class AttachedDatabase;
|
|
25
26
|
class BufferedSerializer;
|
|
26
27
|
class Catalog;
|
|
27
28
|
class DatabaseInstance;
|
|
@@ -36,13 +37,14 @@ class TransactionManager;
|
|
|
36
37
|
|
|
37
38
|
class ReplayState {
|
|
38
39
|
public:
|
|
39
|
-
ReplayState(
|
|
40
|
-
: db(db), context(context),
|
|
41
|
-
checkpoint_id(INVALID_BLOCK) {
|
|
40
|
+
ReplayState(AttachedDatabase &db, ClientContext &context, Deserializer &source)
|
|
41
|
+
: db(db), context(context), catalog(Catalog::GetCatalog(context, INVALID_CATALOG)), source(source),
|
|
42
|
+
current_table(nullptr), deserialize_only(false), checkpoint_id(INVALID_BLOCK) {
|
|
42
43
|
}
|
|
43
44
|
|
|
44
|
-
|
|
45
|
+
AttachedDatabase &db;
|
|
45
46
|
ClientContext &context;
|
|
47
|
+
Catalog &catalog;
|
|
46
48
|
Deserializer &source;
|
|
47
49
|
TableCatalogEntry *current_table;
|
|
48
50
|
bool deserialize_only;
|
|
@@ -89,7 +91,7 @@ protected:
|
|
|
89
91
|
class WriteAheadLog {
|
|
90
92
|
public:
|
|
91
93
|
//! Initialize the WAL in the specified directory
|
|
92
|
-
explicit WriteAheadLog(
|
|
94
|
+
explicit WriteAheadLog(AttachedDatabase &database, const string &path);
|
|
93
95
|
virtual ~WriteAheadLog();
|
|
94
96
|
|
|
95
97
|
//! Skip writing to the WAL
|
|
@@ -97,7 +99,7 @@ public:
|
|
|
97
99
|
|
|
98
100
|
public:
|
|
99
101
|
//! Replay the WAL
|
|
100
|
-
static bool Replay(
|
|
102
|
+
static bool Replay(AttachedDatabase &database, string &path);
|
|
101
103
|
|
|
102
104
|
//! Returns the current size of the WAL in bytes
|
|
103
105
|
int64_t GetWALSize();
|
|
@@ -151,7 +153,7 @@ public:
|
|
|
151
153
|
void WriteCheckpoint(block_id_t meta_block);
|
|
152
154
|
|
|
153
155
|
protected:
|
|
154
|
-
|
|
156
|
+
AttachedDatabase &database;
|
|
155
157
|
unique_ptr<BufferedFileWriter> writer;
|
|
156
158
|
string wal_path;
|
|
157
159
|
};
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
#include "duckdb/storage/table/table_statistics.hpp"
|
|
15
15
|
|
|
16
16
|
namespace duckdb {
|
|
17
|
+
class AttachedDatabase;
|
|
17
18
|
class DataTable;
|
|
18
19
|
class WriteAheadLog;
|
|
19
20
|
struct TableAppendState;
|
|
@@ -123,7 +124,8 @@ public:
|
|
|
123
124
|
explicit LocalStorage(ClientContext &context, Transaction &transaction);
|
|
124
125
|
|
|
125
126
|
static LocalStorage &Get(Transaction &transaction);
|
|
126
|
-
static LocalStorage &Get(ClientContext &context);
|
|
127
|
+
static LocalStorage &Get(ClientContext &context, AttachedDatabase &db);
|
|
128
|
+
static LocalStorage &Get(ClientContext &context, Catalog &catalog);
|
|
127
129
|
|
|
128
130
|
//! Initialize a scan of the local storage
|
|
129
131
|
void InitializeScan(DataTable *table, CollectionScanState &state, TableFilterSet *table_filters);
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
//===----------------------------------------------------------------------===//
|
|
2
|
+
// DuckDB
|
|
3
|
+
//
|
|
4
|
+
// duckdb/transaction/meta_transaction.hpp
|
|
5
|
+
//
|
|
6
|
+
//
|
|
7
|
+
//===----------------------------------------------------------------------===//
|
|
8
|
+
|
|
9
|
+
#pragma once
|
|
10
|
+
|
|
11
|
+
#include "duckdb/common/common.hpp"
|
|
12
|
+
#include "duckdb/common/atomic.hpp"
|
|
13
|
+
#include "duckdb/main/valid_checker.hpp"
|
|
14
|
+
#include "duckdb/common/types/timestamp.hpp"
|
|
15
|
+
#include "duckdb/common/unordered_map.hpp"
|
|
16
|
+
|
|
17
|
+
namespace duckdb {
|
|
18
|
+
class AttachedDatabase;
|
|
19
|
+
class ClientContext;
|
|
20
|
+
class Transaction;
|
|
21
|
+
|
|
22
|
+
//! The MetaTransaction manages multiple transactions for different attached databases
|
|
23
|
+
class MetaTransaction {
|
|
24
|
+
public:
|
|
25
|
+
DUCKDB_API MetaTransaction(ClientContext &context, timestamp_t start_timestamp, idx_t catalog_version);
|
|
26
|
+
|
|
27
|
+
ClientContext &context;
|
|
28
|
+
//! The timestamp when the transaction started
|
|
29
|
+
timestamp_t start_timestamp;
|
|
30
|
+
//! The catalog version when the transaction was started
|
|
31
|
+
idx_t catalog_version;
|
|
32
|
+
//! The validity checker of the transaction
|
|
33
|
+
ValidChecker transaction_validity;
|
|
34
|
+
//! Whether or not any transaction have made modifications
|
|
35
|
+
bool read_only;
|
|
36
|
+
//! The active query number
|
|
37
|
+
transaction_t active_query;
|
|
38
|
+
|
|
39
|
+
public:
|
|
40
|
+
DUCKDB_API static MetaTransaction &Get(ClientContext &context);
|
|
41
|
+
timestamp_t GetCurrentTransactionStartTimestamp() {
|
|
42
|
+
return start_timestamp;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
Transaction &GetTransaction(AttachedDatabase *db);
|
|
46
|
+
|
|
47
|
+
string Commit();
|
|
48
|
+
void Rollback();
|
|
49
|
+
|
|
50
|
+
idx_t GetActiveQuery();
|
|
51
|
+
void SetActiveQuery(transaction_t query_number);
|
|
52
|
+
|
|
53
|
+
void ModifyDatabase(AttachedDatabase *db);
|
|
54
|
+
|
|
55
|
+
private:
|
|
56
|
+
//! The set of active transactions for each database
|
|
57
|
+
unordered_map<AttachedDatabase *, Transaction *> transactions;
|
|
58
|
+
//! The set of transactions in order of when they were started
|
|
59
|
+
vector<AttachedDatabase *> all_transactions;
|
|
60
|
+
//! The database we are modifying - we can only modify one database per transaction
|
|
61
|
+
AttachedDatabase *modified_database;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
} // namespace duckdb
|
|
@@ -10,22 +10,23 @@
|
|
|
10
10
|
|
|
11
11
|
#include "duckdb/catalog/catalog_entry/sequence_catalog_entry.hpp"
|
|
12
12
|
#include "duckdb/common/types/data_chunk.hpp"
|
|
13
|
-
#include "duckdb/common/unordered_map.hpp"
|
|
14
13
|
#include "duckdb/transaction/undo_buffer.hpp"
|
|
15
14
|
#include "duckdb/common/atomic.hpp"
|
|
16
15
|
#include "duckdb/transaction/transaction_data.hpp"
|
|
17
|
-
#include "duckdb/main/valid_checker.hpp"
|
|
18
16
|
|
|
19
17
|
namespace duckdb {
|
|
20
18
|
class SequenceCatalogEntry;
|
|
21
19
|
class SchemaCatalogEntry;
|
|
22
20
|
|
|
21
|
+
class AttachedDatabase;
|
|
23
22
|
class ColumnData;
|
|
24
23
|
class ClientContext;
|
|
25
24
|
class CatalogEntry;
|
|
26
25
|
class DataTable;
|
|
27
26
|
class DatabaseInstance;
|
|
28
27
|
class LocalStorage;
|
|
28
|
+
class MetaTransaction;
|
|
29
|
+
class TransactionManager;
|
|
29
30
|
class WriteAheadLog;
|
|
30
31
|
|
|
31
32
|
class ChunkVectorInfo;
|
|
@@ -37,10 +38,11 @@ struct UpdateInfo;
|
|
|
37
38
|
//! transaction
|
|
38
39
|
class Transaction {
|
|
39
40
|
public:
|
|
40
|
-
Transaction(ClientContext &context, transaction_t start_time,
|
|
41
|
-
|
|
41
|
+
Transaction(TransactionManager &manager, ClientContext &context, transaction_t start_time,
|
|
42
|
+
transaction_t transaction_id);
|
|
42
43
|
~Transaction();
|
|
43
44
|
|
|
45
|
+
TransactionManager &manager;
|
|
44
46
|
weak_ptr<ClientContext> context;
|
|
45
47
|
//! The start timestamp of this transaction
|
|
46
48
|
transaction_t start_time;
|
|
@@ -48,33 +50,26 @@ public:
|
|
|
48
50
|
transaction_t transaction_id;
|
|
49
51
|
//! The commit id of this transaction, if it has successfully been committed
|
|
50
52
|
transaction_t commit_id;
|
|
51
|
-
//!
|
|
52
|
-
|
|
53
|
+
//! Map of all sequences that were used during the transaction and the value they had in this transaction
|
|
54
|
+
unordered_map<SequenceCatalogEntry *, SequenceValue> sequence_usage;
|
|
53
55
|
//! The current active query for the transaction. Set to MAXIMUM_QUERY_ID if
|
|
54
56
|
//! no query is active.
|
|
55
57
|
atomic<transaction_t> active_query;
|
|
56
|
-
//!
|
|
57
|
-
|
|
58
|
-
//! The catalog version when the transaction was started
|
|
59
|
-
idx_t catalog_version;
|
|
60
|
-
//! Map of all sequences that were used during the transaction and the value they had in this transaction
|
|
61
|
-
unordered_map<SequenceCatalogEntry *, SequenceValue> sequence_usage;
|
|
62
|
-
//! The validity checker of the transaction
|
|
63
|
-
ValidChecker transaction_validity;
|
|
64
|
-
//! A pointer to the temporary objects of the client context
|
|
65
|
-
shared_ptr<SchemaCatalogEntry> temporary_objects;
|
|
58
|
+
//! Highest active query when the transaction finished, used for cleaning up
|
|
59
|
+
transaction_t highest_active_query;
|
|
66
60
|
|
|
67
61
|
public:
|
|
68
|
-
static Transaction &
|
|
62
|
+
static Transaction &Get(ClientContext &context, AttachedDatabase &db);
|
|
63
|
+
static Transaction &Get(ClientContext &context, Catalog &catalog);
|
|
69
64
|
LocalStorage &GetLocalStorage();
|
|
70
65
|
|
|
71
66
|
void PushCatalogEntry(CatalogEntry *entry, data_ptr_t extra_data = nullptr, idx_t extra_data_size = 0);
|
|
72
67
|
|
|
73
68
|
//! Commit the current transaction with the given commit identifier. Returns an error message if the transaction
|
|
74
69
|
//! commit failed, or an empty string if the commit was sucessful
|
|
75
|
-
string Commit(
|
|
70
|
+
string Commit(AttachedDatabase &db, transaction_t commit_id, bool checkpoint) noexcept;
|
|
76
71
|
//! Returns whether or not a commit of this transaction should trigger an automatic checkpoint
|
|
77
|
-
bool AutomaticCheckpoint(
|
|
72
|
+
bool AutomaticCheckpoint(AttachedDatabase &db);
|
|
78
73
|
|
|
79
74
|
//! Rollback
|
|
80
75
|
void Rollback() noexcept;
|
|
@@ -83,10 +78,6 @@ public:
|
|
|
83
78
|
|
|
84
79
|
bool ChangesMade();
|
|
85
80
|
|
|
86
|
-
timestamp_t GetCurrentTransactionStartTimestamp() {
|
|
87
|
-
return start_timestamp;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
81
|
void PushDelete(DataTable *table, ChunkVectorInfo *vinfo, row_t rows[], idx_t count, idx_t base_row);
|
|
91
82
|
void PushAppend(DataTable *table, idx_t row_start, idx_t row_count);
|
|
92
83
|
UpdateInfo *CreateUpdateInfo(idx_t type_size, idx_t entries);
|