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
@@ -418,10 +418,9 @@ static unique_ptr<FunctionData> ListAggregatesBind(ClientContext &context, Scala
418
418
 
419
419
  // look up the aggregate function in the catalog
420
420
  QueryErrorContext error_context(nullptr, 0);
421
- auto func =
422
- (AggregateFunctionCatalogEntry *)Catalog::GetSystemCatalog(context).GetEntry<AggregateFunctionCatalogEntry>(
423
- context, DEFAULT_SCHEMA, function_name, false, error_context);
424
- D_ASSERT(func->type == CatalogType::AGGREGATE_FUNCTION_ENTRY);
421
+ auto &func = Catalog::GetSystemCatalog(context).GetEntry<AggregateFunctionCatalogEntry>(
422
+ context, DEFAULT_SCHEMA, function_name, error_context);
423
+ D_ASSERT(func.type == CatalogType::AGGREGATE_FUNCTION_ENTRY);
425
424
 
426
425
  if (is_parameter) {
427
426
  bound_function.arguments[0] = LogicalTypeId::UNKNOWN;
@@ -439,13 +438,13 @@ static unique_ptr<FunctionData> ListAggregatesBind(ClientContext &context, Scala
439
438
  }
440
439
 
441
440
  FunctionBinder function_binder(context);
442
- auto best_function_idx = function_binder.BindFunction(func->name, func->functions, types, error);
441
+ auto best_function_idx = function_binder.BindFunction(func.name, func.functions, types, error);
443
442
  if (best_function_idx == DConstants::INVALID_INDEX) {
444
443
  throw BinderException("No matching aggregate function\n%s", error);
445
444
  }
446
445
 
447
446
  // found a matching function, bind it as an aggregate
448
- auto best_function = func->functions.GetFunctionByOffset(best_function_idx);
447
+ auto best_function = func.functions.GetFunctionByOffset(best_function_idx);
449
448
  if (IS_AGGR) {
450
449
  return ListAggregatesBindFunction<IS_AGGR>(context, bound_function, list_child_type, best_function, arguments);
451
450
  }
@@ -167,8 +167,8 @@ static unique_ptr<BaseStatistics> PropagateNumericStats(ClientContext &context,
167
167
  } else {
168
168
  // no potential overflow: replace with non-overflowing operator
169
169
  if (input.bind_data) {
170
- auto bind_data = (DecimalArithmeticBindData *)input.bind_data;
171
- bind_data->check_overflow = false;
170
+ auto &bind_data = input.bind_data->Cast<DecimalArithmeticBindData>();
171
+ bind_data.check_overflow = false;
172
172
  }
173
173
  expr.function.function = GetScalarIntegerFunction<BASEOP>(expr.return_type.InternalType());
174
174
  }
@@ -76,7 +76,7 @@ struct NextSequenceValueOperator {
76
76
  }
77
77
  };
78
78
 
79
- SequenceCatalogEntry *BindSequence(ClientContext &context, const string &name) {
79
+ SequenceCatalogEntry &BindSequence(ClientContext &context, const string &name) {
80
80
  auto qname = QualifiedName::Parse(name);
81
81
  // fetch the sequence from the catalog
82
82
  Binder::BindSchemaOrCatalog(context, qname.catalog, qname.schema);
@@ -91,36 +91,37 @@ static void NextValFunction(DataChunk &args, ExpressionState &state, Vector &res
91
91
 
92
92
  auto &context = state.GetContext();
93
93
  if (info.sequence) {
94
- auto &transaction = DuckTransaction::Get(context, *info.sequence->catalog);
94
+ auto &sequence = *info.sequence;
95
+ auto &transaction = DuckTransaction::Get(context, sequence.catalog);
95
96
  // sequence to use is hard coded
96
97
  // increment the sequence
97
98
  result.SetVectorType(VectorType::FLAT_VECTOR);
98
99
  auto result_data = FlatVector::GetData<int64_t>(result);
99
100
  for (idx_t i = 0; i < args.size(); i++) {
100
101
  // get the next value from the sequence
101
- result_data[i] = OP::Operation(transaction, *info.sequence);
102
+ result_data[i] = OP::Operation(transaction, sequence);
102
103
  }
103
104
  } else {
104
105
  // sequence to use comes from the input
105
106
  UnaryExecutor::Execute<string_t, int64_t>(input, result, args.size(), [&](string_t value) {
106
107
  // fetch the sequence from the catalog
107
- auto sequence = BindSequence(context, value.GetString());
108
+ auto &sequence = BindSequence(context, value.GetString());
108
109
  // finally get the next value from the sequence
109
- auto &transaction = DuckTransaction::Get(context, *sequence->catalog);
110
- return OP::Operation(transaction, *sequence);
110
+ auto &transaction = DuckTransaction::Get(context, sequence.catalog);
111
+ return OP::Operation(transaction, sequence);
111
112
  });
112
113
  }
113
114
  }
114
115
 
115
116
  static unique_ptr<FunctionData> NextValBind(ClientContext &context, ScalarFunction &bound_function,
116
117
  vector<unique_ptr<Expression>> &arguments) {
117
- SequenceCatalogEntry *sequence = nullptr;
118
+ optional_ptr<SequenceCatalogEntry> sequence;
118
119
  if (arguments[0]->IsFoldable()) {
119
120
  // parameter to nextval function is a foldable constant
120
121
  // evaluate the constant and perform the catalog lookup already
121
122
  auto seqname = ExpressionExecutor::EvaluateScalar(context, *arguments[0]);
122
123
  if (!seqname.IsNull()) {
123
- sequence = BindSequence(context, seqname.ToString());
124
+ sequence = &BindSequence(context, seqname.ToString());
124
125
  }
125
126
  }
126
127
  return make_uniq<NextvalBindData>(sequence);
@@ -197,22 +197,22 @@ static unique_ptr<FunctionData> BindAggregateState(ClientContext &context, Scala
197
197
  auto state_type = AggregateStateType::GetStateType(arg_return_type);
198
198
 
199
199
  // now we can look up the function in the catalog again and bind it
200
- auto func = Catalog::GetSystemCatalog(context).GetEntry(context, CatalogType::SCALAR_FUNCTION_ENTRY, DEFAULT_SCHEMA,
201
- state_type.function_name);
202
- if (func->type != CatalogType::AGGREGATE_FUNCTION_ENTRY) {
200
+ auto &func = Catalog::GetSystemCatalog(context).GetEntry(context, CatalogType::SCALAR_FUNCTION_ENTRY,
201
+ DEFAULT_SCHEMA, state_type.function_name);
202
+ if (func.type != CatalogType::AGGREGATE_FUNCTION_ENTRY) {
203
203
  throw InternalException("Could not find aggregate %s", state_type.function_name);
204
204
  }
205
- auto aggr = (AggregateFunctionCatalogEntry *)func;
205
+ auto &aggr = func.Cast<AggregateFunctionCatalogEntry>();
206
206
 
207
207
  string error;
208
208
 
209
209
  FunctionBinder function_binder(context);
210
210
  idx_t best_function =
211
- function_binder.BindFunction(aggr->name, aggr->functions, state_type.bound_argument_types, error);
211
+ function_binder.BindFunction(aggr.name, aggr.functions, state_type.bound_argument_types, error);
212
212
  if (best_function == DConstants::INVALID_INDEX) {
213
213
  throw InternalException("Could not re-bind exported aggregate %s: %s", state_type.function_name, error);
214
214
  }
215
- auto bound_aggr = aggr->functions.GetFunctionByOffset(best_function);
215
+ auto bound_aggr = aggr.functions.GetFunctionByOffset(best_function);
216
216
  if (bound_aggr.bind) {
217
217
  // FIXME: this is really hacky
218
218
  // but the aggregate state export needs a rework around how it handles more complex aggregates anyway
@@ -271,8 +271,8 @@ unique_ptr<GlobalTableFunctionState> ArrowTableFunction::ArrowScanInitGlobal(Cli
271
271
  TableFunctionInitInput &input) {
272
272
  auto &bind_data = (const ArrowScanFunctionData &)*input.bind_data;
273
273
  auto result = make_uniq<ArrowScanGlobalState>();
274
- result->stream = ProduceArrowScan(bind_data, input.column_ids, input.filters);
275
- result->max_threads = ArrowScanMaxThreads(context, input.bind_data);
274
+ result->stream = ProduceArrowScan(bind_data, input.column_ids, input.filters.get());
275
+ result->max_threads = ArrowScanMaxThreads(context, input.bind_data.get());
276
276
  if (input.CanRemoveFilterColumns()) {
277
277
  result->projection_ids = input.projection_ids;
278
278
  for (const auto &col_idx : input.column_ids) {
@@ -293,12 +293,12 @@ unique_ptr<LocalTableFunctionState> ArrowTableFunction::ArrowScanInitLocal(Execu
293
293
  auto current_chunk = make_uniq<ArrowArrayWrapper>();
294
294
  auto result = make_uniq<ArrowScanLocalState>(std::move(current_chunk));
295
295
  result->column_ids = input.column_ids;
296
- result->filters = input.filters;
296
+ result->filters = input.filters.get();
297
297
  if (input.CanRemoveFilterColumns()) {
298
298
  auto &asgs = global_state_p->Cast<ArrowScanGlobalState>();
299
299
  result->all_columns.Initialize(context.client, asgs.scanned_types);
300
300
  }
301
- if (!ArrowScanParallelStateNext(context.client, input.bind_data, *result, global_state)) {
301
+ if (!ArrowScanParallelStateNext(context.client, input.bind_data.get(), *result, global_state)) {
302
302
  return nullptr;
303
303
  }
304
304
  return std::move(result);
@@ -314,7 +314,7 @@ void ArrowTableFunction::ArrowScanFunction(ClientContext &context, TableFunction
314
314
 
315
315
  //! Out of tuples in this chunk
316
316
  if (state.chunk_offset >= (idx_t)state.chunk->arrow_array.length) {
317
- if (!ArrowScanParallelStateNext(context, data_p.bind_data, state, global_state)) {
317
+ if (!ArrowScanParallelStateNext(context, data_p.bind_data.get(), state, global_state)) {
318
318
  return;
319
319
  }
320
320
  }
@@ -27,7 +27,7 @@ unique_ptr<CSVFileHandle> ReadCSV::OpenCSV(const string &file_path, FileCompress
27
27
  if (file_handle->CanSeek()) {
28
28
  file_handle->Reset();
29
29
  }
30
- return make_uniq<CSVFileHandle>(std::move(file_handle));
30
+ return make_uniq<CSVFileHandle>(std::move(file_handle), false);
31
31
  }
32
32
 
33
33
  void ReadCSVData::FinalizeRead(ClientContext &context) {
@@ -259,6 +259,7 @@ public:
259
259
  idx_t rows_to_skip, bool force_parallelism_p, vector<column_t> column_ids_p)
260
260
  : file_handle(std::move(file_handle_p)), system_threads(system_threads_p), buffer_size(buffer_size_p),
261
261
  force_parallelism(force_parallelism_p), column_ids(std::move(column_ids_p)) {
262
+ file_handle->DisableReset();
262
263
  current_file_path = files_path_p[0];
263
264
  estimated_linenr = rows_to_skip;
264
265
  file_size = file_handle->FileSize();
@@ -861,6 +862,7 @@ static void ReadCSVAddNamedParameters(TableFunction &table_function) {
861
862
  table_function.named_parameters["decimal_separator"] = LogicalType::VARCHAR;
862
863
  table_function.named_parameters["parallel"] = LogicalType::BOOLEAN;
863
864
  table_function.named_parameters["null_padding"] = LogicalType::BOOLEAN;
865
+ table_function.named_parameters["allow_quoted_nulls"] = LogicalType::BOOLEAN;
864
866
  table_function.named_parameters["column_types"] = LogicalType::ANY;
865
867
  table_function.named_parameters["dtypes"] = LogicalType::ANY;
866
868
  table_function.named_parameters["types"] = LogicalType::ANY;
@@ -920,6 +922,7 @@ void BufferedCSVReaderOptions::Serialize(FieldWriter &writer) const {
920
922
  writer.WriteString(null_str);
921
923
  writer.WriteField<FileCompressionType>(compression);
922
924
  writer.WriteField<NewLineIdentifier>(new_line);
925
+ writer.WriteField<bool>(allow_quoted_nulls);
923
926
  // read options
924
927
  writer.WriteField<idx_t>(skip_rows);
925
928
  writer.WriteField<bool>(skip_rows_set);
@@ -954,6 +957,7 @@ void BufferedCSVReaderOptions::Deserialize(FieldReader &reader) {
954
957
  null_str = reader.ReadRequired<string>();
955
958
  compression = reader.ReadRequired<FileCompressionType>();
956
959
  new_line = reader.ReadRequired<NewLineIdentifier>();
960
+ allow_quoted_nulls = reader.ReadRequired<bool>();
957
961
  // read options
958
962
  skip_rows = reader.ReadRequired<idx_t>();
959
963
  skip_rows_set = reader.ReadRequired<bool>();
@@ -16,7 +16,7 @@ struct DuckDBColumnsData : public GlobalTableFunctionState {
16
16
  DuckDBColumnsData() : offset(0), column_offset(0) {
17
17
  }
18
18
 
19
- vector<optional_ptr<CatalogEntry>> entries;
19
+ vector<reference<CatalogEntry>> entries;
20
20
  idx_t offset;
21
21
  idx_t column_offset;
22
22
  };
@@ -83,7 +83,8 @@ unique_ptr<GlobalTableFunctionState> DuckDBColumnsInit(ClientContext &context, T
83
83
  // scan all the schemas for tables and views and collect them
84
84
  auto schemas = Catalog::GetAllSchemas(context);
85
85
  for (auto &schema : schemas) {
86
- schema->Scan(context, CatalogType::TABLE_ENTRY, [&](CatalogEntry *entry) { result->entries.push_back(entry); });
86
+ schema.get().Scan(context, CatalogType::TABLE_ENTRY,
87
+ [&](CatalogEntry &entry) { result->entries.push_back(entry); });
87
88
  }
88
89
  return std::move(result);
89
90
  }
@@ -190,13 +191,13 @@ void ColumnHelper::WriteColumns(idx_t start_index, idx_t start_col, idx_t end_co
190
191
 
191
192
  idx_t col = 0;
192
193
  // database_name, VARCHAR
193
- output.SetValue(col++, index, entry.catalog->GetName());
194
+ output.SetValue(col++, index, entry.catalog.GetName());
194
195
  // database_oid, BIGINT
195
- output.SetValue(col++, index, Value::BIGINT(entry.catalog->GetOid()));
196
+ output.SetValue(col++, index, Value::BIGINT(entry.catalog.GetOid()));
196
197
  // schema_name, VARCHAR
197
- output.SetValue(col++, index, entry.schema->name);
198
+ output.SetValue(col++, index, entry.schema.name);
198
199
  // schema_oid, BIGINT
199
- output.SetValue(col++, index, Value::BIGINT(entry.schema->oid));
200
+ output.SetValue(col++, index, Value::BIGINT(entry.schema.oid));
200
201
  // table_name, VARCHAR
201
202
  output.SetValue(col++, index, entry.name);
202
203
  // table_oid, BIGINT
@@ -298,7 +299,7 @@ void DuckDBColumnsFunction(ClientContext &context, TableFunctionInput &data_p, D
298
299
  idx_t column_offset = data.column_offset;
299
300
  idx_t index = 0;
300
301
  while (next < data.entries.size() && index < STANDARD_VECTOR_SIZE) {
301
- auto column_helper = ColumnHelper::Create(*data.entries[next]);
302
+ auto column_helper = ColumnHelper::Create(data.entries[next].get());
302
303
  idx_t columns = column_helper->NumColumns();
303
304
 
304
305
  // Check to see if we are going to exceed the maximum index for a DataChunk
@@ -53,7 +53,7 @@ struct DuckDBConstraintsData : public GlobalTableFunctionState {
53
53
  DuckDBConstraintsData() : offset(0), constraint_offset(0), unique_constraint_offset(0) {
54
54
  }
55
55
 
56
- vector<optional_ptr<CatalogEntry>> entries;
56
+ vector<reference<CatalogEntry>> entries;
57
57
  idx_t offset;
58
58
  idx_t constraint_offset;
59
59
  idx_t unique_constraint_offset;
@@ -109,15 +109,15 @@ unique_ptr<GlobalTableFunctionState> DuckDBConstraintsInit(ClientContext &contex
109
109
  auto schemas = Catalog::GetAllSchemas(context);
110
110
 
111
111
  for (auto &schema : schemas) {
112
- vector<CatalogEntry *> entries;
112
+ vector<reference<CatalogEntry>> entries;
113
113
 
114
- schema->Scan(context, CatalogType::TABLE_ENTRY, [&](CatalogEntry *entry) {
115
- if (entry->type == CatalogType::TABLE_ENTRY) {
114
+ schema.get().Scan(context, CatalogType::TABLE_ENTRY, [&](CatalogEntry &entry) {
115
+ if (entry.type == CatalogType::TABLE_ENTRY) {
116
116
  entries.push_back(entry);
117
117
  }
118
118
  });
119
119
 
120
- sort(entries.begin(), entries.end(), [&](CatalogEntry *x, CatalogEntry *y) { return (x->name < y->name); });
120
+ sort(entries.begin(), entries.end(), [&](CatalogEntry &x, CatalogEntry &y) { return (x.name < y.name); });
121
121
 
122
122
  result->entries.insert(result->entries.end(), entries.begin(), entries.end());
123
123
  };
@@ -135,7 +135,7 @@ void DuckDBConstraintsFunction(ClientContext &context, TableFunctionInput &data_
135
135
  // either fill up the chunk or return all the remaining columns
136
136
  idx_t count = 0;
137
137
  while (data.offset < data.entries.size() && count < STANDARD_VECTOR_SIZE) {
138
- auto &entry = *data.entries[data.offset];
138
+ auto &entry = data.entries[data.offset].get();
139
139
  D_ASSERT(entry.type == CatalogType::TABLE_ENTRY);
140
140
 
141
141
  auto &table = entry.Cast<TableCatalogEntry>();
@@ -178,13 +178,13 @@ void DuckDBConstraintsFunction(ClientContext &context, TableFunctionInput &data_
178
178
 
179
179
  idx_t col = 0;
180
180
  // database_name, LogicalType::VARCHAR
181
- output.SetValue(col++, count, Value(table.schema->catalog->GetName()));
181
+ output.SetValue(col++, count, Value(table.schema.catalog.GetName()));
182
182
  // database_oid, LogicalType::BIGINT
183
- output.SetValue(col++, count, Value::BIGINT(table.schema->catalog->GetOid()));
183
+ output.SetValue(col++, count, Value::BIGINT(table.schema.catalog.GetOid()));
184
184
  // schema_name, LogicalType::VARCHAR
185
- output.SetValue(col++, count, Value(table.schema->name));
185
+ output.SetValue(col++, count, Value(table.schema.name));
186
186
  // schema_oid, LogicalType::BIGINT
187
- output.SetValue(col++, count, Value::BIGINT(table.schema->oid));
187
+ output.SetValue(col++, count, Value::BIGINT(table.schema.oid));
188
188
  // table_name, LogicalType::VARCHAR
189
189
  output.SetValue(col++, count, Value(table.name));
190
190
  // table_oid, LogicalType::BIGINT
@@ -198,15 +198,15 @@ void DuckDBConstraintsFunction(ClientContext &context, TableFunctionInput &data_
198
198
  switch (bound_constraint.type) {
199
199
  case ConstraintType::UNIQUE: {
200
200
  auto &bound_unique = bound_constraint.Cast<BoundUniqueConstraint>();
201
- uk_info = {table.schema->name, table.name, bound_unique.keys};
201
+ uk_info = {table.schema.name, table.name, bound_unique.keys};
202
202
  break;
203
203
  }
204
204
  case ConstraintType::FOREIGN_KEY: {
205
205
  const auto &bound_foreign_key = bound_constraint.Cast<BoundForeignKeyConstraint>();
206
206
  const auto &info = bound_foreign_key.info;
207
207
  // find the other table
208
- auto table_entry = Catalog::GetEntry<TableCatalogEntry>(context, table.catalog->GetName(),
209
- info.schema, info.table, true);
208
+ auto table_entry = Catalog::GetEntry<TableCatalogEntry>(
209
+ context, table.catalog.GetName(), info.schema, info.table, OnEntryNotFound::RETURN_NULL);
210
210
  if (!table_entry) {
211
211
  throw InternalException("dukdb_constraints: entry %s.%s referenced in foreign key not found",
212
212
  info.schema, info.table);
@@ -215,7 +215,7 @@ void DuckDBConstraintsFunction(ClientContext &context, TableFunctionInput &data_
215
215
  for (auto &key : info.pk_keys) {
216
216
  index.push_back(table_entry->GetColumns().PhysicalToLogical(key));
217
217
  }
218
- uk_info = {table_entry->schema->name, table_entry->name, index};
218
+ uk_info = {table_entry->schema.name, table_entry->name, index};
219
219
  break;
220
220
  }
221
221
  default:
@@ -8,7 +8,7 @@ struct DuckDBDatabasesData : public GlobalTableFunctionState {
8
8
  DuckDBDatabasesData() : offset(0) {
9
9
  }
10
10
 
11
- vector<optional_ptr<AttachedDatabase>> entries;
11
+ vector<reference<AttachedDatabase>> entries;
12
12
  idx_t offset;
13
13
  };
14
14
 
@@ -53,7 +53,7 @@ void DuckDBDatabasesFunction(ClientContext &context, TableFunctionInput &data_p,
53
53
  while (data.offset < data.entries.size() && count < STANDARD_VECTOR_SIZE) {
54
54
  auto &entry = data.entries[data.offset++];
55
55
 
56
- auto &attached = entry->Cast<AttachedDatabase>();
56
+ auto &attached = entry.get().Cast<AttachedDatabase>();
57
57
  // return values:
58
58
 
59
59
  idx_t col = 0;
@@ -21,7 +21,7 @@ struct DuckDBFunctionsData : public GlobalTableFunctionState {
21
21
  DuckDBFunctionsData() : offset(0), offset_in_entry(0) {
22
22
  }
23
23
 
24
- vector<CatalogEntry *> entries;
24
+ vector<reference<CatalogEntry>> entries;
25
25
  idx_t offset;
26
26
  idx_t offset_in_entry;
27
27
  };
@@ -73,24 +73,26 @@ static unique_ptr<FunctionData> DuckDBFunctionsBind(ClientContext &context, Tabl
73
73
  static void ExtractFunctionsFromSchema(ClientContext &context, SchemaCatalogEntry &schema,
74
74
  DuckDBFunctionsData &result) {
75
75
  schema.Scan(context, CatalogType::SCALAR_FUNCTION_ENTRY,
76
- [&](CatalogEntry *entry) { result.entries.push_back(entry); });
76
+ [&](CatalogEntry &entry) { result.entries.push_back(entry); });
77
77
  schema.Scan(context, CatalogType::TABLE_FUNCTION_ENTRY,
78
- [&](CatalogEntry *entry) { result.entries.push_back(entry); });
78
+ [&](CatalogEntry &entry) { result.entries.push_back(entry); });
79
79
  schema.Scan(context, CatalogType::PRAGMA_FUNCTION_ENTRY,
80
- [&](CatalogEntry *entry) { result.entries.push_back(entry); });
80
+ [&](CatalogEntry &entry) { result.entries.push_back(entry); });
81
81
  }
82
82
 
83
83
  unique_ptr<GlobalTableFunctionState> DuckDBFunctionsInit(ClientContext &context, TableFunctionInitInput &input) {
84
84
  auto result = make_uniq<DuckDBFunctionsData>();
85
85
 
86
- // scan all the schemas for tables and collect themand collect them
86
+ // scan all the schemas for tables and collect them and collect them
87
87
  auto schemas = Catalog::GetAllSchemas(context);
88
88
  for (auto &schema : schemas) {
89
- ExtractFunctionsFromSchema(context, *schema, *result);
89
+ ExtractFunctionsFromSchema(context, schema.get(), *result);
90
90
  };
91
91
 
92
92
  std::sort(result->entries.begin(), result->entries.end(),
93
- [&](CatalogEntry *a, CatalogEntry *b) { return (int)a->type < (int)b->type; });
93
+ [&](reference<CatalogEntry> a, reference<CatalogEntry> b) {
94
+ return (int32_t)a.get().type < (int32_t)b.get().type;
95
+ });
94
96
  return std::move(result);
95
97
  }
96
98
 
@@ -420,18 +422,18 @@ struct PragmaFunctionExtractor {
420
422
  };
421
423
 
422
424
  template <class T, class OP>
423
- bool ExtractFunctionData(StandardEntry *entry, idx_t function_idx, DataChunk &output, idx_t output_offset) {
424
- auto &function = (T &)*entry;
425
+ bool ExtractFunctionData(CatalogEntry &entry, idx_t function_idx, DataChunk &output, idx_t output_offset) {
426
+ auto &function = entry.Cast<T>();
425
427
  idx_t col = 0;
426
428
 
427
429
  // database_name, LogicalType::VARCHAR
428
- output.SetValue(col++, output_offset, Value(entry->schema->catalog->GetName()));
430
+ output.SetValue(col++, output_offset, Value(function.schema.catalog.GetName()));
429
431
 
430
432
  // schema_name, LogicalType::VARCHAR
431
- output.SetValue(col++, output_offset, Value(entry->schema->name));
433
+ output.SetValue(col++, output_offset, Value(function.schema.name));
432
434
 
433
435
  // function_name, LogicalType::VARCHAR
434
- output.SetValue(col++, output_offset, Value(entry->name));
436
+ output.SetValue(col++, output_offset, Value(function.name));
435
437
 
436
438
  // function_type, LogicalType::VARCHAR
437
439
  output.SetValue(col++, output_offset, Value(OP::GetFunctionType()));
@@ -458,10 +460,10 @@ bool ExtractFunctionData(StandardEntry *entry, idx_t function_idx, DataChunk &ou
458
460
  output.SetValue(col++, output_offset, OP::HasSideEffects(function, function_idx));
459
461
 
460
462
  // internal, LogicalType::BOOLEAN
461
- output.SetValue(col++, output_offset, Value::BOOLEAN(entry->internal));
463
+ output.SetValue(col++, output_offset, Value::BOOLEAN(function.internal));
462
464
 
463
465
  // function_oid, LogicalType::BIGINT
464
- output.SetValue(col++, output_offset, Value::BIGINT(entry->oid));
466
+ output.SetValue(col++, output_offset, Value::BIGINT(function.oid));
465
467
 
466
468
  return function_idx + 1 == OP::FunctionCount(function);
467
469
  }
@@ -476,35 +478,34 @@ void DuckDBFunctionsFunction(ClientContext &context, TableFunctionInput &data_p,
476
478
  // either fill up the chunk or return all the remaining columns
477
479
  idx_t count = 0;
478
480
  while (data.offset < data.entries.size() && count < STANDARD_VECTOR_SIZE) {
479
- auto &entry = data.entries[data.offset];
480
- auto standard_entry = (StandardEntry *)entry;
481
+ auto &entry = data.entries[data.offset].get();
481
482
  bool finished;
482
483
 
483
- switch (entry->type) {
484
+ switch (entry.type) {
484
485
  case CatalogType::SCALAR_FUNCTION_ENTRY:
485
486
  finished = ExtractFunctionData<ScalarFunctionCatalogEntry, ScalarFunctionExtractor>(
486
- standard_entry, data.offset_in_entry, output, count);
487
+ entry, data.offset_in_entry, output, count);
487
488
  break;
488
489
  case CatalogType::AGGREGATE_FUNCTION_ENTRY:
489
490
  finished = ExtractFunctionData<AggregateFunctionCatalogEntry, AggregateFunctionExtractor>(
490
- standard_entry, data.offset_in_entry, output, count);
491
+ entry, data.offset_in_entry, output, count);
491
492
  break;
492
493
  case CatalogType::TABLE_MACRO_ENTRY:
493
- finished = ExtractFunctionData<TableMacroCatalogEntry, TableMacroExtractor>(
494
- standard_entry, data.offset_in_entry, output, count);
494
+ finished = ExtractFunctionData<TableMacroCatalogEntry, TableMacroExtractor>(entry, data.offset_in_entry,
495
+ output, count);
495
496
  break;
496
497
 
497
498
  case CatalogType::MACRO_ENTRY:
498
- finished = ExtractFunctionData<ScalarMacroCatalogEntry, MacroExtractor>(
499
- standard_entry, data.offset_in_entry, output, count);
499
+ finished = ExtractFunctionData<ScalarMacroCatalogEntry, MacroExtractor>(entry, data.offset_in_entry, output,
500
+ count);
500
501
  break;
501
502
  case CatalogType::TABLE_FUNCTION_ENTRY:
502
503
  finished = ExtractFunctionData<TableFunctionCatalogEntry, TableFunctionExtractor>(
503
- standard_entry, data.offset_in_entry, output, count);
504
+ entry, data.offset_in_entry, output, count);
504
505
  break;
505
506
  case CatalogType::PRAGMA_FUNCTION_ENTRY:
506
507
  finished = ExtractFunctionData<PragmaFunctionCatalogEntry, PragmaFunctionExtractor>(
507
- standard_entry, data.offset_in_entry, output, count);
508
+ entry, data.offset_in_entry, output, count);
508
509
  break;
509
510
  default:
510
511
  throw InternalException("FIXME: unrecognized function type in duckdb_functions");
@@ -15,7 +15,7 @@ struct DuckDBIndexesData : public GlobalTableFunctionState {
15
15
  DuckDBIndexesData() : offset(0) {
16
16
  }
17
17
 
18
- vector<CatalogEntry *> entries;
18
+ vector<reference<CatalogEntry>> entries;
19
19
  idx_t offset;
20
20
  };
21
21
 
@@ -66,7 +66,8 @@ unique_ptr<GlobalTableFunctionState> DuckDBIndexesInit(ClientContext &context, T
66
66
  // scan all the schemas for tables and collect them and collect them
67
67
  auto schemas = Catalog::GetAllSchemas(context);
68
68
  for (auto &schema : schemas) {
69
- schema->Scan(context, CatalogType::INDEX_ENTRY, [&](CatalogEntry *entry) { result->entries.push_back(entry); });
69
+ schema.get().Scan(context, CatalogType::INDEX_ENTRY,
70
+ [&](CatalogEntry &entry) { result->entries.push_back(entry); });
70
71
  };
71
72
  return std::move(result);
72
73
  }
@@ -81,31 +82,31 @@ void DuckDBIndexesFunction(ClientContext &context, TableFunctionInput &data_p, D
81
82
  // either fill up the chunk or return all the remaining columns
82
83
  idx_t count = 0;
83
84
  while (data.offset < data.entries.size() && count < STANDARD_VECTOR_SIZE) {
84
- auto &entry = data.entries[data.offset++];
85
+ auto &entry = data.entries[data.offset++].get();
85
86
 
86
- auto &index = entry->Cast<IndexCatalogEntry>();
87
+ auto &index = entry.Cast<IndexCatalogEntry>();
87
88
  // return values:
88
89
 
89
90
  idx_t col = 0;
90
91
  // database_name, VARCHAR
91
- output.SetValue(col++, count, index.catalog->GetName());
92
+ output.SetValue(col++, count, index.catalog.GetName());
92
93
  // database_oid, BIGINT
93
- output.SetValue(col++, count, Value::BIGINT(index.catalog->GetOid()));
94
+ output.SetValue(col++, count, Value::BIGINT(index.catalog.GetOid()));
94
95
  // schema_name, VARCHAR
95
- output.SetValue(col++, count, Value(index.schema->name));
96
+ output.SetValue(col++, count, Value(index.schema.name));
96
97
  // schema_oid, BIGINT
97
- output.SetValue(col++, count, Value::BIGINT(index.schema->oid));
98
+ output.SetValue(col++, count, Value::BIGINT(index.schema.oid));
98
99
  // index_name, VARCHAR
99
100
  output.SetValue(col++, count, Value(index.name));
100
101
  // index_oid, BIGINT
101
102
  output.SetValue(col++, count, Value::BIGINT(index.oid));
102
103
  // find the table in the catalog
103
- auto table_entry =
104
- index.schema->catalog->GetEntry<TableCatalogEntry>(context, index.GetSchemaName(), index.GetTableName());
104
+ auto &table_entry =
105
+ index.schema.catalog.GetEntry<TableCatalogEntry>(context, index.GetSchemaName(), index.GetTableName());
105
106
  // table_name, VARCHAR
106
- output.SetValue(col++, count, Value(table_entry->name));
107
+ output.SetValue(col++, count, Value(table_entry.name));
107
108
  // table_oid, BIGINT
108
- output.SetValue(col++, count, Value::BIGINT(table_entry->oid));
109
+ output.SetValue(col++, count, Value::BIGINT(table_entry.oid));
109
110
  if (index.index) {
110
111
  // is_unique, BOOLEAN
111
112
  output.SetValue(col++, count, Value::BOOLEAN(index.index->IsUnique()));
@@ -12,7 +12,7 @@ struct DuckDBSchemasData : public GlobalTableFunctionState {
12
12
  DuckDBSchemasData() : offset(0) {
13
13
  }
14
14
 
15
- vector<SchemaCatalogEntry *> entries;
15
+ vector<reference<SchemaCatalogEntry>> entries;
16
16
  idx_t offset;
17
17
  };
18
18
 
@@ -58,20 +58,20 @@ void DuckDBSchemasFunction(ClientContext &context, TableFunctionInput &data_p, D
58
58
  // either fill up the chunk or return all the remaining columns
59
59
  idx_t count = 0;
60
60
  while (data.offset < data.entries.size() && count < STANDARD_VECTOR_SIZE) {
61
- auto &entry = data.entries[data.offset];
61
+ auto &entry = data.entries[data.offset].get();
62
62
 
63
63
  // return values:
64
64
  idx_t col = 0;
65
65
  // "oid", PhysicalType::BIGINT
66
- output.SetValue(col++, count, Value::BIGINT(entry->oid));
66
+ output.SetValue(col++, count, Value::BIGINT(entry.oid));
67
67
  // database_name, VARCHAR
68
- output.SetValue(col++, count, entry->catalog->GetName());
68
+ output.SetValue(col++, count, entry.catalog.GetName());
69
69
  // database_oid, BIGINT
70
- output.SetValue(col++, count, Value::BIGINT(entry->catalog->GetOid()));
70
+ output.SetValue(col++, count, Value::BIGINT(entry.catalog.GetOid()));
71
71
  // "schema_name", PhysicalType::VARCHAR
72
- output.SetValue(col++, count, Value(entry->name));
72
+ output.SetValue(col++, count, Value(entry.name));
73
73
  // "internal", PhysicalType::BOOLEAN
74
- output.SetValue(col++, count, Value::BOOLEAN(entry->internal));
74
+ output.SetValue(col++, count, Value::BOOLEAN(entry.internal));
75
75
  // "sql", PhysicalType::VARCHAR
76
76
  output.SetValue(col++, count, Value());
77
77
 
@@ -13,7 +13,7 @@ struct DuckDBSequencesData : public GlobalTableFunctionState {
13
13
  DuckDBSequencesData() : offset(0) {
14
14
  }
15
15
 
16
- vector<SequenceCatalogEntry *> entries;
16
+ vector<reference<SequenceCatalogEntry>> entries;
17
17
  idx_t offset;
18
18
  };
19
19
 
@@ -70,8 +70,8 @@ unique_ptr<GlobalTableFunctionState> DuckDBSequencesInit(ClientContext &context,
70
70
  // scan all the schemas for tables and collect themand collect them
71
71
  auto schemas = Catalog::GetAllSchemas(context);
72
72
  for (auto &schema : schemas) {
73
- schema->Scan(context, CatalogType::SEQUENCE_ENTRY,
74
- [&](CatalogEntry *entry) { result->entries.push_back((SequenceCatalogEntry *)entry); });
73
+ schema.get().Scan(context, CatalogType::SEQUENCE_ENTRY,
74
+ [&](CatalogEntry &entry) { result->entries.push_back(entry.Cast<SequenceCatalogEntry>()); });
75
75
  };
76
76
  return std::move(result);
77
77
  }
@@ -86,19 +86,18 @@ void DuckDBSequencesFunction(ClientContext &context, TableFunctionInput &data_p,
86
86
  // either fill up the chunk or return all the remaining columns
87
87
  idx_t count = 0;
88
88
  while (data.offset < data.entries.size() && count < STANDARD_VECTOR_SIZE) {
89
- auto &entry = data.entries[data.offset++];
89
+ auto &seq = data.entries[data.offset++].get();
90
90
 
91
- auto &seq = entry->Cast<SequenceCatalogEntry>();
92
91
  // return values:
93
92
  idx_t col = 0;
94
93
  // database_name, VARCHAR
95
- output.SetValue(col++, count, entry->catalog->GetName());
94
+ output.SetValue(col++, count, seq.catalog.GetName());
96
95
  // database_oid, BIGINT
97
- output.SetValue(col++, count, Value::BIGINT(entry->catalog->GetOid()));
96
+ output.SetValue(col++, count, Value::BIGINT(seq.catalog.GetOid()));
98
97
  // schema_name, VARCHAR
99
- output.SetValue(col++, count, Value(seq.schema->name));
98
+ output.SetValue(col++, count, Value(seq.schema.name));
100
99
  // schema_oid, BIGINT
101
- output.SetValue(col++, count, Value::BIGINT(seq.schema->oid));
100
+ output.SetValue(col++, count, Value::BIGINT(seq.schema.oid));
102
101
  // sequence_name, VARCHAR
103
102
  output.SetValue(col++, count, Value(seq.name));
104
103
  // sequence_oid, BIGINT