duckdb 0.6.2-dev781.0 → 0.6.2-dev891.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 (320) hide show
  1. package/binding.gyp +1 -1
  2. package/package.json +1 -1
  3. package/src/connection.cpp +2 -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 +1 -1
  9. package/src/duckdb/extension/icu/icu-makedate.cpp +1 -1
  10. package/src/duckdb/extension/icu/icu-strptime.cpp +2 -2
  11. package/src/duckdb/extension/icu/icu-timezone.cpp +6 -5
  12. package/src/duckdb/extension/json/json-extension.cpp +1 -1
  13. package/src/duckdb/extension/parquet/column_reader.cpp +7 -0
  14. package/src/duckdb/extension/parquet/parquet-extension.cpp +1 -1
  15. package/src/duckdb/src/catalog/catalog.cpp +516 -177
  16. package/src/duckdb/src/catalog/catalog_entry/index_catalog_entry.cpp +1 -0
  17. package/src/duckdb/src/catalog/catalog_entry/schema_catalog_entry.cpp +66 -49
  18. package/src/duckdb/src/catalog/catalog_entry/table_catalog_entry.cpp +15 -16
  19. package/src/duckdb/src/catalog/catalog_entry/view_catalog_entry.cpp +1 -1
  20. package/src/duckdb/src/catalog/catalog_entry.cpp +6 -2
  21. package/src/duckdb/src/catalog/catalog_search_path.cpp +177 -22
  22. package/src/duckdb/src/catalog/catalog_set.cpp +134 -72
  23. package/src/duckdb/src/catalog/catalog_transaction.cpp +28 -0
  24. package/src/duckdb/src/catalog/default/default_views.cpp +4 -4
  25. package/src/duckdb/src/catalog/dependency_list.cpp +13 -0
  26. package/src/duckdb/src/catalog/dependency_manager.cpp +19 -13
  27. package/src/duckdb/src/common/constants.cpp +8 -0
  28. package/src/duckdb/src/common/enums/catalog_type.cpp +2 -0
  29. package/src/duckdb/src/common/enums/logical_operator_type.cpp +2 -0
  30. package/src/duckdb/src/common/enums/physical_operator_type.cpp +2 -0
  31. package/src/duckdb/src/common/enums/statement_type.cpp +2 -0
  32. package/src/duckdb/src/common/file_system.cpp +1 -1
  33. package/src/duckdb/src/common/string_util.cpp +5 -1
  34. package/src/duckdb/src/execution/index/art/art.cpp +1 -1
  35. package/src/duckdb/src/execution/operator/helper/physical_transaction.cpp +1 -0
  36. package/src/duckdb/src/execution/operator/join/physical_index_join.cpp +1 -1
  37. package/src/duckdb/src/execution/operator/persistent/physical_batch_insert.cpp +3 -2
  38. package/src/duckdb/src/execution/operator/persistent/physical_delete.cpp +1 -1
  39. package/src/duckdb/src/execution/operator/persistent/physical_export.cpp +1 -1
  40. package/src/duckdb/src/execution/operator/persistent/physical_insert.cpp +4 -3
  41. package/src/duckdb/src/execution/operator/schema/physical_alter.cpp +1 -1
  42. package/src/duckdb/src/execution/operator/schema/physical_attach.cpp +72 -0
  43. package/src/duckdb/src/execution/operator/schema/physical_create_function.cpp +2 -1
  44. package/src/duckdb/src/execution/operator/schema/physical_create_index.cpp +3 -3
  45. package/src/duckdb/src/execution/operator/schema/physical_create_schema.cpp +5 -1
  46. package/src/duckdb/src/execution/operator/schema/physical_create_sequence.cpp +2 -1
  47. package/src/duckdb/src/execution/operator/schema/physical_create_table.cpp +2 -2
  48. package/src/duckdb/src/execution/operator/schema/physical_create_type.cpp +1 -1
  49. package/src/duckdb/src/execution/operator/schema/physical_create_view.cpp +2 -1
  50. package/src/duckdb/src/execution/operator/schema/physical_drop.cpp +10 -2
  51. package/src/duckdb/src/execution/physical_plan/plan_comparison_join.cpp +4 -4
  52. package/src/duckdb/src/execution/physical_plan/plan_create_index.cpp +1 -1
  53. package/src/duckdb/src/execution/physical_plan/plan_create_table.cpp +2 -3
  54. package/src/duckdb/src/execution/physical_plan/plan_delete.cpp +1 -1
  55. package/src/duckdb/src/execution/physical_plan/plan_insert.cpp +1 -1
  56. package/src/duckdb/src/execution/physical_plan/plan_simple.cpp +4 -0
  57. package/src/duckdb/src/execution/physical_plan/plan_update.cpp +1 -1
  58. package/src/duckdb/src/execution/physical_plan_generator.cpp +3 -2
  59. package/src/duckdb/src/function/built_in_functions.cpp +88 -0
  60. package/src/duckdb/src/function/function.cpp +0 -79
  61. package/src/duckdb/src/function/function_binder.cpp +2 -1
  62. package/src/duckdb/src/function/pragma/pragma_queries.cpp +10 -1
  63. package/src/duckdb/src/function/scalar/date/current.cpp +2 -2
  64. package/src/duckdb/src/function/scalar/list/list_aggregates.cpp +3 -2
  65. package/src/duckdb/src/function/scalar/sequence/nextval.cpp +14 -17
  66. package/src/duckdb/src/function/scalar/system/aggregate_export.cpp +2 -2
  67. package/src/duckdb/src/function/scalar/system/system_functions.cpp +7 -4
  68. package/src/duckdb/src/function/table/checkpoint.cpp +37 -4
  69. package/src/duckdb/src/function/table/read_csv.cpp +1 -1
  70. package/src/duckdb/src/function/table/system/duckdb_columns.cpp +32 -25
  71. package/src/duckdb/src/function/table/system/duckdb_constraints.cpp +26 -22
  72. package/src/duckdb/src/function/table/system/duckdb_dependencies.cpp +1 -1
  73. package/src/duckdb/src/function/table/system/duckdb_extensions.cpp +1 -1
  74. package/src/duckdb/src/function/table/system/duckdb_functions.cpp +22 -15
  75. package/src/duckdb/src/function/table/system/duckdb_indexes.cpp +25 -18
  76. package/src/duckdb/src/function/table/system/duckdb_schemas.cpp +16 -8
  77. package/src/duckdb/src/function/table/system/duckdb_sequences.cpp +26 -19
  78. package/src/duckdb/src/function/table/system/duckdb_tables.cpp +24 -17
  79. package/src/duckdb/src/function/table/system/duckdb_types.cpp +22 -16
  80. package/src/duckdb/src/function/table/system/duckdb_views.cpp +20 -13
  81. package/src/duckdb/src/function/table/system/pragma_collations.cpp +3 -4
  82. package/src/duckdb/src/function/table/system/pragma_database_list.cpp +20 -12
  83. package/src/duckdb/src/function/table/system/pragma_database_size.cpp +39 -24
  84. package/src/duckdb/src/function/table/system/pragma_storage_info.cpp +1 -7
  85. package/src/duckdb/src/function/table/system/pragma_table_info.cpp +3 -2
  86. package/src/duckdb/src/function/table/system_functions.cpp +0 -1
  87. package/src/duckdb/src/function/table/table_scan.cpp +13 -10
  88. package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
  89. package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +102 -81
  90. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/aggregate_function_catalog_entry.hpp +4 -0
  91. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/collate_catalog_entry.hpp +4 -0
  92. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/copy_function_catalog_entry.hpp +4 -0
  93. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/index_catalog_entry.hpp +4 -0
  94. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/pragma_function_catalog_entry.hpp +4 -0
  95. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/scalar_function_catalog_entry.hpp +4 -0
  96. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/scalar_macro_catalog_entry.hpp +4 -0
  97. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/schema_catalog_entry.hpp +21 -14
  98. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/sequence_catalog_entry.hpp +4 -0
  99. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_catalog_entry.hpp +4 -0
  100. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_function_catalog_entry.hpp +4 -0
  101. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_macro_catalog_entry.hpp +4 -0
  102. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/type_catalog_entry.hpp +4 -0
  103. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/view_catalog_entry.hpp +4 -0
  104. package/src/duckdb/src/include/duckdb/catalog/catalog_entry.hpp +2 -0
  105. package/src/duckdb/src/include/duckdb/catalog/catalog_search_path.hpp +30 -11
  106. package/src/duckdb/src/include/duckdb/catalog/catalog_set.hpp +35 -20
  107. package/src/duckdb/src/include/duckdb/catalog/catalog_transaction.hpp +32 -0
  108. package/src/duckdb/src/include/duckdb/catalog/dependency_list.hpp +27 -0
  109. package/src/duckdb/src/include/duckdb/catalog/dependency_manager.hpp +6 -4
  110. package/src/duckdb/src/include/duckdb/common/allocator.hpp +3 -0
  111. package/src/duckdb/src/include/duckdb/common/constants.hpp +8 -3
  112. package/src/duckdb/src/include/duckdb/common/enums/catalog_type.hpp +1 -0
  113. package/src/duckdb/src/include/duckdb/common/enums/logical_operator_type.hpp +1 -0
  114. package/src/duckdb/src/include/duckdb/common/enums/physical_operator_type.hpp +1 -0
  115. package/src/duckdb/src/include/duckdb/common/enums/statement_type.hpp +10 -4
  116. package/src/duckdb/src/include/duckdb/common/file_system.hpp +2 -0
  117. package/src/duckdb/src/include/duckdb/common/string_util.hpp +3 -0
  118. package/src/duckdb/src/include/duckdb/execution/index/art/art.hpp +2 -2
  119. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_attach.hpp +33 -0
  120. package/src/duckdb/src/include/duckdb/execution/physical_plan_generator.hpp +2 -1
  121. package/src/duckdb/src/include/duckdb/function/aggregate/algebraic_functions.hpp +1 -0
  122. package/src/duckdb/src/include/duckdb/function/aggregate/distributive_functions.hpp +1 -0
  123. package/src/duckdb/src/include/duckdb/function/aggregate/holistic_functions.hpp +1 -0
  124. package/src/duckdb/src/include/duckdb/function/aggregate/nested_functions.hpp +1 -0
  125. package/src/duckdb/src/include/duckdb/function/aggregate/regression_functions.hpp +1 -0
  126. package/src/duckdb/src/include/duckdb/function/built_in_functions.hpp +78 -0
  127. package/src/duckdb/src/include/duckdb/function/function.hpp +0 -61
  128. package/src/duckdb/src/include/duckdb/function/function_serialization.hpp +1 -2
  129. package/src/duckdb/src/include/duckdb/function/pragma/pragma_functions.hpp +1 -0
  130. package/src/duckdb/src/include/duckdb/function/scalar/blob_functions.hpp +1 -0
  131. package/src/duckdb/src/include/duckdb/function/scalar/date_functions.hpp +1 -0
  132. package/src/duckdb/src/include/duckdb/function/scalar/enum_functions.hpp +1 -0
  133. package/src/duckdb/src/include/duckdb/function/scalar/generic_functions.hpp +1 -0
  134. package/src/duckdb/src/include/duckdb/function/scalar/math_functions.hpp +1 -0
  135. package/src/duckdb/src/include/duckdb/function/scalar/nested_functions.hpp +1 -0
  136. package/src/duckdb/src/include/duckdb/function/scalar/operators.hpp +1 -0
  137. package/src/duckdb/src/include/duckdb/function/scalar/regexp.hpp +1 -0
  138. package/src/duckdb/src/include/duckdb/function/scalar/sequence_functions.hpp +1 -0
  139. package/src/duckdb/src/include/duckdb/function/scalar/string_functions.hpp +1 -0
  140. package/src/duckdb/src/include/duckdb/function/scalar/trigonometric_functions.hpp +1 -0
  141. package/src/duckdb/src/include/duckdb/function/scalar/uuid_functions.hpp +1 -0
  142. package/src/duckdb/src/include/duckdb/function/scalar_function.hpp +2 -1
  143. package/src/duckdb/src/include/duckdb/function/table/arrow.hpp +1 -0
  144. package/src/duckdb/src/include/duckdb/function/table/range.hpp +1 -0
  145. package/src/duckdb/src/include/duckdb/function/table/read_csv.hpp +1 -0
  146. package/src/duckdb/src/include/duckdb/function/table/summary.hpp +1 -0
  147. package/src/duckdb/src/include/duckdb/function/table/system_functions.hpp +1 -4
  148. package/src/duckdb/src/include/duckdb/function/table/table_scan.hpp +1 -0
  149. package/src/duckdb/src/include/duckdb/function/table_function.hpp +2 -1
  150. package/src/duckdb/src/include/duckdb/main/attached_database.hpp +64 -0
  151. package/src/duckdb/src/include/duckdb/main/client_context.hpp +3 -3
  152. package/src/duckdb/src/include/duckdb/main/client_data.hpp +2 -1
  153. package/src/duckdb/src/include/duckdb/main/config.hpp +3 -0
  154. package/src/duckdb/src/include/duckdb/main/database.hpp +6 -6
  155. package/src/duckdb/src/include/duckdb/main/database_manager.hpp +69 -0
  156. package/src/duckdb/src/include/duckdb/main/settings.hpp +10 -0
  157. package/src/duckdb/src/include/duckdb/main/valid_checker.hpp +2 -2
  158. package/src/duckdb/src/include/duckdb/parser/expression/function_expression.hpp +3 -1
  159. package/src/duckdb/src/include/duckdb/parser/expression/window_expression.hpp +3 -1
  160. package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_function_info.hpp +2 -2
  161. package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_info.hpp +18 -1
  162. package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_table_info.hpp +53 -56
  163. package/src/duckdb/src/include/duckdb/parser/parsed_data/attach_info.hpp +39 -0
  164. package/src/duckdb/src/include/duckdb/parser/parsed_data/copy_info.hpp +4 -1
  165. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_aggregate_function_info.hpp +3 -18
  166. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_collation_info.hpp +4 -13
  167. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_copy_function_info.hpp +3 -12
  168. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_index_info.hpp +1 -1
  169. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_info.hpp +5 -3
  170. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_pragma_function_info.hpp +3 -14
  171. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_table_function_info.hpp +3 -19
  172. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_table_info.hpp +3 -1
  173. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_view_info.hpp +7 -34
  174. package/src/duckdb/src/include/duckdb/parser/parsed_data/drop_info.hpp +7 -1
  175. package/src/duckdb/src/include/duckdb/parser/parsed_data/exported_table_data.hpp +3 -0
  176. package/src/duckdb/src/include/duckdb/parser/parser_extension.hpp +2 -2
  177. package/src/duckdb/src/include/duckdb/parser/qualified_name.hpp +10 -2
  178. package/src/duckdb/src/include/duckdb/parser/query_error_context.hpp +2 -2
  179. package/src/duckdb/src/include/duckdb/parser/statement/attach_statement.hpp +29 -0
  180. package/src/duckdb/src/include/duckdb/parser/statement/export_statement.hpp +1 -0
  181. package/src/duckdb/src/include/duckdb/parser/statement/insert_statement.hpp +2 -0
  182. package/src/duckdb/src/include/duckdb/parser/statement/list.hpp +1 -0
  183. package/src/duckdb/src/include/duckdb/parser/tableref/basetableref.hpp +4 -1
  184. package/src/duckdb/src/include/duckdb/parser/tokens.hpp +1 -0
  185. package/src/duckdb/src/include/duckdb/parser/transformer.hpp +2 -0
  186. package/src/duckdb/src/include/duckdb/planner/bind_context.hpp +2 -0
  187. package/src/duckdb/src/include/duckdb/planner/binder.hpp +11 -1
  188. package/src/duckdb/src/include/duckdb/planner/parsed_data/bound_create_table_info.hpp +2 -1
  189. package/src/duckdb/src/include/duckdb/storage/buffer_manager.hpp +1 -0
  190. package/src/duckdb/src/include/duckdb/storage/checkpoint_manager.hpp +13 -6
  191. package/src/duckdb/src/include/duckdb/storage/data_table.hpp +10 -2
  192. package/src/duckdb/src/include/duckdb/storage/single_file_block_manager.hpp +2 -2
  193. package/src/duckdb/src/include/duckdb/storage/statistics/base_statistics.hpp +2 -2
  194. package/src/duckdb/src/include/duckdb/storage/storage_manager.hpp +9 -12
  195. package/src/duckdb/src/include/duckdb/storage/table/data_table_info.hpp +3 -7
  196. package/src/duckdb/src/include/duckdb/storage/table/row_group.hpp +5 -6
  197. package/src/duckdb/src/include/duckdb/storage/write_ahead_log.hpp +9 -7
  198. package/src/duckdb/src/include/duckdb/transaction/local_storage.hpp +3 -1
  199. package/src/duckdb/src/include/duckdb/transaction/meta_transaction.hpp +64 -0
  200. package/src/duckdb/src/include/duckdb/transaction/transaction.hpp +14 -23
  201. package/src/duckdb/src/include/duckdb/transaction/transaction_context.hpp +12 -8
  202. package/src/duckdb/src/include/duckdb/transaction/transaction_manager.hpp +5 -10
  203. package/src/duckdb/src/include/duckdb/transaction/undo_buffer.hpp +1 -1
  204. package/src/duckdb/src/main/attached_database.cpp +97 -0
  205. package/src/duckdb/src/main/capi/table_function-c.cpp +1 -1
  206. package/src/duckdb/src/main/client_context.cpp +28 -22
  207. package/src/duckdb/src/main/client_data.cpp +5 -2
  208. package/src/duckdb/src/main/config.cpp +1 -0
  209. package/src/duckdb/src/main/database.cpp +54 -40
  210. package/src/duckdb/src/main/database_manager.cpp +95 -0
  211. package/src/duckdb/src/main/materialized_query_result.cpp +1 -1
  212. package/src/duckdb/src/main/prepared_statement_data.cpp +1 -2
  213. package/src/duckdb/src/main/query_result.cpp +4 -4
  214. package/src/duckdb/src/main/settings/settings.cpp +22 -6
  215. package/src/duckdb/src/main/stream_query_result.cpp +1 -1
  216. package/src/duckdb/src/parser/expression/columnref_expression.cpp +9 -3
  217. package/src/duckdb/src/parser/expression/function_expression.cpp +15 -13
  218. package/src/duckdb/src/parser/expression/window_expression.cpp +6 -4
  219. package/src/duckdb/src/parser/parsed_data/alter_function_info.cpp +7 -7
  220. package/src/duckdb/src/parser/parsed_data/alter_info.cpp +12 -2
  221. package/src/duckdb/src/parser/parsed_data/alter_table_info.cpp +96 -98
  222. package/src/duckdb/src/parser/parsed_data/create_aggregate_function_info.cpp +27 -0
  223. package/src/duckdb/src/parser/parsed_data/create_collation_info.cpp +23 -0
  224. package/src/duckdb/src/parser/parsed_data/create_copy_function_info.cpp +21 -0
  225. package/src/duckdb/src/parser/parsed_data/create_info.cpp +3 -0
  226. package/src/duckdb/src/parser/parsed_data/create_pragma_function_info.cpp +23 -0
  227. package/src/duckdb/src/parser/parsed_data/create_scalar_function_info.cpp +3 -1
  228. package/src/duckdb/src/parser/parsed_data/create_table_function_info.cpp +28 -0
  229. package/src/duckdb/src/parser/parsed_data/create_table_info.cpp +9 -3
  230. package/src/duckdb/src/parser/parsed_data/create_view_info.cpp +49 -0
  231. package/src/duckdb/src/parser/statement/attach_statement.cpp +15 -0
  232. package/src/duckdb/src/parser/statement/insert_statement.cpp +6 -2
  233. package/src/duckdb/src/parser/tableref/basetableref.cpp +9 -4
  234. package/src/duckdb/src/parser/transform/constraint/transform_constraint.cpp +15 -13
  235. package/src/duckdb/src/parser/transform/expression/transform_function.cpp +17 -7
  236. package/src/duckdb/src/parser/transform/expression/transform_operator.cpp +4 -9
  237. package/src/duckdb/src/parser/transform/helpers/nodetype_to_string.cpp +4 -0
  238. package/src/duckdb/src/parser/transform/statement/transform_alter_sequence.cpp +5 -4
  239. package/src/duckdb/src/parser/transform/statement/transform_alter_table.cpp +8 -10
  240. package/src/duckdb/src/parser/transform/statement/transform_attach.cpp +32 -0
  241. package/src/duckdb/src/parser/transform/statement/transform_checkpoint.cpp +7 -2
  242. package/src/duckdb/src/parser/transform/statement/transform_copy.cpp +1 -0
  243. package/src/duckdb/src/parser/transform/statement/transform_create_function.cpp +1 -0
  244. package/src/duckdb/src/parser/transform/statement/transform_create_schema.cpp +1 -0
  245. package/src/duckdb/src/parser/transform/statement/transform_create_sequence.cpp +1 -0
  246. package/src/duckdb/src/parser/transform/statement/transform_create_table.cpp +5 -5
  247. package/src/duckdb/src/parser/transform/statement/transform_create_table_as.cpp +1 -0
  248. package/src/duckdb/src/parser/transform/statement/transform_create_type.cpp +6 -13
  249. package/src/duckdb/src/parser/transform/statement/transform_create_view.cpp +6 -6
  250. package/src/duckdb/src/parser/transform/statement/transform_drop.cpp +11 -2
  251. package/src/duckdb/src/parser/transform/statement/transform_export.cpp +5 -1
  252. package/src/duckdb/src/parser/transform/statement/transform_insert.cpp +1 -0
  253. package/src/duckdb/src/parser/transform/statement/transform_rename.cpp +12 -36
  254. package/src/duckdb/src/parser/transform/statement/transform_show.cpp +3 -1
  255. package/src/duckdb/src/parser/transform/statement/transform_use.cpp +21 -0
  256. package/src/duckdb/src/parser/transform/tableref/transform_base_tableref.cpp +11 -3
  257. package/src/duckdb/src/parser/transformer.cpp +4 -0
  258. package/src/duckdb/src/planner/bind_context.cpp +11 -2
  259. package/src/duckdb/src/planner/binder/expression/bind_cast_expression.cpp +1 -1
  260. package/src/duckdb/src/planner/binder/expression/bind_columnref_expression.cpp +43 -13
  261. package/src/duckdb/src/planner/binder/expression/bind_comparison_expression.cpp +1 -1
  262. package/src/duckdb/src/planner/binder/expression/bind_function_expression.cpp +2 -3
  263. package/src/duckdb/src/planner/binder/expression/bind_window_expression.cpp +2 -3
  264. package/src/duckdb/src/planner/binder/statement/bind_attach.cpp +20 -0
  265. package/src/duckdb/src/planner/binder/statement/bind_copy.cpp +7 -4
  266. package/src/duckdb/src/planner/binder/statement/bind_create.cpp +79 -27
  267. package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +11 -7
  268. package/src/duckdb/src/planner/binder/statement/bind_delete.cpp +1 -1
  269. package/src/duckdb/src/planner/binder/statement/bind_drop.cpp +13 -5
  270. package/src/duckdb/src/planner/binder/statement/bind_export.cpp +6 -3
  271. package/src/duckdb/src/planner/binder/statement/bind_extension.cpp +1 -1
  272. package/src/duckdb/src/planner/binder/statement/bind_insert.cpp +3 -2
  273. package/src/duckdb/src/planner/binder/statement/bind_pragma.cpp +2 -2
  274. package/src/duckdb/src/planner/binder/statement/bind_prepare.cpp +0 -2
  275. package/src/duckdb/src/planner/binder/statement/bind_simple.cpp +11 -6
  276. package/src/duckdb/src/planner/binder/statement/bind_update.cpp +1 -1
  277. package/src/duckdb/src/planner/binder/tableref/bind_basetableref.cpp +10 -6
  278. package/src/duckdb/src/planner/binder/tableref/bind_table_function.cpp +2 -4
  279. package/src/duckdb/src/planner/binder.cpp +17 -2
  280. package/src/duckdb/src/planner/logical_operator.cpp +5 -12
  281. package/src/duckdb/src/planner/operator/logical_copy_to_file.cpp +3 -4
  282. package/src/duckdb/src/planner/operator/logical_create.cpp +1 -4
  283. package/src/duckdb/src/planner/operator/logical_create_index.cpp +2 -2
  284. package/src/duckdb/src/planner/operator/logical_delete.cpp +2 -3
  285. package/src/duckdb/src/planner/operator/logical_insert.cpp +1 -1
  286. package/src/duckdb/src/planner/operator/logical_update.cpp +1 -1
  287. package/src/duckdb/src/planner/parsed_data/bound_create_table_info.cpp +1 -1
  288. package/src/duckdb/src/planner/planner.cpp +3 -2
  289. package/src/duckdb/src/planner/pragma_handler.cpp +1 -1
  290. package/src/duckdb/src/storage/buffer_manager.cpp +5 -0
  291. package/src/duckdb/src/storage/checkpoint_manager.cpp +10 -17
  292. package/src/duckdb/src/storage/data_table.cpp +34 -24
  293. package/src/duckdb/src/storage/local_storage.cpp +7 -3
  294. package/src/duckdb/src/storage/single_file_block_manager.cpp +3 -3
  295. package/src/duckdb/src/storage/storage_manager.cpp +25 -42
  296. package/src/duckdb/src/storage/table/column_data.cpp +2 -1
  297. package/src/duckdb/src/storage/table/row_group.cpp +7 -2
  298. package/src/duckdb/src/storage/wal_replay.cpp +6 -22
  299. package/src/duckdb/src/storage/write_ahead_log.cpp +3 -3
  300. package/src/duckdb/src/transaction/meta_transaction.cpp +106 -0
  301. package/src/duckdb/src/transaction/transaction.cpp +21 -21
  302. package/src/duckdb/src/transaction/transaction_context.cpp +44 -8
  303. package/src/duckdb/src/transaction/transaction_manager.cpp +20 -20
  304. package/src/duckdb/src/transaction/undo_buffer.cpp +1 -3
  305. package/src/duckdb/third_party/libpg_query/include/nodes/nodes.hpp +2 -0
  306. package/src/duckdb/third_party/libpg_query/include/nodes/parsenodes.hpp +27 -1
  307. package/src/duckdb/third_party/libpg_query/include/parser/gram.hpp +99 -97
  308. package/src/duckdb/third_party/libpg_query/include/parser/kwlist.hpp +1 -0
  309. package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +15206 -14793
  310. package/src/duckdb/ub_src_catalog.cpp +4 -0
  311. package/src/duckdb/ub_src_execution_operator_schema.cpp +2 -0
  312. package/src/duckdb/ub_src_function.cpp +2 -0
  313. package/src/duckdb/ub_src_function_table_system.cpp +0 -2
  314. package/src/duckdb/ub_src_main.cpp +4 -0
  315. package/src/duckdb/ub_src_parser_parsed_data.cpp +12 -0
  316. package/src/duckdb/ub_src_parser_statement.cpp +2 -0
  317. package/src/duckdb/ub_src_parser_transform_statement.cpp +4 -0
  318. package/src/duckdb/ub_src_planner_binder_statement.cpp +2 -0
  319. package/src/duckdb/ub_src_transaction.cpp +2 -0
  320. package/src/duckdb/src/function/table/system/pragma_functions.cpp +0 -120
