duckdb 0.7.2-dev2507.0 → 0.7.2-dev2675.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 +7 -7
  2. package/package.json +2 -2
  3. package/src/connection.cpp +1 -1
  4. package/src/duckdb/extension/icu/icu-dateadd.cpp +3 -3
  5. package/src/duckdb/extension/icu/icu-datepart.cpp +3 -3
  6. package/src/duckdb/extension/icu/icu-datesub.cpp +2 -2
  7. package/src/duckdb/extension/icu/icu-datetrunc.cpp +1 -1
  8. package/src/duckdb/extension/icu/icu-extension.cpp +3 -3
  9. package/src/duckdb/extension/icu/icu-list-range.cpp +2 -2
  10. package/src/duckdb/extension/icu/icu-makedate.cpp +1 -1
  11. package/src/duckdb/extension/icu/icu-strptime.cpp +4 -4
  12. package/src/duckdb/extension/icu/icu-table-range.cpp +2 -2
  13. package/src/duckdb/extension/icu/icu-timebucket.cpp +1 -1
  14. package/src/duckdb/extension/icu/icu-timezone.cpp +4 -4
  15. package/src/duckdb/extension/json/json-extension.cpp +6 -6
  16. package/src/duckdb/extension/parquet/parquet-extension.cpp +9 -8
  17. package/src/duckdb/extension/parquet/parquet_statistics.cpp +3 -0
  18. package/src/duckdb/src/catalog/catalog.cpp +166 -127
  19. package/src/duckdb/src/catalog/catalog_entry/copy_function_catalog_entry.cpp +3 -3
  20. package/src/duckdb/src/catalog/catalog_entry/duck_index_entry.cpp +1 -1
  21. package/src/duckdb/src/catalog/catalog_entry/duck_schema_entry.cpp +90 -82
  22. package/src/duckdb/src/catalog/catalog_entry/duck_table_entry.cpp +65 -67
  23. package/src/duckdb/src/catalog/catalog_entry/index_catalog_entry.cpp +3 -3
  24. package/src/duckdb/src/catalog/catalog_entry/pragma_function_catalog_entry.cpp +4 -4
  25. package/src/duckdb/src/catalog/catalog_entry/scalar_function_catalog_entry.cpp +8 -8
  26. package/src/duckdb/src/catalog/catalog_entry/scalar_macro_catalog_entry.cpp +10 -10
  27. package/src/duckdb/src/catalog/catalog_entry/schema_catalog_entry.cpp +6 -6
  28. package/src/duckdb/src/catalog/catalog_entry/sequence_catalog_entry.cpp +6 -6
  29. package/src/duckdb/src/catalog/catalog_entry/table_catalog_entry.cpp +4 -4
  30. package/src/duckdb/src/catalog/catalog_entry/table_function_catalog_entry.cpp +9 -9
  31. package/src/duckdb/src/catalog/catalog_entry/type_catalog_entry.cpp +5 -5
  32. package/src/duckdb/src/catalog/catalog_entry/view_catalog_entry.cpp +23 -23
  33. package/src/duckdb/src/catalog/catalog_entry.cpp +27 -6
  34. package/src/duckdb/src/catalog/catalog_search_path.cpp +2 -2
  35. package/src/duckdb/src/catalog/catalog_set.cpp +84 -87
  36. package/src/duckdb/src/catalog/catalog_transaction.cpp +1 -1
  37. package/src/duckdb/src/catalog/default/default_functions.cpp +1 -1
  38. package/src/duckdb/src/catalog/default/default_schemas.cpp +1 -1
  39. package/src/duckdb/src/catalog/default/default_types.cpp +1 -1
  40. package/src/duckdb/src/catalog/default/default_views.cpp +1 -1
  41. package/src/duckdb/src/catalog/dependency_list.cpp +2 -2
  42. package/src/duckdb/src/catalog/dependency_manager.cpp +9 -10
  43. package/src/duckdb/src/catalog/duck_catalog.cpp +30 -26
  44. package/src/duckdb/src/catalog/similar_catalog_entry.cpp +1 -1
  45. package/src/duckdb/src/common/radix_partitioning.cpp +1 -1
  46. package/src/duckdb/src/common/types.cpp +15 -27
  47. package/src/duckdb/src/execution/index/art/art.cpp +286 -269
  48. package/src/duckdb/src/execution/index/art/art_key.cpp +22 -32
  49. package/src/duckdb/src/execution/index/art/fixed_size_allocator.cpp +224 -0
  50. package/src/duckdb/src/execution/index/art/iterator.cpp +142 -123
  51. package/src/duckdb/src/execution/index/art/leaf.cpp +319 -170
  52. package/src/duckdb/src/execution/index/art/leaf_segment.cpp +42 -0
  53. package/src/duckdb/src/execution/index/art/node.cpp +444 -379
  54. package/src/duckdb/src/execution/index/art/node16.cpp +178 -114
  55. package/src/duckdb/src/execution/index/art/node256.cpp +117 -79
  56. package/src/duckdb/src/execution/index/art/node4.cpp +169 -114
  57. package/src/duckdb/src/execution/index/art/node48.cpp +175 -105
  58. package/src/duckdb/src/execution/index/art/prefix.cpp +405 -127
  59. package/src/duckdb/src/execution/index/art/prefix_segment.cpp +42 -0
  60. package/src/duckdb/src/execution/index/art/swizzleable_pointer.cpp +10 -85
  61. package/src/duckdb/src/execution/operator/join/physical_index_join.cpp +4 -3
  62. package/src/duckdb/src/execution/operator/persistent/base_csv_reader.cpp +2 -2
  63. package/src/duckdb/src/execution/operator/persistent/csv_reader_options.cpp +2 -0
  64. package/src/duckdb/src/execution/operator/persistent/physical_batch_insert.cpp +4 -3
  65. package/src/duckdb/src/execution/operator/persistent/physical_export.cpp +19 -18
  66. package/src/duckdb/src/execution/operator/persistent/physical_insert.cpp +5 -5
  67. package/src/duckdb/src/execution/operator/schema/physical_alter.cpp +1 -1
  68. package/src/duckdb/src/execution/operator/schema/physical_create_function.cpp +1 -1
  69. package/src/duckdb/src/execution/operator/schema/physical_create_index.cpp +17 -17
  70. package/src/duckdb/src/execution/operator/schema/physical_create_schema.cpp +1 -1
  71. package/src/duckdb/src/execution/operator/schema/physical_create_sequence.cpp +1 -1
  72. package/src/duckdb/src/execution/operator/schema/physical_create_table.cpp +2 -2
  73. package/src/duckdb/src/execution/operator/schema/physical_create_type.cpp +4 -3
  74. package/src/duckdb/src/execution/operator/schema/physical_create_view.cpp +1 -1
  75. package/src/duckdb/src/execution/operator/schema/physical_detach.cpp +1 -1
  76. package/src/duckdb/src/execution/operator/schema/physical_drop.cpp +2 -2
  77. package/src/duckdb/src/execution/physical_plan/plan_aggregate.cpp +1 -1
  78. package/src/duckdb/src/execution/physical_plan/plan_comparison_join.cpp +4 -4
  79. package/src/duckdb/src/execution/physical_plan/plan_create_table.cpp +4 -3
  80. package/src/duckdb/src/execution/physical_plan/plan_delete.cpp +1 -1
  81. package/src/duckdb/src/execution/physical_plan/plan_insert.cpp +1 -1
  82. package/src/duckdb/src/execution/physical_plan/plan_update.cpp +1 -1
  83. package/src/duckdb/src/function/built_in_functions.cpp +10 -10
  84. package/src/duckdb/src/function/function_binder.cpp +3 -3
  85. package/src/duckdb/src/function/scalar/list/list_aggregates.cpp +5 -6
  86. package/src/duckdb/src/function/scalar/operators/arithmetic.cpp +2 -2
  87. package/src/duckdb/src/function/scalar/sequence/nextval.cpp +9 -8
  88. package/src/duckdb/src/function/scalar/system/aggregate_export.cpp +6 -6
  89. package/src/duckdb/src/function/table/arrow.cpp +5 -5
  90. package/src/duckdb/src/function/table/read_csv.cpp +5 -1
  91. package/src/duckdb/src/function/table/system/duckdb_columns.cpp +8 -7
  92. package/src/duckdb/src/function/table/system/duckdb_constraints.cpp +14 -14
  93. package/src/duckdb/src/function/table/system/duckdb_databases.cpp +2 -2
  94. package/src/duckdb/src/function/table/system/duckdb_functions.cpp +26 -25
  95. package/src/duckdb/src/function/table/system/duckdb_indexes.cpp +13 -12
  96. package/src/duckdb/src/function/table/system/duckdb_schemas.cpp +7 -7
  97. package/src/duckdb/src/function/table/system/duckdb_sequences.cpp +8 -9
  98. package/src/duckdb/src/function/table/system/duckdb_tables.cpp +10 -9
  99. package/src/duckdb/src/function/table/system/duckdb_types.cpp +13 -13
  100. package/src/duckdb/src/function/table/system/duckdb_views.cpp +11 -10
  101. package/src/duckdb/src/function/table/system/pragma_collations.cpp +2 -2
  102. package/src/duckdb/src/function/table/system/pragma_database_size.cpp +5 -5
  103. package/src/duckdb/src/function/table/system/pragma_storage_info.cpp +3 -3
  104. package/src/duckdb/src/function/table/system/pragma_table_info.cpp +2 -2
  105. package/src/duckdb/src/function/table/table_scan.cpp +39 -37
  106. package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
  107. package/src/duckdb/src/function/udf_function.cpp +2 -2
  108. package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +122 -81
  109. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/aggregate_function_catalog_entry.hpp +2 -3
  110. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/collate_catalog_entry.hpp +3 -3
  111. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/copy_function_catalog_entry.hpp +1 -1
  112. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_index_entry.hpp +1 -1
  113. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_schema_entry.hpp +24 -20
  114. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_table_entry.hpp +3 -3
  115. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/index_catalog_entry.hpp +1 -1
  116. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/macro_catalog_entry.hpp +2 -2
  117. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/pragma_function_catalog_entry.hpp +1 -1
  118. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/scalar_function_catalog_entry.hpp +2 -2
  119. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/scalar_macro_catalog_entry.hpp +1 -1
  120. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/schema_catalog_entry.hpp +22 -17
  121. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/sequence_catalog_entry.hpp +1 -1
  122. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_catalog_entry.hpp +1 -1
  123. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_function_catalog_entry.hpp +2 -2
  124. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_macro_catalog_entry.hpp +1 -1
  125. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/type_catalog_entry.hpp +1 -1
  126. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/view_catalog_entry.hpp +3 -3
  127. package/src/duckdb/src/include/duckdb/catalog/catalog_entry.hpp +28 -7
  128. package/src/duckdb/src/include/duckdb/catalog/catalog_set.hpp +20 -19
  129. package/src/duckdb/src/include/duckdb/catalog/duck_catalog.hpp +9 -9
  130. package/src/duckdb/src/include/duckdb/catalog/similar_catalog_entry.hpp +2 -1
  131. package/src/duckdb/src/include/duckdb/catalog/standard_entry.hpp +10 -4
  132. package/src/duckdb/src/include/duckdb/common/enums/on_entry_not_found.hpp +17 -0
  133. package/src/duckdb/src/include/duckdb/common/queue.hpp +1 -1
  134. package/src/duckdb/src/include/duckdb/common/types.hpp +3 -4
  135. package/src/duckdb/src/include/duckdb/execution/index/art/art.hpp +53 -45
  136. package/src/duckdb/src/include/duckdb/execution/index/art/art_key.hpp +29 -24
  137. package/src/duckdb/src/include/duckdb/execution/index/art/fixed_size_allocator.hpp +114 -0
  138. package/src/duckdb/src/include/duckdb/execution/index/art/iterator.hpp +26 -20
  139. package/src/duckdb/src/include/duckdb/execution/index/art/leaf.hpp +63 -39
  140. package/src/duckdb/src/include/duckdb/execution/index/art/leaf_segment.hpp +36 -0
  141. package/src/duckdb/src/include/duckdb/execution/index/art/node.hpp +98 -116
  142. package/src/duckdb/src/include/duckdb/execution/index/art/node16.hpp +48 -36
  143. package/src/duckdb/src/include/duckdb/execution/index/art/node256.hpp +52 -35
  144. package/src/duckdb/src/include/duckdb/execution/index/art/node4.hpp +46 -36
  145. package/src/duckdb/src/include/duckdb/execution/index/art/node48.hpp +57 -35
  146. package/src/duckdb/src/include/duckdb/execution/index/art/prefix.hpp +57 -50
  147. package/src/duckdb/src/include/duckdb/execution/index/art/prefix_segment.hpp +40 -0
  148. package/src/duckdb/src/include/duckdb/execution/index/art/swizzleable_pointer.hpp +38 -31
  149. package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_file_handle.hpp +2 -1
  150. package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_reader_options.hpp +2 -0
  151. package/src/duckdb/src/include/duckdb/function/function_serialization.hpp +4 -4
  152. package/src/duckdb/src/include/duckdb/function/scalar_function.hpp +3 -2
  153. package/src/duckdb/src/include/duckdb/function/table/table_scan.hpp +5 -4
  154. package/src/duckdb/src/include/duckdb/function/table_function.hpp +28 -15
  155. package/src/duckdb/src/include/duckdb/main/attached_database.hpp +2 -0
  156. package/src/duckdb/src/include/duckdb/main/client_context.hpp +1 -1
  157. package/src/duckdb/src/include/duckdb/main/database_manager.hpp +3 -2
  158. package/src/duckdb/src/include/duckdb/parser/expression/bound_expression.hpp +2 -0
  159. package/src/duckdb/src/include/duckdb/parser/keyword_helper.hpp +2 -2
  160. package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_info.hpp +7 -5
  161. package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_table_info.hpp +1 -1
  162. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_table_info.hpp +1 -1
  163. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_view_info.hpp +1 -1
  164. package/src/duckdb/src/include/duckdb/parser/parsed_data/detach_info.hpp +3 -2
  165. package/src/duckdb/src/include/duckdb/parser/parsed_data/drop_info.hpp +5 -5
  166. package/src/duckdb/src/include/duckdb/parser/parsed_data/parse_info.hpp +13 -0
  167. package/src/duckdb/src/include/duckdb/parser/statement/insert_statement.hpp +4 -1
  168. package/src/duckdb/src/include/duckdb/parser/tableref.hpp +5 -2
  169. package/src/duckdb/src/include/duckdb/parser/transformer.hpp +4 -1
  170. package/src/duckdb/src/include/duckdb/planner/binder.hpp +2 -2
  171. package/src/duckdb/src/include/duckdb/planner/expression_binder/base_select_binder.hpp +1 -2
  172. package/src/duckdb/src/include/duckdb/planner/expression_binder.hpp +4 -7
  173. package/src/duckdb/src/include/duckdb/planner/operator/logical_get.hpp +1 -1
  174. package/src/duckdb/src/include/duckdb/storage/buffer_manager.hpp +0 -5
  175. package/src/duckdb/src/include/duckdb/storage/index.hpp +13 -28
  176. package/src/duckdb/src/include/duckdb/storage/standard_buffer_manager.hpp +0 -2
  177. package/src/duckdb/src/include/duckdb/transaction/cleanup_state.hpp +5 -0
  178. package/src/duckdb/src/include/duckdb/transaction/transaction.hpp +12 -0
  179. package/src/duckdb/src/include/duckdb.h +26 -0
  180. package/src/duckdb/src/main/attached_database.cpp +12 -6
  181. package/src/duckdb/src/main/capi/helper-c.cpp +7 -0
  182. package/src/duckdb/src/main/capi/table_function-c.cpp +17 -16
  183. package/src/duckdb/src/main/client_context.cpp +12 -11
  184. package/src/duckdb/src/main/database_manager.cpp +13 -12
  185. package/src/duckdb/src/optimizer/join_order/cardinality_estimator.cpp +1 -2
  186. package/src/duckdb/src/parser/parsed_data/alter_info.cpp +3 -3
  187. package/src/duckdb/src/parser/parsed_data/alter_scalar_function_info.cpp +2 -2
  188. package/src/duckdb/src/parser/parsed_data/alter_table_function_info.cpp +2 -2
  189. package/src/duckdb/src/parser/parsed_data/alter_table_info.cpp +9 -9
  190. package/src/duckdb/src/parser/parsed_data/create_scalar_function_info.cpp +2 -2
  191. package/src/duckdb/src/parser/parsed_data/create_table_function_info.cpp +2 -2
  192. package/src/duckdb/src/parser/parsed_data/create_table_info.cpp +2 -2
  193. package/src/duckdb/src/parser/parsed_data/create_view_info.cpp +2 -2
  194. package/src/duckdb/src/parser/statement/insert_statement.cpp +15 -6
  195. package/src/duckdb/src/parser/transform/constraint/transform_constraint.cpp +1 -1
  196. package/src/duckdb/src/parser/transform/expression/transform_function.cpp +18 -5
  197. package/src/duckdb/src/parser/transform/statement/transform_alter_sequence.cpp +3 -2
  198. package/src/duckdb/src/parser/transform/statement/transform_alter_table.cpp +5 -1
  199. package/src/duckdb/src/parser/transform/statement/transform_detach.cpp +1 -1
  200. package/src/duckdb/src/parser/transform/statement/transform_drop.cpp +1 -1
  201. package/src/duckdb/src/parser/transform/statement/transform_insert.cpp +5 -7
  202. package/src/duckdb/src/parser/transform/statement/transform_rename.cpp +1 -1
  203. package/src/duckdb/src/planner/binder/expression/bind_aggregate_expression.cpp +26 -27
  204. package/src/duckdb/src/planner/binder/expression/bind_between_expression.cpp +17 -17
  205. package/src/duckdb/src/planner/binder/expression/bind_case_expression.cpp +9 -9
  206. package/src/duckdb/src/planner/binder/expression/bind_cast_expression.cpp +6 -6
  207. package/src/duckdb/src/planner/binder/expression/bind_collate_expression.cpp +6 -6
  208. package/src/duckdb/src/planner/binder/expression/bind_columnref_expression.cpp +2 -2
  209. package/src/duckdb/src/planner/binder/expression/bind_comparison_expression.cpp +21 -21
  210. package/src/duckdb/src/planner/binder/expression/bind_conjunction_expression.cpp +2 -3
  211. package/src/duckdb/src/planner/binder/expression/bind_function_expression.cpp +33 -36
  212. package/src/duckdb/src/planner/binder/expression/bind_macro_expression.cpp +5 -5
  213. package/src/duckdb/src/planner/binder/expression/bind_operator_expression.cpp +23 -23
  214. package/src/duckdb/src/planner/binder/expression/bind_subquery_expression.cpp +4 -4
  215. package/src/duckdb/src/planner/binder/expression/bind_unnest_expression.cpp +7 -7
  216. package/src/duckdb/src/planner/binder/expression/bind_window_expression.cpp +23 -23
  217. package/src/duckdb/src/planner/binder/query_node/bind_table_macro_node.cpp +4 -4
  218. package/src/duckdb/src/planner/binder/statement/bind_copy.cpp +14 -13
  219. package/src/duckdb/src/planner/binder/statement/bind_create.cpp +56 -42
  220. package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +3 -3
  221. package/src/duckdb/src/planner/binder/statement/bind_delete.cpp +1 -1
  222. package/src/duckdb/src/planner/binder/statement/bind_drop.cpp +4 -4
  223. package/src/duckdb/src/planner/binder/statement/bind_export.cpp +10 -10
  224. package/src/duckdb/src/planner/binder/statement/bind_insert.cpp +16 -11
  225. package/src/duckdb/src/planner/binder/statement/bind_pragma.cpp +4 -4
  226. package/src/duckdb/src/planner/binder/statement/bind_simple.cpp +5 -4
  227. package/src/duckdb/src/planner/binder/statement/bind_update.cpp +1 -1
  228. package/src/duckdb/src/planner/binder/tableref/bind_basetableref.cpp +3 -3
  229. package/src/duckdb/src/planner/binder/tableref/bind_table_function.cpp +10 -12
  230. package/src/duckdb/src/planner/binder.cpp +2 -2
  231. package/src/duckdb/src/planner/expression/bound_expression.cpp +11 -2
  232. package/src/duckdb/src/planner/operator/logical_copy_to_file.cpp +2 -5
  233. package/src/duckdb/src/planner/operator/logical_create.cpp +2 -1
  234. package/src/duckdb/src/planner/operator/logical_create_index.cpp +2 -2
  235. package/src/duckdb/src/planner/operator/logical_delete.cpp +2 -2
  236. package/src/duckdb/src/planner/operator/logical_get.cpp +1 -1
  237. package/src/duckdb/src/planner/operator/logical_insert.cpp +2 -7
  238. package/src/duckdb/src/planner/operator/logical_update.cpp +2 -6
  239. package/src/duckdb/src/planner/parsed_data/bound_create_table_info.cpp +2 -2
  240. package/src/duckdb/src/planner/pragma_handler.cpp +3 -4
  241. package/src/duckdb/src/storage/checkpoint_manager.cpp +57 -55
  242. package/src/duckdb/src/storage/data_table.cpp +9 -9
  243. package/src/duckdb/src/storage/index.cpp +18 -6
  244. package/src/duckdb/src/storage/local_storage.cpp +8 -2
  245. package/src/duckdb/src/storage/standard_buffer_manager.cpp +0 -9
  246. package/src/duckdb/src/storage/table/update_segment.cpp +1 -1
  247. package/src/duckdb/src/storage/wal_replay.cpp +29 -31
  248. package/src/duckdb/src/storage/write_ahead_log.cpp +8 -8
  249. package/src/duckdb/src/transaction/cleanup_state.cpp +7 -1
  250. package/src/duckdb/src/transaction/commit_state.cpp +3 -4
  251. package/src/duckdb/src/transaction/transaction_context.cpp +1 -1
  252. package/src/duckdb/src/transaction/undo_buffer.cpp +8 -0
  253. package/src/duckdb/ub_extension_icu_third_party_icu_i18n.cpp +4 -4
  254. package/src/duckdb/ub_src_execution_index_art.cpp +7 -1
