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
@@ -12,6 +12,7 @@
12
12
  #include "duckdb/parser/expression/constant_expression.hpp"
13
13
  #include "duckdb/catalog/mapping_value.hpp"
14
14
  #include "duckdb/catalog/catalog_entry/table_catalog_entry.hpp"
15
+ #include "duckdb/catalog/catalog_entry/type_catalog_entry.hpp"
15
16
 
16
17
  namespace duckdb {
17
18
 
@@ -106,7 +107,7 @@ bool CatalogSet::CreateEntry(CatalogTransaction transaction, const string &name,
106
107
  // first create a dummy deleted entry for this entry
107
108
  // so transactions started before the commit of this transaction don't
108
109
  // see it yet
109
- auto dummy_node = make_uniq<CatalogEntry>(CatalogType::INVALID, value->catalog, name);
110
+ auto dummy_node = make_uniq<InCatalogEntry>(CatalogType::INVALID, value->ParentCatalog(), name);
110
111
  dummy_node->timestamp = 0;
111
112
  dummy_node->deleted = true;
112
113
  dummy_node->set = this;
@@ -143,7 +144,7 @@ bool CatalogSet::CreateEntry(CatalogTransaction transaction, const string &name,
143
144
  PutEntry(std::move(entry_index), std::move(value));
144
145
  // push the old entry in the undo buffer for this transaction
145
146
  if (transaction.transaction) {
146
- auto &dtransaction = (DuckTransaction &)*transaction.transaction;
147
+ auto &dtransaction = transaction.transaction->Cast<DuckTransaction>();
147
148
  dtransaction.PushCatalogEntry(*value_ptr->child);
148
149
  }
149
150
  return true;
@@ -154,64 +155,58 @@ bool CatalogSet::CreateEntry(ClientContext &context, const string &name, unique_
154
155
  return CreateEntry(catalog.GetCatalogTransaction(context), name, std::move(value), dependencies);
155
156
  }
156
157
 
157
- bool CatalogSet::GetEntryInternal(CatalogTransaction transaction, EntryIndex &entry_index,
158
- CatalogEntry *&catalog_entry) {
159
- catalog_entry = entry_index.GetEntry().get();
158
+ optional_ptr<CatalogEntry> CatalogSet::GetEntryInternal(CatalogTransaction transaction, EntryIndex &entry_index) {
159
+ auto &catalog_entry = *entry_index.GetEntry();
160
160
  // if it does: we have to retrieve the entry and to check version numbers
161
- if (HasConflict(transaction, catalog_entry->timestamp)) {
161
+ if (HasConflict(transaction, catalog_entry.timestamp)) {
162
162
  // current version has been written to by a currently active
163
163
  // transaction
164
- throw TransactionException("Catalog write-write conflict on alter with \"%s\"", catalog_entry->name);
164
+ throw TransactionException("Catalog write-write conflict on alter with \"%s\"", catalog_entry.name);
165
165
  }
166
166
  // there is a current version that has been committed by this transaction
167
- if (catalog_entry->deleted) {
167
+ if (catalog_entry.deleted) {
168
168
  // if the entry was already deleted, it now does not exist anymore
169
169
  // so we return that we could not find it
170
- return false;
170
+ return nullptr;
171
171
  }
172
- return true;
172
+ return &catalog_entry;
173
173
  }
174
174
 
175
- bool CatalogSet::GetEntryInternal(CatalogTransaction transaction, const string &name, EntryIndex *entry_index,
176
- CatalogEntry *&catalog_entry) {
175
+ optional_ptr<CatalogEntry> CatalogSet::GetEntryInternal(CatalogTransaction transaction, const string &name,
176
+ EntryIndex *entry_index) {
177
177
  auto mapping_value = GetMapping(transaction, name);
178
178
  if (mapping_value == nullptr || mapping_value->deleted) {
179
179
  // the entry does not exist, check if we can create a default entry
180
- return false;
180
+ return nullptr;
181
181
  }
182
182
  if (entry_index) {
183
183
  *entry_index = mapping_value->index.Copy();
184
184
  }
185
- return GetEntryInternal(transaction, mapping_value->index, catalog_entry);
185
+ return GetEntryInternal(transaction, mapping_value->index);
186
186
  }
187
187
 
188
- bool CatalogSet::AlterOwnership(CatalogTransaction transaction, ChangeOwnershipInfo *info) {
189
- CatalogEntry *entry;
190
- if (!GetEntryInternal(transaction, info->name, nullptr, entry)) {
191
- return false;
192
- }
193
-
194
- auto owner_entry = catalog.GetEntry(transaction.GetContext(), info->owner_schema, info->owner_name);
195
- if (!owner_entry) {
188
+ bool CatalogSet::AlterOwnership(CatalogTransaction transaction, ChangeOwnershipInfo &info) {
189
+ auto entry = GetEntryInternal(transaction, info.name, nullptr);
190
+ if (!entry) {
196
191
  return false;
197
192
  }
198
193
 
199
- catalog.GetDependencyManager().AddOwnership(transaction, *owner_entry, *entry);
200
-
194
+ auto &owner_entry = catalog.GetEntry(transaction.GetContext(), info.owner_schema, info.owner_name);
195
+ catalog.GetDependencyManager().AddOwnership(transaction, owner_entry, *entry);
201
196
  return true;
202
197
  }
203
198
 
204
- bool CatalogSet::AlterEntry(CatalogTransaction transaction, const string &name, AlterInfo *alter_info) {
199
+ bool CatalogSet::AlterEntry(CatalogTransaction transaction, const string &name, AlterInfo &alter_info) {
205
200
  // lock the catalog for writing
206
201
  lock_guard<mutex> write_lock(catalog.GetWriteLock());
207
202
 
208
203
  // first check if the entry exists in the unordered set
209
204
  EntryIndex entry_index;
210
- CatalogEntry *entry;
211
- if (!GetEntryInternal(transaction, name, &entry_index, entry)) {
205
+ auto entry = GetEntryInternal(transaction, name, &entry_index);
206
+ if (!entry) {
212
207
  return false;
213
208
  }
214
- if (!alter_info->allow_internal && entry->internal) {
209
+ if (!alter_info.allow_internal && entry->internal) {
215
210
  throw CatalogException("Cannot alter entry \"%s\" because it is an internal system entry", entry->name);
216
211
  }
217
212
 
@@ -235,8 +230,8 @@ bool CatalogSet::AlterEntry(CatalogTransaction transaction, const string &name,
235
230
  if (value->name != original_name) {
236
231
  auto mapping_value = GetMapping(transaction, value->name);
237
232
  if (mapping_value && !mapping_value->deleted) {
238
- auto original_entry = GetEntryForTransaction(transaction, mapping_value->index.GetEntry().get());
239
- if (!original_entry->deleted) {
233
+ auto &original_entry = GetEntryForTransaction(transaction, *mapping_value->index.GetEntry());
234
+ if (!original_entry.deleted) {
240
235
  entry->UndoAlter(context, alter_info);
241
236
  string rename_err_msg =
242
237
  "Could not rename \"%s\" to \"%s\": another entry with this name already exists!";
@@ -258,13 +253,13 @@ bool CatalogSet::AlterEntry(CatalogTransaction transaction, const string &name,
258
253
 
259
254
  // serialize the AlterInfo into a temporary buffer
260
255
  BufferedSerializer serializer;
261
- serializer.WriteString(alter_info->GetColumnName());
262
- alter_info->Serialize(serializer);
256
+ serializer.WriteString(alter_info.GetColumnName());
257
+ alter_info.Serialize(serializer);
263
258
  BinaryData serialized_alter = serializer.GetData();
264
259
 
265
260
  // push the old entry in the undo buffer for this transaction
266
261
  if (transaction.transaction) {
267
- auto &dtransaction = (DuckTransaction &)*transaction.transaction;
262
+ auto &dtransaction = transaction.transaction->Cast<DuckTransaction>();
268
263
  dtransaction.PushCatalogEntry(*new_entry->child, serialized_alter.data.get(), serialized_alter.size);
269
264
  }
270
265
 
@@ -286,8 +281,9 @@ void CatalogSet::DropEntryDependencies(CatalogTransaction transaction, EntryInde
286
281
  entry_index.GetEntry()->deleted = true;
287
282
 
288
283
  // check any dependencies of this object
289
- D_ASSERT(entry.catalog->IsDuckCatalog());
290
- ((DuckCatalog &)*entry.catalog).GetDependencyManager().DropObject(transaction, entry, cascade);
284
+ D_ASSERT(entry.ParentCatalog().IsDuckCatalog());
285
+ auto &duck_catalog = entry.ParentCatalog().Cast<DuckCatalog>();
286
+ duck_catalog.GetDependencyManager().DropObject(transaction, entry, cascade);
291
287
 
292
288
  // dropper destructor is called here
293
289
  // the destructor makes sure to return the value to the previous state
@@ -301,7 +297,7 @@ void CatalogSet::DropEntryInternal(CatalogTransaction transaction, EntryIndex en
301
297
  // create a new entry and replace the currently stored one
302
298
  // set the timestamp to the timestamp of the current transaction
303
299
  // and point it at the dummy node
304
- auto value = make_uniq<CatalogEntry>(CatalogType::DELETED_ENTRY, entry.catalog, entry.name);
300
+ auto value = make_uniq<InCatalogEntry>(CatalogType::DELETED_ENTRY, entry.ParentCatalog(), entry.name);
305
301
  value->timestamp = transaction.transaction_id;
306
302
  value->set = this;
307
303
  value->deleted = true;
@@ -310,7 +306,7 @@ void CatalogSet::DropEntryInternal(CatalogTransaction transaction, EntryIndex en
310
306
 
311
307
  // push the old entry in the undo buffer for this transaction
312
308
  if (transaction.transaction) {
313
- auto &dtransaction = (DuckTransaction &)*transaction.transaction;
309
+ auto &dtransaction = transaction.transaction->Cast<DuckTransaction>();
314
310
  dtransaction.PushCatalogEntry(*value_ptr->child);
315
311
  }
316
312
  }
@@ -320,8 +316,8 @@ bool CatalogSet::DropEntry(CatalogTransaction transaction, const string &name, b
320
316
  lock_guard<mutex> write_lock(catalog.GetWriteLock());
321
317
  // we can only delete an entry that exists
322
318
  EntryIndex entry_index;
323
- CatalogEntry *entry;
324
- if (!GetEntryInternal(transaction, name, &entry_index, entry)) {
319
+ auto entry = GetEntryInternal(transaction, name, &entry_index);
320
+ if (!entry) {
325
321
  return false;
326
322
  }
327
323
  if (entry->internal && !allow_drop_internal) {
@@ -341,25 +337,25 @@ DuckCatalog &CatalogSet::GetCatalog() {
341
337
  return catalog;
342
338
  }
343
339
 
344
- void CatalogSet::CleanupEntry(CatalogEntry *catalog_entry) {
340
+ void CatalogSet::CleanupEntry(CatalogEntry &catalog_entry) {
345
341
  // destroy the backed up entry: it is no longer required
346
- D_ASSERT(catalog_entry->parent);
347
- if (catalog_entry->parent->type != CatalogType::UPDATED_ENTRY) {
342
+ D_ASSERT(catalog_entry.parent);
343
+ if (catalog_entry.parent->type != CatalogType::UPDATED_ENTRY) {
348
344
  lock_guard<mutex> write_lock(catalog.GetWriteLock());
349
345
  lock_guard<mutex> lock(catalog_lock);
350
- if (!catalog_entry->deleted) {
346
+ if (!catalog_entry.deleted) {
351
347
  // delete the entry from the dependency manager, if it is not deleted yet
352
- D_ASSERT(catalog_entry->catalog->IsDuckCatalog());
353
- ((DuckCatalog &)*catalog_entry->catalog).GetDependencyManager().EraseObject(*catalog_entry);
348
+ D_ASSERT(catalog_entry.ParentCatalog().IsDuckCatalog());
349
+ catalog_entry.ParentCatalog().Cast<DuckCatalog>().GetDependencyManager().EraseObject(catalog_entry);
354
350
  }
355
- auto parent = catalog_entry->parent;
356
- parent->child = std::move(catalog_entry->child);
351
+ auto parent = catalog_entry.parent;
352
+ parent->child = std::move(catalog_entry.child);
357
353
  if (parent->deleted && !parent->child && !parent->parent) {
358
354
  auto mapping_entry = mapping.find(parent->name);
359
355
  D_ASSERT(mapping_entry != mapping.end());
360
- auto entry = mapping_entry->second->index.GetEntry().get();
356
+ auto &entry = mapping_entry->second->index.GetEntry();
361
357
  D_ASSERT(entry);
362
- if (entry == parent) {
358
+ if (entry.get() == parent.get()) {
363
359
  mapping.erase(mapping_entry);
364
360
  }
365
361
  }
@@ -371,8 +367,8 @@ bool CatalogSet::HasConflict(CatalogTransaction transaction, transaction_t times
371
367
  (timestamp < TRANSACTION_ID_START && timestamp > transaction.start_time);
372
368
  }
373
369
 
374
- MappingValue *CatalogSet::GetMapping(CatalogTransaction transaction, const string &name, bool get_latest) {
375
- MappingValue *mapping_value;
370
+ optional_ptr<MappingValue> CatalogSet::GetMapping(CatalogTransaction transaction, const string &name, bool get_latest) {
371
+ optional_ptr<MappingValue> mapping_value;
376
372
  auto entry = mapping.find(name);
377
373
  if (entry != mapping.end()) {
378
374
  mapping_value = entry->second.get();
@@ -430,27 +426,27 @@ bool CatalogSet::UseTimestamp(CatalogTransaction transaction, transaction_t time
430
426
  return false;
431
427
  }
432
428
 
433
- CatalogEntry *CatalogSet::GetEntryForTransaction(CatalogTransaction transaction, CatalogEntry *current) {
434
- while (current->child) {
435
- if (UseTimestamp(transaction, current->timestamp)) {
429
+ CatalogEntry &CatalogSet::GetEntryForTransaction(CatalogTransaction transaction, CatalogEntry &current) {
430
+ reference<CatalogEntry> entry(current);
431
+ while (entry.get().child) {
432
+ if (UseTimestamp(transaction, entry.get().timestamp)) {
436
433
  break;
437
434
  }
438
- current = current->child.get();
439
- D_ASSERT(current);
435
+ entry = *entry.get().child;
440
436
  }
441
- return current;
437
+ return entry.get();
442
438
  }
443
439
 
444
- CatalogEntry *CatalogSet::GetCommittedEntry(CatalogEntry *current) {
445
- while (current->child) {
446
- if (current->timestamp < TRANSACTION_ID_START) {
440
+ CatalogEntry &CatalogSet::GetCommittedEntry(CatalogEntry &current) {
441
+ reference<CatalogEntry> entry(current);
442
+ while (entry.get().child) {
443
+ if (entry.get().timestamp < TRANSACTION_ID_START) {
447
444
  // this entry is committed: use it
448
445
  break;
449
446
  }
450
- current = current->child.get();
451
- D_ASSERT(current);
447
+ entry = *entry.get().child;
452
448
  }
453
- return current;
449
+ return entry.get();
454
450
  }
455
451
 
456
452
  SimilarCatalogEntry CatalogSet::SimilarEntry(CatalogTransaction transaction, const string &name) {
@@ -471,7 +467,8 @@ SimilarCatalogEntry CatalogSet::SimilarEntry(CatalogTransaction transaction, con
471
467
  return result;
472
468
  }
473
469
 
474
- CatalogEntry *CatalogSet::CreateEntryInternal(CatalogTransaction transaction, unique_ptr<CatalogEntry> entry) {
470
+ optional_ptr<CatalogEntry> CatalogSet::CreateEntryInternal(CatalogTransaction transaction,
471
+ unique_ptr<CatalogEntry> entry) {
475
472
  if (mapping.find(entry->name) != mapping.end()) {
476
473
  return nullptr;
477
474
  }
@@ -487,8 +484,8 @@ CatalogEntry *CatalogSet::CreateEntryInternal(CatalogTransaction transaction, un
487
484
  return catalog_entry;
488
485
  }
489
486
 
490
- CatalogEntry *CatalogSet::CreateDefaultEntry(CatalogTransaction transaction, const string &name,
491
- unique_lock<mutex> &lock) {
487
+ optional_ptr<CatalogEntry> CatalogSet::CreateDefaultEntry(CatalogTransaction transaction, const string &name,
488
+ unique_lock<mutex> &lock) {
492
489
  // no entry found with this name, check for defaults
493
490
  if (!defaults || defaults->created_all_entries) {
494
491
  // no defaults either: return null
@@ -520,24 +517,24 @@ CatalogEntry *CatalogSet::CreateDefaultEntry(CatalogTransaction transaction, con
520
517
  return GetEntry(transaction, name);
521
518
  }
522
519
 
523
- CatalogEntry *CatalogSet::GetEntry(CatalogTransaction transaction, const string &name) {
520
+ optional_ptr<CatalogEntry> CatalogSet::GetEntry(CatalogTransaction transaction, const string &name) {
524
521
  unique_lock<mutex> lock(catalog_lock);
525
522
  auto mapping_value = GetMapping(transaction, name);
526
523
  if (mapping_value != nullptr && !mapping_value->deleted) {
527
524
  // we found an entry for this name
528
525
  // check the version numbers
529
526
 
530
- auto catalog_entry = mapping_value->index.GetEntry().get();
531
- CatalogEntry *current = GetEntryForTransaction(transaction, catalog_entry);
532
- if (current->deleted || (current->name != name && !UseTimestamp(transaction, mapping_value->timestamp))) {
527
+ auto &catalog_entry = *mapping_value->index.GetEntry();
528
+ auto &current = GetEntryForTransaction(transaction, catalog_entry);
529
+ if (current.deleted || (current.name != name && !UseTimestamp(transaction, mapping_value->timestamp))) {
533
530
  return nullptr;
534
531
  }
535
- return current;
532
+ return &current;
536
533
  }
537
534
  return CreateDefaultEntry(transaction, name, lock);
538
535
  }
539
536
 
540
- CatalogEntry *CatalogSet::GetEntry(ClientContext &context, const string &name) {
537
+ optional_ptr<CatalogEntry> CatalogSet::GetEntry(ClientContext &context, const string &name) {
541
538
  return GetEntry(catalog.GetCatalogTransaction(context), name);
542
539
  }
543
540
 
@@ -547,11 +544,11 @@ void CatalogSet::UpdateTimestamp(CatalogEntry &entry, transaction_t timestamp) {
547
544
  }
548
545
 
549
546
  void CatalogSet::AdjustUserDependency(CatalogEntry &entry, ColumnDefinition &column, bool remove) {
550
- CatalogEntry *user_type_catalog_p = (CatalogEntry *)LogicalType::GetCatalog(column.Type());
547
+ auto user_type_catalog_p = EnumType::GetCatalog(column.Type());
551
548
  if (!user_type_catalog_p) {
552
549
  return;
553
550
  }
554
- auto &user_type_catalog = *user_type_catalog_p;
551
+ auto &user_type_catalog = user_type_catalog_p->Cast<CatalogEntry>();
555
552
  auto &dependency_manager = catalog.GetDependencyManager();
556
553
  if (remove) {
557
554
  dependency_manager.dependents_map[user_type_catalog].erase(*entry.parent);
@@ -685,42 +682,42 @@ void CatalogSet::CreateDefaultEntries(CatalogTransaction transaction, unique_loc
685
682
  defaults->created_all_entries = true;
686
683
  }
687
684
 
688
- void CatalogSet::Scan(CatalogTransaction transaction, const std::function<void(CatalogEntry *)> &callback) {
685
+ void CatalogSet::Scan(CatalogTransaction transaction, const std::function<void(CatalogEntry &)> &callback) {
689
686
  // lock the catalog set
690
687
  unique_lock<mutex> lock(catalog_lock);
691
688
  CreateDefaultEntries(transaction, lock);
692
689
 
693
690
  for (auto &kv : entries) {
694
- auto entry = kv.second.entry.get();
695
- entry = GetEntryForTransaction(transaction, entry);
696
- if (!entry->deleted) {
697
- callback(entry);
691
+ auto &entry = *kv.second.entry.get();
692
+ auto &entry_for_transaction = GetEntryForTransaction(transaction, entry);
693
+ if (!entry_for_transaction.deleted) {
694
+ callback(entry_for_transaction);
698
695
  }
699
696
  }
700
697
  }
701
698
 
702
- void CatalogSet::Scan(ClientContext &context, const std::function<void(CatalogEntry *)> &callback) {
699
+ void CatalogSet::Scan(ClientContext &context, const std::function<void(CatalogEntry &)> &callback) {
703
700
  Scan(catalog.GetCatalogTransaction(context), callback);
704
701
  }
705
702
 
706
- void CatalogSet::Scan(const std::function<void(CatalogEntry *)> &callback) {
703
+ void CatalogSet::Scan(const std::function<void(CatalogEntry &)> &callback) {
707
704
  // lock the catalog set
708
705
  lock_guard<mutex> lock(catalog_lock);
709
706
  for (auto &kv : entries) {
710
707
  auto entry = kv.second.entry.get();
711
- entry = GetCommittedEntry(entry);
712
- if (!entry->deleted) {
713
- callback(entry);
708
+ auto &commited_entry = GetCommittedEntry(*entry);
709
+ if (!commited_entry.deleted) {
710
+ callback(commited_entry);
714
711
  }
715
712
  }
716
713
  }
717
714
 
718
715
  void CatalogSet::Verify(Catalog &catalog_p) {
719
716
  D_ASSERT(&catalog_p == &catalog);
720
- vector<CatalogEntry *> entries;
721
- Scan([&](CatalogEntry *entry) { entries.push_back(entry); });
717
+ vector<reference<CatalogEntry>> entries;
718
+ Scan([&](CatalogEntry &entry) { entries.push_back(entry); });
722
719
  for (auto &entry : entries) {
723
- entry->Verify(catalog_p);
720
+ entry.get().Verify(catalog_p);
724
721
  }
725
722
  }
726
723
 
@@ -12,7 +12,7 @@ CatalogTransaction::CatalogTransaction(Catalog &catalog, ClientContext &context)
12
12
  this->transaction_id = transaction_t(-1);
13
13
  this->start_time = transaction_t(-1);
14
14
  } else {
15
- auto &dtransaction = (DuckTransaction &)transaction;
15
+ auto &dtransaction = transaction.Cast<DuckTransaction>();
16
16
  this->transaction_id = dtransaction.transaction_id;
17
17
  this->start_time = dtransaction.start_time;
18
18
  }
@@ -194,7 +194,7 @@ unique_ptr<CatalogEntry> DefaultFunctionGenerator::CreateDefaultEntry(ClientCont
194
194
  const string &entry_name) {
195
195
  auto info = GetDefaultFunction(schema.name, entry_name);
196
196
  if (info) {
197
- return make_uniq_base<CatalogEntry, ScalarMacroCatalogEntry>(&catalog, &schema, (CreateMacroInfo *)info.get());
197
+ return make_uniq_base<CatalogEntry, ScalarMacroCatalogEntry>(catalog, schema, info->Cast<CreateMacroInfo>());
198
198
  }
199
199
  return nullptr;
200
200
  }
@@ -25,7 +25,7 @@ DefaultSchemaGenerator::DefaultSchemaGenerator(Catalog &catalog) : DefaultGenera
25
25
 
26
26
  unique_ptr<CatalogEntry> DefaultSchemaGenerator::CreateDefaultEntry(ClientContext &context, const string &entry_name) {
27
27
  if (GetDefaultSchema(entry_name)) {
28
- return make_uniq_base<CatalogEntry, DuckSchemaEntry>(&catalog, StringUtil::Lower(entry_name), true);
28
+ return make_uniq_base<CatalogEntry, DuckSchemaEntry>(catalog, StringUtil::Lower(entry_name), true);
29
29
  }
30
30
  return nullptr;
31
31
  }
@@ -111,7 +111,7 @@ unique_ptr<CatalogEntry> DefaultTypeGenerator::CreateDefaultEntry(ClientContext
111
111
  info.type = LogicalType(type_id);
112
112
  info.internal = true;
113
113
  info.temporary = true;
114
- return make_uniq_base<CatalogEntry, TypeCatalogEntry>(&catalog, &schema, &info);
114
+ return make_uniq_base<CatalogEntry, TypeCatalogEntry>(catalog, schema, info);
115
115
  }
116
116
 
117
117
  vector<string> DefaultTypeGenerator::GetDefaultEntries() {
@@ -76,7 +76,7 @@ DefaultViewGenerator::DefaultViewGenerator(Catalog &catalog, SchemaCatalogEntry
76
76
  unique_ptr<CatalogEntry> DefaultViewGenerator::CreateDefaultEntry(ClientContext &context, const string &entry_name) {
77
77
  auto info = GetDefaultView(context, schema.name, entry_name);
78
78
  if (info) {
79
- return make_uniq_base<CatalogEntry, ViewCatalogEntry>(&catalog, &schema, info.get());
79
+ return make_uniq_base<CatalogEntry, ViewCatalogEntry>(catalog, schema, *info);
80
80
  }
81
81
  return nullptr;
82
82
  }
@@ -14,11 +14,11 @@ void DependencyList::AddDependency(CatalogEntry &entry) {
14
14
  void DependencyList::VerifyDependencies(Catalog &catalog, const string &name) {
15
15
  for (auto &dep_entry : set) {
16
16
  auto &dep = dep_entry.get();
17
- if (dep.catalog != &catalog) {
17
+ if (&dep.ParentCatalog() != &catalog) {
18
18
  throw DependencyException(
19
19
  "Error adding dependency for object \"%s\" - dependency \"%s\" is in catalog "
20
20
  "\"%s\", which does not match the catalog \"%s\".\nCross catalog dependencies are not supported.",
21
- name, dep.name, dep.catalog->GetName(), catalog.GetName());
21
+ name, dep.name, dep.ParentCatalog().GetName(), catalog.GetName());
22
22
  }
23
23
  }
24
24
  }
@@ -18,17 +18,17 @@ void DependencyManager::AddObject(CatalogTransaction transaction, CatalogEntry &
18
18
  // check for each object in the sources if they were not deleted yet
19
19
  for (auto &dep : dependencies.set) {
20
20
  auto &dependency = dep.get();
21
- CatalogEntry *catalog_entry;
22
- if (dependency.catalog != object.catalog) {
21
+ if (&dependency.ParentCatalog() != &object.ParentCatalog()) {
23
22
  throw DependencyException(
24
23
  "Error adding dependency for object \"%s\" - dependency \"%s\" is in catalog "
25
24
  "\"%s\", which does not match the catalog \"%s\".\nCross catalog dependencies are not supported.",
26
- object.name, dependency.name, dependency.catalog->GetName(), object.catalog->GetName());
25
+ object.name, dependency.name, dependency.ParentCatalog().GetName(), object.ParentCatalog().GetName());
27
26
  }
28
27
  if (!dependency.set) {
29
28
  throw InternalException("Dependency has no set");
30
29
  }
31
- if (!dependency.set->GetEntryInternal(transaction, dependency.name, nullptr, catalog_entry)) {
30
+ auto catalog_entry = dependency.set->GetEntryInternal(transaction, dependency.name, nullptr);
31
+ if (!catalog_entry) {
32
32
  throw InternalException("Dependency has already been deleted?");
33
33
  }
34
34
  }
@@ -58,9 +58,8 @@ void DependencyManager::DropObject(CatalogTransaction transaction, CatalogEntry
58
58
  if (mapping_value == nullptr) {
59
59
  continue;
60
60
  }
61
- CatalogEntry *dependency_entry;
62
-
63
- if (!catalog_set.GetEntryInternal(transaction, mapping_value->index, dependency_entry)) {
61
+ auto dependency_entry = catalog_set.GetEntryInternal(transaction, mapping_value->index);
62
+ if (!dependency_entry) {
64
63
  // the dependent object was already deleted, no conflict
65
64
  continue;
66
65
  }
@@ -89,8 +88,8 @@ void DependencyManager::AlterObject(CatalogTransaction transaction, CatalogEntry
89
88
  // look up the entry in the catalog set
90
89
  auto &entry = dep.entry.get();
91
90
  auto &catalog_set = *entry.set;
92
- CatalogEntry *dependency_entry;
93
- if (!catalog_set.GetEntryInternal(transaction, entry.name, nullptr, dependency_entry)) {
91
+ auto dependency_entry = catalog_set.GetEntryInternal(transaction, entry.name, nullptr);
92
+ if (!dependency_entry) {
94
93
  // the dependent object was already deleted, no conflict
95
94
  continue;
96
95
  }
@@ -138,7 +137,7 @@ void DependencyManager::AlterObject(CatalogTransaction transaction, CatalogEntry
138
137
  if (new_obj.type == CatalogType::TABLE_ENTRY) {
139
138
  auto &table = new_obj.Cast<TableCatalogEntry>();
140
139
  for (auto &column : table.GetColumns().Logical()) {
141
- auto user_type_catalog = LogicalType::GetCatalog(column.Type());
140
+ auto user_type_catalog = EnumType::GetCatalog(column.Type());
142
141
  if (user_type_catalog) {
143
142
  to_add.push_back(*user_type_catalog);
144
143
  }
@@ -28,7 +28,7 @@ void DuckCatalog::Initialize(bool load_builtin) {
28
28
  CreateSchemaInfo info;
29
29
  info.schema = DEFAULT_SCHEMA;
30
30
  info.internal = true;
31
- CreateSchema(data, &info);
31
+ CreateSchema(data, info);
32
32
 
33
33
  if (load_builtin) {
34
34
  // initialize default functions
@@ -46,29 +46,29 @@ bool DuckCatalog::IsDuckCatalog() {
46
46
  //===--------------------------------------------------------------------===//
47
47
  // Schema
48
48
  //===--------------------------------------------------------------------===//
49
- CatalogEntry *DuckCatalog::CreateSchemaInternal(CatalogTransaction transaction, CreateSchemaInfo *info) {
49
+ optional_ptr<CatalogEntry> DuckCatalog::CreateSchemaInternal(CatalogTransaction transaction, CreateSchemaInfo &info) {
50
50
  DependencyList dependencies;
51
- auto entry = make_uniq<DuckSchemaEntry>(this, info->schema, info->internal);
51
+ auto entry = make_uniq<DuckSchemaEntry>(*this, info.schema, info.internal);
52
52
  auto result = entry.get();
53
- if (!schemas->CreateEntry(transaction, info->schema, std::move(entry), dependencies)) {
53
+ if (!schemas->CreateEntry(transaction, info.schema, std::move(entry), dependencies)) {
54
54
  return nullptr;
55
55
  }
56
56
  return (CatalogEntry *)result;
57
57
  }
58
58
 
59
- CatalogEntry *DuckCatalog::CreateSchema(CatalogTransaction transaction, CreateSchemaInfo *info) {
60
- D_ASSERT(!info->schema.empty());
59
+ optional_ptr<CatalogEntry> DuckCatalog::CreateSchema(CatalogTransaction transaction, CreateSchemaInfo &info) {
60
+ D_ASSERT(!info.schema.empty());
61
61
  auto result = CreateSchemaInternal(transaction, info);
62
62
  if (!result) {
63
- switch (info->on_conflict) {
63
+ switch (info.on_conflict) {
64
64
  case OnCreateConflict::ERROR_ON_CONFLICT:
65
- throw CatalogException("Schema with name %s already exists!", info->schema);
65
+ throw CatalogException("Schema with name %s already exists!", info.schema);
66
66
  case OnCreateConflict::REPLACE_ON_CONFLICT: {
67
67
  DropInfo drop_info;
68
68
  drop_info.type = CatalogType::SCHEMA_ENTRY;
69
- drop_info.catalog = info->catalog;
70
- drop_info.name = info->schema;
71
- DropSchema(transaction, &drop_info);
69
+ drop_info.catalog = info.catalog;
70
+ drop_info.name = info.schema;
71
+ DropSchema(transaction, drop_info);
72
72
  result = CreateSchemaInternal(transaction, info);
73
73
  if (!result) {
74
74
  throw InternalException("Failed to create schema entry in CREATE_OR_REPLACE");
@@ -85,36 +85,40 @@ CatalogEntry *DuckCatalog::CreateSchema(CatalogTransaction transaction, CreateSc
85
85
  return result;
86
86
  }
87
87
 
88
- void DuckCatalog::DropSchema(CatalogTransaction transaction, DropInfo *info) {
89
- D_ASSERT(!info->name.empty());
88
+ void DuckCatalog::DropSchema(CatalogTransaction transaction, DropInfo &info) {
89
+ D_ASSERT(!info.name.empty());
90
90
  ModifyCatalog();
91
- if (!schemas->DropEntry(transaction, info->name, info->cascade)) {
92
- if (!info->if_exists) {
93
- throw CatalogException("Schema with name \"%s\" does not exist!", info->name);
91
+ if (!schemas->DropEntry(transaction, info.name, info.cascade)) {
92
+ if (info.if_not_found == OnEntryNotFound::THROW_EXCEPTION) {
93
+ throw CatalogException("Schema with name \"%s\" does not exist!", info.name);
94
94
  }
95
95
  }
96
96
  }
97
97
 
98
- void DuckCatalog::DropSchema(ClientContext &context, DropInfo *info) {
98
+ void DuckCatalog::DropSchema(ClientContext &context, DropInfo &info) {
99
99
  DropSchema(GetCatalogTransaction(context), info);
100
100
  }
101
101
 
102
- void DuckCatalog::ScanSchemas(ClientContext &context, std::function<void(CatalogEntry *)> callback) {
103
- schemas->Scan(GetCatalogTransaction(context), [&](CatalogEntry *entry) { callback(entry); });
102
+ void DuckCatalog::ScanSchemas(ClientContext &context, std::function<void(SchemaCatalogEntry &)> callback) {
103
+ schemas->Scan(GetCatalogTransaction(context),
104
+ [&](CatalogEntry &entry) { callback(entry.Cast<SchemaCatalogEntry>()); });
104
105
  }
105
106
 
106
- void DuckCatalog::ScanSchemas(std::function<void(CatalogEntry *)> callback) {
107
- schemas->Scan([&](CatalogEntry *entry) { callback(entry); });
107
+ void DuckCatalog::ScanSchemas(std::function<void(SchemaCatalogEntry &)> callback) {
108
+ schemas->Scan([&](CatalogEntry &entry) { callback(entry.Cast<SchemaCatalogEntry>()); });
108
109
  }
109
110
 
110
- SchemaCatalogEntry *DuckCatalog::GetSchema(CatalogTransaction transaction, const string &schema_name, bool if_exists,
111
- QueryErrorContext error_context) {
111
+ optional_ptr<SchemaCatalogEntry> DuckCatalog::GetSchema(CatalogTransaction transaction, const string &schema_name,
112
+ OnEntryNotFound if_not_found, QueryErrorContext error_context) {
112
113
  D_ASSERT(!schema_name.empty());
113
114
  auto entry = schemas->GetEntry(transaction, schema_name);
114
- if (!entry && !if_exists) {
115
- throw CatalogException(error_context.FormatError("Schema with name %s does not exist!", schema_name));
115
+ if (!entry) {
116
+ if (if_not_found == OnEntryNotFound::THROW_EXCEPTION) {
117
+ throw CatalogException(error_context.FormatError("Schema with name %s does not exist!", schema_name));
118
+ }
119
+ return nullptr;
116
120
  }
117
- return (SchemaCatalogEntry *)entry;
121
+ return &entry->Cast<SchemaCatalogEntry>();
118
122
  }
119
123
 
120
124
  DatabaseSize DuckCatalog::GetDatabaseSize(ClientContext &context) {
@@ -8,7 +8,7 @@ string SimilarCatalogEntry::GetQualifiedName(bool qualify_catalog, bool qualify_
8
8
  D_ASSERT(Found());
9
9
  string result;
10
10
  if (qualify_catalog) {
11
- result += schema->catalog->GetName();
11
+ result += schema->catalog.GetName();
12
12
  }
13
13
  if (qualify_schema) {
14
14
  if (!result.empty()) {
@@ -9,7 +9,7 @@
9
9
  namespace duckdb {
10
10
 
11
11
  template <class OP, class RETURN_TYPE, typename... ARGS>
12
- RETURN_TYPE RadixBitsSwitch(idx_t radix_bits, ARGS &&...args) {
12
+ RETURN_TYPE RadixBitsSwitch(idx_t radix_bits, ARGS &&... args) {
13
13
  D_ASSERT(radix_bits <= sizeof(hash_t) * 8);
14
14
  switch (radix_bits) {
15
15
  case 1: