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.
Files changed (254) hide show
  1. package/binding.gyp +1 -0
  2. package/package.json +1 -1
  3. package/src/duckdb/extension/icu/icu-datepart.cpp +55 -1
  4. package/src/duckdb/extension/parquet/parquet-extension.cpp +5 -4
  5. package/src/duckdb/src/catalog/catalog_entry/table_catalog_entry.cpp +18 -7
  6. package/src/duckdb/src/catalog/default/default_functions.cpp +2 -0
  7. package/src/duckdb/src/common/arrow/arrow_appender.cpp +3 -3
  8. package/src/duckdb/src/common/arrow/arrow_converter.cpp +2 -2
  9. package/src/duckdb/src/common/local_file_system.cpp +1 -3
  10. package/src/duckdb/src/common/multi_file_reader.cpp +11 -8
  11. package/src/duckdb/src/common/sort/partition_state.cpp +1 -1
  12. package/src/duckdb/src/common/string_util.cpp +6 -1
  13. package/src/duckdb/src/core_functions/function_list.cpp +2 -0
  14. package/src/duckdb/src/core_functions/scalar/string/format_bytes.cpp +29 -0
  15. package/src/duckdb/src/execution/index/art/art.cpp +5 -1
  16. package/src/duckdb/src/execution/operator/aggregate/physical_hash_aggregate.cpp +62 -43
  17. package/src/duckdb/src/execution/operator/aggregate/physical_perfecthash_aggregate.cpp +17 -11
  18. package/src/duckdb/src/execution/operator/aggregate/physical_ungrouped_aggregate.cpp +32 -39
  19. package/src/duckdb/src/execution/operator/aggregate/physical_window.cpp +10 -9
  20. package/src/duckdb/src/execution/operator/helper/physical_batch_collector.cpp +4 -4
  21. package/src/duckdb/src/execution/operator/helper/physical_explain_analyze.cpp +6 -21
  22. package/src/duckdb/src/execution/operator/helper/physical_limit.cpp +13 -13
  23. package/src/duckdb/src/execution/operator/helper/physical_limit_percent.cpp +15 -14
  24. package/src/duckdb/src/execution/operator/helper/physical_load.cpp +3 -2
  25. package/src/duckdb/src/execution/operator/helper/physical_materialized_collector.cpp +4 -4
  26. package/src/duckdb/src/execution/operator/helper/physical_pragma.cpp +4 -2
  27. package/src/duckdb/src/execution/operator/helper/physical_prepare.cpp +4 -2
  28. package/src/duckdb/src/execution/operator/helper/physical_reservoir_sample.cpp +10 -8
  29. package/src/duckdb/src/execution/operator/helper/physical_reset.cpp +4 -3
  30. package/src/duckdb/src/execution/operator/helper/physical_set.cpp +7 -6
  31. package/src/duckdb/src/execution/operator/helper/physical_transaction.cpp +4 -2
  32. package/src/duckdb/src/execution/operator/helper/physical_vacuum.cpp +8 -8
  33. package/src/duckdb/src/execution/operator/join/physical_asof_join.cpp +17 -16
  34. package/src/duckdb/src/execution/operator/join/physical_blockwise_nl_join.cpp +10 -8
  35. package/src/duckdb/src/execution/operator/join/physical_cross_product.cpp +3 -4
  36. package/src/duckdb/src/execution/operator/join/physical_delim_join.cpp +5 -5
  37. package/src/duckdb/src/execution/operator/join/physical_hash_join.cpp +16 -15
  38. package/src/duckdb/src/execution/operator/join/physical_iejoin.cpp +13 -12
  39. package/src/duckdb/src/execution/operator/join/physical_nested_loop_join.cpp +12 -10
  40. package/src/duckdb/src/execution/operator/join/physical_piecewise_merge_join.cpp +13 -11
  41. package/src/duckdb/src/execution/operator/join/physical_positional_join.cpp +8 -6
  42. package/src/duckdb/src/execution/operator/join/physical_range_join.cpp +1 -1
  43. package/src/duckdb/src/execution/operator/order/physical_order.cpp +13 -13
  44. package/src/duckdb/src/execution/operator/order/physical_top_n.cpp +8 -8
  45. package/src/duckdb/src/execution/operator/persistent/physical_batch_insert.cpp +160 -145
  46. package/src/duckdb/src/execution/operator/persistent/physical_copy_to_file.cpp +10 -25
  47. package/src/duckdb/src/execution/operator/persistent/physical_delete.cpp +14 -19
  48. package/src/duckdb/src/execution/operator/persistent/physical_export.cpp +7 -6
  49. package/src/duckdb/src/execution/operator/persistent/physical_insert.cpp +18 -30
  50. package/src/duckdb/src/execution/operator/persistent/physical_update.cpp +14 -18
  51. package/src/duckdb/src/execution/operator/scan/physical_column_data_scan.cpp +6 -4
  52. package/src/duckdb/src/execution/operator/scan/physical_dummy_scan.cpp +4 -19
  53. package/src/duckdb/src/execution/operator/scan/physical_empty_result.cpp +3 -2
  54. package/src/duckdb/src/execution/operator/scan/physical_positional_scan.cpp +14 -5
  55. package/src/duckdb/src/execution/operator/scan/physical_table_scan.cpp +6 -4
  56. package/src/duckdb/src/execution/operator/schema/physical_alter.cpp +3 -19
  57. package/src/duckdb/src/execution/operator/schema/physical_attach.cpp +4 -18
  58. package/src/duckdb/src/execution/operator/schema/physical_create_function.cpp +4 -19
  59. package/src/duckdb/src/execution/operator/schema/physical_create_index.cpp +8 -9
  60. package/src/duckdb/src/execution/operator/schema/physical_create_schema.cpp +4 -19
  61. package/src/duckdb/src/execution/operator/schema/physical_create_sequence.cpp +4 -19
  62. package/src/duckdb/src/execution/operator/schema/physical_create_table.cpp +4 -19
  63. package/src/duckdb/src/execution/operator/schema/physical_create_type.cpp +20 -28
  64. package/src/duckdb/src/execution/operator/schema/physical_create_view.cpp +4 -19
  65. package/src/duckdb/src/execution/operator/schema/physical_detach.cpp +4 -19
  66. package/src/duckdb/src/execution/operator/schema/physical_drop.cpp +3 -19
  67. package/src/duckdb/src/execution/operator/set/physical_recursive_cte.cpp +9 -8
  68. package/src/duckdb/src/execution/operator/set/physical_union.cpp +1 -1
  69. package/src/duckdb/src/execution/physical_operator.cpp +11 -5
  70. package/src/duckdb/src/execution/radix_partitioned_hashtable.cpp +16 -16
  71. package/src/duckdb/src/function/table/arrow_conversion.cpp +3 -3
  72. package/src/duckdb/src/function/table/read_csv.cpp +7 -4
  73. package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
  74. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_catalog_entry.hpp +7 -1
  75. package/src/duckdb/src/include/duckdb/common/enums/operator_result_type.hpp +16 -4
  76. package/src/duckdb/src/include/duckdb/common/multi_file_reader.hpp +5 -4
  77. package/src/duckdb/src/include/duckdb/common/optional_idx.hpp +45 -0
  78. package/src/duckdb/src/include/duckdb/common/set.hpp +2 -1
  79. package/src/duckdb/src/include/duckdb/core_functions/scalar/string_functions.hpp +15 -0
  80. package/src/duckdb/src/include/duckdb/execution/executor.hpp +10 -1
  81. package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_hash_aggregate.hpp +5 -8
  82. package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_perfecthash_aggregate.hpp +2 -4
  83. package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_ungrouped_aggregate.hpp +3 -7
  84. package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_window.hpp +2 -4
  85. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_batch_collector.hpp +1 -2
  86. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_explain_analyze.hpp +2 -5
  87. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_limit.hpp +2 -4
  88. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_limit_percent.hpp +2 -4
  89. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_load.hpp +1 -2
  90. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_materialized_collector.hpp +1 -2
  91. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_pragma.hpp +1 -2
  92. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_prepare.hpp +1 -2
  93. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_reservoir_sample.hpp +2 -4
  94. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_reset.hpp +1 -2
  95. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_set.hpp +1 -2
  96. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_transaction.hpp +1 -2
  97. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_vacuum.hpp +2 -4
  98. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_asof_join.hpp +2 -4
  99. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_blockwise_nl_join.hpp +2 -4
  100. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_cross_product.hpp +1 -2
  101. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_delim_join.hpp +1 -2
  102. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_hash_join.hpp +2 -4
  103. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_iejoin.hpp +2 -4
  104. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_nested_loop_join.hpp +2 -4
  105. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_piecewise_merge_join.hpp +2 -4
  106. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_positional_join.hpp +2 -4
  107. package/src/duckdb/src/include/duckdb/execution/operator/order/physical_order.hpp +2 -4
  108. package/src/duckdb/src/include/duckdb/execution/operator/order/physical_top_n.hpp +2 -4
  109. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_batch_insert.hpp +3 -5
  110. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_copy_to_file.hpp +2 -5
  111. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_delete.hpp +2 -4
  112. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_export.hpp +2 -4
  113. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_insert.hpp +2 -4
  114. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_update.hpp +2 -4
  115. package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_column_data_scan.hpp +1 -2
  116. package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_dummy_scan.hpp +1 -3
  117. package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_empty_result.hpp +1 -2
  118. package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_positional_scan.hpp +1 -2
  119. package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_table_scan.hpp +1 -2
  120. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_alter.hpp +1 -3
  121. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_attach.hpp +1 -3
  122. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_function.hpp +1 -3
  123. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_index.hpp +2 -4
  124. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_schema.hpp +1 -3
  125. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_sequence.hpp +1 -3
  126. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_table.hpp +1 -3
  127. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_type.hpp +6 -5
  128. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_view.hpp +1 -3
  129. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_detach.hpp +1 -3
  130. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_drop.hpp +1 -3
  131. package/src/duckdb/src/include/duckdb/execution/operator/set/physical_recursive_cte.hpp +2 -4
  132. package/src/duckdb/src/include/duckdb/execution/physical_operator.hpp +7 -4
  133. package/src/duckdb/src/include/duckdb/execution/physical_operator_states.hpp +26 -6
  134. package/src/duckdb/src/include/duckdb/execution/radix_partitioned_hashtable.hpp +5 -5
  135. package/src/duckdb/src/include/duckdb/function/aggregate_function.hpp +2 -1
  136. package/src/duckdb/src/include/duckdb/function/table_function.hpp +0 -1
  137. package/src/duckdb/src/include/duckdb/main/client_config.hpp +2 -0
  138. package/src/duckdb/src/include/duckdb/main/config.hpp +2 -0
  139. package/src/duckdb/src/include/duckdb/main/database.hpp +1 -0
  140. package/src/duckdb/src/include/duckdb/main/database_manager.hpp +3 -0
  141. package/src/duckdb/src/include/duckdb/main/extension_helper.hpp +0 -2
  142. package/src/duckdb/src/include/duckdb/parallel/event.hpp +1 -1
  143. package/src/duckdb/src/include/duckdb/parallel/interrupt.hpp +63 -0
  144. package/src/duckdb/src/include/duckdb/parallel/pipeline.hpp +16 -3
  145. package/src/duckdb/src/include/duckdb/parallel/pipeline_executor.hpp +51 -7
  146. package/src/duckdb/src/include/duckdb/parallel/task.hpp +21 -2
  147. package/src/duckdb/src/include/duckdb/parallel/task_counter.hpp +2 -2
  148. package/src/duckdb/src/include/duckdb/parallel/task_scheduler.hpp +2 -2
  149. package/src/duckdb/src/include/duckdb/parser/tableref/pivotref.hpp +3 -0
  150. package/src/duckdb/src/include/duckdb/parser/transformer.hpp +5 -1
  151. package/src/duckdb/src/include/duckdb/planner/column_binding.hpp +6 -0
  152. package/src/duckdb/src/include/duckdb/planner/expression/bound_columnref_expression.hpp +1 -0
  153. package/src/duckdb/src/include/duckdb/planner/operator/logical_aggregate.hpp +1 -0
  154. package/src/duckdb/src/include/duckdb/planner/operator/logical_column_data_get.hpp +1 -0
  155. package/src/duckdb/src/include/duckdb/planner/operator/logical_cteref.hpp +1 -0
  156. package/src/duckdb/src/include/duckdb/planner/operator/logical_delete.hpp +1 -0
  157. package/src/duckdb/src/include/duckdb/planner/operator/logical_delim_get.hpp +1 -0
  158. package/src/duckdb/src/include/duckdb/planner/operator/logical_dummy_scan.hpp +1 -0
  159. package/src/duckdb/src/include/duckdb/planner/operator/logical_expression_get.hpp +1 -0
  160. package/src/duckdb/src/include/duckdb/planner/operator/logical_insert.hpp +1 -0
  161. package/src/duckdb/src/include/duckdb/planner/operator/logical_pivot.hpp +1 -0
  162. package/src/duckdb/src/include/duckdb/planner/operator/logical_projection.hpp +1 -0
  163. package/src/duckdb/src/include/duckdb/planner/operator/logical_recursive_cte.hpp +1 -0
  164. package/src/duckdb/src/include/duckdb/planner/operator/logical_set_operation.hpp +1 -0
  165. package/src/duckdb/src/include/duckdb/planner/operator/logical_unnest.hpp +1 -0
  166. package/src/duckdb/src/include/duckdb/planner/operator/logical_update.hpp +1 -0
  167. package/src/duckdb/src/include/duckdb/planner/operator/logical_window.hpp +1 -0
  168. package/src/duckdb/src/include/duckdb/storage/data_table.hpp +1 -0
  169. package/src/duckdb/src/include/duckdb/storage/optimistic_data_writer.hpp +46 -0
  170. package/src/duckdb/src/include/duckdb/storage/partial_block_manager.hpp +24 -3
  171. package/src/duckdb/src/include/duckdb/storage/table/column_checkpoint_state.hpp +46 -1
  172. package/src/duckdb/src/include/duckdb/storage/table/column_data.hpp +9 -10
  173. package/src/duckdb/src/include/duckdb/storage/table/column_segment.hpp +1 -1
  174. package/src/duckdb/src/include/duckdb/storage/table/list_column_data.hpp +2 -2
  175. package/src/duckdb/src/include/duckdb/storage/table/row_group.hpp +3 -3
  176. package/src/duckdb/src/include/duckdb/storage/table/row_group_collection.hpp +1 -0
  177. package/src/duckdb/src/include/duckdb/storage/table/segment_base.hpp +1 -1
  178. package/src/duckdb/src/include/duckdb/storage/table/segment_tree.hpp +22 -0
  179. package/src/duckdb/src/include/duckdb/storage/table/standard_column_data.hpp +3 -3
  180. package/src/duckdb/src/include/duckdb/storage/table/struct_column_data.hpp +2 -2
  181. package/src/duckdb/src/include/duckdb/storage/table/update_segment.hpp +0 -2
  182. package/src/duckdb/src/include/duckdb/storage/table/validity_column_data.hpp +1 -2
  183. package/src/duckdb/src/include/duckdb/transaction/local_storage.hpp +9 -34
  184. package/src/duckdb/src/include/duckdb/verification/no_operator_caching_verifier.hpp +25 -0
  185. package/src/duckdb/src/include/duckdb/verification/statement_verifier.hpp +5 -0
  186. package/src/duckdb/src/main/attached_database.cpp +5 -3
  187. package/src/duckdb/src/main/client_verify.cpp +4 -0
  188. package/src/duckdb/src/main/config.cpp +4 -0
  189. package/src/duckdb/src/main/database.cpp +45 -48
  190. package/src/duckdb/src/main/extension/extension_load.cpp +32 -49
  191. package/src/duckdb/src/parallel/event.cpp +1 -1
  192. package/src/duckdb/src/parallel/executor.cpp +39 -3
  193. package/src/duckdb/src/parallel/executor_task.cpp +11 -0
  194. package/src/duckdb/src/parallel/interrupt.cpp +57 -0
  195. package/src/duckdb/src/parallel/pipeline.cpp +49 -6
  196. package/src/duckdb/src/parallel/pipeline_executor.cpp +248 -69
  197. package/src/duckdb/src/parallel/pipeline_initialize_event.cpp +1 -1
  198. package/src/duckdb/src/parallel/task_scheduler.cpp +57 -22
  199. package/src/duckdb/src/parser/base_expression.cpp +6 -0
  200. package/src/duckdb/src/parser/transform/statement/transform_create_function.cpp +1 -4
  201. package/src/duckdb/src/parser/transform/statement/transform_create_view.cpp +2 -4
  202. package/src/duckdb/src/parser/transform/statement/transform_pivot_stmt.cpp +43 -24
  203. package/src/duckdb/src/parser/transform/tableref/transform_pivot.cpp +3 -0
  204. package/src/duckdb/src/planner/binder/statement/bind_create.cpp +17 -28
  205. package/src/duckdb/src/planner/expression/bound_columnref_expression.cpp +17 -3
  206. package/src/duckdb/src/planner/expression/bound_reference_expression.cpp +8 -2
  207. package/src/duckdb/src/planner/operator/logical_aggregate.cpp +13 -1
  208. package/src/duckdb/src/planner/operator/logical_column_data_get.cpp +11 -0
  209. package/src/duckdb/src/planner/operator/logical_cteref.cpp +11 -0
  210. package/src/duckdb/src/planner/operator/logical_delete.cpp +10 -0
  211. package/src/duckdb/src/planner/operator/logical_delim_get.cpp +12 -1
  212. package/src/duckdb/src/planner/operator/logical_dummy_scan.cpp +12 -1
  213. package/src/duckdb/src/planner/operator/logical_expression_get.cpp +12 -1
  214. package/src/duckdb/src/planner/operator/logical_get.cpp +10 -4
  215. package/src/duckdb/src/planner/operator/logical_insert.cpp +12 -1
  216. package/src/duckdb/src/planner/operator/logical_pivot.cpp +11 -0
  217. package/src/duckdb/src/planner/operator/logical_projection.cpp +11 -0
  218. package/src/duckdb/src/planner/operator/logical_recursive_cte.cpp +11 -0
  219. package/src/duckdb/src/planner/operator/logical_set_operation.cpp +11 -0
  220. package/src/duckdb/src/planner/operator/logical_unnest.cpp +12 -1
  221. package/src/duckdb/src/planner/operator/logical_update.cpp +10 -0
  222. package/src/duckdb/src/planner/operator/logical_window.cpp +11 -0
  223. package/src/duckdb/src/storage/checkpoint_manager.cpp +1 -1
  224. package/src/duckdb/src/storage/data_table.cpp +5 -0
  225. package/src/duckdb/src/storage/local_storage.cpp +40 -110
  226. package/src/duckdb/src/storage/optimistic_data_writer.cpp +96 -0
  227. package/src/duckdb/src/storage/partial_block_manager.cpp +73 -9
  228. package/src/duckdb/src/storage/single_file_block_manager.cpp +3 -1
  229. package/src/duckdb/src/storage/standard_buffer_manager.cpp +17 -12
  230. package/src/duckdb/src/storage/statistics/base_statistics.cpp +3 -0
  231. package/src/duckdb/src/storage/table/column_checkpoint_state.cpp +90 -82
  232. package/src/duckdb/src/storage/table/column_data.cpp +19 -45
  233. package/src/duckdb/src/storage/table/column_data_checkpointer.cpp +7 -7
  234. package/src/duckdb/src/storage/table/column_segment.cpp +1 -1
  235. package/src/duckdb/src/storage/table/list_column_data.cpp +6 -11
  236. package/src/duckdb/src/storage/table/row_group.cpp +13 -14
  237. package/src/duckdb/src/storage/table/row_group_collection.cpp +10 -4
  238. package/src/duckdb/src/storage/table/standard_column_data.cpp +6 -10
  239. package/src/duckdb/src/storage/table/struct_column_data.cpp +7 -13
  240. package/src/duckdb/src/storage/table/update_segment.cpp +0 -25
  241. package/src/duckdb/src/storage/table/validity_column_data.cpp +2 -6
  242. package/src/duckdb/src/transaction/commit_state.cpp +4 -4
  243. package/src/duckdb/src/verification/no_operator_caching_verifier.cpp +13 -0
  244. package/src/duckdb/src/verification/statement_verifier.cpp +4 -0
  245. package/src/duckdb/third_party/fmt/format.cc +0 -5
  246. package/src/duckdb/third_party/fmt/include/fmt/core.h +10 -12
  247. package/src/duckdb/third_party/fmt/include/fmt/format-inl.h +2 -33
  248. package/src/duckdb/third_party/fmt/include/fmt/format.h +61 -24
  249. package/src/duckdb/third_party/fmt/include/fmt/printf.h +15 -1
  250. package/src/duckdb/third_party/libpg_query/include/nodes/parsenodes.hpp +1 -0
  251. package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +10735 -10674
  252. package/src/duckdb/ub_src_core_functions_scalar_string.cpp +2 -0
  253. package/src/duckdb/ub_src_parallel.cpp +2 -0
  254. 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 *block_manager, block_id_t block_id);
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 *parent = nullptr);
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 &collection;
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);
@@ -27,7 +27,7 @@ public:
27
27
  }
28
28
 
29
29
  //! The start row id of this chunk
30
- const idx_t start;
30
+ idx_t start;
31
31
  //! The amount of entries in this storage chunk
32
32
  atomic<idx_t> count;
33
33
  //! The next segment after this one
@@ -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 *parent = nullptr);
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 *segment, ColumnScanState &state, idx_t row_group_start, idx_t count,
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 *parent = nullptr);
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 *parent);
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
- //! Check if we should flush the previously written row-group to disk
83
- void CheckFlushToDisk();
84
- //! Flushes the final row group to disk (if any)
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 / 2;
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
- #include "duckdb/storage/storage_manager.hpp"
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/function/compression_function.hpp"
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/attached_database.hpp"
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/storage_extension.hpp"
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 extensionon database
153
- auto entry = config.storage_extensions.find(type);
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
- // check if all unrecognized options can be handled by the loaded extension(s)
240
- for (auto &unrecognized_option : config.options.unrecognized_options) {
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
- // if so - set the options
248
- Connection con(*this);
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 void (*ext_storage_init_t)(DBConfig &);
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 ComputeSHA256(FileHandle *handle, const idx_t start, const idx_t end, std::string *res) {
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
- // Invoke MbedTls function to actually compute sha256
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> chunks(numChunks);
93
+ std::vector<std::string> hash_chunks(numChunks);
90
94
  std::vector<idx_t> splits(numChunks + 1);
91
95
 
92
- splits.back() = signature_offset;
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(ComputeSHA256, handle.get(), splits[i], splits[i + 1], &chunks[i]);
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
- ComputeSHA256(handle.get(), splits[i], splits[i + 1], &chunks[i]);
113
+ ComputeSHA256FileSegment(handle.get(), splits[i], splits[i + 1], &hash_chunks[i]);
110
114
  }
111
115
  #endif // DUCKDB_NO_THREADS
112
116
 
113
- string file_content;
114
- file_content.reserve(256 * numChunks);
117
+ string hash_concatenation;
118
+ hash_concatenation.reserve(32 * numChunks); // 256 bits -> 32 bytes per chunk
115
119
 
116
- for (auto &chunk : chunks) {
117
- file_content += chunk;
120
+ for (auto &hash_chunk : hash_chunks) {
121
+ hash_concatenation += hash_chunk;
118
122
  }
119
123
 
120
- string hash;
121
- ComputeSHA256(handle.get(), 0, file_content.size(), &hash);
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, hash)) {
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
- throw IOException(error);
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<unique_ptr<Task>> tasks) {
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());