duckdb 1.1.4-dev9.0 → 1.2.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 (220) hide show
  1. package/LICENSE +1 -1
  2. package/binding.gyp +1 -0
  3. package/package.json +2 -2
  4. package/src/duckdb/extension/core_functions/function_list.cpp +1 -0
  5. package/src/duckdb/extension/core_functions/include/core_functions/scalar/map_functions.hpp +9 -0
  6. package/src/duckdb/extension/core_functions/scalar/date/current.cpp +1 -0
  7. package/src/duckdb/extension/core_functions/scalar/generic/can_implicitly_cast.cpp +2 -2
  8. package/src/duckdb/extension/core_functions/scalar/generic/typeof.cpp +1 -1
  9. package/src/duckdb/extension/core_functions/scalar/list/flatten.cpp +91 -61
  10. package/src/duckdb/extension/core_functions/scalar/map/map_extract.cpp +89 -8
  11. package/src/duckdb/extension/icu/icu-current.cpp +63 -0
  12. package/src/duckdb/extension/icu/icu-makedate.cpp +43 -39
  13. package/src/duckdb/extension/icu/icu-timezone.cpp +63 -63
  14. package/src/duckdb/extension/icu/icu_extension.cpp +2 -0
  15. package/src/duckdb/extension/icu/include/icu-casts.hpp +39 -0
  16. package/src/duckdb/extension/icu/include/icu-current.hpp +17 -0
  17. package/src/duckdb/extension/icu/third_party/icu/stubdata/stubdata.cpp +1 -1
  18. package/src/duckdb/extension/json/json_functions/json_structure.cpp +3 -1
  19. package/src/duckdb/extension/parquet/column_writer.cpp +26 -18
  20. package/src/duckdb/extension/parquet/include/parquet_reader.hpp +0 -6
  21. package/src/duckdb/extension/parquet/include/parquet_writer.hpp +15 -1
  22. package/src/duckdb/extension/parquet/include/resizable_buffer.hpp +1 -0
  23. package/src/duckdb/extension/parquet/parquet_extension.cpp +67 -15
  24. package/src/duckdb/extension/parquet/parquet_reader.cpp +5 -3
  25. package/src/duckdb/extension/parquet/parquet_writer.cpp +5 -6
  26. package/src/duckdb/src/catalog/catalog.cpp +21 -8
  27. package/src/duckdb/src/catalog/catalog_search_path.cpp +17 -1
  28. package/src/duckdb/src/catalog/catalog_set.cpp +1 -1
  29. package/src/duckdb/src/catalog/default/default_functions.cpp +0 -3
  30. package/src/duckdb/src/catalog/dependency_list.cpp +7 -0
  31. package/src/duckdb/src/common/adbc/adbc.cpp +1 -56
  32. package/src/duckdb/src/common/arrow/arrow_converter.cpp +3 -2
  33. package/src/duckdb/src/common/arrow/arrow_type_extension.cpp +58 -28
  34. package/src/duckdb/src/common/arrow/schema_metadata.cpp +1 -1
  35. package/src/duckdb/src/common/compressed_file_system.cpp +6 -2
  36. package/src/duckdb/src/common/enum_util.cpp +26 -22
  37. package/src/duckdb/src/common/error_data.cpp +3 -2
  38. package/src/duckdb/src/common/gzip_file_system.cpp +8 -8
  39. package/src/duckdb/src/common/local_file_system.cpp +2 -2
  40. package/src/duckdb/src/common/multi_file_reader.cpp +1 -1
  41. package/src/duckdb/src/common/random_engine.cpp +4 -1
  42. package/src/duckdb/src/common/serializer/memory_stream.cpp +23 -19
  43. package/src/duckdb/src/common/serializer/serializer.cpp +1 -1
  44. package/src/duckdb/src/common/types/bit.cpp +1 -1
  45. package/src/duckdb/src/common/types/column/column_data_allocator.cpp +0 -5
  46. package/src/duckdb/src/common/types/column/column_data_collection.cpp +4 -1
  47. package/src/duckdb/src/common/types/data_chunk.cpp +2 -1
  48. package/src/duckdb/src/common/types/row/tuple_data_segment.cpp +0 -4
  49. package/src/duckdb/src/common/types.cpp +1 -1
  50. package/src/duckdb/src/execution/index/art/art.cpp +52 -42
  51. package/src/duckdb/src/execution/index/art/leaf.cpp +4 -9
  52. package/src/duckdb/src/execution/index/art/node.cpp +13 -13
  53. package/src/duckdb/src/execution/index/art/prefix.cpp +21 -16
  54. package/src/duckdb/src/execution/index/bound_index.cpp +6 -8
  55. package/src/duckdb/src/execution/index/fixed_size_allocator.cpp +39 -34
  56. package/src/duckdb/src/execution/index/fixed_size_buffer.cpp +2 -1
  57. package/src/duckdb/src/execution/index/unbound_index.cpp +10 -0
  58. package/src/duckdb/src/execution/operator/aggregate/physical_streaming_window.cpp +62 -44
  59. package/src/duckdb/src/execution/operator/csv_scanner/scanner/column_count_scanner.cpp +26 -0
  60. package/src/duckdb/src/execution/operator/csv_scanner/scanner/string_value_scanner.cpp +69 -40
  61. package/src/duckdb/src/execution/operator/csv_scanner/sniffer/dialect_detection.cpp +3 -7
  62. package/src/duckdb/src/execution/operator/csv_scanner/sniffer/header_detection.cpp +11 -5
  63. package/src/duckdb/src/execution/operator/csv_scanner/sniffer/type_detection.cpp +4 -0
  64. package/src/duckdb/src/execution/operator/csv_scanner/state_machine/csv_state_machine_cache.cpp +8 -8
  65. package/src/duckdb/src/execution/operator/csv_scanner/util/csv_error.cpp +36 -12
  66. package/src/duckdb/src/execution/operator/csv_scanner/util/csv_reader_options.cpp +12 -9
  67. package/src/duckdb/src/execution/operator/join/physical_hash_join.cpp +0 -1
  68. package/src/duckdb/src/execution/operator/persistent/physical_copy_database.cpp +29 -1
  69. package/src/duckdb/src/execution/operator/persistent/physical_delete.cpp +58 -10
  70. package/src/duckdb/src/execution/operator/persistent/physical_insert.cpp +58 -35
  71. package/src/duckdb/src/execution/operator/schema/physical_create_art_index.cpp +2 -1
  72. package/src/duckdb/src/execution/radix_partitioned_hashtable.cpp +9 -4
  73. package/src/duckdb/src/execution/sample/reservoir_sample.cpp +7 -6
  74. package/src/duckdb/src/function/compression_config.cpp +4 -0
  75. package/src/duckdb/src/function/function_binder.cpp +1 -1
  76. package/src/duckdb/src/function/scalar/system/write_log.cpp +2 -2
  77. package/src/duckdb/src/function/table/arrow/arrow_duck_schema.cpp +15 -2
  78. package/src/duckdb/src/function/table/arrow_conversion.cpp +10 -10
  79. package/src/duckdb/src/function/table/copy_csv.cpp +8 -5
  80. package/src/duckdb/src/function/table/read_csv.cpp +21 -4
  81. package/src/duckdb/src/function/table/sniff_csv.cpp +7 -0
  82. package/src/duckdb/src/function/table/system/duckdb_extensions.cpp +4 -0
  83. package/src/duckdb/src/function/table/system/duckdb_secret_types.cpp +71 -0
  84. package/src/duckdb/src/function/table/system_functions.cpp +1 -0
  85. package/src/duckdb/src/function/table/table_scan.cpp +120 -36
  86. package/src/duckdb/src/function/table/version/pragma_version.cpp +4 -4
  87. package/src/duckdb/src/function/window/window_aggregate_function.cpp +6 -1
  88. package/src/duckdb/src/function/window/window_boundaries_state.cpp +135 -11
  89. package/src/duckdb/src/function/window/window_segment_tree.cpp +50 -22
  90. package/src/duckdb/src/function/window/window_token_tree.cpp +4 -3
  91. package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +4 -0
  92. package/src/duckdb/src/include/duckdb/catalog/catalog_search_path.hpp +2 -0
  93. package/src/duckdb/src/include/duckdb/catalog/dependency_list.hpp +1 -0
  94. package/src/duckdb/src/include/duckdb/common/arrow/arrow_type_extension.hpp +4 -2
  95. package/src/duckdb/src/include/duckdb/common/enum_util.hpp +8 -8
  96. package/src/duckdb/src/include/duckdb/common/multi_file_reader.hpp +0 -2
  97. package/src/duckdb/src/include/duckdb/common/serializer/deserializer.hpp +8 -3
  98. package/src/duckdb/src/include/duckdb/common/serializer/memory_stream.hpp +6 -1
  99. package/src/duckdb/src/include/duckdb/common/serializer/serialization_data.hpp +25 -0
  100. package/src/duckdb/src/include/duckdb/common/serializer/serializer.hpp +9 -3
  101. package/src/duckdb/src/include/duckdb/common/types/selection_vector.hpp +1 -1
  102. package/src/duckdb/src/include/duckdb/execution/index/art/art.hpp +11 -14
  103. package/src/duckdb/src/include/duckdb/execution/index/art/prefix.hpp +5 -4
  104. package/src/duckdb/src/include/duckdb/execution/index/bound_index.hpp +21 -10
  105. package/src/duckdb/src/include/duckdb/execution/index/fixed_size_allocator.hpp +6 -5
  106. package/src/duckdb/src/include/duckdb/execution/index/fixed_size_buffer.hpp +37 -32
  107. package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/base_scanner.hpp +36 -1
  108. package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/column_count_scanner.hpp +3 -0
  109. package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/sniffer/csv_sniffer.hpp +2 -0
  110. package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/state_machine_options.hpp +5 -5
  111. package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/string_value_scanner.hpp +5 -30
  112. package/src/duckdb/src/include/duckdb/execution/reservoir_sample.hpp +7 -1
  113. package/src/duckdb/src/include/duckdb/function/scalar_function.hpp +3 -3
  114. package/src/duckdb/src/include/duckdb/function/table/arrow/arrow_duck_schema.hpp +1 -0
  115. package/src/duckdb/src/include/duckdb/function/table/system_functions.hpp +4 -0
  116. package/src/duckdb/src/include/duckdb/function/window/window_boundaries_state.hpp +2 -2
  117. package/src/duckdb/src/include/duckdb/logging/logger.hpp +40 -119
  118. package/src/duckdb/src/include/duckdb/logging/logging.hpp +0 -2
  119. package/src/duckdb/src/include/duckdb/main/config.hpp +5 -0
  120. package/src/duckdb/src/include/duckdb/main/connection.hpp +0 -8
  121. package/src/duckdb/src/include/duckdb/main/connection_manager.hpp +2 -1
  122. package/src/duckdb/src/include/duckdb/main/extension.hpp +1 -0
  123. package/src/duckdb/src/include/duckdb/main/extension_entries.hpp +11 -7
  124. package/src/duckdb/src/include/duckdb/main/extension_helper.hpp +1 -0
  125. package/src/duckdb/src/include/duckdb/main/secret/secret.hpp +2 -0
  126. package/src/duckdb/src/include/duckdb/main/secret/secret_manager.hpp +3 -0
  127. package/src/duckdb/src/include/duckdb/main/settings.hpp +10 -0
  128. package/src/duckdb/src/include/duckdb/parser/constraint.hpp +9 -0
  129. package/src/duckdb/src/include/duckdb/parser/expression/window_expression.hpp +36 -9
  130. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_view_info.hpp +2 -1
  131. package/src/duckdb/src/include/duckdb/parser/query_node/set_operation_node.hpp +8 -2
  132. package/src/duckdb/src/include/duckdb/planner/binder.hpp +4 -0
  133. package/src/duckdb/src/include/duckdb/planner/expression/bound_parameter_data.hpp +9 -1
  134. package/src/duckdb/src/include/duckdb/planner/filter/constant_filter.hpp +1 -0
  135. package/src/duckdb/src/include/duckdb/planner/filter/in_filter.hpp +0 -2
  136. package/src/duckdb/src/include/duckdb/planner/filter/optional_filter.hpp +4 -4
  137. package/src/duckdb/src/include/duckdb/planner/table_filter.hpp +1 -1
  138. package/src/duckdb/src/include/duckdb/storage/data_table.hpp +14 -10
  139. package/src/duckdb/src/include/duckdb/storage/index_storage_info.hpp +4 -0
  140. package/src/duckdb/src/include/duckdb/storage/single_file_block_manager.hpp +6 -1
  141. package/src/duckdb/src/include/duckdb/storage/storage_info.hpp +7 -2
  142. package/src/duckdb/src/include/duckdb/storage/storage_manager.hpp +9 -0
  143. package/src/duckdb/src/include/duckdb/storage/storage_options.hpp +2 -0
  144. package/src/duckdb/src/include/duckdb/storage/string_uncompressed.hpp +4 -3
  145. package/src/duckdb/src/include/duckdb/storage/table/column_data.hpp +2 -0
  146. package/src/duckdb/src/include/duckdb/storage/table/table_index_list.hpp +6 -4
  147. package/src/duckdb/src/include/duckdb/storage/table/table_statistics.hpp +1 -1
  148. package/src/duckdb/src/include/duckdb/storage/write_ahead_log.hpp +2 -0
  149. package/src/duckdb/src/include/duckdb/transaction/local_storage.hpp +2 -0
  150. package/src/duckdb/src/include/duckdb/transaction/meta_transaction.hpp +1 -1
  151. package/src/duckdb/src/logging/logger.cpp +8 -66
  152. package/src/duckdb/src/main/attached_database.cpp +3 -1
  153. package/src/duckdb/src/main/client_context.cpp +4 -2
  154. package/src/duckdb/src/main/config.cpp +20 -2
  155. package/src/duckdb/src/main/connection.cpp +2 -29
  156. package/src/duckdb/src/main/connection_manager.cpp +5 -3
  157. package/src/duckdb/src/main/database.cpp +2 -2
  158. package/src/duckdb/src/main/extension/extension_helper.cpp +4 -5
  159. package/src/duckdb/src/main/extension/extension_install.cpp +23 -10
  160. package/src/duckdb/src/main/extension/extension_load.cpp +6 -7
  161. package/src/duckdb/src/main/extension.cpp +27 -9
  162. package/src/duckdb/src/main/secret/secret_manager.cpp +11 -0
  163. package/src/duckdb/src/main/settings/custom_settings.cpp +44 -0
  164. package/src/duckdb/src/optimizer/column_lifetime_analyzer.cpp +6 -0
  165. package/src/duckdb/src/optimizer/filter_combiner.cpp +13 -3
  166. package/src/duckdb/src/optimizer/filter_pushdown.cpp +33 -6
  167. package/src/duckdb/src/optimizer/late_materialization.cpp +14 -3
  168. package/src/duckdb/src/optimizer/remove_unused_columns.cpp +0 -3
  169. package/src/duckdb/src/parser/parsed_data/attach_info.cpp +5 -1
  170. package/src/duckdb/src/parser/parsed_data/create_view_info.cpp +6 -3
  171. package/src/duckdb/src/parser/query_node/set_operation_node.cpp +49 -0
  172. package/src/duckdb/src/parser/transform/expression/transform_columnref.cpp +1 -0
  173. package/src/duckdb/src/parser/transform/expression/transform_function.cpp +50 -12
  174. package/src/duckdb/src/planner/binder/expression/bind_columnref_expression.cpp +7 -5
  175. package/src/duckdb/src/planner/binder/expression/bind_comparison_expression.cpp +1 -0
  176. package/src/duckdb/src/planner/binder/expression/bind_operator_expression.cpp +2 -2
  177. package/src/duckdb/src/planner/binder/expression/bind_star_expression.cpp +12 -2
  178. package/src/duckdb/src/planner/binder/statement/bind_copy_database.cpp +0 -1
  179. package/src/duckdb/src/planner/binder/statement/bind_create.cpp +55 -39
  180. package/src/duckdb/src/planner/binder/statement/bind_execute.cpp +2 -1
  181. package/src/duckdb/src/planner/binder/tableref/bind_basetableref.cpp +15 -7
  182. package/src/duckdb/src/planner/binder/tableref/bind_showref.cpp +13 -8
  183. package/src/duckdb/src/planner/binder/tableref/bind_table_function.cpp +8 -3
  184. package/src/duckdb/src/planner/expression/bound_function_expression.cpp +17 -1
  185. package/src/duckdb/src/planner/expression_binder/index_binder.cpp +1 -0
  186. package/src/duckdb/src/planner/filter/conjunction_filter.cpp +1 -0
  187. package/src/duckdb/src/planner/filter/constant_filter.cpp +21 -0
  188. package/src/duckdb/src/planner/filter/in_filter.cpp +4 -7
  189. package/src/duckdb/src/planner/logical_operator.cpp +5 -3
  190. package/src/duckdb/src/planner/planner.cpp +1 -1
  191. package/src/duckdb/src/planner/subquery/flatten_dependent_join.cpp +2 -0
  192. package/src/duckdb/src/storage/checkpoint/table_data_writer.cpp +3 -4
  193. package/src/duckdb/src/storage/checkpoint_manager.cpp +3 -5
  194. package/src/duckdb/src/storage/compression/dictionary/decompression.cpp +4 -4
  195. package/src/duckdb/src/storage/compression/fsst.cpp +2 -2
  196. package/src/duckdb/src/storage/compression/roaring/common.cpp +10 -1
  197. package/src/duckdb/src/storage/compression/string_uncompressed.cpp +11 -6
  198. package/src/duckdb/src/storage/compression/validity_uncompressed.cpp +4 -0
  199. package/src/duckdb/src/storage/compression/zstd.cpp +6 -0
  200. package/src/duckdb/src/storage/data_table.cpp +104 -109
  201. package/src/duckdb/src/storage/local_storage.cpp +8 -6
  202. package/src/duckdb/src/storage/magic_bytes.cpp +1 -1
  203. package/src/duckdb/src/storage/serialization/serialize_dependency.cpp +3 -3
  204. package/src/duckdb/src/storage/serialization/serialize_nodes.cpp +3 -3
  205. package/src/duckdb/src/storage/serialization/serialize_query_node.cpp +7 -5
  206. package/src/duckdb/src/storage/single_file_block_manager.cpp +95 -28
  207. package/src/duckdb/src/storage/storage_info.cpp +38 -0
  208. package/src/duckdb/src/storage/storage_manager.cpp +11 -0
  209. package/src/duckdb/src/storage/table/column_data.cpp +4 -0
  210. package/src/duckdb/src/storage/table/column_data_checkpointer.cpp +3 -3
  211. package/src/duckdb/src/storage/table/row_group_collection.cpp +67 -68
  212. package/src/duckdb/src/storage/table/table_statistics.cpp +4 -4
  213. package/src/duckdb/src/storage/table_index_list.cpp +41 -15
  214. package/src/duckdb/src/storage/wal_replay.cpp +3 -1
  215. package/src/duckdb/src/storage/write_ahead_log.cpp +11 -4
  216. package/src/duckdb/src/transaction/meta_transaction.cpp +1 -1
  217. package/src/duckdb/src/verification/deserialized_statement_verifier.cpp +2 -1
  218. package/src/duckdb/third_party/httplib/httplib.hpp +0 -1
  219. package/src/duckdb/third_party/re2/util/logging.h +10 -10
  220. package/src/duckdb/ub_src_function_table_system.cpp +2 -0
