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
@@ -20,7 +20,7 @@ string LogicalGet::GetName() const {
20
20
  return StringUtil::Upper(function.name);
21
21
  }
22
22
 
23
- TableCatalogEntry *LogicalGet::GetTable() const {
23
+ optional_ptr<TableCatalogEntry> LogicalGet::GetTable() const {
24
24
  return TableScanFunction::GetTableEntry(function, bind_data.get());
25
25
  }
26
26
 
@@ -43,13 +43,8 @@ unique_ptr<LogicalOperator> LogicalInsert::Deserialize(LogicalDeserializationSta
43
43
 
44
44
  auto &catalog = Catalog::GetCatalog(context, INVALID_CATALOG);
45
45
 
46
- auto table_catalog_entry = catalog.GetEntry<TableCatalogEntry>(context, info->schema, info->table);
47
-
48
- if (!table_catalog_entry) {
49
- throw InternalException("Cant find catalog entry for table %s", info->table);
50
- }
51
-
52
- auto result = make_uniq<LogicalInsert>(*table_catalog_entry, table_index);
46
+ auto &table_catalog_entry = catalog.GetEntry<TableCatalogEntry>(context, info->schema, info->table);
47
+ auto result = make_uniq<LogicalInsert>(table_catalog_entry, table_index);
53
48
  result->type = state.type;
54
49
  result->return_chunk = return_chunk;
55
50
  result->insert_values = std::move(insert_values);
@@ -23,12 +23,8 @@ unique_ptr<LogicalOperator> LogicalUpdate::Deserialize(LogicalDeserializationSta
23
23
  auto info = TableCatalogEntry::Deserialize(reader.GetSource(), context);
24
24
  auto &catalog = Catalog::GetCatalog(context, INVALID_CATALOG);
25
25
 
26
- auto table_catalog_entry = catalog.GetEntry<TableCatalogEntry>(context, info->schema, info->table);
27
- if (!table_catalog_entry) {
28
- throw InternalException("Cant find catalog entry for table %s", info->table);
29
- }
30
-
31
- auto result = make_uniq<LogicalUpdate>(*table_catalog_entry);
26
+ auto &table_catalog_entry = catalog.GetEntry<TableCatalogEntry>(context, info->schema, info->table);
27
+ auto result = make_uniq<LogicalUpdate>(table_catalog_entry);
32
28
  result->table_index = reader.ReadRequired<idx_t>();
33
29
  result->return_chunk = reader.ReadRequired<bool>();
34
30
  result->columns = reader.ReadRequiredIndexList<PhysicalIndex>();
@@ -37,8 +37,8 @@ unique_ptr<BoundCreateTableInfo> BoundCreateTableInfo::Deserialize(Deserializer
37
37
  auto &context = state.context;
38
38
  auto create_info = SchemaCatalogEntry::Deserialize(source);
39
39
  auto schema_name = create_info->schema;
40
- auto schema = Catalog::GetSchema(context, INVALID_CATALOG, schema_name);
41
- auto result = make_uniq<BoundCreateTableInfo>(*schema, std::move(create_info));
40
+ auto &schema = Catalog::GetSchema(context, INVALID_CATALOG, schema_name);
41
+ auto result = make_uniq<BoundCreateTableInfo>(schema, std::move(create_info));
42
42
  result->base = source.ReadOptional<CreateInfo>();
43
43
 
44
44
  source.ReadList<Constraint>(result->constraints);
@@ -70,16 +70,15 @@ void PragmaHandler::HandlePragmaStatements(ClientContextLock &lock, vector<uniqu
70
70
 
71
71
  bool PragmaHandler::HandlePragma(SQLStatement *statement, string &resulting_query) { // PragmaInfo &info
72
72
  auto info = *(statement->Cast<PragmaStatement>()).info;
73
- auto entry =
74
- Catalog::GetEntry<PragmaFunctionCatalogEntry>(context, INVALID_CATALOG, DEFAULT_SCHEMA, info.name, false);
73
+ auto &entry = Catalog::GetEntry<PragmaFunctionCatalogEntry>(context, INVALID_CATALOG, DEFAULT_SCHEMA, info.name);
75
74
  string error;
76
75
 
77
76
  FunctionBinder function_binder(context);
78
- idx_t bound_idx = function_binder.BindFunction(entry->name, entry->functions, info, error);
77
+ idx_t bound_idx = function_binder.BindFunction(entry.name, entry.functions, info, error);
79
78
  if (bound_idx == DConstants::INVALID_INDEX) {
80
79
  throw BinderException(error);
81
80
  }
82
- auto bound_function = entry->functions.GetFunctionByOffset(bound_idx);
81
+ auto bound_function = entry.functions.GetFunctionByOffset(bound_idx);
83
82
  if (bound_function.query) {
84
83
  QueryErrorContext error_context(statement, statement->stmt_location);
85
84
  Binder::BindNamedParameters(bound_function.named_parameters, info.named_parameters, error_context,
@@ -71,15 +71,15 @@ void SingleFileCheckpointWriter::CreateCheckpoint() {
71
71
  // get the id of the first meta block
72
72
  block_id_t meta_block = metadata_writer->GetBlockPointer().block_id;
73
73
 
74
- vector<SchemaCatalogEntry *> schemas;
74
+ vector<reference<SchemaCatalogEntry>> schemas;
75
75
  // we scan the set of committed schemas
76
76
  auto &catalog = (DuckCatalog &)Catalog::GetCatalog(db);
77
- catalog.ScanSchemas([&](CatalogEntry *entry) { schemas.push_back((SchemaCatalogEntry *)entry); });
77
+ catalog.ScanSchemas([&](SchemaCatalogEntry &entry) { schemas.push_back(entry); });
78
78
  // write the actual data into the database
79
79
  // write the amount of schemas
80
80
  metadata_writer->Write<uint32_t>(schemas.size());
81
81
  for (auto &schema : schemas) {
82
- WriteSchema(*schema);
82
+ WriteSchema(schema.get());
83
83
  }
84
84
  partial_block_manager.FlushPartialBlocks();
85
85
  // flush the meta data to disk
@@ -150,58 +150,58 @@ void CheckpointWriter::WriteSchema(SchemaCatalogEntry &schema) {
150
150
  // then, we fetch the tables/views/sequences information
151
151
  vector<reference<TableCatalogEntry>> tables;
152
152
  vector<reference<ViewCatalogEntry>> views;
153
- schema.Scan(CatalogType::TABLE_ENTRY, [&](CatalogEntry *entry) {
154
- if (entry->internal) {
153
+ schema.Scan(CatalogType::TABLE_ENTRY, [&](CatalogEntry &entry) {
154
+ if (entry.internal) {
155
155
  return;
156
156
  }
157
- if (entry->type == CatalogType::TABLE_ENTRY) {
158
- tables.push_back(entry->Cast<TableCatalogEntry>());
159
- } else if (entry->type == CatalogType::VIEW_ENTRY) {
160
- views.push_back(entry->Cast<ViewCatalogEntry>());
157
+ if (entry.type == CatalogType::TABLE_ENTRY) {
158
+ tables.push_back(entry.Cast<TableCatalogEntry>());
159
+ } else if (entry.type == CatalogType::VIEW_ENTRY) {
160
+ views.push_back(entry.Cast<ViewCatalogEntry>());
161
161
  } else {
162
162
  throw NotImplementedException("Catalog type for entries");
163
163
  }
164
164
  });
165
165
  vector<reference<SequenceCatalogEntry>> sequences;
166
- schema.Scan(CatalogType::SEQUENCE_ENTRY, [&](CatalogEntry *entry) {
167
- if (entry->internal) {
166
+ schema.Scan(CatalogType::SEQUENCE_ENTRY, [&](CatalogEntry &entry) {
167
+ if (entry.internal) {
168
168
  return;
169
169
  }
170
- sequences.push_back(entry->Cast<SequenceCatalogEntry>());
170
+ sequences.push_back(entry.Cast<SequenceCatalogEntry>());
171
171
  });
172
172
 
173
173
  vector<reference<TypeCatalogEntry>> custom_types;
174
- schema.Scan(CatalogType::TYPE_ENTRY, [&](CatalogEntry *entry) {
175
- if (entry->internal) {
174
+ schema.Scan(CatalogType::TYPE_ENTRY, [&](CatalogEntry &entry) {
175
+ if (entry.internal) {
176
176
  return;
177
177
  }
178
- custom_types.push_back(entry->Cast<TypeCatalogEntry>());
178
+ custom_types.push_back(entry.Cast<TypeCatalogEntry>());
179
179
  });
180
180
 
181
181
  vector<reference<ScalarMacroCatalogEntry>> macros;
182
- schema.Scan(CatalogType::SCALAR_FUNCTION_ENTRY, [&](CatalogEntry *entry) {
183
- if (entry->internal) {
182
+ schema.Scan(CatalogType::SCALAR_FUNCTION_ENTRY, [&](CatalogEntry &entry) {
183
+ if (entry.internal) {
184
184
  return;
185
185
  }
186
- if (entry->type == CatalogType::MACRO_ENTRY) {
187
- macros.push_back(entry->Cast<ScalarMacroCatalogEntry>());
186
+ if (entry.type == CatalogType::MACRO_ENTRY) {
187
+ macros.push_back(entry.Cast<ScalarMacroCatalogEntry>());
188
188
  }
189
189
  });
190
190
 
191
191
  vector<reference<TableMacroCatalogEntry>> table_macros;
192
- schema.Scan(CatalogType::TABLE_FUNCTION_ENTRY, [&](CatalogEntry *entry) {
193
- if (entry->internal) {
192
+ schema.Scan(CatalogType::TABLE_FUNCTION_ENTRY, [&](CatalogEntry &entry) {
193
+ if (entry.internal) {
194
194
  return;
195
195
  }
196
- if (entry->type == CatalogType::TABLE_MACRO_ENTRY) {
197
- table_macros.push_back(entry->Cast<TableMacroCatalogEntry>());
196
+ if (entry.type == CatalogType::TABLE_MACRO_ENTRY) {
197
+ table_macros.push_back(entry.Cast<TableMacroCatalogEntry>());
198
198
  }
199
199
  });
200
200
 
201
201
  vector<reference<IndexCatalogEntry>> indexes;
202
- schema.Scan(CatalogType::INDEX_ENTRY, [&](CatalogEntry *entry) {
203
- D_ASSERT(!entry->internal);
204
- indexes.push_back(entry->Cast<IndexCatalogEntry>());
202
+ schema.Scan(CatalogType::INDEX_ENTRY, [&](CatalogEntry &entry) {
203
+ D_ASSERT(!entry.internal);
204
+ indexes.push_back(entry.Cast<IndexCatalogEntry>());
205
205
  });
206
206
 
207
207
  FieldWriter writer(GetMetaBlockWriter());
@@ -254,7 +254,7 @@ void CheckpointReader::ReadSchema(ClientContext &context, MetaBlockReader &reade
254
254
  auto info = SchemaCatalogEntry::Deserialize(reader);
255
255
  // we set create conflict to ignore to ignore the failure of recreating the main schema
256
256
  info->on_conflict = OnCreateConflict::IGNORE_ON_CONFLICT;
257
- catalog.CreateSchema(context, info.get());
257
+ catalog.CreateSchema(context, *info);
258
258
 
259
259
  // first read all the counts
260
260
  FieldReader field_reader(reader);
@@ -307,7 +307,7 @@ void CheckpointWriter::WriteView(ViewCatalogEntry &view) {
307
307
 
308
308
  void CheckpointReader::ReadView(ClientContext &context, MetaBlockReader &reader) {
309
309
  auto info = ViewCatalogEntry::Deserialize(reader, context);
310
- catalog.CreateView(context, info.get());
310
+ catalog.CreateView(context, *info);
311
311
  }
312
312
 
313
313
  //===--------------------------------------------------------------------===//
@@ -319,7 +319,7 @@ void CheckpointWriter::WriteSequence(SequenceCatalogEntry &seq) {
319
319
 
320
320
  void CheckpointReader::ReadSequence(ClientContext &context, MetaBlockReader &reader) {
321
321
  auto info = SequenceCatalogEntry::Deserialize(reader);
322
- catalog.CreateSequence(context, info.get());
322
+ catalog.CreateSequence(context, *info);
323
323
  }
324
324
 
325
325
  //===--------------------------------------------------------------------===//
@@ -338,30 +338,32 @@ void CheckpointWriter::WriteIndex(IndexCatalogEntry &index_catalog) {
338
338
 
339
339
  void CheckpointReader::ReadIndex(ClientContext &context, MetaBlockReader &reader) {
340
340
 
341
- // Deserialize the index meta data
341
+ // deserialize the index metadata
342
342
  auto info = IndexCatalogEntry::Deserialize(reader, context);
343
343
 
344
- // Create index in the catalog
345
- auto schema_catalog = catalog.GetSchema(context, info->schema);
346
- auto table_catalog =
347
- (DuckTableEntry *)catalog.GetEntry(context, CatalogType::TABLE_ENTRY, info->schema, info->table->table_name);
348
- auto index_catalog = (DuckIndexEntry *)schema_catalog->CreateIndex(context, info.get(), table_catalog);
349
- index_catalog->info = table_catalog->GetStorage().info;
350
- // Here we just gotta read the root node
344
+ // create the index in the catalog
345
+ auto &schema_catalog = catalog.GetSchema(context, info->schema);
346
+ auto &table_catalog = catalog.GetEntry(context, CatalogType::TABLE_ENTRY, info->schema, info->table->table_name)
347
+ .Cast<DuckTableEntry>();
348
+ auto &index_catalog = schema_catalog.CreateIndex(context, *info, table_catalog)->Cast<DuckIndexEntry>();
349
+ index_catalog.info = table_catalog.GetStorage().info;
350
+
351
+ // we deserialize the index lazily, i.e., we do not need to load any node information
352
+ // except the root block id and offset
351
353
  auto root_block_id = reader.Read<block_id_t>();
352
354
  auto root_offset = reader.Read<uint32_t>();
353
355
 
354
- // create an adaptive radix tree around the expressions
356
+ // obtain the expressions of the ART from the index metadata
355
357
  vector<unique_ptr<Expression>> unbound_expressions;
356
358
  vector<unique_ptr<ParsedExpression>> parsed_expressions;
357
-
358
359
  for (auto &p_exp : info->parsed_expressions) {
359
360
  parsed_expressions.push_back(p_exp->Copy());
360
361
  }
361
362
 
363
+ // bind the parsed expressions
362
364
  auto binder = Binder::CreateBinder(context);
363
- auto table_ref = (TableRef *)info->table.get();
364
- auto bound_table = binder->Bind(*table_ref);
365
+ auto &table_ref = info->table->Cast<TableRef>();
366
+ auto bound_table = binder->Bind(table_ref);
365
367
  D_ASSERT(bound_table->type == TableReferenceType::BASE_TABLE);
366
368
  IndexBinder idx_binder(*binder, context);
367
369
  unbound_expressions.reserve(parsed_expressions.size());
@@ -370,27 +372,27 @@ void CheckpointReader::ReadIndex(ClientContext &context, MetaBlockReader &reader
370
372
  }
371
373
 
372
374
  if (parsed_expressions.empty()) {
373
- // If no parsed_expressions are present, this means this is a PK/FK index, so we create the necessary bound
374
- // column refs
375
+ // this is a PK/FK index: we create the necessary bound column ref expressions
375
376
  unbound_expressions.reserve(info->column_ids.size());
376
377
  for (idx_t key_nr = 0; key_nr < info->column_ids.size(); key_nr++) {
377
- auto &col = table_catalog->GetColumn(LogicalIndex(info->column_ids[key_nr]));
378
+ auto &col = table_catalog.GetColumn(LogicalIndex(info->column_ids[key_nr]));
378
379
  unbound_expressions.push_back(
379
380
  make_uniq<BoundColumnRefExpression>(col.GetName(), col.GetType(), ColumnBinding(0, key_nr)));
380
381
  }
381
382
  }
382
383
 
384
+ // create the index and add it to the storage
383
385
  switch (info->index_type) {
384
386
  case IndexType::ART: {
385
- auto &storage = table_catalog->GetStorage();
387
+ auto &storage = table_catalog.GetStorage();
386
388
  auto art = make_uniq<ART>(info->column_ids, TableIOManager::Get(storage), std::move(unbound_expressions),
387
- info->constraint_type, storage.db, true, root_block_id, root_offset);
388
- index_catalog->index = art.get();
389
+ info->constraint_type, storage.db, root_block_id, root_offset);
390
+ index_catalog.index = art.get();
389
391
  storage.info->indexes.AddIndex(std::move(art));
390
392
  break;
391
393
  }
392
394
  default:
393
- throw InternalException("Can't read this index type");
395
+ throw InternalException("Unknown index type for ReadIndex");
394
396
  }
395
397
  }
396
398
 
@@ -403,9 +405,9 @@ void CheckpointWriter::WriteType(TypeCatalogEntry &type) {
403
405
 
404
406
  void CheckpointReader::ReadType(ClientContext &context, MetaBlockReader &reader) {
405
407
  auto info = TypeCatalogEntry::Deserialize(reader);
406
- auto catalog_entry = (TypeCatalogEntry *)catalog.CreateType(context, info.get());
408
+ auto &catalog_entry = catalog.CreateType(context, *info)->Cast<TypeCatalogEntry>();
407
409
  if (info->type.id() == LogicalTypeId::ENUM) {
408
- EnumType::SetCatalog(info->type, catalog_entry);
410
+ EnumType::SetCatalog(info->type, &catalog_entry);
409
411
  }
410
412
  }
411
413
 
@@ -418,7 +420,7 @@ void CheckpointWriter::WriteMacro(ScalarMacroCatalogEntry &macro) {
418
420
 
419
421
  void CheckpointReader::ReadMacro(ClientContext &context, MetaBlockReader &reader) {
420
422
  auto info = ScalarMacroCatalogEntry::Deserialize(reader, context);
421
- catalog.CreateFunction(context, info.get());
423
+ catalog.CreateFunction(context, *info);
422
424
  }
423
425
 
424
426
  void CheckpointWriter::WriteTableMacro(TableMacroCatalogEntry &macro) {
@@ -427,7 +429,7 @@ void CheckpointWriter::WriteTableMacro(TableMacroCatalogEntry &macro) {
427
429
 
428
430
  void CheckpointReader::ReadTableMacro(ClientContext &context, MetaBlockReader &reader) {
429
431
  auto info = TableMacroCatalogEntry::Deserialize(reader, context);
430
- catalog.CreateFunction(context, info.get());
432
+ catalog.CreateFunction(context, *info);
431
433
  }
432
434
 
433
435
  //===--------------------------------------------------------------------===//
@@ -447,14 +449,14 @@ void CheckpointReader::ReadTable(ClientContext &context, MetaBlockReader &reader
447
449
  auto info = TableCatalogEntry::Deserialize(reader, context);
448
450
  // bind the info
449
451
  auto binder = Binder::CreateBinder(context);
450
- auto schema = catalog.GetSchema(context, info->schema);
451
- auto bound_info = binder->BindCreateTableInfo(std::move(info), *schema);
452
+ auto &schema = catalog.GetSchema(context, info->schema);
453
+ auto bound_info = binder->BindCreateTableInfo(std::move(info), schema);
452
454
 
453
455
  // now read the actual table data and place it into the create table info
454
456
  ReadTableData(context, reader, *bound_info);
455
457
 
456
458
  // finally create the table in the catalog
457
- catalog.CreateTable(context, bound_info.get());
459
+ catalog.CreateTable(context, *bound_info);
458
460
  }
459
461
 
460
462
  void CheckpointReader::ReadTableData(ClientContext &context, MetaBlockReader &reader,
@@ -397,14 +397,11 @@ void DataTable::VerifyForeignKeyConstraint(const BoundForeignKeyConstraint &bfk,
397
397
  dst_keys_ptr = &bfk.info.fk_keys;
398
398
  }
399
399
 
400
- auto table_entry_ptr =
400
+ auto &table_entry_ptr =
401
401
  Catalog::GetEntry<TableCatalogEntry>(context, INVALID_CATALOG, bfk.info.schema, bfk.info.table);
402
- if (table_entry_ptr == nullptr) {
403
- throw InternalException("Can't find table \"%s\" in foreign key constraint", bfk.info.table);
404
- }
405
402
  // make the data chunk to check
406
403
  vector<LogicalType> types;
407
- for (auto &col : table_entry_ptr->GetColumns().Physical()) {
404
+ for (auto &col : table_entry_ptr.GetColumns().Physical()) {
408
405
  types.emplace_back(col.Type());
409
406
  }
410
407
  DataChunk dst_chunk;
@@ -413,7 +410,7 @@ void DataTable::VerifyForeignKeyConstraint(const BoundForeignKeyConstraint &bfk,
413
410
  dst_chunk.data[(*dst_keys_ptr)[i].index].Reference(chunk.data[(*src_keys_ptr)[i].index]);
414
411
  }
415
412
  dst_chunk.SetCardinality(chunk.size());
416
- auto &data_table = table_entry_ptr->GetStorage();
413
+ auto &data_table = table_entry_ptr.GetStorage();
417
414
 
418
415
  idx_t count = dst_chunk.size();
419
416
  if (count <= 0) {
@@ -1165,9 +1162,7 @@ void DataTable::WALAddIndex(ClientContext &context, unique_ptr<Index> index,
1165
1162
 
1166
1163
  auto &allocator = Allocator::Get(db);
1167
1164
 
1168
- DataChunk result;
1169
- result.Initialize(allocator, index->logical_types);
1170
-
1165
+ // intermediate holds scanned chunks of the underlying data to create the index
1171
1166
  DataChunk intermediate;
1172
1167
  vector<LogicalType> intermediate_types;
1173
1168
  auto column_ids = index->column_ids;
@@ -1179,6 +1174,10 @@ void DataTable::WALAddIndex(ClientContext &context, unique_ptr<Index> index,
1179
1174
  intermediate_types.emplace_back(LogicalType::ROW_TYPE);
1180
1175
  intermediate.Initialize(allocator, intermediate_types);
1181
1176
 
1177
+ // holds the result of executing the index expression on the intermediate chunks
1178
+ DataChunk result;
1179
+ result.Initialize(allocator, index->logical_types);
1180
+
1182
1181
  // initialize an index scan
1183
1182
  CreateIndexScanState state;
1184
1183
  InitializeWALCreateIndexScan(state, column_ids);
@@ -1212,6 +1211,7 @@ void DataTable::WALAddIndex(ClientContext &context, unique_ptr<Index> index,
1212
1211
  }
1213
1212
  }
1214
1213
  }
1214
+
1215
1215
  info->indexes.AddIndex(std::move(index));
1216
1216
  }
1217
1217
 
@@ -10,10 +10,10 @@ namespace duckdb {
10
10
 
11
11
  Index::Index(AttachedDatabase &db, IndexType type, TableIOManager &table_io_manager,
12
12
  const vector<column_t> &column_ids_p, const vector<unique_ptr<Expression>> &unbound_expressions,
13
- IndexConstraintType constraint_type_p, bool track_memory)
13
+ IndexConstraintType constraint_type_p)
14
14
 
15
15
  : type(type), table_io_manager(table_io_manager), column_ids(column_ids_p), constraint_type(constraint_type_p),
16
- db(db), buffer_manager(BufferManager::GetBufferManager(db)), memory_size(0), track_memory(track_memory) {
16
+ db(db), buffer_manager(BufferManager::GetBufferManager(db)) {
17
17
 
18
18
  for (auto &expr : unbound_expressions) {
19
19
  types.push_back(expr->return_type.InternalType());
@@ -49,19 +49,31 @@ void Index::Delete(DataChunk &entries, Vector &row_identifiers) {
49
49
  }
50
50
 
51
51
  bool Index::MergeIndexes(Index &other_index) {
52
+
52
53
  IndexLock state;
53
54
  InitializeLock(state);
54
55
 
55
56
  switch (this->type) {
56
- case IndexType::ART: {
57
- auto &art = Cast<ART>();
58
- return art.MergeIndexes(state, other_index);
59
- }
57
+ case IndexType::ART:
58
+ return Cast<ART>().MergeIndexes(state, other_index);
60
59
  default:
61
60
  throw InternalException("Unimplemented index type for merge");
62
61
  }
63
62
  }
64
63
 
64
+ void Index::Vacuum() {
65
+
66
+ IndexLock state;
67
+ InitializeLock(state);
68
+
69
+ switch (this->type) {
70
+ case IndexType::ART:
71
+ return Cast<ART>().Vacuum(state);
72
+ default:
73
+ throw InternalException("Unimplemented index type for vacuum");
74
+ }
75
+ }
76
+
65
77
  void Index::ExecuteExpressions(DataChunk &input, DataChunk &result) {
66
78
  executor.Execute(input, result);
67
79
  }
@@ -118,6 +118,7 @@ LocalTableStorage::LocalTableStorage(DataTable &table)
118
118
  row_groups = make_shared<RowGroupCollection>(table.info, TableIOManager::Get(table).GetBlockManagerForRowData(),
119
119
  types, MAX_ROW_ID, 0);
120
120
  row_groups->InitializeEmpty();
121
+
121
122
  table.info->indexes.Scan([&](Index &index) {
122
123
  D_ASSERT(index.type == IndexType::ART);
123
124
  auto &art = index.Cast<ART>();
@@ -129,7 +130,7 @@ LocalTableStorage::LocalTableStorage(DataTable &table)
129
130
  unbound_expressions.push_back(expr->Copy());
130
131
  }
131
132
  indexes.AddIndex(make_uniq<ART>(art.column_ids, art.table_io_manager, std::move(unbound_expressions),
132
- art.constraint_type, art.db, true));
133
+ art.constraint_type, art.db));
133
134
  }
134
135
  return false;
135
136
  });
@@ -520,6 +521,12 @@ void LocalStorage::Flush(DataTable &table, LocalTableStorage &storage) {
520
521
  storage.AppendToIndexes(transaction, append_state, append_count, true);
521
522
  }
522
523
  transaction.PushAppend(table, append_state.row_start, append_count);
524
+
525
+ // possibly vacuum any excess index data
526
+ table.info->indexes.Scan([&](Index &index) {
527
+ index.Vacuum();
528
+ return false;
529
+ });
523
530
  }
524
531
 
525
532
  void LocalStorage::Commit(LocalStorage::CommitState &commit_state, DuckTransaction &transaction) {
@@ -531,7 +538,6 @@ void LocalStorage::Commit(LocalStorage::CommitState &commit_state, DuckTransacti
531
538
  auto table = entry.first;
532
539
  auto storage = entry.second.get();
533
540
  Flush(table, *storage);
534
-
535
541
  entry.second.reset();
536
542
  }
537
543
  }
@@ -229,15 +229,6 @@ void StandardBufferManager::Unpin(shared_ptr<BlockHandle> &handle) {
229
229
  }
230
230
  }
231
231
 
232
- // POTENTIALLY PROBLEMATIC
233
- void StandardBufferManager::IncreaseUsedMemory(idx_t size, bool unsafe) {
234
- ReserveMemory(size);
235
- }
236
-
237
- void StandardBufferManager::DecreaseUsedMemory(idx_t size) {
238
- FreeReservedMemory(size);
239
- }
240
-
241
232
  void StandardBufferManager::SetLimit(idx_t limit) {
242
233
  buffer_pool.SetLimit(limit, InMemoryWarning());
243
234
  }
@@ -1138,7 +1138,7 @@ void UpdateSegment::Update(TransactionData transaction, idx_t column_index, Vect
1138
1138
  if (!node) {
1139
1139
  // no updates made yet by this transaction: initially the update info to empty
1140
1140
  if (transaction.transaction) {
1141
- auto &dtransaction = (DuckTransaction &)*transaction.transaction;
1141
+ auto &dtransaction = transaction.transaction->Cast<DuckTransaction>();
1142
1142
  node = dtransaction.CreateUpdateInfo(type_size, count);
1143
1143
  } else {
1144
1144
  node = CreateEmptyUpdateInfo(transaction, type_size, count, update_info_data);