@@ -7,45 +7,52 @@
7
7
  //===----------------------------------------------------------------------===//
8
8
  #pragma once
9
9
 
10
- #include "duckdb/execution/index/art/node.hpp"
10
+ #include "duckdb/common/constants.hpp"
11
11
 
12
12
  namespace duckdb {
13
13
 
14
- class ART;
15
- class Node;
14
+ // classes
15
+ class MetaBlockReader;
16
16
 
17
- // SwizzleablePointer assumes that the 64-bit blockId always has 0s in the top
18
- // 33 bits. It thus uses 8 bytes of memory rather than 12.
17
+ // structs
18
+ struct BlockPointer;
19
+
20
+ //! SwizzleablePointer provides functions on a (possibly) swizzled pointer. If the swizzle flag is set, then the
21
+ //! pointer points to a storage address (and has no type), otherwise the pointer has a type and stores
22
+ //! other information (e.g., a buffer location)
19
23
  class SwizzleablePointer {
20
24
  public:
21
- ~SwizzleablePointer();
22
- explicit SwizzleablePointer(duckdb::MetaBlockReader &reader);
23
- SwizzleablePointer() : pointer(0) {};
24
-
25
- BlockPointer Serialize(ART &art, duckdb::MetaBlockWriter &writer);
26
-
27
- //! Transforms from Node* to uint64_t
28
- SwizzleablePointer &operator=(const Node *ptr);
25
+ //! Constructs an empty SwizzleablePointer
26
+ SwizzleablePointer() : swizzle_flag(0), type(0), offset(0), buffer_id(0) {};
27
+ //! Constructs a swizzled pointer from a buffer ID and an offset
28
+ explicit SwizzleablePointer(MetaBlockReader &reader);
29
+ //! Constructs a non-swizzled pointer from a buffer ID and an offset
30
+ SwizzleablePointer(uint32_t offset, uint32_t buffer_id)
31
+ : swizzle_flag(0), type(0), offset(offset), buffer_id(buffer_id) {};
32
+
33
+ //! The swizzle flag, set if swizzled, not set otherwise
34
+ uint8_t swizzle_flag : 1;
35
+ //! The type of the pointer, zero if not set
36
+ uint8_t type : 7;
37
+ //! The offset of a memory location
38
+ uint32_t offset : 24;
39
+ //! The buffer ID of a memory location
40
+ uint32_t buffer_id : 32;
29
41
 
30
- //! Checks if pointer is swizzled
31
- bool IsSwizzled();
32
- //! Unswizzle the pointer (if possible)
33
- Node *Unswizzle(ART &art);
34
-
35
- operator bool() const {
36
- return pointer;
42
+ public:
43
+ //! Checks if the pointer is swizzled
44
+ inline bool IsSwizzled() const {
45
+ return swizzle_flag;
46
+ }
47
+ //! Returns true, if neither the swizzle flag nor the type is set, and false otherwise
48
+ inline bool IsSet() const {
49
+ return swizzle_flag || type;
50
+ }
51
+ //! Reset the pointer
52
+ inline void Reset() {
53
+ swizzle_flag = 0;
54
+ type = 0;
37
55
  }
38
-
39
- //! Deletes the underlying object (if necessary) and set the pointer to nullptr
40
- void Reset();
41
-
42
- private:
43
- uint64_t pointer;
44
-
45
- friend bool operator!=(const SwizzleablePointer &s_ptr, const uint64_t &ptr);
46
-
47
- //! Extracts the block info from swizzled pointer
48
- BlockPointer GetSwizzledBlockInfo();
49
56
  };
50
57
 
51
58
  } // namespace duckdb
@@ -16,7 +16,8 @@ namespace duckdb {
16
16
 
17
17
  struct CSVFileHandle {
18
18
  public:
19
- explicit CSVFileHandle(unique_ptr<FileHandle> file_handle_p) : file_handle(std::move(file_handle_p)) {
19
+ explicit CSVFileHandle(unique_ptr<FileHandle> file_handle_p, bool enable_reset = true)
20
+ : file_handle(std::move(file_handle_p)), reset_enabled(enable_reset) {
20
21
  can_seek = file_handle->CanSeek();
21
22
  plain_file_source = file_handle->OnDiskFile() && can_seek;
22
23
  file_size = file_handle->GetFileSize();
@@ -62,6 +62,8 @@ struct BufferedCSVReaderOptions {
62
62
  //! Whether file is compressed or not, and if so which compression type
63
63
  //! AUTO_DETECT (default; infer from file extension)
64
64
  FileCompressionType compression = FileCompressionType::AUTO_DETECT;
65
+ //! Option to convert quoted values to NULL values
66
+ bool allow_quoted_nulls = true;
65
67
 
66
68
  //===--------------------------------------------------------------------===//
67
69
  // CSVAutoOptions
@@ -47,13 +47,13 @@ public:
47
47
  // note: original_arguments are optional (can be list of size 0)
48
48
  auto original_arguments = reader.ReadRequiredSerializableList<LogicalType, LogicalType>();
49
49
 
50
- auto func_catalog = Catalog::GetEntry(context, type, SYSTEM_CATALOG, DEFAULT_SCHEMA, name);
51
- if (!func_catalog || func_catalog->type != type) {
50
+ auto &func_catalog = Catalog::GetEntry(context, type, SYSTEM_CATALOG, DEFAULT_SCHEMA, name);
51
+ if (func_catalog.type != type) {
52
52
  throw InternalException("Cant find catalog entry for function %s", name);
53
53
  }
54
54
 
55
- auto functions = (CATALOG_ENTRY *)func_catalog;
56
- auto function = functions->functions.GetFunctionByArguments(
55
+ auto &functions = func_catalog.Cast<CATALOG_ENTRY>();
56
+ auto function = functions.functions.GetFunctionByArguments(
57
57
  state.context, original_arguments.empty() ? arguments : original_arguments);
58
58
  function.arguments = std::move(arguments);
59
59
  function.original_arguments = std::move(original_arguments);
@@ -15,6 +15,7 @@
15
15
  #include "duckdb/execution/expression_executor_state.hpp"
16
16
  #include "duckdb/function/function.hpp"
17
17
  #include "duckdb/storage/statistics/base_statistics.hpp"
18
+ #include "duckdb/common/optional_ptr.hpp"
18
19
 
19
20
  namespace duckdb {
20
21
 
@@ -39,13 +40,13 @@ class DependencyList;
39
40
  class ScalarFunctionCatalogEntry;
40
41
 
41
42
  struct FunctionStatisticsInput {
42
- FunctionStatisticsInput(BoundFunctionExpression &expr_p, FunctionData *bind_data_p,
43
+ FunctionStatisticsInput(BoundFunctionExpression &expr_p, optional_ptr<FunctionData> bind_data_p,
43
44
  vector<BaseStatistics> &child_stats_p, unique_ptr<Expression> *expr_ptr_p)
44
45
  : expr(expr_p), bind_data(bind_data_p), child_stats(child_stats_p), expr_ptr(expr_ptr_p) {
45
46
  }
46
47
 
47
48
  BoundFunctionExpression &expr;
48
- FunctionData *bind_data;
49
+ optional_ptr<FunctionData> bind_data;
49
50
  vector<BaseStatistics> &child_stats;
50
51
  unique_ptr<Expression> *expr_ptr;
51
52
  };
@@ -17,11 +17,11 @@ class DuckTableEntry;
17
17
  class TableCatalogEntry;
18
18
 
19
19
  struct TableScanBindData : public TableFunctionData {
20
- explicit TableScanBindData(DuckTableEntry *table) : table(table), is_index_scan(false), is_create_index(false) {
20
+ explicit TableScanBindData(DuckTableEntry &table) : table(table), is_index_scan(false), is_create_index(false) {
21
21
  }
22
22
 
23
23
  //! The table to scan
24
- DuckTableEntry *table;
24
+ DuckTableEntry &table;
25
25
 
26
26
  //! Whether or not the table scan is an index scan
27
27
  bool is_index_scan;
@@ -33,7 +33,7 @@ struct TableScanBindData : public TableFunctionData {
33
33
  public:
34
34
  bool Equals(const FunctionData &other_p) const override {
35
35
  auto &other = (const TableScanBindData &)other_p;
36
- return other.table == table && result_ids == other.result_ids;
36
+ return &other.table == &table && result_ids == other.result_ids;
37
37
  }
38
38
  };
39
39
 
@@ -42,7 +42,8 @@ struct TableScanFunction {
42
42
  static void RegisterFunction(BuiltinFunctions &set);
43
43
  static TableFunction GetFunction();
44
44
  static TableFunction GetIndexScanFunction();
45
- static TableCatalogEntry *GetTableEntry(const TableFunction &function, const FunctionData *bind_data);
45
+ static optional_ptr<TableCatalogEntry> GetTableEntry(const TableFunction &function,
46
+ const optional_ptr<FunctionData> bind_data);
46
47
  };
47
48
 
48
49
  } // namespace duckdb
@@ -14,6 +14,7 @@
14
14
  #include "duckdb/planner/bind_context.hpp"
15
15
  #include "duckdb/planner/logical_operator.hpp"
16
16
  #include "duckdb/storage/statistics/node_statistics.hpp"
17
+ #include "duckdb/common/optional_ptr.hpp"
17
18
 
18
19
  #include <functional>
19
20
 
@@ -26,6 +27,17 @@ class TableFilterSet;
26
27
 
27
28
  struct TableFunctionInfo {
28
29
  DUCKDB_API virtual ~TableFunctionInfo();
30
+
31
+ template <class TARGET>
32
+ TARGET &Cast() {
33
+ D_ASSERT(dynamic_cast<TARGET *>(this));
34
+ return (TARGET &)*this;
35
+ }
36
+ template <class TARGET>
37
+ const TARGET &Cast() const {
38
+ D_ASSERT(dynamic_cast<const TARGET *>(this));
39
+ return (const TARGET &)*this;
40
+ }
29
41
  };
30
42
 
31
43
  struct GlobalTableFunctionState {
@@ -70,7 +82,7 @@ struct LocalTableFunctionState {
70
82
  struct TableFunctionBindInput {
71
83
  TableFunctionBindInput(vector<Value> &inputs, named_parameter_map_t &named_parameters,
72
84
  vector<LogicalType> &input_table_types, vector<string> &input_table_names,
73
- TableFunctionInfo *info)
85
+ optional_ptr<TableFunctionInfo> info)
74
86
  : inputs(inputs), named_parameters(named_parameters), input_table_types(input_table_types),
75
87
  input_table_names(input_table_names), info(info) {
76
88
  }
@@ -79,19 +91,19 @@ struct TableFunctionBindInput {
79
91
  named_parameter_map_t &named_parameters;
80
92
  vector<LogicalType> &input_table_types;
81
93
  vector<string> &input_table_names;
82
- TableFunctionInfo *info;
94
+ optional_ptr<TableFunctionInfo> info;
83
95
  };
84
96
 
85
97
  struct TableFunctionInitInput {
86
- TableFunctionInitInput(const FunctionData *bind_data_p, const vector<column_t> &column_ids_p,
87
- const vector<idx_t> &projection_ids_p, TableFilterSet *filters_p)
98
+ TableFunctionInitInput(optional_ptr<const FunctionData> bind_data_p, const vector<column_t> &column_ids_p,
99
+ const vector<idx_t> &projection_ids_p, optional_ptr<TableFilterSet> filters_p)
88
100
  : bind_data(bind_data_p), column_ids(column_ids_p), projection_ids(projection_ids_p), filters(filters_p) {
89
101
  }
90
102
 
91
- const FunctionData *bind_data;
103
+ optional_ptr<const FunctionData> bind_data;
92
104
  const vector<column_t> &column_ids;
93
105
  const vector<idx_t> projection_ids;
94
- TableFilterSet *filters;
106
+ optional_ptr<TableFilterSet> filters;
95
107
 
96
108
  bool CanRemoveFilterColumns() const {
97
109
  if (projection_ids.empty()) {
@@ -109,15 +121,16 @@ struct TableFunctionInitInput {
109
121
 
110
122
  struct TableFunctionInput {
111
123
  public:
112
- TableFunctionInput(const FunctionData *bind_data_p, LocalTableFunctionState *local_state_p,
113
- GlobalTableFunctionState *global_state_p)
124
+ TableFunctionInput(optional_ptr<const FunctionData> bind_data_p,
125
+ optional_ptr<LocalTableFunctionState> local_state_p,
126
+ optional_ptr<GlobalTableFunctionState> global_state_p)
114
127
  : bind_data(bind_data_p), local_state(local_state_p), global_state(global_state_p) {
115
128
  }
116
129
 
117
130
  public:
118
- const FunctionData *bind_data;
119
- LocalTableFunctionState *local_state;
120
- GlobalTableFunctionState *global_state;
131
+ optional_ptr<const FunctionData> bind_data;
132
+ optional_ptr<LocalTableFunctionState> local_state;
133
+ optional_ptr<GlobalTableFunctionState> global_state;
121
134
  };
122
135
 
123
136
  enum ScanType { TABLE, PARQUET };
@@ -127,21 +140,21 @@ public:
127
140
  explicit BindInfo(ScanType type_p) : type(type_p) {};
128
141
  unordered_map<string, Value> options;
129
142
  ScanType type;
130
- void InsertOption(string name, Value value) {
143
+ void InsertOption(const string &name, Value value) {
131
144
  if (options.find(name) != options.end()) {
132
145
  throw InternalException("This option already exists");
133
146
  }
134
- options[name] = value;
147
+ options[name] = std::move(value);
135
148
  }
136
149
  template <class T>
137
- T GetOption(string name) {
150
+ T GetOption(const string &name) {
138
151
  if (options.find(name) == options.end()) {
139
152
  throw InternalException("This option does not exist");
140
153
  }
141
154
  return options[name].GetValue<T>();
142
155
  }
143
156
  template <class T>
144
- vector<T> GetOptionList(string name) {
157
+ vector<T> GetOptionList(const string &name) {
145
158
  if (options.find(name) == options.end()) {
146
159
  throw InternalException("This option does not exist");
147
160
  }
@@ -44,6 +44,7 @@ public:
44
44
 
45
45
  void Initialize();
46
46
 
47
+ Catalog &ParentCatalog() override;
47
48
  StorageManager &GetStorageManager();
48
49
  Catalog &GetCatalog();
49
50
  TransactionManager &GetTransactionManager();
@@ -65,6 +66,7 @@ private:
65
66
  unique_ptr<Catalog> catalog;
66
67
  unique_ptr<TransactionManager> transaction_manager;
67
68
  AttachedDatabaseType type;
69
+ optional_ptr<Catalog> parent_catalog;
68
70
  };
69
71
 
70
72
  } // namespace duckdb
@@ -149,7 +149,7 @@ public:
149
149
  DUCKDB_API double GetProgress();
150
150
 
151
151
  //! Register function in the temporary schema
152
- DUCKDB_API void RegisterFunction(CreateFunctionInfo *info);
152
+ DUCKDB_API void RegisterFunction(CreateFunctionInfo &info);
153
153
 
154
154
  //! Parse statements from a query
155
155
  DUCKDB_API vector<unique_ptr<SQLStatement>> ParseStatements(const string &query);
@@ -13,6 +13,7 @@
13
13
  #include "duckdb/common/mutex.hpp"
14
14
  #include "duckdb/common/atomic.hpp"
15
15
  #include "duckdb/common/optional_ptr.hpp"
16
+ #include "duckdb/common/enums/on_entry_not_found.hpp"
16
17
 
17
18
  namespace duckdb {
18
19
  class AttachedDatabase;
@@ -39,13 +40,13 @@ public:
39
40
  optional_ptr<AttachedDatabase> GetDatabase(ClientContext &context, const string &name);
40
41
  //! Add a new attached database to the database manager
41
42
  void AddDatabase(ClientContext &context, unique_ptr<AttachedDatabase> db);
42
- void DetachDatabase(ClientContext &context, const string &name, bool if_exists);
43
+ void DetachDatabase(ClientContext &context, const string &name, OnEntryNotFound if_not_found);
43
44
  //! Returns a reference to the system catalog
44
45
  Catalog &GetSystemCatalog();
45
46
  static const string &GetDefaultDatabase(ClientContext &context);
46
47
 
47
48
  optional_ptr<AttachedDatabase> GetDatabaseFromPath(ClientContext &context, const string &path);
48
- vector<optional_ptr<AttachedDatabase>> GetDatabases(ClientContext &context);
49
+ vector<reference<AttachedDatabase>> GetDatabases(ClientContext &context);
49
50
 
50
51
  transaction_t GetNewQueryNumber() {
51
52
  return current_query_number++;
@@ -28,6 +28,8 @@ public:
28
28
  unique_ptr<Expression> expr;
29
29
 
30
30
  public:
31
+ static unique_ptr<Expression> &GetExpression(ParsedExpression &expr);
32
+
31
33
  string ToString() const override;
32
34
 
33
35
  bool Equals(const BaseExpression *other) const override;
@@ -18,10 +18,10 @@ public:
18
18
  static bool IsKeyword(const string &text);
19
19
 
20
20
  //! Returns true if the given string needs to be quoted when written as an identifier
21
- static bool RequiresQuotes(const string &text, bool allow_caps = false);
21
+ static bool RequiresQuotes(const string &text, bool allow_caps = true);
22
22
 
23
23
  //! Writes a string that is optionally quoted + escaped so it can be used as an identifier
24
- static string WriteOptionallyQuoted(const string &text, char quote = '"', bool allow_caps = false);
24
+ static string WriteOptionallyQuoted(const string &text, char quote = '"', bool allow_caps = true);
25
25
  };
26
26
 
27
27
  } // namespace duckdb
@@ -11,6 +11,7 @@
11
11
  #include "duckdb/common/enums/catalog_type.hpp"
12
12
  #include "duckdb/parser/column_definition.hpp"
13
13
  #include "duckdb/parser/parsed_data/parse_info.hpp"
14
+ #include "duckdb/common/enums/on_entry_not_found.hpp"
14
15
 
15
16
  namespace duckdb {
16
17
 
@@ -27,23 +28,24 @@ enum class AlterType : uint8_t {
27
28
  struct AlterEntryData {
28
29
  AlterEntryData() {
29
30
  }
30
- AlterEntryData(string catalog_p, string schema_p, string name_p, bool if_exists)
31
- : catalog(std::move(catalog_p)), schema(std::move(schema_p)), name(std::move(name_p)), if_exists(if_exists) {
31
+ AlterEntryData(string catalog_p, string schema_p, string name_p, OnEntryNotFound if_not_found)
32
+ : catalog(std::move(catalog_p)), schema(std::move(schema_p)), name(std::move(name_p)),
33
+ if_not_found(if_not_found) {
32
34
  }
33
35
 
34
36
  string catalog;
35
37
  string schema;
36
38
  string name;
37
- bool if_exists;
39
+ OnEntryNotFound if_not_found;
38
40
  };
39
41
 
40
42
  struct AlterInfo : public ParseInfo {
41
- AlterInfo(AlterType type, string catalog, string schema, string name, bool if_exists);
43
+ AlterInfo(AlterType type, string catalog, string schema, string name, OnEntryNotFound if_not_found);
42
44
  virtual ~AlterInfo() override;
43
45
 
44
46
  AlterType type;
45
47
  //! if exists
46
- bool if_exists;
48
+ OnEntryNotFound if_not_found;
47
49
  //! Catalog name to alter
48
50
  string catalog;
49
51
  //! Schema name to alter
@@ -22,7 +22,7 @@ enum AlterForeignKeyType : uint8_t { AFT_ADD = 0, AFT_DELETE = 1 };
22
22
  //===--------------------------------------------------------------------===//
23
23
  struct ChangeOwnershipInfo : public AlterInfo {
24
24
  ChangeOwnershipInfo(CatalogType entry_catalog_type, string entry_catalog, string entry_schema, string entry_name,
25
- string owner_schema, string owner_name, bool if_exists);
25
+ string owner_schema, string owner_name, OnEntryNotFound if_not_found);
26
26
 
27
27
  // Catalog type refers to the entry type, since this struct is usually built from an
28
28
  // ALTER <TYPE> <schema>.<name> OWNED BY <owner_schema>.<owner_name> statement
@@ -22,7 +22,7 @@ class SchemaCatalogEntry;
22
22
  struct CreateTableInfo : public CreateInfo {
23
23
  DUCKDB_API CreateTableInfo();
24
24
  DUCKDB_API CreateTableInfo(string catalog, string schema, string name);
25
- DUCKDB_API CreateTableInfo(SchemaCatalogEntry *schema, string name);
25
+ DUCKDB_API CreateTableInfo(SchemaCatalogEntry &schema, string name);
26
26
 
27
27
  //! Table name to insert to
28
28
  string table;
@@ -16,7 +16,7 @@ class SchemaCatalogEntry;
16
16
 
17
17
  struct CreateViewInfo : public CreateInfo {
18
18
  CreateViewInfo();
19
- CreateViewInfo(SchemaCatalogEntry *schema, string view_name);
19
+ CreateViewInfo(SchemaCatalogEntry &schema, string view_name);
20
20
  CreateViewInfo(string catalog_p, string schema_p, string view_name);
21
21
 
22
22
  //! Table name to insert to
@@ -9,6 +9,7 @@
9
9
  #pragma once
10
10
 
11
11
  #include "duckdb/parser/parsed_data/parse_info.hpp"
12
+ #include "duckdb/common/enums/on_entry_not_found.hpp"
12
13
 
13
14
  namespace duckdb {
14
15
 
@@ -19,13 +20,13 @@ struct DetachInfo : public ParseInfo {
19
20
  //! The alias of the attached database
20
21
  string name;
21
22
  //! Whether to throw an exception if alias is not found
22
- bool if_exists;
23
+ OnEntryNotFound if_not_found;
23
24
 
24
25
  public:
25
26
  unique_ptr<DetachInfo> Copy() const {
26
27
  auto result = make_uniq<DetachInfo>();
27
28
  result->name = name;
28
- result->if_exists = if_exists;
29
+ result->if_not_found = if_not_found;
29
30
  return result;
30
31
  }
31
32
  };
@@ -15,7 +15,7 @@
15
15
  namespace duckdb {
16
16
 
17
17
  struct DropInfo : public ParseInfo {
18
- DropInfo() : catalog(INVALID_CATALOG), schema(INVALID_SCHEMA), if_exists(false), cascade(false) {
18
+ DropInfo() : catalog(INVALID_CATALOG), schema(INVALID_SCHEMA), cascade(false) {
19
19
  }
20
20
 
21
21
  //! The catalog type to drop
@@ -27,7 +27,7 @@ struct DropInfo : public ParseInfo {
27
27
  //! Element name to drop
28
28
  string name;
29
29
  //! Ignore if the entry does not exist instead of failing
30
- bool if_exists = false;
30
+ OnEntryNotFound if_not_found = OnEntryNotFound::THROW_EXCEPTION;
31
31
  //! Cascade drop (drop all dependents instead of throwing an error if there
32
32
  //! are any)
33
33
  bool cascade = false;
@@ -41,7 +41,7 @@ public:
41
41
  result->catalog = catalog;
42
42
  result->schema = schema;
43
43
  result->name = name;
44
- result->if_exists = if_exists;
44
+ result->if_not_found = if_not_found;
45
45
  result->cascade = cascade;
46
46
  result->allow_drop_internal = allow_drop_internal;
47
47
  return result;
@@ -53,7 +53,7 @@ public:
53
53
  writer.WriteString(catalog);
54
54
  writer.WriteString(schema);
55
55
  writer.WriteString(name);
56
- writer.WriteField(if_exists);
56
+ writer.WriteField(if_not_found);
57
57
  writer.WriteField(cascade);
58
58
  writer.WriteField(allow_drop_internal);
59
59
  writer.Finalize();
@@ -66,7 +66,7 @@ public:
66
66
  drop_info->catalog = reader.ReadRequired<string>();
67
67
  drop_info->schema = reader.ReadRequired<string>();
68
68
  drop_info->name = reader.ReadRequired<string>();
69
- drop_info->if_exists = reader.ReadRequired<bool>();
69
+ drop_info->if_not_found = reader.ReadRequired<OnEntryNotFound>();
70
70
  drop_info->cascade = reader.ReadRequired<bool>();
71
71
  drop_info->allow_drop_internal = reader.ReadRequired<bool>();
72
72
  reader.Finalize();
@@ -15,6 +15,19 @@ namespace duckdb {
15
15
  struct ParseInfo {
16
16
  virtual ~ParseInfo() {
17
17
  }
18
+
19
+ public:
20
+ template <class TARGET>
21
+ TARGET &Cast() {
22
+ D_ASSERT(dynamic_cast<TARGET *>(this));
23
+ return (TARGET &)*this;
24
+ }
25
+
26
+ template <class TARGET>
27
+ const TARGET &Cast() const {
28
+ D_ASSERT(dynamic_cast<const TARGET *>(this));
29
+ return (const TARGET &)*this;
30
+ }
18
31
  };
19
32
 
20
33
  } // namespace duckdb
@@ -72,6 +72,9 @@ public:
72
72
  //! CTEs
73
73
  CommonTableExpressionMap cte_map;
74
74
 
75
+ //! Whether or not this a DEFAULT VALUES
76
+ bool default_values = false;
77
+
75
78
  protected:
76
79
  InsertStatement(const InsertStatement &other);
77
80
 
@@ -82,7 +85,7 @@ public:
82
85
 
83
86
  //! If the INSERT statement is inserted DIRECTLY from a values list (i.e. INSERT INTO tbl VALUES (...)) this returns
84
87
  //! the expression list Otherwise, this returns NULL
85
- ExpressionListRef *GetValuesList() const;
88
+ optional_ptr<ExpressionListRef> GetValuesList() const;
86
89
  };
87
90
 
88
91
  } // namespace duckdb
@@ -18,6 +18,9 @@ class Serializer;
18
18
 
19
19
  //! Represents a generic expression that returns a table.
20
20
  class TableRef {
21
+ public:
22
+ static constexpr const TableReferenceType TYPE = TableReferenceType::INVALID;
23
+
21
24
  public:
22
25
  explicit TableRef(TableReferenceType type) : type(type) {
23
26
  }
@@ -57,7 +60,7 @@ public:
57
60
  public:
58
61
  template <class TARGET>
59
62
  TARGET &Cast() {
60
- if (type != TARGET::TYPE) {
63
+ if (type != TARGET::TYPE && TARGET::TYPE != TableReferenceType::INVALID) {
61
64
  throw InternalException("Failed to cast constraint to type - constraint type mismatch");
62
65
  }
63
66
  return (TARGET &)*this;
@@ -65,7 +68,7 @@ public:
65
68
 
66
69
  template <class TARGET>
67
70
  const TARGET &Cast() const {
68
- if (type != TARGET::TYPE) {
71
+ if (type != TARGET::TYPE && TARGET::TYPE != TableReferenceType::INVALID) {
69
72
  throw InternalException("Failed to cast constraint to type - constraint type mismatch");
70
73
  }
71
74
  return (const TARGET &)*this;
@@ -312,7 +312,8 @@ private:
312
312
  void TransformExpressionList(duckdb_libpgquery::PGList &list, vector<unique_ptr<ParsedExpression>> &result);
313
313
 
314
314
  //! Transform a Postgres PARTITION BY/ORDER BY specification into lists of expressions
315
- void TransformWindowDef(duckdb_libpgquery::PGWindowDef *window_spec, WindowExpression *expr);
315
+ void TransformWindowDef(duckdb_libpgquery::PGWindowDef *window_spec, WindowExpression *expr,
316
+ const char *window_name = nullptr);
316
317
  //! Transform a Postgres window frame specification into frame expressions
317
318
  void TransformWindowFrame(duckdb_libpgquery::PGWindowDef *window_spec, WindowExpression *expr);
318
319
 
@@ -320,6 +321,8 @@ private:
320
321
  //! Returns true if an expression is only a star (i.e. "*", without any other decorators)
321
322
  bool ExpressionIsEmptyStar(ParsedExpression &expr);
322
323
 
324
+ OnEntryNotFound TransformOnEntryNotFound(bool missing_ok);
325
+
323
326
  private:
324
327
  //! Current stack depth
325
328
  idx_t stack_depth;
@@ -172,7 +172,7 @@ public:
172
172
  void BindOnConflictClause(LogicalInsert &insert, TableCatalogEntry &table, InsertStatement &stmt);
173
173
 
174
174
  static void BindSchemaOrCatalog(ClientContext &context, string &catalog, string &schema);
175
- static void BindLogicalType(ClientContext &context, LogicalType &type, Catalog *catalog = nullptr,
175
+ static void BindLogicalType(ClientContext &context, LogicalType &type, optional_ptr<Catalog> catalog = nullptr,
176
176
  const string &schema = INVALID_SCHEMA);
177
177
 
178
178
  bool HasMatchingBinding(const string &table_name, const string &column_name, string &error_message);
@@ -259,7 +259,7 @@ private:
259
259
  const string &alias, idx_t update_table_index,
260
260
  unique_ptr<LogicalOperator> child_operator, BoundStatement result);
261
261
 
262
- unique_ptr<QueryNode> BindTableMacro(FunctionExpression &function, TableMacroCatalogEntry *macro_func, idx_t depth);
262
+ unique_ptr<QueryNode> BindTableMacro(FunctionExpression &function, TableMacroCatalogEntry &macro_func, idx_t depth);
263
263
 
264
264
  unique_ptr<BoundQueryNode> BindNode(SelectNode &node);
265
265
  unique_ptr<BoundQueryNode> BindNode(SetOperationNode &node);
@@ -43,8 +43,7 @@ protected:
43
43
  BindResult BindExpression(unique_ptr<ParsedExpression> &expr_ptr, idx_t depth,
44
44
  bool root_expression = false) override;
45
45
 
46
- BindResult BindAggregate(FunctionExpression &expr, optional_ptr<AggregateFunctionCatalogEntry> function,
47
- idx_t depth) override;
46
+ BindResult BindAggregate(FunctionExpression &expr, AggregateFunctionCatalogEntry &function, idx_t depth) override;
48
47
 
49
48
  bool inside_window;
50
49
  bool bound_aggregate = false;
@@ -134,14 +134,11 @@ protected:
134
134
 
135
135
  protected:
136
136
  virtual BindResult BindGroupingFunction(OperatorExpression &op, idx_t depth);
137
- virtual BindResult BindFunction(FunctionExpression &expr, optional_ptr<ScalarFunctionCatalogEntry> function,
138
- idx_t depth);
139
- virtual BindResult BindLambdaFunction(FunctionExpression &expr, optional_ptr<ScalarFunctionCatalogEntry> function,
140
- idx_t depth);
141
- virtual BindResult BindAggregate(FunctionExpression &expr, optional_ptr<AggregateFunctionCatalogEntry> function,
142
- idx_t depth);
137
+ virtual BindResult BindFunction(FunctionExpression &expr, ScalarFunctionCatalogEntry &function, idx_t depth);
138
+ virtual BindResult BindLambdaFunction(FunctionExpression &expr, ScalarFunctionCatalogEntry &function, idx_t depth);
139
+ virtual BindResult BindAggregate(FunctionExpression &expr, AggregateFunctionCatalogEntry &function, idx_t depth);
143
140
  virtual BindResult BindUnnest(FunctionExpression &expr, idx_t depth, bool root_expression);
144
- virtual BindResult BindMacro(FunctionExpression &expr, optional_ptr<ScalarMacroCatalogEntry> macro, idx_t depth,
141
+ virtual BindResult BindMacro(FunctionExpression &expr, ScalarMacroCatalogEntry &macro, idx_t depth,
145
142
  unique_ptr<ParsedExpression> &expr_ptr);
146
143
 
147
144
  virtual string UnsupportedAggregateMessage();
@@ -53,7 +53,7 @@ public:
53
53
  string GetName() const override;
54
54
  string ParamsToString() const override;
55
55
  //! Returns the underlying table that is being scanned, or nullptr if there is none
56
- TableCatalogEntry *GetTable() const;
56
+ optional_ptr<TableCatalogEntry> GetTable() const;
57
57
 
58
58
  public:
59
59
  vector<ColumnBinding> GetColumnBindings() override;