@@ -135,6 +135,7 @@ static constexpr ExtensionFunctionEntry EXTENSION_FUNCTIONS[] = {
135
135
  {"covar_samp", "core_functions", CatalogType::AGGREGATE_FUNCTION_ENTRY},
136
136
  {"create_fts_index", "fts", CatalogType::PRAGMA_FUNCTION_ENTRY},
137
137
  {"current_database", "core_functions", CatalogType::SCALAR_FUNCTION_ENTRY},
138
+ {"current_date", "icu", CatalogType::SCALAR_FUNCTION_ENTRY},
138
139
  {"current_localtime", "icu", CatalogType::SCALAR_FUNCTION_ENTRY},
139
140
  {"current_localtimestamp", "icu", CatalogType::SCALAR_FUNCTION_ENTRY},
140
141
  {"current_query", "core_functions", CatalogType::SCALAR_FUNCTION_ENTRY},
@@ -179,8 +180,6 @@ static constexpr ExtensionFunctionEntry EXTENSION_FUNCTIONS[] = {
179
180
  {"from_hex", "core_functions", CatalogType::SCALAR_FUNCTION_ENTRY},
180
181
  {"from_json", "json", CatalogType::SCALAR_FUNCTION_ENTRY},
181
182
  {"from_json_strict", "json", CatalogType::SCALAR_FUNCTION_ENTRY},
182
- {"from_substrait", "substrait", CatalogType::TABLE_FUNCTION_ENTRY},
183
- {"from_substrait_json", "substrait", CatalogType::TABLE_FUNCTION_ENTRY},
184
183
  {"fsum", "core_functions", CatalogType::AGGREGATE_FUNCTION_ENTRY},
185
184
  {"fuzz_all_functions", "sqlsmith", CatalogType::TABLE_FUNCTION_ENTRY},
186
185
  {"fuzzyduck", "sqlsmith", CatalogType::TABLE_FUNCTION_ENTRY},
@@ -188,9 +187,8 @@ static constexpr ExtensionFunctionEntry EXTENSION_FUNCTIONS[] = {
188
187
  {"gcd", "core_functions", CatalogType::SCALAR_FUNCTION_ENTRY},
189
188
  {"gen_random_uuid", "core_functions", CatalogType::SCALAR_FUNCTION_ENTRY},
190
189
  {"get_bit", "core_functions", CatalogType::SCALAR_FUNCTION_ENTRY},
190
+ {"get_current_time", "icu", CatalogType::SCALAR_FUNCTION_ENTRY},
191
191
  {"get_current_timestamp", "core_functions", CatalogType::SCALAR_FUNCTION_ENTRY},
192
- {"get_substrait", "substrait", CatalogType::TABLE_FUNCTION_ENTRY},
193
- {"get_substrait_json", "substrait", CatalogType::TABLE_FUNCTION_ENTRY},
194
192
  {"grade_up", "core_functions", CatalogType::SCALAR_FUNCTION_ENTRY},
195
193
  {"greatest", "core_functions", CatalogType::SCALAR_FUNCTION_ENTRY},
196
194
  {"greatest_common_divisor", "core_functions", CatalogType::SCALAR_FUNCTION_ENTRY},
@@ -430,6 +428,7 @@ static constexpr ExtensionFunctionEntry EXTENSION_FUNCTIONS[] = {
430
428
  {"map_concat", "core_functions", CatalogType::SCALAR_FUNCTION_ENTRY},
431
429
  {"map_entries", "core_functions", CatalogType::SCALAR_FUNCTION_ENTRY},
432
430
  {"map_extract", "core_functions", CatalogType::SCALAR_FUNCTION_ENTRY},
431
+ {"map_extract_value", "core_functions", CatalogType::SCALAR_FUNCTION_ENTRY},
433
432
  {"map_from_entries", "core_functions", CatalogType::SCALAR_FUNCTION_ENTRY},
434
433
  {"map_keys", "core_functions", CatalogType::SCALAR_FUNCTION_ENTRY},
435
434
  {"map_values", "core_functions", CatalogType::SCALAR_FUNCTION_ENTRY},
@@ -523,6 +522,7 @@ static constexpr ExtensionFunctionEntry EXTENSION_FUNCTIONS[] = {
523
522
  {"skewness", "core_functions", CatalogType::AGGREGATE_FUNCTION_ENTRY},
524
523
  {"sql_auto_complete", "autocomplete", CatalogType::TABLE_FUNCTION_ENTRY},
525
524
  {"sqlite_attach", "sqlite_scanner", CatalogType::TABLE_FUNCTION_ENTRY},
525
+ {"sqlite_query", "sqlite_scanner", CatalogType::TABLE_FUNCTION_ENTRY},
526
526
  {"sqlite_scan", "sqlite_scanner", CatalogType::TABLE_FUNCTION_ENTRY},
527
527
  {"sqlsmith", "sqlsmith", CatalogType::TABLE_FUNCTION_ENTRY},
528
528
  {"sqrt", "core_functions", CatalogType::SCALAR_FUNCTION_ENTRY},
@@ -682,6 +682,7 @@ static constexpr ExtensionFunctionEntry EXTENSION_FUNCTIONS[] = {
682
682
  {"to_timestamp", "core_functions", CatalogType::SCALAR_FUNCTION_ENTRY},
683
683
  {"to_weeks", "core_functions", CatalogType::SCALAR_FUNCTION_ENTRY},
684
684
  {"to_years", "core_functions", CatalogType::SCALAR_FUNCTION_ENTRY},
685
+ {"today", "icu", CatalogType::SCALAR_FUNCTION_ENTRY},
685
686
  {"tpcds", "tpcds", CatalogType::PRAGMA_FUNCTION_ENTRY},
686
687
  {"tpcds_answers", "tpcds", CatalogType::TABLE_FUNCTION_ENTRY},
687
688
  {"tpcds_queries", "tpcds", CatalogType::TABLE_FUNCTION_ENTRY},
@@ -980,7 +981,9 @@ static constexpr ExtensionEntry EXTENSION_SETTINGS[] = {
980
981
  {"s3_url_style", "httpfs"},
981
982
  {"s3_use_ssl", "httpfs"},
982
983
  {"sqlite_all_varchar", "sqlite_scanner"},
984
+ {"sqlite_debug_show_queries", "sqlite_scanner"},
983
985
  {"timezone", "icu"},
986
+ {"unsafe_enable_version_guessing", "iceberg"},
984
987
  }; // END_OF_EXTENSION_SETTINGS
985
988
 
986
989
  // Note: these are currently hardcoded in scripts/generate_extensions_function.py
@@ -1068,8 +1071,9 @@ static constexpr ExtensionEntry EXTENSION_SECRET_PROVIDERS[] = {
1068
1071
  {"postgres/config", "postgres_scanner"}}; // EXTENSION_SECRET_PROVIDERS
1069
1072
 
1070
1073
  static constexpr const char *AUTOLOADABLE_EXTENSIONS[] = {
1071
- "aws", "azure", "autocomplete", "core_functions", "delta", "excel", "fts", "httpfs",
1072
- "inet", "icu", "json", "mysql_scanner", "parquet", "sqlite_scanner", "sqlsmith", "postgres_scanner",
1073
- "tpcds", "tpch"}; // END_OF_AUTOLOADABLE_EXTENSIONS
1074
+ "aws", "azure", "autocomplete", "core_functions", "delta", "excel",
1075
+ "fts", "httpfs", "iceberg", "inet", "icu", "json",
1076
+ "motherduck", "mysql_scanner", "parquet", "sqlite_scanner", "sqlsmith", "postgres_scanner",
1077
+ "tpcds", "tpch", "uc_catalog"}; // END_OF_AUTOLOADABLE_EXTENSIONS
1074
1078
 
1075
1079
  } // namespace duckdb
@@ -236,6 +236,7 @@ public:
236
236
 
237
237
  static bool IsRelease(const string &version_tag);
238
238
  static bool CreateSuggestions(const string &extension_name, string &message);
239
+ static string ExtensionInstallDocumentationLink(const string &extension_name);
239
240
 
240
241
  private:
241
242
  static unique_ptr<ExtensionInstallInfo> InstallExtensionInternal(DatabaseInstance &db, FileSystem &fs,
@@ -78,6 +78,8 @@ struct SecretType {
78
78
  secret_deserializer_t deserializer;
79
79
  //! Provider to use when non is specified
80
80
  string default_provider;
81
+ //! The extension that registered this secret type
82
+ string extension;
81
83
  };
82
84
 
83
85
  enum class SecretSerializationType : uint8_t {
@@ -135,6 +135,9 @@ public:
135
135
  //! List all secrets from all secret storages
136
136
  DUCKDB_API vector<SecretEntry> AllSecrets(CatalogTransaction transaction);
137
137
 
138
+ //! List all secret types
139
+ DUCKDB_API vector<SecretType> AllSecretTypes();
140
+
138
141
  //! Secret Manager settings
139
142
  DUCKDB_API virtual void SetEnablePersistentSecrets(bool enabled);
140
143
  DUCKDB_API virtual void ResetEnablePersistentSecrets();
@@ -419,6 +419,16 @@ struct DefaultSecretStorageSetting {
419
419
  static Value GetSetting(const ClientContext &context);
420
420
  };
421
421
 
422
+ struct DisabledCompressionMethodsSetting {
423
+ using RETURN_TYPE = string;
424
+ static constexpr const char *Name = "disabled_compression_methods";
425
+ static constexpr const char *Description = "Disable a specific set of compression methods (comma separated)";
426
+ static constexpr const char *InputType = "VARCHAR";
427
+ static void SetGlobal(DatabaseInstance *db, DBConfig &config, const Value &parameter);
428
+ static void ResetGlobal(DatabaseInstance *db, DBConfig &config);
429
+ static Value GetSetting(const ClientContext &context);
430
+ };
431
+
422
432
  struct DisabledFilesystemsSetting {
423
433
  using RETURN_TYPE = string;
424
434
  static constexpr const char *Name = "disabled_filesystems";
@@ -44,6 +44,15 @@ struct ForeignKeyInfo {
44
44
  vector<PhysicalIndex> pk_keys;
45
45
  //! The set of foreign key table's column's index
46
46
  vector<PhysicalIndex> fk_keys;
47
+
48
+ bool IsDeleteConstraint() const {
49
+ return type == ForeignKeyType::FK_TYPE_PRIMARY_KEY_TABLE ||
50
+ type == ForeignKeyType::FK_TYPE_SELF_REFERENCE_TABLE;
51
+ }
52
+ bool IsAppendConstraint() const {
53
+ return type == ForeignKeyType::FK_TYPE_FOREIGN_KEY_TABLE ||
54
+ type == ForeignKeyType::FK_TYPE_SELF_REFERENCE_TABLE;
55
+ }
47
56
  };
48
57
 
49
58
  //! Constraint is the base class of any type of table constraint.
@@ -22,7 +22,10 @@ enum class WindowBoundary : uint8_t {
22
22
  EXPR_PRECEDING_ROWS = 5,
23
23
  EXPR_FOLLOWING_ROWS = 6,
24
24
  EXPR_PRECEDING_RANGE = 7,
25
- EXPR_FOLLOWING_RANGE = 8
25
+ EXPR_FOLLOWING_RANGE = 8,
26
+ CURRENT_ROW_GROUPS = 9,
27
+ EXPR_PRECEDING_GROUPS = 10,
28
+ EXPR_FOLLOWING_GROUPS = 11
26
29
  };
27
30
 
28
31
  //! Represents the window exclusion mode
@@ -92,6 +95,17 @@ public:
92
95
  static ExpressionType WindowToExpressionType(string &fun_name);
93
96
 
94
97
  public:
98
+ static inline string ToUnits(const WindowBoundary boundary, const WindowBoundary rows, const WindowBoundary range,
99
+ const WindowBoundary groups) {
100
+ if (boundary == rows) {
101
+ return "ROWS";
102
+ } else if (boundary == range) {
103
+ return "RANGE";
104
+ } else {
105
+ return "GROUPS";
106
+ }
107
+ }
108
+
95
109
  template <class T, class BASE, class ORDER_NODE>
96
110
  static string ToString(const T &entry, const string &schema, const string &function_name) {
97
111
  // Start with function call
@@ -156,8 +170,10 @@ public:
156
170
  switch (entry.start) {
157
171
  case WindowBoundary::CURRENT_ROW_RANGE:
158
172
  case WindowBoundary::CURRENT_ROW_ROWS:
173
+ case WindowBoundary::CURRENT_ROW_GROUPS:
159
174
  from = "CURRENT ROW";
160
- units = (entry.start == WindowBoundary::CURRENT_ROW_RANGE) ? "RANGE" : "ROWS";
175
+ units = ToUnits(entry.start, WindowBoundary::CURRENT_ROW_ROWS, WindowBoundary::CURRENT_ROW_RANGE,
176
+ WindowBoundary::CURRENT_ROW_GROUPS);
161
177
  break;
162
178
  case WindowBoundary::UNBOUNDED_PRECEDING:
163
179
  if (entry.end != WindowBoundary::CURRENT_ROW_RANGE) {
@@ -166,15 +182,20 @@ public:
166
182
  break;
167
183
  case WindowBoundary::EXPR_PRECEDING_ROWS:
168
184
  case WindowBoundary::EXPR_PRECEDING_RANGE:
185
+ case WindowBoundary::EXPR_PRECEDING_GROUPS:
169
186
  from = entry.start_expr->ToString() + " PRECEDING";
170
- units = (entry.start == WindowBoundary::EXPR_PRECEDING_RANGE) ? "RANGE" : "ROWS";
187
+ units = ToUnits(entry.start, WindowBoundary::EXPR_PRECEDING_ROWS, WindowBoundary::EXPR_PRECEDING_RANGE,
188
+ WindowBoundary::EXPR_PRECEDING_GROUPS);
171
189
  break;
172
190
  case WindowBoundary::EXPR_FOLLOWING_ROWS:
173
191
  case WindowBoundary::EXPR_FOLLOWING_RANGE:
192
+ case WindowBoundary::EXPR_FOLLOWING_GROUPS:
174
193
  from = entry.start_expr->ToString() + " FOLLOWING";
175
- units = (entry.start == WindowBoundary::EXPR_FOLLOWING_RANGE) ? "RANGE" : "ROWS";
194
+ units = ToUnits(entry.start, WindowBoundary::EXPR_FOLLOWING_ROWS, WindowBoundary::EXPR_FOLLOWING_RANGE,
195
+ WindowBoundary::EXPR_FOLLOWING_GROUPS);
176
196
  break;
177
- default:
197
+ case WindowBoundary::UNBOUNDED_FOLLOWING:
198
+ case WindowBoundary::INVALID:
178
199
  throw InternalException("Unrecognized FROM in WindowExpression");
179
200
  }
180
201
 
@@ -187,8 +208,10 @@ public:
187
208
  }
188
209
  break;
189
210
  case WindowBoundary::CURRENT_ROW_ROWS:
211
+ case WindowBoundary::CURRENT_ROW_GROUPS:
190
212
  to = "CURRENT ROW";
191
- units = "ROWS";
213
+ units = ToUnits(entry.end, WindowBoundary::CURRENT_ROW_ROWS, WindowBoundary::CURRENT_ROW_RANGE,
214
+ WindowBoundary::CURRENT_ROW_GROUPS);
192
215
  break;
193
216
  case WindowBoundary::UNBOUNDED_PRECEDING:
194
217
  to = "UNBOUNDED PRECEDING";
@@ -198,15 +221,19 @@ public:
198
221
  break;
199
222
  case WindowBoundary::EXPR_PRECEDING_ROWS:
200
223
  case WindowBoundary::EXPR_PRECEDING_RANGE:
224
+ case WindowBoundary::EXPR_PRECEDING_GROUPS:
201
225
  to = entry.end_expr->ToString() + " PRECEDING";
202
- units = (entry.end == WindowBoundary::EXPR_PRECEDING_RANGE) ? "RANGE" : "ROWS";
226
+ units = ToUnits(entry.end, WindowBoundary::EXPR_PRECEDING_ROWS, WindowBoundary::EXPR_PRECEDING_RANGE,
227
+ WindowBoundary::EXPR_PRECEDING_GROUPS);
203
228
  break;
204
229
  case WindowBoundary::EXPR_FOLLOWING_ROWS:
205
230
  case WindowBoundary::EXPR_FOLLOWING_RANGE:
231
+ case WindowBoundary::EXPR_FOLLOWING_GROUPS:
206
232
  to = entry.end_expr->ToString() + " FOLLOWING";
207
- units = (entry.end == WindowBoundary::EXPR_FOLLOWING_RANGE) ? "RANGE" : "ROWS";
233
+ units = ToUnits(entry.end, WindowBoundary::EXPR_FOLLOWING_ROWS, WindowBoundary::EXPR_FOLLOWING_RANGE,
234
+ WindowBoundary::EXPR_FOLLOWING_GROUPS);
208
235
  break;
209
- default:
236
+ case WindowBoundary::INVALID:
210
237
  throw InternalException("Unrecognized TO in WindowExpression");
211
238
  }
212
239
  if (entry.exclude_clause != WindowExcludeMode::NO_OTHER) {
@@ -40,7 +40,8 @@ public:
40
40
  //! Gets a bound CreateViewInfo object from a SELECT statement and a view name, schema name, etc
41
41
  DUCKDB_API static unique_ptr<CreateViewInfo> FromSelect(ClientContext &context, unique_ptr<CreateViewInfo> info);
42
42
  //! Gets a bound CreateViewInfo object from a CREATE VIEW statement
43
- DUCKDB_API static unique_ptr<CreateViewInfo> FromCreateView(ClientContext &context, const string &sql);
43
+ DUCKDB_API static unique_ptr<CreateViewInfo> FromCreateView(ClientContext &context, SchemaCatalogEntry &schema,
44
+ const string &sql);
44
45
  //! Parse a SELECT statement from a SQL string
45
46
  DUCKDB_API static unique_ptr<SelectStatement> ParseSelect(const string &sql);
46
47
 
@@ -20,8 +20,7 @@ public:
20
20
  static constexpr const QueryNodeType TYPE = QueryNodeType::SET_OPERATION_NODE;
21
21
 
22
22
  public:
23
- SetOperationNode() : QueryNode(QueryNodeType::SET_OPERATION_NODE) {
24
- }
23
+ SetOperationNode();
25
24
 
26
25
  //! The type of set operation
27
26
  SetOperationType setop_type = SetOperationType::NONE;
@@ -49,6 +48,13 @@ public:
49
48
 
50
49
  void Serialize(Serializer &serializer) const override;
51
50
  static unique_ptr<QueryNode> Deserialize(Deserializer &source);
51
+
52
+ public:
53
+ // these methods exist for forwards/backwards compatibility of (de)serialization
54
+ SetOperationNode(SetOperationType setop_type, unique_ptr<QueryNode> left, unique_ptr<QueryNode> right,
55
+ vector<unique_ptr<QueryNode>> children, bool setop_all);
56
+
57
+ vector<unique_ptr<QueryNode>> SerializeChildNodes() const;
52
58
  };
53
59
 
54
60
  } // namespace duckdb
@@ -419,6 +419,10 @@ private:
419
419
  const string BindCatalog(string &catalog_name);
420
420
  SchemaCatalogEntry &BindCreateSchema(CreateInfo &info);
421
421
 
422
+ vector<CatalogSearchEntry> GetSearchPath(Catalog &catalog, const string &schema_name);
423
+
424
+ LogicalType BindLogicalTypeInternal(const LogicalType &type, optional_ptr<Catalog> catalog, const string &schema);
425
+
422
426
  unique_ptr<BoundQueryNode> BindSelectNode(SelectNode &statement, unique_ptr<BoundTableRef> from_table);
423
427
 
424
428
  unique_ptr<LogicalOperator> BindCopyDatabaseSchema(Catalog &source_catalog, const string &target_database_name);
@@ -17,7 +17,7 @@ struct BoundParameterData {
17
17
  public:
18
18
  BoundParameterData() {
19
19
  }
20
- explicit BoundParameterData(Value val) : value(std::move(val)), return_type(value.type()) {
20
+ explicit BoundParameterData(Value val) : value(std::move(val)), return_type(GetDefaultType(value.type())) {
21
21
  }
22
22
  BoundParameterData(Value val, LogicalType type_p) : value(std::move(val)), return_type(std::move(type_p)) {
23
23
  }
@@ -39,6 +39,14 @@ public:
39
39
 
40
40
  void Serialize(Serializer &serializer) const;
41
41
  static shared_ptr<BoundParameterData> Deserialize(Deserializer &deserializer);
42
+
43
+ private:
44
+ LogicalType GetDefaultType(const LogicalType &type) {
45
+ if (value.type().id() == LogicalTypeId::VARCHAR && StringType::GetCollation(type).empty()) {
46
+ return LogicalTypeId::STRING_LITERAL;
47
+ }
48
+ return value.type();
49
+ }
42
50
  };
43
51
 
44
52
  } // namespace duckdb
@@ -27,6 +27,7 @@ public:
27
27
  Value constant;
28
28
 
29
29
  public:
30
+ bool Compare(const Value &value) const;
30
31
  FilterPropagateResult CheckStatistics(BaseStatistics &stats) override;
31
32
  string ToString(const string &column_name) override;
32
33
  bool Equals(const TableFilter &other) const override;
@@ -19,10 +19,8 @@ public:
19
19
 
20
20
  public:
21
21
  explicit InFilter(vector<Value> values);
22
- InFilter(vector<Value> values, bool origin_is_hash_join);
23
22
 
24
23
  vector<Value> values;
25
- bool origin_is_hash_join;
26
24
 
27
25
  public:
28
26
  FilterPropagateResult CheckStatistics(BaseStatistics &stats) override;
@@ -20,16 +20,16 @@ public:
20
20
  public:
21
21
  explicit OptionalFilter(unique_ptr<TableFilter> filter = nullptr);
22
22
 
23
+ //! Optional child filters.
24
+ unique_ptr<TableFilter> child_filter;
25
+
26
+ public:
23
27
  string ToString(const string &column_name) override;
24
28
  unique_ptr<TableFilter> Copy() const override;
25
29
  unique_ptr<Expression> ToExpression(const Expression &column) const override;
26
30
  FilterPropagateResult CheckStatistics(BaseStatistics &stats) override;
27
31
  void Serialize(Serializer &serializer) const override;
28
32
  static unique_ptr<TableFilter> Deserialize(Deserializer &deserializer);
29
-
30
- public:
31
- // optional child filters
32
- unique_ptr<TableFilter> child_filter;
33
33
  };
34
34
 
35
35
  } // namespace duckdb
@@ -52,7 +52,7 @@ public:
52
52
  string DebugToString();
53
53
  virtual unique_ptr<TableFilter> Copy() const = 0;
54
54
  virtual bool Equals(const TableFilter &other) const {
55
- return filter_type != other.filter_type;
55
+ return filter_type == other.filter_type;
56
56
  }
57
57
  virtual unique_ptr<Expression> ToExpression(const Expression &column) const = 0;
58
58
 
@@ -107,8 +107,8 @@ public:
107
107
  const vector<unique_ptr<BoundConstraint>> &bound_constraints, Vector &row_ids,
108
108
  DataChunk &delete_chunk);
109
109
  //! Append a chunk to the transaction-local storage of this table.
110
- void LocalAppend(TableCatalogEntry &table, ClientContext &context, DataChunk &chunk,
111
- const vector<unique_ptr<BoundConstraint>> &bound_constraints);
110
+ void LocalWALAppend(TableCatalogEntry &table, ClientContext &context, DataChunk &chunk,
111
+ const vector<unique_ptr<BoundConstraint>> &bound_constraints);
112
112
  //! Append a column data collection with default values to the transaction-local storage of this table.
113
113
  void LocalAppend(TableCatalogEntry &table, ClientContext &context, ColumnDataCollection &collection,
114
114
  const vector<unique_ptr<BoundConstraint>> &bound_constraints,
@@ -167,9 +167,10 @@ public:
167
167
 
168
168
  //! Append a chunk with the row ids [row_start, ..., row_start + chunk.size()] to all indexes of the table.
169
169
  //! Returns empty ErrorData, if the append was successful.
170
- ErrorData AppendToIndexes(optional_ptr<TableIndexList> delete_indexes, DataChunk &chunk, row_t row_start);
170
+ ErrorData AppendToIndexes(optional_ptr<TableIndexList> delete_indexes, DataChunk &chunk, row_t row_start,
171
+ const IndexAppendMode index_append_mode);
171
172
  static ErrorData AppendToIndexes(TableIndexList &indexes, optional_ptr<TableIndexList> delete_indexes,
172
- DataChunk &chunk, row_t row_start);
173
+ DataChunk &chunk, row_t row_start, const IndexAppendMode index_append_mode);
173
174
  //! Remove a chunk with the row ids [row_start, ..., row_start + chunk.size()] from all indexes of the table
174
175
  void RemoveFromIndexes(TableAppendState &state, DataChunk &chunk, row_t row_start);
175
176
  //! Remove the chunk with the specified set of row identifiers from all indexes of the table
@@ -206,7 +207,6 @@ public:
206
207
  idx_t GetTotalRows() const;
207
208
 
208
209
  vector<ColumnSegmentInfo> GetColumnSegmentInfo();
209
- static bool IsForeignKeyIndex(const vector<PhysicalIndex> &fk_keys, Index &index, ForeignKeyType fk_type);
210
210
 
211
211
  //! Scans the next chunk for the CREATE INDEX operator
212
212
  bool CreateIndexScan(TableScanState &state, DataChunk &result, TableScanType type);
@@ -259,16 +259,20 @@ private:
259
259
  void VerifyUpdateConstraints(ConstraintState &state, ClientContext &context, DataChunk &chunk,
260
260
  const vector<PhysicalIndex> &column_ids);
261
261
  //! Verify constraints with a chunk from the Delete containing all columns of the table
262
- void VerifyDeleteConstraints(TableDeleteState &state, ClientContext &context, DataChunk &chunk);
262
+ void VerifyDeleteConstraints(optional_ptr<LocalTableStorage> storage, TableDeleteState &state,
263
+ ClientContext &context, DataChunk &chunk);
263
264
 
264
265
  void InitializeScanWithOffset(DuckTransaction &transaction, TableScanState &state,
265
266
  const vector<StorageIndex> &column_ids, idx_t start_row, idx_t end_row);
266
267
 
267
- void VerifyForeignKeyConstraint(const BoundForeignKeyConstraint &bfk, ClientContext &context, DataChunk &chunk,
268
- VerifyExistenceType verify_type);
269
- void VerifyAppendForeignKeyConstraint(const BoundForeignKeyConstraint &bfk, ClientContext &context,
268
+ void VerifyForeignKeyConstraint(optional_ptr<LocalTableStorage> storage,
269
+ const BoundForeignKeyConstraint &bound_foreign_key, ClientContext &context,
270
+ DataChunk &chunk, VerifyExistenceType type);
271
+ void VerifyAppendForeignKeyConstraint(optional_ptr<LocalTableStorage> storage,
272
+ const BoundForeignKeyConstraint &bound_foreign_key, ClientContext &context,
270
273
  DataChunk &chunk);
271
- void VerifyDeleteForeignKeyConstraint(const BoundForeignKeyConstraint &bfk, ClientContext &context,
274
+ void VerifyDeleteForeignKeyConstraint(optional_ptr<LocalTableStorage> storage,
275
+ const BoundForeignKeyConstraint &bound_foreign_key, ClientContext &context,
272
276
  DataChunk &chunk);
273
277
 
274
278
  private:
@@ -62,6 +62,10 @@ struct IndexStorageInfo {
62
62
  BlockPointer root_block_ptr;
63
63
 
64
64
  //! Returns true, if IndexStorageInfo holds information to deserialize an index.
65
+ //! Note that the name can be misleading - any index that is empty (no nodes, etc.) might
66
+ //! also have neither a root_block_ptr nor allocator_infos.
67
+ //! Ensure that your index constructor initializes an empty index correctly without the
68
+ //! need for these fields.
65
69
  bool IsValid() const {
66
70
  return root_block_ptr.IsValid() || !allocator_infos.empty();
67
71
  }
@@ -26,7 +26,9 @@ struct StorageManagerOptions {
26
26
  bool read_only = false;
27
27
  bool use_direct_io = false;
28
28
  DebugInitialize debug_initialize = DebugInitialize::NO_INITIALIZE;
29
- optional_idx block_alloc_size = optional_idx();
29
+ optional_idx block_alloc_size;
30
+ optional_idx storage_version;
31
+ optional_idx version_number;
30
32
  };
31
33
 
32
34
  //! SingleFileBlockManager is an implementation for a BlockManager which manages blocks in a single file
@@ -107,6 +109,9 @@ private:
107
109
  //! Verify the block usage count
108
110
  void VerifyBlocks(const unordered_map<block_id_t, idx_t> &block_usage_count) override;
109
111
 
112
+ void AddStorageVersionTag();
113
+ uint64_t GetVersionNumber();
114
+
110
115
  private:
111
116
  AttachedDatabase &db;
112
117
  //! The active DatabaseHeader, either 0 (h1) or 1 (h2)
@@ -54,10 +54,13 @@ struct Storage {
54
54
  static void VerifyBlockAllocSize(const idx_t block_alloc_size);
55
55
  };
56
56
 
57
- //! The version number of the database storage format
57
+ //! The version number default, lower and upper bounds of the database storage format
58
58
  extern const uint64_t VERSION_NUMBER;
59
+ extern const uint64_t VERSION_NUMBER_LOWER;
60
+ extern const uint64_t VERSION_NUMBER_UPPER;
59
61
  string GetDuckDBVersion(idx_t version_number);
60
62
  optional_idx GetStorageVersion(const char *version_string);
63
+ string GetStorageVersionName(idx_t serialization_version);
61
64
  optional_idx GetSerializationVersion(const char *version_string);
62
65
  vector<string> GetSerializationCandidates();
63
66
 
@@ -109,9 +112,11 @@ struct DatabaseHeader {
109
112
  idx_t block_alloc_size;
110
113
  //! The vector size of the database file
111
114
  idx_t vector_size;
115
+ //! The serialization compatibility version
116
+ idx_t serialization_compatibility;
112
117
 
113
118
  void Write(WriteStream &ser);
114
- static DatabaseHeader Read(ReadStream &source);
119
+ static DatabaseHeader Read(const MainHeader &header, ReadStream &source);
115
120
  };
116
121
 
117
122
  //! Detect mismatching constant values when compiling
@@ -106,6 +106,13 @@ public:
106
106
  virtual shared_ptr<TableIOManager> GetTableIOManager(BoundCreateTableInfo *info) = 0;
107
107
  virtual BlockManager &GetBlockManager() = 0;
108
108
 
109
+ void SetStorageVersion(idx_t version) {
110
+ storage_version = version;
111
+ }
112
+ idx_t GetStorageVersion() const {
113
+ return storage_version.GetIndex();
114
+ }
115
+
109
116
  protected:
110
117
  virtual void LoadDatabase(StorageOptions options) = 0;
111
118
 
@@ -121,6 +128,8 @@ protected:
121
128
  //! When loading a database, we do not yet set the wal-field. Therefore, GetWriteAheadLog must
122
129
  //! return nullptr when loading a database
123
130
  bool load_complete = false;
131
+ //! The serialization compatibility version when reading and writing from this database
132
+ optional_idx storage_version;
124
133
 
125
134
  public:
126
135
  template <class TARGET>
@@ -18,6 +18,8 @@ struct StorageOptions {
18
18
  optional_idx block_alloc_size;
19
19
  //! The row group size for this attached database (if any)
20
20
  optional_idx row_group_size;
21
+ //! Target storage version (if any)
22
+ optional_idx storage_version;
21
23
  };
22
24
 
23
25
  } // namespace duckdb
@@ -207,6 +207,7 @@ public:
207
207
 
208
208
  static void SetDictionary(ColumnSegment &segment, BufferHandle &handle, StringDictionaryContainer dict);
209
209
  static StringDictionaryContainer GetDictionary(ColumnSegment &segment, BufferHandle &handle);
210
+ static uint32_t GetDictionaryEnd(ColumnSegment &segment, BufferHandle &handle);
210
211
  static idx_t RemainingSpace(ColumnSegment &segment, BufferHandle &handle);
211
212
  static void WriteString(ColumnSegment &segment, string_t string, block_id_t &result_block, int32_t &result_offset);
212
213
  static void WriteStringMemory(ColumnSegment &segment, string_t string, block_id_t &result_block,
@@ -217,12 +218,12 @@ public:
217
218
  static void WriteStringMarker(data_ptr_t target, block_id_t block_id, int32_t offset);
218
219
  static void ReadStringMarker(data_ptr_t target, block_id_t &block_id, int32_t &offset);
219
220
 
220
- inline static string_t FetchStringFromDict(ColumnSegment &segment, StringDictionaryContainer dict, Vector &result,
221
+ inline static string_t FetchStringFromDict(ColumnSegment &segment, uint32_t dict_end_offset, Vector &result,
221
222
  data_ptr_t base_ptr, int32_t dict_offset, uint32_t string_length) {
222
223
  D_ASSERT(dict_offset <= NumericCast<int32_t>(segment.GetBlockManager().GetBlockSize()));
223
224
  if (DUCKDB_LIKELY(dict_offset >= 0)) {
224
225
  // regular string - fetch from dictionary
225
- auto dict_end = base_ptr + dict.end;
226
+ auto dict_end = base_ptr + dict_end_offset;
226
227
  auto dict_pos = dict_end - dict_offset;
227
228
 
228
229
  auto str_ptr = char_ptr_cast(dict_pos);
@@ -231,7 +232,7 @@ public:
231
232
  // read overflow string
232
233
  block_id_t block_id;
233
234
  int32_t offset;
234
- ReadStringMarker(base_ptr + dict.end - AbsValue<int32_t>(dict_offset), block_id, offset);
235
+ ReadStringMarker(base_ptr + dict_end_offset - AbsValue<int32_t>(dict_offset), block_id, offset);
235
236
 
236
237
  return ReadOverflowString(segment, result, block_id, offset);
237
238
  }
@@ -26,6 +26,7 @@ class ColumnSegment;
26
26
  class DatabaseInstance;
27
27
  class RowGroup;
28
28
  class RowGroupWriter;
29
+ class StorageManager;
29
30
  class TableDataWriter;
30
31
  class TableStorageInfo;
31
32
  struct DataTableInfo;
@@ -77,6 +78,7 @@ public:
77
78
  }
78
79
  DatabaseInstance &GetDatabase() const;
79
80
  DataTableInfo &GetTableInfo() const;
81
+ StorageManager &GetStorageManager() const;
80
82
  virtual idx_t GetMaxEntry();
81
83
 
82
84
  idx_t GetAllocationSize() const {
@@ -16,7 +16,7 @@
16
16
  namespace duckdb {
17
17
 
18
18
  class ConflictManager;
19
-
19
+ class LocalTableStorage;
20
20
  struct IndexStorageInfo;
21
21
  struct DataTableInfo;
22
22
 
@@ -78,17 +78,19 @@ public:
78
78
  //! Overwrite this list with the other list.
79
79
  void Move(TableIndexList &other);
80
80
  //! Find the foreign key matching the keys.
81
- Index *FindForeignKeyIndex(const vector<PhysicalIndex> &fk_keys, const ForeignKeyType fk_type);
81
+ optional_ptr<Index> FindForeignKeyIndex(const vector<PhysicalIndex> &fk_keys, const ForeignKeyType fk_type);
82
82
  //! Verify a foreign key constraint.
83
- void VerifyForeignKey(const vector<PhysicalIndex> &fk_keys, DataChunk &chunk, ConflictManager &conflict_manager);
83
+ void VerifyForeignKey(optional_ptr<LocalTableStorage> storage, const vector<PhysicalIndex> &fk_keys,
84
+ DataChunk &chunk, ConflictManager &conflict_manager);
84
85
  //! Get the combined column ids of the indexes in this list.
85
86
  unordered_set<column_t> GetRequiredColumns();
86
87
  //! Serialize all indexes of this table.
87
88
  vector<IndexStorageInfo> GetStorageInfos(const case_insensitive_map_t<Value> &options);
88
89
 
89
90
  private:
91
+ //! A lock to prevent any concurrent changes to the indexes.
90
92
  mutex indexes_lock;
91
- // Indexes associated with the table.
93
+ //! Indexes associated with the table.
92
94
  vector<unique_ptr<Index>> indexes;
93
95
  };
94
96
 
@@ -49,7 +49,7 @@ public:
49
49
  //! The reference can only be safely accessed while the lock is held
50
50
  ColumnStatistics &GetStats(TableStatisticsLock &lock, idx_t i);
51
51
  //! Get a reference to the table sample - this requires us to hold the lock.
52
- BlockingSample &GetTableSampleRef(TableStatisticsLock &lock);
52
+ // BlockingSample &GetTableSampleRef(TableStatisticsLock &lock);
53
53
  //! Take ownership of the sample, needed for merging. Requires the lock
54
54
  unique_ptr<BlockingSample> GetTableSample(TableStatisticsLock &lock);
55
55
  void SetTableSample(TableStatisticsLock &lock, unique_ptr<BlockingSample> sample);
@@ -55,6 +55,8 @@ public:
55
55
  //! Replay and initialize the WAL
56
56
  static unique_ptr<WriteAheadLog> Replay(FileSystem &fs, AttachedDatabase &database, const string &wal_path);
57
57
 
58
+ AttachedDatabase &GetDatabase();
59
+
58
60
  //! Gets the total bytes written to the WAL since startup
59
61
  idx_t GetWALSize() const;
60
62
  //! Gets the total bytes written to the WAL since startup
@@ -48,6 +48,8 @@ public:
48
48
  TableIndexList append_indexes;
49
49
  //! The set of delete indexes.
50
50
  TableIndexList delete_indexes;
51
+ //! Set to INSERT_DUPLICATES, if we are skipping constraint checking during, e.g., WAL replay.
52
+ IndexAppendMode index_append_mode = IndexAppendMode::DEFAULT;
51
53
  //! The number of deleted rows
52
54
  idx_t deleted_rows;
53
55
  //! The main optimistic data writer
@@ -33,7 +33,7 @@ public:
33
33
  //! The validity checker of the transaction
34
34
  ValidChecker transaction_validity;
35
35
  //! The active query number
36
- transaction_t active_query;
36
+ atomic<transaction_t> active_query;
37
37
 
38
38
  public:
39
39
  DUCKDB_API static MetaTransaction &Get(ClientContext &context);