duckdb 0.7.2-dev2820.0 → 0.7.2-dev2995.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 -0
- package/package.json +1 -1
- package/src/duckdb/extension/icu/icu-datepart.cpp +55 -1
- package/src/duckdb/extension/parquet/parquet-extension.cpp +5 -4
- package/src/duckdb/src/catalog/catalog_entry/table_catalog_entry.cpp +18 -7
- package/src/duckdb/src/catalog/default/default_functions.cpp +2 -0
- package/src/duckdb/src/common/arrow/arrow_appender.cpp +3 -3
- package/src/duckdb/src/common/arrow/arrow_converter.cpp +2 -2
- package/src/duckdb/src/common/local_file_system.cpp +1 -3
- package/src/duckdb/src/common/multi_file_reader.cpp +11 -8
- package/src/duckdb/src/common/sort/partition_state.cpp +1 -1
- package/src/duckdb/src/common/string_util.cpp +6 -1
- package/src/duckdb/src/core_functions/function_list.cpp +2 -0
- package/src/duckdb/src/core_functions/scalar/string/format_bytes.cpp +29 -0
- package/src/duckdb/src/execution/index/art/art.cpp +5 -1
- package/src/duckdb/src/execution/operator/aggregate/physical_hash_aggregate.cpp +62 -43
- package/src/duckdb/src/execution/operator/aggregate/physical_perfecthash_aggregate.cpp +17 -11
- package/src/duckdb/src/execution/operator/aggregate/physical_ungrouped_aggregate.cpp +32 -39
- package/src/duckdb/src/execution/operator/aggregate/physical_window.cpp +10 -9
- package/src/duckdb/src/execution/operator/helper/physical_batch_collector.cpp +4 -4
- package/src/duckdb/src/execution/operator/helper/physical_explain_analyze.cpp +6 -21
- package/src/duckdb/src/execution/operator/helper/physical_limit.cpp +13 -13
- package/src/duckdb/src/execution/operator/helper/physical_limit_percent.cpp +15 -14
- package/src/duckdb/src/execution/operator/helper/physical_load.cpp +3 -2
- package/src/duckdb/src/execution/operator/helper/physical_materialized_collector.cpp +4 -4
- package/src/duckdb/src/execution/operator/helper/physical_pragma.cpp +4 -2
- package/src/duckdb/src/execution/operator/helper/physical_prepare.cpp +4 -2
- package/src/duckdb/src/execution/operator/helper/physical_reservoir_sample.cpp +10 -8
- package/src/duckdb/src/execution/operator/helper/physical_reset.cpp +4 -3
- package/src/duckdb/src/execution/operator/helper/physical_set.cpp +7 -6
- package/src/duckdb/src/execution/operator/helper/physical_transaction.cpp +4 -2
- package/src/duckdb/src/execution/operator/helper/physical_vacuum.cpp +8 -8
- package/src/duckdb/src/execution/operator/join/physical_asof_join.cpp +17 -16
- package/src/duckdb/src/execution/operator/join/physical_blockwise_nl_join.cpp +10 -8
- package/src/duckdb/src/execution/operator/join/physical_cross_product.cpp +3 -4
- package/src/duckdb/src/execution/operator/join/physical_delim_join.cpp +5 -5
- package/src/duckdb/src/execution/operator/join/physical_hash_join.cpp +16 -15
- package/src/duckdb/src/execution/operator/join/physical_iejoin.cpp +13 -12
- package/src/duckdb/src/execution/operator/join/physical_nested_loop_join.cpp +12 -10
- package/src/duckdb/src/execution/operator/join/physical_piecewise_merge_join.cpp +13 -11
- package/src/duckdb/src/execution/operator/join/physical_positional_join.cpp +8 -6
- package/src/duckdb/src/execution/operator/join/physical_range_join.cpp +1 -1
- package/src/duckdb/src/execution/operator/order/physical_order.cpp +13 -13
- package/src/duckdb/src/execution/operator/order/physical_top_n.cpp +8 -8
- package/src/duckdb/src/execution/operator/persistent/physical_batch_insert.cpp +160 -145
- package/src/duckdb/src/execution/operator/persistent/physical_copy_to_file.cpp +10 -25
- package/src/duckdb/src/execution/operator/persistent/physical_delete.cpp +14 -19
- package/src/duckdb/src/execution/operator/persistent/physical_export.cpp +7 -6
- package/src/duckdb/src/execution/operator/persistent/physical_insert.cpp +18 -30
- package/src/duckdb/src/execution/operator/persistent/physical_update.cpp +14 -18
- package/src/duckdb/src/execution/operator/scan/physical_column_data_scan.cpp +6 -4
- package/src/duckdb/src/execution/operator/scan/physical_dummy_scan.cpp +4 -19
- package/src/duckdb/src/execution/operator/scan/physical_empty_result.cpp +3 -2
- package/src/duckdb/src/execution/operator/scan/physical_positional_scan.cpp +14 -5
- package/src/duckdb/src/execution/operator/scan/physical_table_scan.cpp +6 -4
- package/src/duckdb/src/execution/operator/schema/physical_alter.cpp +3 -19
- package/src/duckdb/src/execution/operator/schema/physical_attach.cpp +4 -18
- package/src/duckdb/src/execution/operator/schema/physical_create_function.cpp +4 -19
- package/src/duckdb/src/execution/operator/schema/physical_create_index.cpp +8 -9
- package/src/duckdb/src/execution/operator/schema/physical_create_schema.cpp +4 -19
- package/src/duckdb/src/execution/operator/schema/physical_create_sequence.cpp +4 -19
- package/src/duckdb/src/execution/operator/schema/physical_create_table.cpp +4 -19
- package/src/duckdb/src/execution/operator/schema/physical_create_type.cpp +20 -28
- package/src/duckdb/src/execution/operator/schema/physical_create_view.cpp +4 -19
- package/src/duckdb/src/execution/operator/schema/physical_detach.cpp +4 -19
- package/src/duckdb/src/execution/operator/schema/physical_drop.cpp +3 -19
- package/src/duckdb/src/execution/operator/set/physical_recursive_cte.cpp +9 -8
- package/src/duckdb/src/execution/operator/set/physical_union.cpp +1 -1
- package/src/duckdb/src/execution/physical_operator.cpp +11 -5
- package/src/duckdb/src/execution/radix_partitioned_hashtable.cpp +16 -16
- package/src/duckdb/src/function/table/arrow_conversion.cpp +3 -3
- package/src/duckdb/src/function/table/read_csv.cpp +7 -4
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_catalog_entry.hpp +7 -1
- package/src/duckdb/src/include/duckdb/common/enums/operator_result_type.hpp +16 -4
- package/src/duckdb/src/include/duckdb/common/multi_file_reader.hpp +5 -4
- package/src/duckdb/src/include/duckdb/common/optional_idx.hpp +45 -0
- package/src/duckdb/src/include/duckdb/common/set.hpp +2 -1
- package/src/duckdb/src/include/duckdb/core_functions/scalar/string_functions.hpp +15 -0
- package/src/duckdb/src/include/duckdb/execution/executor.hpp +10 -1
- package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_hash_aggregate.hpp +5 -8
- package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_perfecthash_aggregate.hpp +2 -4
- package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_ungrouped_aggregate.hpp +3 -7
- package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_window.hpp +2 -4
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_batch_collector.hpp +1 -2
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_explain_analyze.hpp +2 -5
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_limit.hpp +2 -4
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_limit_percent.hpp +2 -4
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_load.hpp +1 -2
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_materialized_collector.hpp +1 -2
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_pragma.hpp +1 -2
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_prepare.hpp +1 -2
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_reservoir_sample.hpp +2 -4
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_reset.hpp +1 -2
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_set.hpp +1 -2
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_transaction.hpp +1 -2
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_vacuum.hpp +2 -4
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_asof_join.hpp +2 -4
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_blockwise_nl_join.hpp +2 -4
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_cross_product.hpp +1 -2
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_delim_join.hpp +1 -2
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_hash_join.hpp +2 -4
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_iejoin.hpp +2 -4
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_nested_loop_join.hpp +2 -4
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_piecewise_merge_join.hpp +2 -4
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_positional_join.hpp +2 -4
- package/src/duckdb/src/include/duckdb/execution/operator/order/physical_order.hpp +2 -4
- package/src/duckdb/src/include/duckdb/execution/operator/order/physical_top_n.hpp +2 -4
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_batch_insert.hpp +3 -5
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_copy_to_file.hpp +2 -5
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_delete.hpp +2 -4
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_export.hpp +2 -4
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_insert.hpp +2 -4
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_update.hpp +2 -4
- package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_column_data_scan.hpp +1 -2
- package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_dummy_scan.hpp +1 -3
- package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_empty_result.hpp +1 -2
- package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_positional_scan.hpp +1 -2
- package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_table_scan.hpp +1 -2
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_alter.hpp +1 -3
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_attach.hpp +1 -3
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_function.hpp +1 -3
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_index.hpp +2 -4
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_schema.hpp +1 -3
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_sequence.hpp +1 -3
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_table.hpp +1 -3
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_type.hpp +6 -5
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_view.hpp +1 -3
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_detach.hpp +1 -3
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_drop.hpp +1 -3
- package/src/duckdb/src/include/duckdb/execution/operator/set/physical_recursive_cte.hpp +2 -4
- package/src/duckdb/src/include/duckdb/execution/physical_operator.hpp +7 -4
- package/src/duckdb/src/include/duckdb/execution/physical_operator_states.hpp +26 -6
- package/src/duckdb/src/include/duckdb/execution/radix_partitioned_hashtable.hpp +5 -5
- package/src/duckdb/src/include/duckdb/function/aggregate_function.hpp +2 -1
- package/src/duckdb/src/include/duckdb/function/table_function.hpp +0 -1
- package/src/duckdb/src/include/duckdb/main/client_config.hpp +2 -0
- package/src/duckdb/src/include/duckdb/main/config.hpp +2 -0
- package/src/duckdb/src/include/duckdb/main/database.hpp +1 -0
- package/src/duckdb/src/include/duckdb/main/database_manager.hpp +3 -0
- package/src/duckdb/src/include/duckdb/main/extension_helper.hpp +0 -2
- package/src/duckdb/src/include/duckdb/parallel/event.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parallel/interrupt.hpp +63 -0
- package/src/duckdb/src/include/duckdb/parallel/pipeline.hpp +16 -3
- package/src/duckdb/src/include/duckdb/parallel/pipeline_executor.hpp +51 -7
- package/src/duckdb/src/include/duckdb/parallel/task.hpp +21 -2
- package/src/duckdb/src/include/duckdb/parallel/task_counter.hpp +2 -2
- package/src/duckdb/src/include/duckdb/parallel/task_scheduler.hpp +2 -2
- package/src/duckdb/src/include/duckdb/parser/tableref/pivotref.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/transformer.hpp +5 -1
- package/src/duckdb/src/include/duckdb/planner/column_binding.hpp +6 -0
- package/src/duckdb/src/include/duckdb/planner/expression/bound_columnref_expression.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_aggregate.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_column_data_get.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_cteref.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_delete.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_delim_get.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_dummy_scan.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_expression_get.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_insert.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_pivot.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_projection.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_recursive_cte.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_set_operation.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_unnest.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_update.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_window.hpp +1 -0
- package/src/duckdb/src/include/duckdb/storage/data_table.hpp +1 -0
- package/src/duckdb/src/include/duckdb/storage/optimistic_data_writer.hpp +46 -0
- package/src/duckdb/src/include/duckdb/storage/partial_block_manager.hpp +24 -3
- package/src/duckdb/src/include/duckdb/storage/table/column_checkpoint_state.hpp +46 -1
- package/src/duckdb/src/include/duckdb/storage/table/column_data.hpp +9 -10
- package/src/duckdb/src/include/duckdb/storage/table/column_segment.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/table/list_column_data.hpp +2 -2
- package/src/duckdb/src/include/duckdb/storage/table/row_group.hpp +3 -3
- package/src/duckdb/src/include/duckdb/storage/table/row_group_collection.hpp +1 -0
- package/src/duckdb/src/include/duckdb/storage/table/segment_base.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/table/segment_tree.hpp +22 -0
- package/src/duckdb/src/include/duckdb/storage/table/standard_column_data.hpp +3 -3
- package/src/duckdb/src/include/duckdb/storage/table/struct_column_data.hpp +2 -2
- package/src/duckdb/src/include/duckdb/storage/table/update_segment.hpp +0 -2
- package/src/duckdb/src/include/duckdb/storage/table/validity_column_data.hpp +1 -2
- package/src/duckdb/src/include/duckdb/transaction/local_storage.hpp +9 -34
- package/src/duckdb/src/include/duckdb/verification/no_operator_caching_verifier.hpp +25 -0
- package/src/duckdb/src/include/duckdb/verification/statement_verifier.hpp +5 -0
- package/src/duckdb/src/main/attached_database.cpp +5 -3
- package/src/duckdb/src/main/client_verify.cpp +4 -0
- package/src/duckdb/src/main/config.cpp +4 -0
- package/src/duckdb/src/main/database.cpp +45 -48
- package/src/duckdb/src/main/extension/extension_load.cpp +32 -49
- package/src/duckdb/src/parallel/event.cpp +1 -1
- package/src/duckdb/src/parallel/executor.cpp +39 -3
- package/src/duckdb/src/parallel/executor_task.cpp +11 -0
- package/src/duckdb/src/parallel/interrupt.cpp +57 -0
- package/src/duckdb/src/parallel/pipeline.cpp +49 -6
- package/src/duckdb/src/parallel/pipeline_executor.cpp +248 -69
- package/src/duckdb/src/parallel/pipeline_initialize_event.cpp +1 -1
- package/src/duckdb/src/parallel/task_scheduler.cpp +57 -22
- package/src/duckdb/src/parser/base_expression.cpp +6 -0
- package/src/duckdb/src/parser/transform/statement/transform_create_function.cpp +1 -4
- package/src/duckdb/src/parser/transform/statement/transform_create_view.cpp +2 -4
- package/src/duckdb/src/parser/transform/statement/transform_pivot_stmt.cpp +43 -24
- package/src/duckdb/src/parser/transform/tableref/transform_pivot.cpp +3 -0
- package/src/duckdb/src/planner/binder/statement/bind_create.cpp +17 -28
- package/src/duckdb/src/planner/expression/bound_columnref_expression.cpp +17 -3
- package/src/duckdb/src/planner/expression/bound_reference_expression.cpp +8 -2
- package/src/duckdb/src/planner/operator/logical_aggregate.cpp +13 -1
- package/src/duckdb/src/planner/operator/logical_column_data_get.cpp +11 -0
- package/src/duckdb/src/planner/operator/logical_cteref.cpp +11 -0
- package/src/duckdb/src/planner/operator/logical_delete.cpp +10 -0
- package/src/duckdb/src/planner/operator/logical_delim_get.cpp +12 -1
- package/src/duckdb/src/planner/operator/logical_dummy_scan.cpp +12 -1
- package/src/duckdb/src/planner/operator/logical_expression_get.cpp +12 -1
- package/src/duckdb/src/planner/operator/logical_get.cpp +10 -4
- package/src/duckdb/src/planner/operator/logical_insert.cpp +12 -1
- package/src/duckdb/src/planner/operator/logical_pivot.cpp +11 -0
- package/src/duckdb/src/planner/operator/logical_projection.cpp +11 -0
- package/src/duckdb/src/planner/operator/logical_recursive_cte.cpp +11 -0
- package/src/duckdb/src/planner/operator/logical_set_operation.cpp +11 -0
- package/src/duckdb/src/planner/operator/logical_unnest.cpp +12 -1
- package/src/duckdb/src/planner/operator/logical_update.cpp +10 -0
- package/src/duckdb/src/planner/operator/logical_window.cpp +11 -0
- package/src/duckdb/src/storage/checkpoint_manager.cpp +1 -1
- package/src/duckdb/src/storage/data_table.cpp +5 -0
- package/src/duckdb/src/storage/local_storage.cpp +40 -110
- package/src/duckdb/src/storage/optimistic_data_writer.cpp +96 -0
- package/src/duckdb/src/storage/partial_block_manager.cpp +73 -9
- package/src/duckdb/src/storage/single_file_block_manager.cpp +3 -1
- package/src/duckdb/src/storage/standard_buffer_manager.cpp +17 -12
- package/src/duckdb/src/storage/statistics/base_statistics.cpp +3 -0
- package/src/duckdb/src/storage/table/column_checkpoint_state.cpp +90 -82
- package/src/duckdb/src/storage/table/column_data.cpp +19 -45
- package/src/duckdb/src/storage/table/column_data_checkpointer.cpp +7 -7
- package/src/duckdb/src/storage/table/column_segment.cpp +1 -1
- package/src/duckdb/src/storage/table/list_column_data.cpp +6 -11
- package/src/duckdb/src/storage/table/row_group.cpp +13 -14
- package/src/duckdb/src/storage/table/row_group_collection.cpp +10 -4
- package/src/duckdb/src/storage/table/standard_column_data.cpp +6 -10
- package/src/duckdb/src/storage/table/struct_column_data.cpp +7 -13
- package/src/duckdb/src/storage/table/update_segment.cpp +0 -25
- package/src/duckdb/src/storage/table/validity_column_data.cpp +2 -6
- package/src/duckdb/src/transaction/commit_state.cpp +4 -4
- package/src/duckdb/src/verification/no_operator_caching_verifier.cpp +13 -0
- package/src/duckdb/src/verification/statement_verifier.cpp +4 -0
- package/src/duckdb/third_party/fmt/format.cc +0 -5
- package/src/duckdb/third_party/fmt/include/fmt/core.h +10 -12
- package/src/duckdb/third_party/fmt/include/fmt/format-inl.h +2 -33
- package/src/duckdb/third_party/fmt/include/fmt/format.h +61 -24
- package/src/duckdb/third_party/fmt/include/fmt/printf.h +15 -1
- package/src/duckdb/third_party/libpg_query/include/nodes/parsenodes.hpp +1 -0
- package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +10735 -10674
- package/src/duckdb/ub_src_core_functions_scalar_string.cpp +2 -0
- package/src/duckdb/ub_src_parallel.cpp +2 -0
- package/src/duckdb/ub_src_storage.cpp +2 -0
@@ -93,7 +93,7 @@ public:
|
|
93
93
|
|
94
94
|
//! Convert a transient in-memory segment into a persistent segment blocked by an on-disk block.
|
95
95
|
//! Only used during checkpointing.
|
96
|
-
void ConvertToPersistent(BlockManager
|
96
|
+
void ConvertToPersistent(optional_ptr<BlockManager> block_manager, block_id_t block_id);
|
97
97
|
//! Updates pointers to refer to the given block and offset. This is only used
|
98
98
|
//! when sharing a block among segments. This is invoked only AFTER the block is written.
|
99
99
|
void MarkAsPersistent(shared_ptr<BlockHandle> block, uint32_t offset_in_block);
|
@@ -17,8 +17,7 @@ namespace duckdb {
|
|
17
17
|
class ListColumnData : public ColumnData {
|
18
18
|
public:
|
19
19
|
ListColumnData(BlockManager &block_manager, DataTableInfo &info, idx_t column_index, idx_t start_row,
|
20
|
-
LogicalType type, ColumnData
|
21
|
-
ListColumnData(ColumnData &original, idx_t start_row, ColumnData *parent = nullptr);
|
20
|
+
LogicalType type, optional_ptr<ColumnData> parent = nullptr);
|
22
21
|
|
23
22
|
//! The child-column of the list
|
24
23
|
unique_ptr<ColumnData> child_column;
|
@@ -26,6 +25,7 @@ public:
|
|
26
25
|
ValidityColumnData validity;
|
27
26
|
|
28
27
|
public:
|
28
|
+
void SetStart(idx_t new_start) override;
|
29
29
|
bool CheckZonemap(ColumnScanState &state, TableFilter &filter) override;
|
30
30
|
|
31
31
|
void InitializeScan(ColumnScanState &state) override;
|
@@ -59,20 +59,20 @@ public:
|
|
59
59
|
public:
|
60
60
|
RowGroup(RowGroupCollection &collection, idx_t start, idx_t count);
|
61
61
|
RowGroup(RowGroupCollection &collection, RowGroupPointer &&pointer);
|
62
|
-
RowGroup(RowGroup &row_group, RowGroupCollection &collection, idx_t start);
|
63
62
|
~RowGroup();
|
64
63
|
|
65
64
|
private:
|
66
65
|
//! The RowGroupCollection this row-group is a part of
|
67
|
-
RowGroupCollection
|
66
|
+
reference<RowGroupCollection> collection;
|
68
67
|
//! The version info of the row_group (inserted and deleted tuple info)
|
69
68
|
shared_ptr<VersionNode> version_info;
|
70
69
|
//! The column data of the row_group
|
71
70
|
vector<shared_ptr<ColumnData>> columns;
|
72
71
|
|
73
72
|
public:
|
73
|
+
void MoveToCollection(RowGroupCollection &collection, idx_t new_start);
|
74
74
|
RowGroupCollection &GetCollection() {
|
75
|
-
return collection;
|
75
|
+
return collection.get();
|
76
76
|
}
|
77
77
|
DatabaseInstance &GetDatabase();
|
78
78
|
BlockManager &GetBlockManager();
|
@@ -44,6 +44,7 @@ public:
|
|
44
44
|
void AppendRowGroup(SegmentLock &l, idx_t start_row);
|
45
45
|
//! Get the nth row-group, negative numbers start from the back (so -1 is the last row group, etc)
|
46
46
|
RowGroup *GetRowGroup(int64_t index);
|
47
|
+
idx_t RowGroupCount();
|
47
48
|
void Verify();
|
48
49
|
|
49
50
|
void InitializeScan(CollectionScanState &state, const vector<column_t> &column_ids, TableFilterSet *table_filters);
|
@@ -63,6 +63,14 @@ public:
|
|
63
63
|
LoadAllSegments(l);
|
64
64
|
return std::move(nodes);
|
65
65
|
}
|
66
|
+
vector<SegmentNode<T>> MoveSegments() {
|
67
|
+
auto l = Lock();
|
68
|
+
return MoveSegments(l);
|
69
|
+
}
|
70
|
+
idx_t GetSegmentCount() {
|
71
|
+
auto l = Lock();
|
72
|
+
return nodes.size();
|
73
|
+
}
|
66
74
|
//! Gets a pointer to the nth segment. Negative numbers start from the back.
|
67
75
|
T *GetSegmentByIndex(int64_t index) {
|
68
76
|
auto l = Lock();
|
@@ -243,6 +251,20 @@ public:
|
|
243
251
|
return SegmentIterationHelper(*this);
|
244
252
|
}
|
245
253
|
|
254
|
+
void Reinitialize() {
|
255
|
+
if (nodes.empty()) {
|
256
|
+
return;
|
257
|
+
}
|
258
|
+
idx_t offset = nodes[0].node->start;
|
259
|
+
for (auto &entry : nodes) {
|
260
|
+
if (entry.node->start != offset) {
|
261
|
+
throw InternalException("In SegmentTree::Reinitialize - gap found between nodes!");
|
262
|
+
}
|
263
|
+
entry.row_start = offset;
|
264
|
+
offset += entry.node->count;
|
265
|
+
}
|
266
|
+
}
|
267
|
+
|
246
268
|
protected:
|
247
269
|
atomic<bool> finished_loading;
|
248
270
|
|
@@ -17,13 +17,13 @@ namespace duckdb {
|
|
17
17
|
class StandardColumnData : public ColumnData {
|
18
18
|
public:
|
19
19
|
StandardColumnData(BlockManager &block_manager, DataTableInfo &info, idx_t column_index, idx_t start_row,
|
20
|
-
LogicalType type, ColumnData
|
21
|
-
StandardColumnData(ColumnData &original, idx_t start_row, ColumnData *parent = nullptr);
|
20
|
+
LogicalType type, optional_ptr<ColumnData> parent = nullptr);
|
22
21
|
|
23
22
|
//! The validity column data
|
24
23
|
ValidityColumnData validity;
|
25
24
|
|
26
25
|
public:
|
26
|
+
void SetStart(idx_t new_start) override;
|
27
27
|
bool CheckZonemap(ColumnScanState &state, TableFilter &filter) override;
|
28
28
|
|
29
29
|
void InitializeScan(ColumnScanState &state) override;
|
@@ -51,7 +51,7 @@ public:
|
|
51
51
|
PartialBlockManager &partial_block_manager) override;
|
52
52
|
unique_ptr<ColumnCheckpointState> Checkpoint(RowGroup &row_group, PartialBlockManager &partial_block_manager,
|
53
53
|
ColumnCheckpointInfo &checkpoint_info) override;
|
54
|
-
void CheckpointScan(ColumnSegment
|
54
|
+
void CheckpointScan(ColumnSegment &segment, ColumnScanState &state, idx_t row_group_start, idx_t count,
|
55
55
|
Vector &scan_vector) override;
|
56
56
|
|
57
57
|
void DeserializeColumn(Deserializer &source) override;
|
@@ -17,8 +17,7 @@ namespace duckdb {
|
|
17
17
|
class StructColumnData : public ColumnData {
|
18
18
|
public:
|
19
19
|
StructColumnData(BlockManager &block_manager, DataTableInfo &info, idx_t column_index, idx_t start_row,
|
20
|
-
LogicalType type, ColumnData
|
21
|
-
StructColumnData(ColumnData &original, idx_t start_row, ColumnData *parent = nullptr);
|
20
|
+
LogicalType type, optional_ptr<ColumnData> parent = nullptr);
|
22
21
|
|
23
22
|
//! The sub-columns of the struct
|
24
23
|
vector<unique_ptr<ColumnData>> sub_columns;
|
@@ -26,6 +25,7 @@ public:
|
|
26
25
|
ValidityColumnData validity;
|
27
26
|
|
28
27
|
public:
|
28
|
+
void SetStart(idx_t new_start) override;
|
29
29
|
bool CheckZonemap(ColumnScanState &state, TableFilter &filter) override;
|
30
30
|
idx_t GetMaxEntry() override;
|
31
31
|
|
@@ -23,8 +23,6 @@ struct UpdateNode;
|
|
23
23
|
class UpdateSegment {
|
24
24
|
public:
|
25
25
|
UpdateSegment(ColumnData &column_data);
|
26
|
-
// Construct a duplicate of 'other' with 'new_owner' as it's column data
|
27
|
-
UpdateSegment(UpdateSegment &other, ColumnData &new_owner);
|
28
26
|
~UpdateSegment();
|
29
27
|
|
30
28
|
ColumnData &column_data;
|
@@ -16,8 +16,7 @@ namespace duckdb {
|
|
16
16
|
class ValidityColumnData : public ColumnData {
|
17
17
|
public:
|
18
18
|
ValidityColumnData(BlockManager &block_manager, DataTableInfo &info, idx_t column_index, idx_t start_row,
|
19
|
-
ColumnData
|
20
|
-
ValidityColumnData(ColumnData &original, idx_t start_row, ColumnData *parent = nullptr);
|
19
|
+
ColumnData &parent);
|
21
20
|
|
22
21
|
public:
|
23
22
|
bool CheckZonemap(ColumnScanState &state, TableFilter &filter) override;
|
@@ -11,6 +11,7 @@
|
|
11
11
|
#include "duckdb/storage/table/row_group_collection.hpp"
|
12
12
|
#include "duckdb/storage/table/table_index_list.hpp"
|
13
13
|
#include "duckdb/storage/table/table_statistics.hpp"
|
14
|
+
#include "duckdb/storage/optimistic_data_writer.hpp"
|
14
15
|
|
15
16
|
namespace duckdb {
|
16
17
|
class AttachedDatabase;
|
@@ -20,35 +21,6 @@ class WriteAheadLog;
|
|
20
21
|
struct LocalAppendState;
|
21
22
|
struct TableAppendState;
|
22
23
|
|
23
|
-
class OptimisticDataWriter {
|
24
|
-
public:
|
25
|
-
OptimisticDataWriter(DataTable &table);
|
26
|
-
OptimisticDataWriter(DataTable &table, OptimisticDataWriter &parent);
|
27
|
-
~OptimisticDataWriter();
|
28
|
-
|
29
|
-
void CheckFlushToDisk(RowGroupCollection &row_groups);
|
30
|
-
//! Flushes a specific row group to disk
|
31
|
-
void FlushToDisk(RowGroup *row_group);
|
32
|
-
//! Flushes the final row group to disk (if any)
|
33
|
-
void FlushToDisk(RowGroupCollection &row_groups, bool force = false);
|
34
|
-
//! Final flush: flush the partial block manager to disk
|
35
|
-
void FinalFlush();
|
36
|
-
|
37
|
-
void Rollback();
|
38
|
-
|
39
|
-
private:
|
40
|
-
//! Prepare a write to disk
|
41
|
-
bool PrepareWrite();
|
42
|
-
|
43
|
-
private:
|
44
|
-
//! The table
|
45
|
-
DataTable &table;
|
46
|
-
//! The partial block manager (if we created one yet)
|
47
|
-
unique_ptr<PartialBlockManager> partial_manager;
|
48
|
-
//! The set of blocks that have been pre-emptively written to disk
|
49
|
-
unordered_set<block_id_t> written_blocks;
|
50
|
-
};
|
51
|
-
|
52
24
|
class LocalTableStorage : public std::enable_shared_from_this<LocalTableStorage> {
|
53
25
|
public:
|
54
26
|
// Create a new LocalTableStorage
|
@@ -76,13 +48,14 @@ public:
|
|
76
48
|
OptimisticDataWriter optimistic_writer;
|
77
49
|
//! The set of all optimistic data writers associated with this table
|
78
50
|
vector<unique_ptr<OptimisticDataWriter>> optimistic_writers;
|
51
|
+
//! Whether or not storage was merged
|
52
|
+
bool merged_storage = false;
|
79
53
|
|
80
54
|
public:
|
81
55
|
void InitializeScan(CollectionScanState &state, optional_ptr<TableFilterSet> table_filters = nullptr);
|
82
|
-
//!
|
83
|
-
void
|
84
|
-
|
85
|
-
void FlushToDisk();
|
56
|
+
//! Write a new row group to disk (if possible)
|
57
|
+
void WriteNewRowGroup();
|
58
|
+
void FlushBlocks();
|
86
59
|
void Rollback();
|
87
60
|
idx_t EstimatedSize();
|
88
61
|
|
@@ -93,6 +66,7 @@ public:
|
|
93
66
|
|
94
67
|
//! Creates an optimistic writer for this table
|
95
68
|
OptimisticDataWriter &CreateOptimisticWriter();
|
69
|
+
void FinalizeOptimisticWriter(OptimisticDataWriter &writer);
|
96
70
|
};
|
97
71
|
|
98
72
|
class LocalTableManager {
|
@@ -114,7 +88,7 @@ private:
|
|
114
88
|
class LocalStorage {
|
115
89
|
public:
|
116
90
|
// Threshold to merge row groups instead of appending
|
117
|
-
static constexpr const idx_t MERGE_THRESHOLD = RowGroup::ROW_GROUP_SIZE
|
91
|
+
static constexpr const idx_t MERGE_THRESHOLD = RowGroup::ROW_GROUP_SIZE;
|
118
92
|
|
119
93
|
public:
|
120
94
|
struct CommitState {
|
@@ -150,6 +124,7 @@ public:
|
|
150
124
|
void LocalMerge(DataTable &table, RowGroupCollection &collection);
|
151
125
|
//! Create an optimistic writer for the specified table
|
152
126
|
OptimisticDataWriter &CreateOptimisticWriter(DataTable &table);
|
127
|
+
void FinalizeOptimisticWriter(DataTable &table, OptimisticDataWriter &writer);
|
153
128
|
|
154
129
|
//! Delete a set of rows from the local storage
|
155
130
|
idx_t Delete(DataTable &table, Vector &row_ids, idx_t count);
|
@@ -0,0 +1,25 @@
|
|
1
|
+
//===----------------------------------------------------------------------===//
|
2
|
+
// DuckDB
|
3
|
+
//
|
4
|
+
// duckdb/verification/unoptimized_statement_verifier.hpp
|
5
|
+
//
|
6
|
+
//
|
7
|
+
//===----------------------------------------------------------------------===//
|
8
|
+
|
9
|
+
#pragma once
|
10
|
+
|
11
|
+
#include "duckdb/verification/statement_verifier.hpp"
|
12
|
+
|
13
|
+
namespace duckdb {
|
14
|
+
|
15
|
+
class NoOperatorCachingVerifier : public StatementVerifier {
|
16
|
+
public:
|
17
|
+
explicit NoOperatorCachingVerifier(unique_ptr<SQLStatement> statement_p);
|
18
|
+
static unique_ptr<StatementVerifier> Create(const SQLStatement &statement_p);
|
19
|
+
|
20
|
+
bool DisableOperatorCaching() const override {
|
21
|
+
return true;
|
22
|
+
}
|
23
|
+
};
|
24
|
+
|
25
|
+
} // namespace duckdb
|
@@ -20,6 +20,7 @@ enum class VerificationType : uint8_t {
|
|
20
20
|
DESERIALIZED,
|
21
21
|
PARSED,
|
22
22
|
UNOPTIMIZED,
|
23
|
+
NO_OPERATOR_CACHING,
|
23
24
|
PREPARED,
|
24
25
|
EXTERNAL,
|
25
26
|
|
@@ -59,6 +60,10 @@ public:
|
|
59
60
|
return false;
|
60
61
|
}
|
61
62
|
|
63
|
+
virtual bool DisableOperatorCaching() const {
|
64
|
+
return false;
|
65
|
+
}
|
66
|
+
|
62
67
|
virtual bool ForceExternal() const {
|
63
68
|
return false;
|
64
69
|
}
|
@@ -1,9 +1,11 @@
|
|
1
1
|
#include "duckdb/main/attached_database.hpp"
|
2
|
-
|
3
|
-
#include "duckdb/transaction/duck_transaction_manager.hpp"
|
4
|
-
#include "duckdb/common/file_system.hpp"
|
2
|
+
|
5
3
|
#include "duckdb/catalog/duck_catalog.hpp"
|
4
|
+
#include "duckdb/common/file_system.hpp"
|
5
|
+
#include "duckdb/parser/parsed_data/attach_info.hpp"
|
6
6
|
#include "duckdb/storage/storage_extension.hpp"
|
7
|
+
#include "duckdb/storage/storage_manager.hpp"
|
8
|
+
#include "duckdb/transaction/duck_transaction_manager.hpp"
|
7
9
|
|
8
10
|
namespace duckdb {
|
9
11
|
|
@@ -28,6 +28,10 @@ PreservedError ClientContext::VerifyQuery(ClientContextLock &lock, const string
|
|
28
28
|
statement_verifiers.emplace_back(StatementVerifier::Create(VerificationType::DESERIALIZED, stmt));
|
29
29
|
statement_verifiers.emplace_back(StatementVerifier::Create(VerificationType::UNOPTIMIZED, stmt));
|
30
30
|
prepared_statement_verifier = StatementVerifier::Create(VerificationType::PREPARED, stmt);
|
31
|
+
#ifdef DUCKDB_DEBUG_ASYNC_SINK_SOURCE
|
32
|
+
// This verification is quite slow, so we only run it for the async sink/source debug mode
|
33
|
+
statement_verifiers.emplace_back(StatementVerifier::Create(VerificationType::NO_OPERATOR_CACHING, stmt));
|
34
|
+
#endif
|
31
35
|
}
|
32
36
|
if (config.verify_external) {
|
33
37
|
statement_verifiers.emplace_back(StatementVerifier::Create(VerificationType::EXTERNAL, stmt));
|
@@ -14,6 +14,10 @@
|
|
14
14
|
|
15
15
|
namespace duckdb {
|
16
16
|
|
17
|
+
#ifdef DEBUG
|
18
|
+
bool DBConfigOptions::debug_print_bindings = false;
|
19
|
+
#endif
|
20
|
+
|
17
21
|
#define DUCKDB_GLOBAL(_PARAM) \
|
18
22
|
{ \
|
19
23
|
_PARAM::Name, _PARAM::Description, _PARAM::InputType, _PARAM::SetGlobal, nullptr, _PARAM::ResetGlobal, \
|
@@ -1,24 +1,24 @@
|
|
1
1
|
#include "duckdb/main/database.hpp"
|
2
2
|
|
3
3
|
#include "duckdb/catalog/catalog.hpp"
|
4
|
-
#include "duckdb/main/database_manager.hpp"
|
5
4
|
#include "duckdb/common/virtual_file_system.hpp"
|
5
|
+
#include "duckdb/execution/operator/helper/physical_set.hpp"
|
6
|
+
#include "duckdb/function/cast/cast_function_set.hpp"
|
7
|
+
#include "duckdb/function/compression_function.hpp"
|
8
|
+
#include "duckdb/main/attached_database.hpp"
|
6
9
|
#include "duckdb/main/client_context.hpp"
|
7
|
-
#include "duckdb/parallel/task_scheduler.hpp"
|
8
|
-
#include "duckdb/storage/storage_manager.hpp"
|
9
|
-
#include "duckdb/storage/object_cache.hpp"
|
10
|
-
#include "duckdb/transaction/transaction_manager.hpp"
|
11
10
|
#include "duckdb/main/connection_manager.hpp"
|
12
|
-
#include "duckdb/
|
13
|
-
#include "duckdb/main/extension_helper.hpp"
|
14
|
-
#include "duckdb/function/cast/cast_function_set.hpp"
|
11
|
+
#include "duckdb/main/database_manager.hpp"
|
15
12
|
#include "duckdb/main/error_manager.hpp"
|
16
|
-
#include "duckdb/main/
|
13
|
+
#include "duckdb/main/extension_helper.hpp"
|
14
|
+
#include "duckdb/parallel/task_scheduler.hpp"
|
17
15
|
#include "duckdb/parser/parsed_data/attach_info.hpp"
|
18
16
|
#include "duckdb/storage/magic_bytes.hpp"
|
19
|
-
#include "duckdb/storage/
|
20
|
-
#include "duckdb/execution/operator/helper/physical_set.hpp"
|
17
|
+
#include "duckdb/storage/object_cache.hpp"
|
21
18
|
#include "duckdb/storage/standard_buffer_manager.hpp"
|
19
|
+
#include "duckdb/storage/storage_extension.hpp"
|
20
|
+
#include "duckdb/storage/storage_manager.hpp"
|
21
|
+
#include "duckdb/transaction/transaction_manager.hpp"
|
22
22
|
|
23
23
|
#ifndef DUCKDB_NO_THREADS
|
24
24
|
#include "duckdb/common/thread.hpp"
|
@@ -149,8 +149,9 @@ duckdb::unique_ptr<AttachedDatabase> DatabaseInstance::CreateAttachedDatabase(At
|
|
149
149
|
AccessMode access_mode) {
|
150
150
|
duckdb::unique_ptr<AttachedDatabase> attached_database;
|
151
151
|
if (!type.empty()) {
|
152
|
-
// find the storage
|
153
|
-
auto
|
152
|
+
// find the storage extension
|
153
|
+
auto extension_name = ExtensionHelper::ApplyExtensionAlias(type);
|
154
|
+
auto entry = config.storage_extensions.find(extension_name);
|
154
155
|
if (entry == config.storage_extensions.end()) {
|
155
156
|
throw BinderException("Unrecognized storage type \"%s\"", type);
|
156
157
|
}
|
@@ -171,6 +172,33 @@ duckdb::unique_ptr<AttachedDatabase> DatabaseInstance::CreateAttachedDatabase(At
|
|
171
172
|
return attached_database;
|
172
173
|
}
|
173
174
|
|
175
|
+
void DatabaseInstance::CreateDatabase(const string &database_type) {
|
176
|
+
AttachInfo info;
|
177
|
+
info.name = AttachedDatabase::ExtractDatabaseName(config.options.database_path);
|
178
|
+
info.path = config.options.database_path;
|
179
|
+
|
180
|
+
auto attached_database = CreateAttachedDatabase(info, database_type, config.options.access_mode);
|
181
|
+
auto initial_database = attached_database.get();
|
182
|
+
{
|
183
|
+
Connection con(*this);
|
184
|
+
con.BeginTransaction();
|
185
|
+
db_manager->AddDatabase(*con.context, std::move(attached_database));
|
186
|
+
con.Commit();
|
187
|
+
}
|
188
|
+
|
189
|
+
// initialize the database
|
190
|
+
initial_database->Initialize();
|
191
|
+
}
|
192
|
+
|
193
|
+
void ThrowExtensionSetUnrecognizedOptions(const unordered_map<string, Value> &unrecognized_options) {
|
194
|
+
auto unrecognized_options_iter = unrecognized_options.begin();
|
195
|
+
string unrecognized_option_keys = unrecognized_options_iter->first;
|
196
|
+
for (; unrecognized_options_iter == unrecognized_options.end(); ++unrecognized_options_iter) {
|
197
|
+
unrecognized_option_keys = "," + unrecognized_options_iter->first;
|
198
|
+
}
|
199
|
+
throw InvalidInputException("Unrecognized configuration property \"%s\"", unrecognized_option_keys);
|
200
|
+
}
|
201
|
+
|
174
202
|
void DatabaseInstance::Initialize(const char *database_path, DBConfig *user_config) {
|
175
203
|
DBConfig default_config;
|
176
204
|
DBConfig *config_ptr = &default_config;
|
@@ -208,27 +236,9 @@ void DatabaseInstance::Initialize(const char *database_path, DBConfig *user_conf
|
|
208
236
|
|
209
237
|
// check if we are opening a standard DuckDB database or an extension database
|
210
238
|
auto database_type = ExtractDatabaseType(config.options.database_path);
|
211
|
-
if (!database_type.empty()) {
|
212
|
-
// we are opening an extension database, run storage_init
|
213
|
-
ExtensionHelper::StorageInit(database_type, config);
|
214
|
-
}
|
215
|
-
AttachInfo info;
|
216
|
-
info.name = AttachedDatabase::ExtractDatabaseName(config.options.database_path);
|
217
|
-
info.path = config.options.database_path;
|
218
|
-
|
219
|
-
auto attached_database = CreateAttachedDatabase(info, database_type, config.options.access_mode);
|
220
|
-
auto initial_database = attached_database.get();
|
221
|
-
{
|
222
|
-
Connection con(*this);
|
223
|
-
con.BeginTransaction();
|
224
|
-
db_manager->AddDatabase(*con.context, std::move(attached_database));
|
225
|
-
con.Commit();
|
226
|
-
}
|
227
239
|
|
228
240
|
// initialize the system catalog
|
229
241
|
db_manager->InitializeSystemCatalog();
|
230
|
-
// initialize the database
|
231
|
-
initial_database->Initialize();
|
232
242
|
|
233
243
|
if (!database_type.empty()) {
|
234
244
|
// if we are opening an extension database - load the extension
|
@@ -236,24 +246,11 @@ void DatabaseInstance::Initialize(const char *database_path, DBConfig *user_conf
|
|
236
246
|
}
|
237
247
|
|
238
248
|
if (!config.options.unrecognized_options.empty()) {
|
239
|
-
|
240
|
-
|
241
|
-
auto entry = config.extension_parameters.find(unrecognized_option.first);
|
242
|
-
if (entry == config.extension_parameters.end()) {
|
243
|
-
throw InvalidInputException("Unrecognized configuration property \"%s\"", unrecognized_option.first);
|
244
|
-
}
|
245
|
-
}
|
249
|
+
ThrowExtensionSetUnrecognizedOptions(config.options.unrecognized_options);
|
250
|
+
}
|
246
251
|
|
247
|
-
|
248
|
-
|
249
|
-
con.BeginTransaction();
|
250
|
-
for (auto &unrecognized_option : config.options.unrecognized_options) {
|
251
|
-
auto entry = config.extension_parameters.find(unrecognized_option.first);
|
252
|
-
D_ASSERT(entry != config.extension_parameters.end());
|
253
|
-
PhysicalSet::SetExtensionVariable(*con.context, entry->second, unrecognized_option.first, SetScope::GLOBAL,
|
254
|
-
unrecognized_option.second);
|
255
|
-
}
|
256
|
-
con.Commit();
|
252
|
+
if (!db_manager->HasDefaultDatabase()) {
|
253
|
+
CreateDatabase(database_type);
|
257
254
|
}
|
258
255
|
|
259
256
|
// only increase thread count after storage init because we get races on catalog otherwise
|
@@ -19,7 +19,7 @@ namespace duckdb {
|
|
19
19
|
//===--------------------------------------------------------------------===//
|
20
20
|
typedef void (*ext_init_fun_t)(DatabaseInstance &);
|
21
21
|
typedef const char *(*ext_version_fun_t)(void);
|
22
|
-
typedef
|
22
|
+
typedef bool (*ext_is_storage_t)(void);
|
23
23
|
|
24
24
|
template <class T>
|
25
25
|
static T LoadFunctionFromDLL(void *dll, const string &function_name, const string &filename) {
|
@@ -30,14 +30,18 @@ static T LoadFunctionFromDLL(void *dll, const string &function_name, const strin
|
|
30
30
|
return (T)function;
|
31
31
|
}
|
32
32
|
|
33
|
-
void
|
33
|
+
static void ComputeSHA256String(const std::string &to_hash, std::string *res) {
|
34
|
+
// Invoke MbedTls function to actually compute sha256
|
35
|
+
*res = duckdb_mbedtls::MbedTlsWrapper::ComputeSha256Hash(to_hash);
|
36
|
+
}
|
37
|
+
|
38
|
+
static void ComputeSHA256FileSegment(FileHandle *handle, const idx_t start, const idx_t end, std::string *res) {
|
34
39
|
const idx_t len = end - start;
|
35
40
|
string file_content;
|
36
41
|
file_content.resize(len);
|
37
42
|
handle->Read((void *)file_content.data(), len, start);
|
38
43
|
|
39
|
-
|
40
|
-
*res = duckdb_mbedtls::MbedTlsWrapper::ComputeSha256Hash(file_content);
|
44
|
+
ComputeSHA256String(file_content, res);
|
41
45
|
}
|
42
46
|
|
43
47
|
bool ExtensionHelper::TryInitialLoad(DBConfig &config, FileOpener *opener, const string &extension,
|
@@ -86,19 +90,19 @@ bool ExtensionHelper::TryInitialLoad(DBConfig &config, FileOpener *opener, const
|
|
86
90
|
|
87
91
|
const idx_t maxLenChunks = 1024 * 1024;
|
88
92
|
const idx_t numChunks = (signature_offset + maxLenChunks - 1) / maxLenChunks;
|
89
|
-
std::vector<std::string>
|
93
|
+
std::vector<std::string> hash_chunks(numChunks);
|
90
94
|
std::vector<idx_t> splits(numChunks + 1);
|
91
95
|
|
92
|
-
|
93
|
-
for (idx_t i = 0; i < chunks.size(); i++) {
|
96
|
+
for (idx_t i = 0; i < numChunks; i++) {
|
94
97
|
splits[i] = maxLenChunks * i;
|
95
98
|
}
|
99
|
+
splits.back() = signature_offset;
|
96
100
|
|
97
101
|
#ifndef DUCKDB_NO_THREADS
|
98
102
|
std::vector<std::thread> threads;
|
99
103
|
threads.reserve(numChunks);
|
100
104
|
for (idx_t i = 0; i < numChunks; i++) {
|
101
|
-
threads.emplace_back(
|
105
|
+
threads.emplace_back(ComputeSHA256FileSegment, handle.get(), splits[i], splits[i + 1], &hash_chunks[i]);
|
102
106
|
}
|
103
107
|
|
104
108
|
for (auto &thread : threads) {
|
@@ -106,26 +110,26 @@ bool ExtensionHelper::TryInitialLoad(DBConfig &config, FileOpener *opener, const
|
|
106
110
|
}
|
107
111
|
#else
|
108
112
|
for (idx_t i = 0; i < numChunks; i++) {
|
109
|
-
|
113
|
+
ComputeSHA256FileSegment(handle.get(), splits[i], splits[i + 1], &hash_chunks[i]);
|
110
114
|
}
|
111
115
|
#endif // DUCKDB_NO_THREADS
|
112
116
|
|
113
|
-
string
|
114
|
-
|
117
|
+
string hash_concatenation;
|
118
|
+
hash_concatenation.reserve(32 * numChunks); // 256 bits -> 32 bytes per chunk
|
115
119
|
|
116
|
-
for (auto &
|
117
|
-
|
120
|
+
for (auto &hash_chunk : hash_chunks) {
|
121
|
+
hash_concatenation += hash_chunk;
|
118
122
|
}
|
119
123
|
|
120
|
-
string
|
121
|
-
|
124
|
+
string two_level_hash;
|
125
|
+
ComputeSHA256String(hash_concatenation, &two_level_hash);
|
122
126
|
|
123
127
|
// TODO maybe we should do a stream read / hash update here
|
124
128
|
handle->Read((void *)signature.data(), signature.size(), signature_offset);
|
125
129
|
|
126
130
|
bool any_valid = false;
|
127
131
|
for (auto &key : ExtensionHelper::GetPublicKeys()) {
|
128
|
-
if (duckdb_mbedtls::MbedTlsWrapper::IsValidSha256Signature(key, signature,
|
132
|
+
if (duckdb_mbedtls::MbedTlsWrapper::IsValidSha256Signature(key, signature, two_level_hash)) {
|
129
133
|
any_valid = true;
|
130
134
|
break;
|
131
135
|
}
|
@@ -201,7 +205,18 @@ ExtensionInitResult ExtensionHelper::InitialLoad(DBConfig &config, FileOpener *o
|
|
201
205
|
string error;
|
202
206
|
ExtensionInitResult result;
|
203
207
|
if (!TryInitialLoad(config, opener, extension, result, error)) {
|
204
|
-
|
208
|
+
if (!ExtensionHelper::AllowAutoInstall(extension)) {
|
209
|
+
throw IOException(error);
|
210
|
+
}
|
211
|
+
// the extension load failed - try installing the extension
|
212
|
+
if (!config.file_system) {
|
213
|
+
throw InternalException("Attempting to install an extension without a file system");
|
214
|
+
}
|
215
|
+
ExtensionHelper::InstallExtension(config, *config.file_system, extension, false);
|
216
|
+
// try loading again
|
217
|
+
if (!TryInitialLoad(config, nullptr, extension, result, error)) {
|
218
|
+
throw IOException(error);
|
219
|
+
}
|
205
220
|
}
|
206
221
|
return result;
|
207
222
|
}
|
@@ -251,38 +266,6 @@ void ExtensionHelper::LoadExternalExtension(ClientContext &context, const string
|
|
251
266
|
LoadExternalExtension(DatabaseInstance::GetDatabase(context), FileSystem::GetFileOpener(context), extension);
|
252
267
|
}
|
253
268
|
|
254
|
-
void ExtensionHelper::StorageInit(string &extension, DBConfig &config) {
|
255
|
-
extension = ExtensionHelper::ApplyExtensionAlias(extension);
|
256
|
-
ExtensionInitResult res;
|
257
|
-
string error;
|
258
|
-
if (!TryInitialLoad(config, nullptr, extension, res, error)) {
|
259
|
-
if (!ExtensionHelper::AllowAutoInstall(extension)) {
|
260
|
-
throw IOException(error);
|
261
|
-
}
|
262
|
-
// the extension load failed - try installing the extension
|
263
|
-
if (!config.file_system) {
|
264
|
-
throw InternalException("Attempting to install an extension without a file system");
|
265
|
-
}
|
266
|
-
ExtensionHelper::InstallExtension(config, *config.file_system, extension, false);
|
267
|
-
// try loading again
|
268
|
-
if (!TryInitialLoad(config, nullptr, extension, res, error)) {
|
269
|
-
throw IOException(error);
|
270
|
-
}
|
271
|
-
}
|
272
|
-
auto storage_fun_name = res.basename + "_storage_init";
|
273
|
-
|
274
|
-
ext_storage_init_t storage_init_fun;
|
275
|
-
storage_init_fun = LoadFunctionFromDLL<ext_storage_init_t>(res.lib_hdl, storage_fun_name, res.filename);
|
276
|
-
|
277
|
-
try {
|
278
|
-
(*storage_init_fun)(config);
|
279
|
-
} catch (std::exception &e) {
|
280
|
-
throw InvalidInputException(
|
281
|
-
"Storage initialization function \"%s\" from file \"%s\" threw an exception: \"%s\"", storage_fun_name,
|
282
|
-
res.filename, e.what());
|
283
|
-
}
|
284
|
-
}
|
285
|
-
|
286
269
|
string ExtensionHelper::ExtractExtensionPrefixFromPath(const string &path) {
|
287
270
|
auto first_colon = path.find(':');
|
288
271
|
if (first_colon == string::npos || first_colon < 2) { // needs to be at least two characters because windows c: ...
|
@@ -72,7 +72,7 @@ void Event::InsertEvent(shared_ptr<Event> replacement_event) {
|
|
72
72
|
executor.AddEvent(std::move(replacement_event));
|
73
73
|
}
|
74
74
|
|
75
|
-
void Event::SetTasks(vector<
|
75
|
+
void Event::SetTasks(vector<shared_ptr<Task>> tasks) {
|
76
76
|
auto &ts = TaskScheduler::GetScheduler(executor.context);
|
77
77
|
D_ASSERT(total_tasks == 0);
|
78
78
|
D_ASSERT(!tasks.empty());
|