@@ -11,9 +11,11 @@
11
11
  #include "duckdb/catalog/catalog_entry.hpp"
12
12
  #include "duckdb/common/mutex.hpp"
13
13
  #include "duckdb/parser/query_error_context.hpp"
14
+ #include "duckdb/catalog/catalog_transaction.hpp"
15
+ #include "duckdb/common/unordered_set.hpp"
16
+ #include "duckdb/common/atomic.hpp"
14
17
 
15
18
  #include <functional>
16
- #include "duckdb/common/atomic.hpp"
17
19
 
18
20
  namespace duckdb {
19
21
  struct CreateSchemaInfo;
@@ -30,6 +32,7 @@ struct CreateCollationInfo;
30
32
  struct CreateTypeInfo;
31
33
  struct CreateTableInfo;
32
34
 
35
+ class AttachedDatabase;
33
36
  class ClientContext;
34
37
  class Transaction;
35
38
 
@@ -46,40 +49,16 @@ class CatalogSet;
46
49
  class DatabaseInstance;
47
50
  class DependencyManager;
48
51
 
49
- //! Return value of Catalog::LookupEntry
50
- struct CatalogEntryLookup {
51
- SchemaCatalogEntry *schema;
52
- CatalogEntry *entry;
53
-
54
- DUCKDB_API bool Found() const {
55
- return entry;
56
- }
57
- };
58
-
59
- //! Return value of SimilarEntryInSchemas
60
- struct SimilarCatalogEntry {
61
- //! The entry name. Empty if absent
62
- string name;
63
- //! The distance to the given name.
64
- idx_t distance;
65
- //! The schema of the entry.
66
- SchemaCatalogEntry *schema;
67
-
68
- DUCKDB_API bool Found() const {
69
- return !name.empty();
70
- }
71
-
72
- DUCKDB_API string GetQualifiedName() const;
73
- };
52
+ struct CatalogLookup;
53
+ struct CatalogEntryLookup;
54
+ struct SimilarCatalogEntry;
74
55
 
75
56
  //! The Catalog object represents the catalog of the database.
76
57
  class Catalog {
77
58
  public:
78
- explicit Catalog(DatabaseInstance &db);
59
+ explicit Catalog(AttachedDatabase &db);
79
60
  ~Catalog();
80
61
 
81
- //! Reference to the database
82
- DatabaseInstance &db;
83
62
  //! The catalog set holding the schemas
84
63
  unique_ptr<CatalogSet> schemas;
85
64
  //! The DependencyManager manages dependencies between different catalog objects
@@ -88,67 +67,98 @@ public:
88
67
  mutex write_lock;
89
68
 
90
69
  public:
91
- //! Get the Catalog from the ClientContext
92
- DUCKDB_API static Catalog &GetCatalog(ClientContext &context);
93
- //! Get the Catalog from the DatabaseInstance
94
- DUCKDB_API static Catalog &GetCatalog(DatabaseInstance &db);
70
+ //! Get the SystemCatalog from the ClientContext
71
+ DUCKDB_API static Catalog &GetSystemCatalog(ClientContext &context);
72
+ //! Get the SystemCatalog from the DatabaseInstance
73
+ DUCKDB_API static Catalog &GetSystemCatalog(DatabaseInstance &db);
74
+ //! Get the specified Catalog from the ClientContext
75
+ DUCKDB_API static Catalog &GetCatalog(ClientContext &context, const string &catalog_name);
76
+ //! Get the specified Catalog from the DatabaseInstance
77
+ DUCKDB_API static Catalog &GetCatalog(DatabaseInstance &db, const string &catalog_name);
78
+ //! Get the specific Catalog from the AttachedDatabase
79
+ DUCKDB_API static Catalog &GetCatalog(AttachedDatabase &db);
95
80
 
96
81
  DUCKDB_API DependencyManager &GetDependencyManager() {
97
82
  return *dependency_manager;
98
83
  }
84
+ DUCKDB_API AttachedDatabase &GetAttached();
85
+ DUCKDB_API DatabaseInstance &GetDatabase();
86
+
87
+ void Initialize(bool load_builtin);
88
+
89
+ bool IsSystemCatalog() const;
90
+ bool IsTemporaryCatalog() const;
99
91
 
100
92
  //! Returns the current version of the catalog (incremented whenever anything changes, not stored between restarts)
101
93
  DUCKDB_API idx_t GetCatalogVersion();
102
94
  //! Trigger a modification in the catalog, increasing the catalog version and returning the previous version
103
95
  DUCKDB_API idx_t ModifyCatalog();
104
96
 
97
+ //! Returns the catalog name - based on how the catalog was attached
98
+ DUCKDB_API const string &GetName();
99
+ DUCKDB_API idx_t GetOid();
100
+
101
+ DUCKDB_API CatalogTransaction GetCatalogTransaction(ClientContext &context);
102
+
105
103
  //! Creates a schema in the catalog.
104
+ DUCKDB_API CatalogEntry *CreateSchema(CatalogTransaction transaction, CreateSchemaInfo *info);
106
105
  DUCKDB_API CatalogEntry *CreateSchema(ClientContext &context, CreateSchemaInfo *info);
107
106
  //! Creates a table in the catalog.
107
+ DUCKDB_API CatalogEntry *CreateTable(CatalogTransaction transaction, BoundCreateTableInfo *info);
108
108
  DUCKDB_API CatalogEntry *CreateTable(ClientContext &context, BoundCreateTableInfo *info);
109
109
  //! Creates a table in the catalog.
110
110
  DUCKDB_API CatalogEntry *CreateTable(ClientContext &context, unique_ptr<CreateTableInfo> info);
111
111
  //! Create a table function in the catalog
112
+ DUCKDB_API CatalogEntry *CreateTableFunction(CatalogTransaction transaction, CreateTableFunctionInfo *info);
112
113
  DUCKDB_API CatalogEntry *CreateTableFunction(ClientContext &context, CreateTableFunctionInfo *info);
113
114
  //! Create a copy function in the catalog
115
+ DUCKDB_API CatalogEntry *CreateCopyFunction(CatalogTransaction transaction, CreateCopyFunctionInfo *info);
114
116
  DUCKDB_API CatalogEntry *CreateCopyFunction(ClientContext &context, CreateCopyFunctionInfo *info);
115
117
  //! Create a pragma function in the catalog
118
+ DUCKDB_API CatalogEntry *CreatePragmaFunction(CatalogTransaction transaction, CreatePragmaFunctionInfo *info);
116
119
  DUCKDB_API CatalogEntry *CreatePragmaFunction(ClientContext &context, CreatePragmaFunctionInfo *info);
117
120
  //! Create a scalar or aggregate function in the catalog
121
+ DUCKDB_API CatalogEntry *CreateFunction(CatalogTransaction transaction, CreateFunctionInfo *info);
118
122
  DUCKDB_API CatalogEntry *CreateFunction(ClientContext &context, CreateFunctionInfo *info);
119
123
  //! Creates a table in the catalog.
124
+ DUCKDB_API CatalogEntry *CreateView(CatalogTransaction transaction, CreateViewInfo *info);
120
125
  DUCKDB_API CatalogEntry *CreateView(ClientContext &context, CreateViewInfo *info);
121
126
  //! Creates a sequence in the catalog.
127
+ DUCKDB_API CatalogEntry *CreateSequence(CatalogTransaction transaction, CreateSequenceInfo *info);
122
128
  DUCKDB_API CatalogEntry *CreateSequence(ClientContext &context, CreateSequenceInfo *info);
123
129
  //! Creates a Enum in the catalog.
130
+ DUCKDB_API CatalogEntry *CreateType(CatalogTransaction transaction, CreateTypeInfo *info);
124
131
  DUCKDB_API CatalogEntry *CreateType(ClientContext &context, CreateTypeInfo *info);
125
132
  //! Creates a collation in the catalog
133
+ DUCKDB_API CatalogEntry *CreateCollation(CatalogTransaction transaction, CreateCollationInfo *info);
126
134
  DUCKDB_API CatalogEntry *CreateCollation(ClientContext &context, CreateCollationInfo *info);
127
135
 
128
136
  //! Creates a table in the catalog.
129
- DUCKDB_API CatalogEntry *CreateTable(ClientContext &context, SchemaCatalogEntry *schema,
137
+ DUCKDB_API CatalogEntry *CreateTable(CatalogTransaction transaction, SchemaCatalogEntry *schema,
130
138
  BoundCreateTableInfo *info);
131
139
  //! Create a table function in the catalog
132
- DUCKDB_API CatalogEntry *CreateTableFunction(ClientContext &context, SchemaCatalogEntry *schema,
140
+ DUCKDB_API CatalogEntry *CreateTableFunction(CatalogTransaction transaction, SchemaCatalogEntry *schema,
133
141
  CreateTableFunctionInfo *info);
134
142
  //! Create a copy function in the catalog
135
- DUCKDB_API CatalogEntry *CreateCopyFunction(ClientContext &context, SchemaCatalogEntry *schema,
143
+ DUCKDB_API CatalogEntry *CreateCopyFunction(CatalogTransaction transaction, SchemaCatalogEntry *schema,
136
144
  CreateCopyFunctionInfo *info);
137
145
  //! Create a pragma function in the catalog
138
- DUCKDB_API CatalogEntry *CreatePragmaFunction(ClientContext &context, SchemaCatalogEntry *schema,
146
+ DUCKDB_API CatalogEntry *CreatePragmaFunction(CatalogTransaction transaction, SchemaCatalogEntry *schema,
139
147
  CreatePragmaFunctionInfo *info);
140
148
  //! Create a scalar or aggregate function in the catalog
141
- DUCKDB_API CatalogEntry *CreateFunction(ClientContext &context, SchemaCatalogEntry *schema,
149
+ DUCKDB_API CatalogEntry *CreateFunction(CatalogTransaction transaction, SchemaCatalogEntry *schema,
142
150
  CreateFunctionInfo *info);
143
151
  //! Creates a table in the catalog.
144
- DUCKDB_API CatalogEntry *CreateView(ClientContext &context, SchemaCatalogEntry *schema, CreateViewInfo *info);
152
+ DUCKDB_API CatalogEntry *CreateView(CatalogTransaction transaction, SchemaCatalogEntry *schema,
153
+ CreateViewInfo *info);
145
154
  //! Creates a table in the catalog.
146
- DUCKDB_API CatalogEntry *CreateSequence(ClientContext &context, SchemaCatalogEntry *schema,
155
+ DUCKDB_API CatalogEntry *CreateSequence(CatalogTransaction transaction, SchemaCatalogEntry *schema,
147
156
  CreateSequenceInfo *info);
148
157
  //! Creates a enum in the catalog.
149
- DUCKDB_API CatalogEntry *CreateType(ClientContext &context, SchemaCatalogEntry *schema, CreateTypeInfo *info);
158
+ DUCKDB_API CatalogEntry *CreateType(CatalogTransaction transaction, SchemaCatalogEntry *schema,
159
+ CreateTypeInfo *info);
150
160
  //! Creates a collation in the catalog
151
- DUCKDB_API CatalogEntry *CreateCollation(ClientContext &context, SchemaCatalogEntry *schema,
161
+ DUCKDB_API CatalogEntry *CreateCollation(CatalogTransaction transaction, SchemaCatalogEntry *schema,
152
162
  CreateCollationInfo *info);
153
163
 
154
164
  //! Drops an entry from the catalog
@@ -158,6 +168,12 @@ public:
158
168
  DUCKDB_API SchemaCatalogEntry *GetSchema(ClientContext &context, const string &name = DEFAULT_SCHEMA,
159
169
  bool if_exists = false,
160
170
  QueryErrorContext error_context = QueryErrorContext());
171
+ DUCKDB_API SchemaCatalogEntry *GetSchema(CatalogTransaction transaction, const string &schema_name,
172
+ bool if_exists = false,
173
+ QueryErrorContext error_context = QueryErrorContext());
174
+ DUCKDB_API static SchemaCatalogEntry *GetSchema(ClientContext &context, const string &catalog_name,
175
+ const string &schema_name, bool if_exists = false,
176
+ QueryErrorContext error_context = QueryErrorContext());
161
177
  //! Scans all the schemas in the system one-by-one, invoking the callback for each entry
162
178
  DUCKDB_API void ScanSchemas(ClientContext &context, std::function<void(CatalogEntry *)> callback);
163
179
  //! Gets the "schema.name" entry of the specified type, if if_exists=true returns nullptr if entry does not
@@ -165,16 +181,28 @@ public:
165
181
  DUCKDB_API CatalogEntry *GetEntry(ClientContext &context, CatalogType type, const string &schema,
166
182
  const string &name, bool if_exists = false,
167
183
  QueryErrorContext error_context = QueryErrorContext());
184
+ //! Gets the "catalog.schema.name" entry of the specified type, if if_exists=true returns nullptr if entry does not
185
+ //! exist, otherwise an exception is thrown
186
+ DUCKDB_API static CatalogEntry *GetEntry(ClientContext &context, CatalogType type, const string &catalog,
187
+ const string &schema, const string &name, bool if_exists = false,
188
+ QueryErrorContext error_context = QueryErrorContext());
168
189
 
169
190
  //! Gets the "schema.name" entry without a specified type, if entry does not exist an exception is thrown
170
191
  DUCKDB_API CatalogEntry *GetEntry(ClientContext &context, const string &schema, const string &name);
171
192
 
172
193
  //! Fetches a logical type from the catalog
173
- DUCKDB_API LogicalType GetType(ClientContext &context, const string &schema, const string &name);
194
+ DUCKDB_API static LogicalType GetType(ClientContext &context, const string &catalog_name, const string &schema,
195
+ const string &name);
174
196
 
175
197
  template <class T>
176
198
  T *GetEntry(ClientContext &context, const string &schema_name, const string &name, bool if_exists = false,
177
- QueryErrorContext error_context = QueryErrorContext());
199
+ QueryErrorContext error_context = QueryErrorContext()) {
200
+ auto entry = GetEntry(context, T::Type, schema_name, name, if_exists, error_context);
201
+ if (entry && entry->type != T::Type) {
202
+ throw CatalogException(error_context.FormatError("%s is not an %s", name, T::Name));
203
+ }
204
+ return (T *)entry;
205
+ }
178
206
 
179
207
  //! Append a scalar or aggregate function to the catalog
180
208
  DUCKDB_API CatalogEntry *AddFunction(ClientContext &context, CreateFunctionInfo *info);
@@ -182,54 +210,47 @@ public:
182
210
  //! Alter an existing entry in the catalog.
183
211
  DUCKDB_API void Alter(ClientContext &context, AlterInfo *info);
184
212
 
213
+ public:
214
+ template <class T>
215
+ static T *GetEntry(ClientContext &context, const string &catalog_name, const string &schema_name,
216
+ const string &name, bool if_exists = false,
217
+ QueryErrorContext error_context = QueryErrorContext()) {
218
+ auto entry = GetEntry(context, T::Type, catalog_name, schema_name, name, if_exists, error_context);
219
+ if (entry && entry->type != T::Type) {
220
+ throw CatalogException(error_context.FormatError("%s is not an %s", name, T::Name));
221
+ }
222
+ return (T *)entry;
223
+ }
224
+
225
+ DUCKDB_API static vector<SchemaCatalogEntry *> GetSchemas(ClientContext &context, const string &catalog_name);
226
+ DUCKDB_API static vector<SchemaCatalogEntry *> GetAllSchemas(ClientContext &context);
227
+
228
+ DUCKDB_API void Verify();
229
+
185
230
  private:
186
- //! The catalog version, incremented whenever anything changes in the catalog
187
- atomic<idx_t> catalog_version;
231
+ //! Reference to the database
232
+ AttachedDatabase &db;
188
233
 
189
234
  private:
190
- //! A variation of GetEntry that returns an associated schema as well.
235
+ CatalogEntryLookup LookupEntryInternal(CatalogTransaction transaction, CatalogType type, const string &schema,
236
+ const string &name);
191
237
  CatalogEntryLookup LookupEntry(ClientContext &context, CatalogType type, const string &schema, const string &name,
192
238
  bool if_exists = false, QueryErrorContext error_context = QueryErrorContext());
239
+ static CatalogEntryLookup LookupEntry(ClientContext &context, vector<CatalogLookup> &lookups, CatalogType type,
240
+ const string &name, bool if_exists = false,
241
+ QueryErrorContext error_context = QueryErrorContext());
193
242
 
194
243
  //! Return an exception with did-you-mean suggestion.
195
- CatalogException CreateMissingEntryException(ClientContext &context, const string &entry_name, CatalogType type,
196
- const vector<SchemaCatalogEntry *> &schemas,
197
- QueryErrorContext error_context);
244
+ static CatalogException CreateMissingEntryException(ClientContext &context, const string &entry_name,
245
+ CatalogType type,
246
+ const unordered_set<SchemaCatalogEntry *> &schemas,
247
+ QueryErrorContext error_context);
198
248
 
199
249
  //! Return the close entry name, the distance and the belonging schema.
200
- SimilarCatalogEntry SimilarEntryInSchemas(ClientContext &context, const string &entry_name, CatalogType type,
201
- const vector<SchemaCatalogEntry *> &schemas);
250
+ static SimilarCatalogEntry SimilarEntryInSchemas(ClientContext &context, const string &entry_name, CatalogType type,
251
+ const unordered_set<SchemaCatalogEntry *> &schemas);
202
252
 
203
253
  void DropSchema(ClientContext &context, DropInfo *info);
204
254
  };
205
255
 
206
- template <>
207
- DUCKDB_API TableCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name, const string &name,
208
- bool if_exists, QueryErrorContext error_context);
209
- template <>
210
- DUCKDB_API SequenceCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name,
211
- const string &name, bool if_exists, QueryErrorContext error_context);
212
- template <>
213
- DUCKDB_API TableFunctionCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name,
214
- const string &name, bool if_exists,
215
- QueryErrorContext error_context);
216
- template <>
217
- DUCKDB_API CopyFunctionCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name,
218
- const string &name, bool if_exists,
219
- QueryErrorContext error_context);
220
- template <>
221
- DUCKDB_API PragmaFunctionCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name,
222
- const string &name, bool if_exists,
223
- QueryErrorContext error_context);
224
- template <>
225
- DUCKDB_API AggregateFunctionCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name,
226
- const string &name, bool if_exists,
227
- QueryErrorContext error_context);
228
- template <>
229
- DUCKDB_API CollateCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name, const string &name,
230
- bool if_exists, QueryErrorContext error_context);
231
- template <>
232
- DUCKDB_API TypeCatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema_name, const string &name,
233
- bool if_exists, QueryErrorContext error_context);
234
-
235
256
  } // namespace duckdb
@@ -17,6 +17,10 @@ namespace duckdb {
17
17
 
18
18
  //! An aggregate function in the catalog
19
19
  class AggregateFunctionCatalogEntry : public StandardEntry {
20
+ public:
21
+ static constexpr const CatalogType Type = CatalogType::AGGREGATE_FUNCTION_ENTRY;
22
+ static constexpr const char *Name = "aggregate function";
23
+
20
24
  public:
21
25
  AggregateFunctionCatalogEntry(Catalog *catalog, SchemaCatalogEntry *schema, CreateAggregateFunctionInfo *info)
22
26
  : StandardEntry(CatalogType::AGGREGATE_FUNCTION_ENTRY, schema, catalog, info->name),
@@ -16,6 +16,10 @@ namespace duckdb {
16
16
 
17
17
  //! A collation catalog entry
18
18
  class CollateCatalogEntry : public StandardEntry {
19
+ public:
20
+ static constexpr const CatalogType Type = CatalogType::COLLATION_ENTRY;
21
+ static constexpr const char *Name = "collation";
22
+
19
23
  public:
20
24
  CollateCatalogEntry(Catalog *catalog, SchemaCatalogEntry *schema, CreateCollationInfo *info)
21
25
  : StandardEntry(CatalogType::COLLATION_ENTRY, schema, catalog, info->name), function(info->function),
@@ -19,6 +19,10 @@ struct CreateCopyFunctionInfo;
19
19
 
20
20
  //! A table function in the catalog
21
21
  class CopyFunctionCatalogEntry : public StandardEntry {
22
+ public:
23
+ static constexpr const CatalogType Type = CatalogType::COPY_FUNCTION_ENTRY;
24
+ static constexpr const char *Name = "copy function";
25
+
22
26
  public:
23
27
  CopyFunctionCatalogEntry(Catalog *catalog, SchemaCatalogEntry *schema, CreateCopyFunctionInfo *info);
24
28
 
@@ -19,6 +19,10 @@ class Index;
19
19
 
20
20
  //! An index catalog entry
21
21
  class IndexCatalogEntry : public StandardEntry {
22
+ public:
23
+ static constexpr const CatalogType Type = CatalogType::INDEX_ENTRY;
24
+ static constexpr const char *Name = "index";
25
+
22
26
  public:
23
27
  //! Create an IndexCatalogEntry and initialize storage for it
24
28
  IndexCatalogEntry(Catalog *catalog, SchemaCatalogEntry *schema, CreateIndexInfo *info);
@@ -19,6 +19,10 @@ struct CreatePragmaFunctionInfo;
19
19
 
20
20
  //! A table function in the catalog
21
21
  class PragmaFunctionCatalogEntry : public StandardEntry {
22
+ public:
23
+ static constexpr const CatalogType Type = CatalogType::PRAGMA_FUNCTION_ENTRY;
24
+ static constexpr const char *Name = "pragma function";
25
+
22
26
  public:
23
27
  PragmaFunctionCatalogEntry(Catalog *catalog, SchemaCatalogEntry *schema, CreatePragmaFunctionInfo *info);
24
28
 
@@ -17,6 +17,10 @@ namespace duckdb {
17
17
 
18
18
  //! A table function in the catalog
19
19
  class ScalarFunctionCatalogEntry : public StandardEntry {
20
+ public:
21
+ static constexpr const CatalogType Type = CatalogType::SCALAR_FUNCTION_ENTRY;
22
+ static constexpr const char *Name = "scalar function";
23
+
20
24
  public:
21
25
  ScalarFunctionCatalogEntry(Catalog *catalog, SchemaCatalogEntry *schema, CreateScalarFunctionInfo *info);
22
26
 
@@ -17,6 +17,10 @@ namespace duckdb {
17
17
 
18
18
  //! A macro function in the catalog
19
19
  class ScalarMacroCatalogEntry : public MacroCatalogEntry {
20
+ public:
21
+ static constexpr const CatalogType Type = CatalogType::MACRO_ENTRY;
22
+ static constexpr const char *Name = "macro function";
23
+
20
24
  public:
21
25
  ScalarMacroCatalogEntry(Catalog *catalog, SchemaCatalogEntry *schema, CreateMacroInfo *info);
22
26
 
@@ -43,6 +43,10 @@ struct DropInfo;
43
43
  class SchemaCatalogEntry : public CatalogEntry {
44
44
  friend class Catalog;
45
45
 
46
+ public:
47
+ static constexpr const CatalogType Type = CatalogType::SCHEMA_ENTRY;
48
+ static constexpr const char *Name = "schema";
49
+
46
50
  public:
47
51
  SchemaCatalogEntry(Catalog *catalog, string name, bool is_internal);
48
52
 
@@ -67,8 +71,6 @@ private:
67
71
  CatalogSet types;
68
72
 
69
73
  public:
70
- static SchemaCatalogEntry *GetTemporaryObjects(ClientContext &context);
71
-
72
74
  //! Scan the specified catalog set, invoking the callback method for every entry
73
75
  void Scan(ClientContext &context, CatalogType type, const std::function<void(CatalogEntry *)> &callback);
74
76
  //! Scan the specified catalog set, invoking the callback method for every committed entry
@@ -84,25 +86,27 @@ public:
84
86
  //! Creates an index with the given name in the schema
85
87
  CatalogEntry *CreateIndex(ClientContext &context, CreateIndexInfo *info, TableCatalogEntry *table);
86
88
 
89
+ void Verify(Catalog &catalog) override;
90
+
87
91
  private:
88
92
  //! Create a scalar or aggregate function within the given schema
89
- CatalogEntry *CreateFunction(ClientContext &context, CreateFunctionInfo *info);
93
+ CatalogEntry *CreateFunction(CatalogTransaction transaction, CreateFunctionInfo *info);
90
94
  //! Creates a table with the given name in the schema
91
- CatalogEntry *CreateTable(ClientContext &context, BoundCreateTableInfo *info);
95
+ CatalogEntry *CreateTable(CatalogTransaction transaction, BoundCreateTableInfo *info);
92
96
  //! Creates a view with the given name in the schema
93
- CatalogEntry *CreateView(ClientContext &context, CreateViewInfo *info);
97
+ CatalogEntry *CreateView(CatalogTransaction transaction, CreateViewInfo *info);
94
98
  //! Creates a sequence with the given name in the schema
95
- CatalogEntry *CreateSequence(ClientContext &context, CreateSequenceInfo *info);
99
+ CatalogEntry *CreateSequence(CatalogTransaction transaction, CreateSequenceInfo *info);
96
100
  //! Create a table function within the given schema
97
- CatalogEntry *CreateTableFunction(ClientContext &context, CreateTableFunctionInfo *info);
101
+ CatalogEntry *CreateTableFunction(CatalogTransaction transaction, CreateTableFunctionInfo *info);
98
102
  //! Create a copy function within the given schema
99
- CatalogEntry *CreateCopyFunction(ClientContext &context, CreateCopyFunctionInfo *info);
103
+ CatalogEntry *CreateCopyFunction(CatalogTransaction transaction, CreateCopyFunctionInfo *info);
100
104
  //! Create a pragma function within the given schema
101
- CatalogEntry *CreatePragmaFunction(ClientContext &context, CreatePragmaFunctionInfo *info);
105
+ CatalogEntry *CreatePragmaFunction(CatalogTransaction transaction, CreatePragmaFunctionInfo *info);
102
106
  //! Create a collation within the given schema
103
- CatalogEntry *CreateCollation(ClientContext &context, CreateCollationInfo *info);
107
+ CatalogEntry *CreateCollation(CatalogTransaction transaction, CreateCollationInfo *info);
104
108
  //! Create a enum within the given schema
105
- CatalogEntry *CreateType(ClientContext &context, CreateTypeInfo *info);
109
+ CatalogEntry *CreateType(CatalogTransaction transaction, CreateTypeInfo *info);
106
110
 
107
111
  //! Drops an entry from the schema
108
112
  void DropEntry(ClientContext &context, DropInfo *info);
@@ -111,12 +115,15 @@ private:
111
115
  void Alter(ClientContext &context, AlterInfo *info);
112
116
 
113
117
  //! Add a catalog entry to this schema
114
- CatalogEntry *AddEntry(ClientContext &context, unique_ptr<StandardEntry> entry, OnCreateConflict on_conflict);
118
+ CatalogEntry *AddEntry(CatalogTransaction transaction, unique_ptr<StandardEntry> entry,
119
+ OnCreateConflict on_conflict);
115
120
  //! Add a catalog entry to this schema
116
- CatalogEntry *AddEntry(ClientContext &context, unique_ptr<StandardEntry> entry, OnCreateConflict on_conflict,
117
- unordered_set<CatalogEntry *> dependencies);
121
+ CatalogEntry *AddEntry(CatalogTransaction transaction, unique_ptr<StandardEntry> entry,
122
+ OnCreateConflict on_conflict, DependencyList dependencies);
118
123
 
119
124
  //! Get the catalog set for the specified type
120
125
  CatalogSet &GetCatalogSet(CatalogType type);
126
+
127
+ CatalogTransaction GetCatalogTransaction(ClientContext &context);
121
128
  };
122
129
  } // namespace duckdb
@@ -29,6 +29,10 @@ struct SequenceValue {
29
29
 
30
30
  //! A sequence catalog entry
31
31
  class SequenceCatalogEntry : public StandardEntry {
32
+ public:
33
+ static constexpr const CatalogType Type = CatalogType::SEQUENCE_ENTRY;
34
+ static constexpr const char *Name = "sequence";
35
+
32
36
  public:
33
37
  //! Create a real TableCatalogEntry and initialize storage for it
34
38
  SequenceCatalogEntry(Catalog *catalog, SchemaCatalogEntry *schema, CreateSequenceInfo *info);
@@ -35,6 +35,10 @@ struct DropNotNullInfo;
35
35
 
36
36
  //! A table catalog entry
37
37
  class TableCatalogEntry : public StandardEntry {
38
+ public:
39
+ static constexpr const CatalogType Type = CatalogType::TABLE_ENTRY;
40
+ static constexpr const char *Name = "table";
41
+
38
42
  public:
39
43
  //! Create a real TableCatalogEntry and initialize storage for it
40
44
  TableCatalogEntry(Catalog *catalog, SchemaCatalogEntry *schema, BoundCreateTableInfo *info,
@@ -22,6 +22,10 @@ struct CreateTableFunctionInfo;
22
22
 
23
23
  //! A table function in the catalog
24
24
  class TableFunctionCatalogEntry : public StandardEntry {
25
+ public:
26
+ static constexpr const CatalogType Type = CatalogType::TABLE_FUNCTION_ENTRY;
27
+ static constexpr const char *Name = "table function";
28
+
25
29
  public:
26
30
  TableFunctionCatalogEntry(Catalog *catalog, SchemaCatalogEntry *schema, CreateTableFunctionInfo *info);
27
31
 
@@ -16,6 +16,10 @@ namespace duckdb {
16
16
 
17
17
  //! A macro function in the catalog
18
18
  class TableMacroCatalogEntry : public MacroCatalogEntry {
19
+ public:
20
+ static constexpr const CatalogType Type = CatalogType::TABLE_MACRO_ENTRY;
21
+ static constexpr const char *Name = "table macro function";
22
+
19
23
  public:
20
24
  TableMacroCatalogEntry(Catalog *catalog, SchemaCatalogEntry *schema, CreateMacroInfo *info);
21
25
 
@@ -18,6 +18,10 @@ class Deserializer;
18
18
 
19
19
  //! A type catalog entry
20
20
  class TypeCatalogEntry : public StandardEntry {
21
+ public:
22
+ static constexpr const CatalogType Type = CatalogType::TYPE_ENTRY;
23
+ static constexpr const char *Name = "type";
24
+
21
25
  public:
22
26
  //! Create a TypeCatalogEntry and initialize storage for it
23
27
  TypeCatalogEntry(Catalog *catalog, SchemaCatalogEntry *schema, CreateTypeInfo *info);
@@ -20,6 +20,10 @@ struct CreateViewInfo;
20
20
 
21
21
  //! A view catalog entry
22
22
  class ViewCatalogEntry : public StandardEntry {
23
+ public:
24
+ static constexpr const CatalogType Type = CatalogType::VIEW_ENTRY;
25
+ static constexpr const char *Name = "view";
26
+
23
27
  public:
24
28
  //! Create a real TableCatalogEntry and initialize storage for it
25
29
  ViewCatalogEntry(Catalog *catalog, SchemaCatalogEntry *schema, CreateViewInfo *info);
@@ -62,5 +62,7 @@ public:
62
62
 
63
63
  //! Convert the catalog entry to a SQL string that can be used to re-construct the catalog entry
64
64
  virtual string ToSQL();
65
+
66
+ virtual void Verify(Catalog &catalog);
65
67
  };
66
68
  } // namespace duckdb
@@ -18,33 +18,52 @@ namespace duckdb {
18
18
 
19
19
  class ClientContext;
20
20
 
21
+ struct CatalogSearchEntry {
22
+ CatalogSearchEntry(string catalog, string schema);
23
+
24
+ string catalog;
25
+ string schema;
26
+
27
+ public:
28
+ string ToString() const;
29
+ static string ListToString(const vector<CatalogSearchEntry> &input);
30
+ static CatalogSearchEntry Parse(const string &input);
31
+ static vector<CatalogSearchEntry> ParseList(const string &input);
32
+
33
+ private:
34
+ static CatalogSearchEntry ParseInternal(const string &input, idx_t &pos);
35
+ static string WriteOptionallyQuoted(const string &input);
36
+ };
37
+
21
38
  //! The schema search path, in order by which entries are searched if no schema entry is provided
22
39
  class CatalogSearchPath {
23
40
  public:
24
41
  DUCKDB_API explicit CatalogSearchPath(ClientContext &client_p);
25
42
  CatalogSearchPath(const CatalogSearchPath &other) = delete;
26
43
 
27
- DUCKDB_API void Set(const string &new_value, bool is_set_schema);
28
- DUCKDB_API void Set(vector<string> &new_paths, bool is_set_schema = false);
44
+ DUCKDB_API void Set(CatalogSearchEntry new_value, bool is_set_schema);
45
+ DUCKDB_API void Set(vector<CatalogSearchEntry> new_paths, bool is_set_schema = false);
29
46
  DUCKDB_API void Reset();
30
47
 
31
- DUCKDB_API const vector<string> &Get();
32
- DUCKDB_API const vector<string> &GetSetPaths() {
48
+ DUCKDB_API const vector<CatalogSearchEntry> &Get();
49
+ DUCKDB_API const vector<CatalogSearchEntry> &GetSetPaths() {
33
50
  return set_paths;
34
51
  }
35
- DUCKDB_API const string &GetDefault();
36
- DUCKDB_API const string &GetOrDefault(const string &name);
52
+ DUCKDB_API const CatalogSearchEntry &GetDefault();
53
+ DUCKDB_API string GetDefaultSchema(const string &catalog);
54
+ DUCKDB_API string GetDefaultCatalog(const string &schema);
37
55
 
38
- private:
39
- static vector<string> ParsePaths(const string &value);
56
+ DUCKDB_API vector<string> GetSchemasForCatalog(const string &catalog);
57
+ DUCKDB_API vector<string> GetCatalogsForSchema(const string &schema);
40
58
 
41
- void SetPaths(vector<string> new_paths);
59
+ private:
60
+ void SetPaths(vector<CatalogSearchEntry> new_paths);
42
61
 
43
62
  private:
44
63
  ClientContext &context;
45
- vector<string> paths;
64
+ vector<CatalogSearchEntry> paths;
46
65
  //! Only the paths that were explicitly set (minus the always included paths)
47
- vector<string> set_paths;
66
+ vector<CatalogSearchEntry> set_paths;
48
67
  };
49
68
 
50
69
  } // namespace duckdb