duckdb 0.6.2-dev772.0 → 0.6.2-dev889.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/parquet-extension.cpp +1 -1
  14. package/src/duckdb/src/catalog/catalog.cpp +516 -177
  15. package/src/duckdb/src/catalog/catalog_entry/index_catalog_entry.cpp +1 -0
  16. package/src/duckdb/src/catalog/catalog_entry/schema_catalog_entry.cpp +66 -49
  17. package/src/duckdb/src/catalog/catalog_entry/table_catalog_entry.cpp +15 -16
  18. package/src/duckdb/src/catalog/catalog_entry/view_catalog_entry.cpp +1 -1
  19. package/src/duckdb/src/catalog/catalog_entry.cpp +6 -2
  20. package/src/duckdb/src/catalog/catalog_search_path.cpp +177 -22
  21. package/src/duckdb/src/catalog/catalog_set.cpp +134 -72
  22. package/src/duckdb/src/catalog/catalog_transaction.cpp +28 -0
  23. package/src/duckdb/src/catalog/default/default_views.cpp +4 -4
  24. package/src/duckdb/src/catalog/dependency_list.cpp +13 -0
  25. package/src/duckdb/src/catalog/dependency_manager.cpp +19 -13
  26. package/src/duckdb/src/common/constants.cpp +8 -0
  27. package/src/duckdb/src/common/enums/catalog_type.cpp +2 -0
  28. package/src/duckdb/src/common/enums/logical_operator_type.cpp +2 -0
  29. package/src/duckdb/src/common/enums/physical_operator_type.cpp +2 -0
  30. package/src/duckdb/src/common/enums/statement_type.cpp +2 -0
  31. package/src/duckdb/src/common/file_system.cpp +1 -1
  32. package/src/duckdb/src/common/string_util.cpp +5 -1
  33. package/src/duckdb/src/execution/index/art/art.cpp +1 -1
  34. package/src/duckdb/src/execution/operator/helper/physical_transaction.cpp +1 -0
  35. package/src/duckdb/src/execution/operator/join/physical_index_join.cpp +1 -1
  36. package/src/duckdb/src/execution/operator/persistent/physical_batch_insert.cpp +3 -2
  37. package/src/duckdb/src/execution/operator/persistent/physical_delete.cpp +1 -1
  38. package/src/duckdb/src/execution/operator/persistent/physical_export.cpp +1 -1
  39. package/src/duckdb/src/execution/operator/persistent/physical_insert.cpp +4 -3
  40. package/src/duckdb/src/execution/operator/schema/physical_alter.cpp +1 -1
  41. package/src/duckdb/src/execution/operator/schema/physical_attach.cpp +72 -0
  42. package/src/duckdb/src/execution/operator/schema/physical_create_function.cpp +2 -1
  43. package/src/duckdb/src/execution/operator/schema/physical_create_index.cpp +3 -3
  44. package/src/duckdb/src/execution/operator/schema/physical_create_schema.cpp +5 -1
  45. package/src/duckdb/src/execution/operator/schema/physical_create_sequence.cpp +2 -1
  46. package/src/duckdb/src/execution/operator/schema/physical_create_table.cpp +2 -2
  47. package/src/duckdb/src/execution/operator/schema/physical_create_type.cpp +1 -1
  48. package/src/duckdb/src/execution/operator/schema/physical_create_view.cpp +2 -1
  49. package/src/duckdb/src/execution/operator/schema/physical_drop.cpp +10 -2
  50. package/src/duckdb/src/execution/physical_plan/plan_comparison_join.cpp +4 -4
  51. package/src/duckdb/src/execution/physical_plan/plan_create_index.cpp +1 -1
  52. package/src/duckdb/src/execution/physical_plan/plan_create_table.cpp +2 -3
  53. package/src/duckdb/src/execution/physical_plan/plan_delete.cpp +1 -1
  54. package/src/duckdb/src/execution/physical_plan/plan_insert.cpp +1 -1
  55. package/src/duckdb/src/execution/physical_plan/plan_simple.cpp +4 -0
  56. package/src/duckdb/src/execution/physical_plan/plan_update.cpp +1 -1
  57. package/src/duckdb/src/execution/physical_plan_generator.cpp +3 -2
  58. package/src/duckdb/src/function/built_in_functions.cpp +88 -0
  59. package/src/duckdb/src/function/function.cpp +0 -79
  60. package/src/duckdb/src/function/function_binder.cpp +2 -1
  61. package/src/duckdb/src/function/pragma/pragma_queries.cpp +10 -1
  62. package/src/duckdb/src/function/scalar/date/current.cpp +2 -2
  63. package/src/duckdb/src/function/scalar/list/list_aggregates.cpp +3 -2
  64. package/src/duckdb/src/function/scalar/sequence/nextval.cpp +14 -17
  65. package/src/duckdb/src/function/scalar/system/aggregate_export.cpp +2 -2
  66. package/src/duckdb/src/function/scalar/system/system_functions.cpp +7 -4
  67. package/src/duckdb/src/function/table/checkpoint.cpp +37 -4
  68. package/src/duckdb/src/function/table/read_csv.cpp +1 -1
  69. package/src/duckdb/src/function/table/system/duckdb_columns.cpp +32 -25
  70. package/src/duckdb/src/function/table/system/duckdb_constraints.cpp +26 -22
  71. package/src/duckdb/src/function/table/system/duckdb_dependencies.cpp +1 -1
  72. package/src/duckdb/src/function/table/system/duckdb_extensions.cpp +1 -1
  73. package/src/duckdb/src/function/table/system/duckdb_functions.cpp +22 -15
  74. package/src/duckdb/src/function/table/system/duckdb_indexes.cpp +25 -18
  75. package/src/duckdb/src/function/table/system/duckdb_schemas.cpp +16 -8
  76. package/src/duckdb/src/function/table/system/duckdb_sequences.cpp +26 -19
  77. package/src/duckdb/src/function/table/system/duckdb_tables.cpp +24 -17
  78. package/src/duckdb/src/function/table/system/duckdb_types.cpp +22 -16
  79. package/src/duckdb/src/function/table/system/duckdb_views.cpp +20 -13
  80. package/src/duckdb/src/function/table/system/pragma_collations.cpp +3 -4
  81. package/src/duckdb/src/function/table/system/pragma_database_list.cpp +20 -12
  82. package/src/duckdb/src/function/table/system/pragma_database_size.cpp +39 -24
  83. package/src/duckdb/src/function/table/system/pragma_storage_info.cpp +1 -7
  84. package/src/duckdb/src/function/table/system/pragma_table_info.cpp +3 -2
  85. package/src/duckdb/src/function/table/system_functions.cpp +0 -1
  86. package/src/duckdb/src/function/table/table_scan.cpp +13 -10
  87. package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
  88. package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +102 -81
  89. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/aggregate_function_catalog_entry.hpp +4 -0
  90. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/collate_catalog_entry.hpp +4 -0
  91. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/copy_function_catalog_entry.hpp +4 -0
  92. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/index_catalog_entry.hpp +4 -0
  93. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/pragma_function_catalog_entry.hpp +4 -0
  94. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/scalar_function_catalog_entry.hpp +4 -0
  95. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/scalar_macro_catalog_entry.hpp +4 -0
  96. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/schema_catalog_entry.hpp +21 -14
  97. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/sequence_catalog_entry.hpp +4 -0
  98. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_catalog_entry.hpp +4 -0
  99. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_function_catalog_entry.hpp +4 -0
  100. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_macro_catalog_entry.hpp +4 -0
  101. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/type_catalog_entry.hpp +4 -0
  102. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/view_catalog_entry.hpp +4 -0
  103. package/src/duckdb/src/include/duckdb/catalog/catalog_entry.hpp +2 -0
  104. package/src/duckdb/src/include/duckdb/catalog/catalog_search_path.hpp +30 -11
  105. package/src/duckdb/src/include/duckdb/catalog/catalog_set.hpp +35 -20
  106. package/src/duckdb/src/include/duckdb/catalog/catalog_transaction.hpp +32 -0
  107. package/src/duckdb/src/include/duckdb/catalog/dependency_list.hpp +27 -0
  108. package/src/duckdb/src/include/duckdb/catalog/dependency_manager.hpp +6 -4
  109. package/src/duckdb/src/include/duckdb/common/allocator.hpp +3 -0
  110. package/src/duckdb/src/include/duckdb/common/constants.hpp +8 -3
  111. package/src/duckdb/src/include/duckdb/common/enums/catalog_type.hpp +1 -0
  112. package/src/duckdb/src/include/duckdb/common/enums/logical_operator_type.hpp +1 -0
  113. package/src/duckdb/src/include/duckdb/common/enums/physical_operator_type.hpp +1 -0
  114. package/src/duckdb/src/include/duckdb/common/enums/statement_type.hpp +10 -4
  115. package/src/duckdb/src/include/duckdb/common/file_system.hpp +2 -0
  116. package/src/duckdb/src/include/duckdb/common/string_util.hpp +3 -0
  117. package/src/duckdb/src/include/duckdb/execution/index/art/art.hpp +2 -2
  118. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_attach.hpp +33 -0
  119. package/src/duckdb/src/include/duckdb/execution/physical_plan_generator.hpp +2 -1
  120. package/src/duckdb/src/include/duckdb/function/aggregate/algebraic_functions.hpp +1 -0
  121. package/src/duckdb/src/include/duckdb/function/aggregate/distributive_functions.hpp +1 -0
  122. package/src/duckdb/src/include/duckdb/function/aggregate/holistic_functions.hpp +1 -0
  123. package/src/duckdb/src/include/duckdb/function/aggregate/nested_functions.hpp +1 -0
  124. package/src/duckdb/src/include/duckdb/function/aggregate/regression_functions.hpp +1 -0
  125. package/src/duckdb/src/include/duckdb/function/built_in_functions.hpp +78 -0
  126. package/src/duckdb/src/include/duckdb/function/function.hpp +0 -61
  127. package/src/duckdb/src/include/duckdb/function/function_serialization.hpp +1 -2
  128. package/src/duckdb/src/include/duckdb/function/pragma/pragma_functions.hpp +1 -0
  129. package/src/duckdb/src/include/duckdb/function/scalar/blob_functions.hpp +1 -0
  130. package/src/duckdb/src/include/duckdb/function/scalar/date_functions.hpp +1 -0
  131. package/src/duckdb/src/include/duckdb/function/scalar/enum_functions.hpp +1 -0
  132. package/src/duckdb/src/include/duckdb/function/scalar/generic_functions.hpp +1 -0
  133. package/src/duckdb/src/include/duckdb/function/scalar/math_functions.hpp +1 -0
  134. package/src/duckdb/src/include/duckdb/function/scalar/nested_functions.hpp +1 -0
  135. package/src/duckdb/src/include/duckdb/function/scalar/operators.hpp +1 -0
  136. package/src/duckdb/src/include/duckdb/function/scalar/regexp.hpp +1 -0
  137. package/src/duckdb/src/include/duckdb/function/scalar/sequence_functions.hpp +1 -0
  138. package/src/duckdb/src/include/duckdb/function/scalar/string_functions.hpp +1 -0
  139. package/src/duckdb/src/include/duckdb/function/scalar/trigonometric_functions.hpp +1 -0
  140. package/src/duckdb/src/include/duckdb/function/scalar/uuid_functions.hpp +1 -0
  141. package/src/duckdb/src/include/duckdb/function/scalar_function.hpp +2 -1
  142. package/src/duckdb/src/include/duckdb/function/table/arrow.hpp +1 -0
  143. package/src/duckdb/src/include/duckdb/function/table/range.hpp +1 -0
  144. package/src/duckdb/src/include/duckdb/function/table/read_csv.hpp +1 -0
  145. package/src/duckdb/src/include/duckdb/function/table/summary.hpp +1 -0
  146. package/src/duckdb/src/include/duckdb/function/table/system_functions.hpp +1 -4
  147. package/src/duckdb/src/include/duckdb/function/table/table_scan.hpp +1 -0
  148. package/src/duckdb/src/include/duckdb/function/table_function.hpp +2 -1
  149. package/src/duckdb/src/include/duckdb/main/attached_database.hpp +64 -0
  150. package/src/duckdb/src/include/duckdb/main/client_context.hpp +3 -3
  151. package/src/duckdb/src/include/duckdb/main/client_data.hpp +2 -1
  152. package/src/duckdb/src/include/duckdb/main/config.hpp +3 -0
  153. package/src/duckdb/src/include/duckdb/main/database.hpp +6 -6
  154. package/src/duckdb/src/include/duckdb/main/database_manager.hpp +69 -0
  155. package/src/duckdb/src/include/duckdb/main/settings.hpp +10 -0
  156. package/src/duckdb/src/include/duckdb/main/valid_checker.hpp +2 -2
  157. package/src/duckdb/src/include/duckdb/parser/expression/function_expression.hpp +3 -1
  158. package/src/duckdb/src/include/duckdb/parser/expression/window_expression.hpp +3 -1
  159. package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_function_info.hpp +2 -2
  160. package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_info.hpp +18 -1
  161. package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_table_info.hpp +53 -56
  162. package/src/duckdb/src/include/duckdb/parser/parsed_data/attach_info.hpp +39 -0
  163. package/src/duckdb/src/include/duckdb/parser/parsed_data/copy_info.hpp +4 -1
  164. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_aggregate_function_info.hpp +3 -18
  165. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_collation_info.hpp +4 -13
  166. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_copy_function_info.hpp +3 -12
  167. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_index_info.hpp +1 -1
  168. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_info.hpp +5 -3
  169. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_pragma_function_info.hpp +3 -14
  170. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_table_function_info.hpp +3 -19
  171. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_table_info.hpp +3 -1
  172. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_view_info.hpp +7 -34
  173. package/src/duckdb/src/include/duckdb/parser/parsed_data/drop_info.hpp +7 -1
  174. package/src/duckdb/src/include/duckdb/parser/parsed_data/exported_table_data.hpp +3 -0
  175. package/src/duckdb/src/include/duckdb/parser/parser_extension.hpp +2 -2
  176. package/src/duckdb/src/include/duckdb/parser/qualified_name.hpp +10 -2
  177. package/src/duckdb/src/include/duckdb/parser/query_error_context.hpp +2 -2
  178. package/src/duckdb/src/include/duckdb/parser/statement/attach_statement.hpp +29 -0
  179. package/src/duckdb/src/include/duckdb/parser/statement/export_statement.hpp +1 -0
  180. package/src/duckdb/src/include/duckdb/parser/statement/insert_statement.hpp +2 -0
  181. package/src/duckdb/src/include/duckdb/parser/statement/list.hpp +1 -0
  182. package/src/duckdb/src/include/duckdb/parser/tableref/basetableref.hpp +4 -1
  183. package/src/duckdb/src/include/duckdb/parser/tokens.hpp +1 -0
  184. package/src/duckdb/src/include/duckdb/parser/transformer.hpp +2 -0
  185. package/src/duckdb/src/include/duckdb/planner/bind_context.hpp +2 -0
  186. package/src/duckdb/src/include/duckdb/planner/binder.hpp +11 -1
  187. package/src/duckdb/src/include/duckdb/planner/parsed_data/bound_create_table_info.hpp +2 -1
  188. package/src/duckdb/src/include/duckdb/storage/buffer_manager.hpp +1 -0
  189. package/src/duckdb/src/include/duckdb/storage/checkpoint_manager.hpp +13 -6
  190. package/src/duckdb/src/include/duckdb/storage/data_table.hpp +10 -2
  191. package/src/duckdb/src/include/duckdb/storage/single_file_block_manager.hpp +2 -2
  192. package/src/duckdb/src/include/duckdb/storage/statistics/base_statistics.hpp +2 -2
  193. package/src/duckdb/src/include/duckdb/storage/storage_manager.hpp +9 -12
  194. package/src/duckdb/src/include/duckdb/storage/table/data_table_info.hpp +3 -7
  195. package/src/duckdb/src/include/duckdb/storage/table/row_group.hpp +5 -6
  196. package/src/duckdb/src/include/duckdb/storage/write_ahead_log.hpp +9 -7
  197. package/src/duckdb/src/include/duckdb/transaction/local_storage.hpp +3 -1
  198. package/src/duckdb/src/include/duckdb/transaction/meta_transaction.hpp +64 -0
  199. package/src/duckdb/src/include/duckdb/transaction/transaction.hpp +14 -23
  200. package/src/duckdb/src/include/duckdb/transaction/transaction_context.hpp +12 -8
  201. package/src/duckdb/src/include/duckdb/transaction/transaction_manager.hpp +5 -10
  202. package/src/duckdb/src/include/duckdb/transaction/undo_buffer.hpp +1 -1
  203. package/src/duckdb/src/main/attached_database.cpp +97 -0
  204. package/src/duckdb/src/main/capi/table_function-c.cpp +1 -1
  205. package/src/duckdb/src/main/client_context.cpp +28 -22
  206. package/src/duckdb/src/main/client_data.cpp +5 -2
  207. package/src/duckdb/src/main/config.cpp +1 -0
  208. package/src/duckdb/src/main/connection.cpp +1 -1
  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
@@ -19,6 +19,7 @@
19
19
  #include "duckdb/catalog/catalog_entry/table_catalog_entry.hpp"
20
20
  #include "duckdb/catalog/catalog_entry/sequence_catalog_entry.hpp"
21
21
  #include "duckdb/transaction/transaction.hpp"
22
+ #include "duckdb/catalog/catalog_transaction.hpp"
22
23
  #include <functional>
23
24
  #include <memory>
24
25
 
@@ -26,6 +27,7 @@ namespace duckdb {
26
27
  struct AlterInfo;
27
28
 
28
29
  class ClientContext;
30
+ class DependencyList;
29
31
  struct MappingValue;
30
32
  struct EntryIndex;
31
33
 
@@ -69,23 +71,31 @@ public:
69
71
 
70
72
  //! Create an entry in the catalog set. Returns whether or not it was
71
73
  //! successful.
74
+ DUCKDB_API bool CreateEntry(CatalogTransaction transaction, const string &name, unique_ptr<CatalogEntry> value,
75
+ DependencyList &dependencies);
72
76
  DUCKDB_API bool CreateEntry(ClientContext &context, const string &name, unique_ptr<CatalogEntry> value,
73
- unordered_set<CatalogEntry *> &dependencies);
77
+ DependencyList &dependencies);
74
78
 
75
- DUCKDB_API bool AlterEntry(ClientContext &context, const string &name, AlterInfo *alter_info);
79
+ DUCKDB_API bool AlterEntry(CatalogTransaction transaction, const string &name, AlterInfo *alter_info);
76
80
 
77
- DUCKDB_API bool DropEntry(ClientContext &context, const string &name, bool cascade);
81
+ DUCKDB_API bool DropEntry(CatalogTransaction transaction, const string &name, bool cascade,
82
+ bool allow_drop_internal = false);
83
+ DUCKDB_API bool DropEntry(ClientContext &context, const string &name, bool cascade,
84
+ bool allow_drop_internal = false);
78
85
 
79
- bool AlterOwnership(ClientContext &context, ChangeOwnershipInfo *info);
86
+ DUCKDB_API Catalog &GetCatalog();
87
+
88
+ bool AlterOwnership(CatalogTransaction transaction, ChangeOwnershipInfo *info);
80
89
 
81
90
  void CleanupEntry(CatalogEntry *catalog_entry);
82
91
 
83
92
  //! Returns the entry with the specified name
93
+ DUCKDB_API CatalogEntry *GetEntry(CatalogTransaction transaction, const string &name);
84
94
  DUCKDB_API CatalogEntry *GetEntry(ClientContext &context, const string &name);
85
95
 
86
96
  //! Gets the entry that is most similar to the given name (i.e. smallest levenshtein distance), or empty string if
87
97
  //! none is found. The returned pair consists of the entry name and the distance (smaller means closer).
88
- pair<string, idx_t> SimilarEntry(ClientContext &context, const string &name);
98
+ pair<string, idx_t> SimilarEntry(CatalogTransaction transaction, const string &name);
89
99
 
90
100
  //! Rollback <entry> to be the currently valid entry for a certain catalog
91
101
  //! entry
@@ -94,20 +104,23 @@ public:
94
104
  //! Scan the catalog set, invoking the callback method for every committed entry
95
105
  DUCKDB_API void Scan(const std::function<void(CatalogEntry *)> &callback);
96
106
  //! Scan the catalog set, invoking the callback method for every entry
107
+ DUCKDB_API void Scan(CatalogTransaction transaction, const std::function<void(CatalogEntry *)> &callback);
97
108
  DUCKDB_API void Scan(ClientContext &context, const std::function<void(CatalogEntry *)> &callback);
98
109
 
99
110
  template <class T>
100
- vector<T *> GetEntries(ClientContext &context) {
111
+ vector<T *> GetEntries(CatalogTransaction transaction) {
101
112
  vector<T *> result;
102
- Scan(context, [&](CatalogEntry *entry) { result.push_back((T *)entry); });
113
+ Scan(transaction, [&](CatalogEntry *entry) { result.push_back((T *)entry); });
103
114
  return result;
104
115
  }
105
116
 
106
- DUCKDB_API static bool HasConflict(ClientContext &context, transaction_t timestamp);
107
- DUCKDB_API static bool UseTimestamp(ClientContext &context, transaction_t timestamp);
117
+ DUCKDB_API bool HasConflict(CatalogTransaction transaction, transaction_t timestamp);
118
+ DUCKDB_API bool UseTimestamp(CatalogTransaction transaction, transaction_t timestamp);
108
119
 
109
120
  void UpdateTimestamp(CatalogEntry *entry, transaction_t timestamp);
110
121
 
122
+ void Verify(Catalog &catalog);
123
+
111
124
  private:
112
125
  //! Adjusts table dependencies on the event of an UNDO
113
126
  void AdjustTableDependencies(CatalogEntry *entry);
@@ -116,22 +129,24 @@ private:
116
129
  //! Adjust User dependency
117
130
  void AdjustUserDependency(CatalogEntry *entry, ColumnDefinition &column, bool remove);
118
131
  //! Given a root entry, gets the entry valid for this transaction
119
- CatalogEntry *GetEntryForTransaction(ClientContext &context, CatalogEntry *current);
132
+ CatalogEntry *GetEntryForTransaction(CatalogTransaction transaction, CatalogEntry *current);
120
133
  CatalogEntry *GetCommittedEntry(CatalogEntry *current);
121
- bool GetEntryInternal(ClientContext &context, const string &name, EntryIndex *entry_index, CatalogEntry *&entry);
122
- bool GetEntryInternal(ClientContext &context, EntryIndex &entry_index, CatalogEntry *&entry);
134
+ bool GetEntryInternal(CatalogTransaction transaction, const string &name, EntryIndex *entry_index,
135
+ CatalogEntry *&entry);
136
+ bool GetEntryInternal(CatalogTransaction transaction, EntryIndex &entry_index, CatalogEntry *&entry);
123
137
  //! Drops an entry from the catalog set; must hold the catalog_lock to safely call this
124
- void DropEntryInternal(ClientContext &context, EntryIndex entry_index, CatalogEntry &entry, bool cascade);
125
- CatalogEntry *CreateEntryInternal(ClientContext &context, unique_ptr<CatalogEntry> entry);
126
- MappingValue *GetMapping(ClientContext &context, const string &name, bool get_latest = false);
127
- void PutMapping(ClientContext &context, const string &name, EntryIndex entry_index);
128
- void DeleteMapping(ClientContext &context, const string &name);
129
- void DropEntryDependencies(ClientContext &context, EntryIndex &entry_index, CatalogEntry &entry, bool cascade);
138
+ void DropEntryInternal(CatalogTransaction transaction, EntryIndex entry_index, CatalogEntry &entry, bool cascade);
139
+ CatalogEntry *CreateEntryInternal(CatalogTransaction transaction, unique_ptr<CatalogEntry> entry);
140
+ MappingValue *GetMapping(CatalogTransaction transaction, const string &name, bool get_latest = false);
141
+ void PutMapping(CatalogTransaction transaction, const string &name, EntryIndex entry_index);
142
+ void DeleteMapping(CatalogTransaction transaction, const string &name);
143
+ void DropEntryDependencies(CatalogTransaction transaction, EntryIndex &entry_index, CatalogEntry &entry,
144
+ bool cascade);
130
145
 
131
146
  //! Create all default entries
132
- void CreateDefaultEntries(ClientContext &context, unique_lock<mutex> &lock);
147
+ void CreateDefaultEntries(CatalogTransaction transaction, unique_lock<mutex> &lock);
133
148
  //! Attempt to create a default entry with the specified name. Returns the entry if successful, nullptr otherwise.
134
- CatalogEntry *CreateDefaultEntry(ClientContext &context, const string &name, unique_lock<mutex> &lock);
149
+ CatalogEntry *CreateDefaultEntry(CatalogTransaction transaction, const string &name, unique_lock<mutex> &lock);
135
150
 
136
151
  EntryIndex PutEntry(idx_t entry_index, unique_ptr<CatalogEntry> entry);
137
152
  void PutEntry(EntryIndex index, unique_ptr<CatalogEntry> entry);
@@ -0,0 +1,32 @@
1
+ //===----------------------------------------------------------------------===//
2
+ // DuckDB
3
+ //
4
+ // duckdb/catalog/catalog_transaction.hpp
5
+ //
6
+ //
7
+ //===----------------------------------------------------------------------===//
8
+
9
+ #pragma once
10
+
11
+ #include "duckdb/common/common.hpp"
12
+
13
+ namespace duckdb {
14
+ class Catalog;
15
+ class ClientContext;
16
+ class DatabaseInstance;
17
+ class Transaction;
18
+
19
+ struct CatalogTransaction {
20
+ CatalogTransaction(Catalog &catalog, ClientContext &context);
21
+ CatalogTransaction(DatabaseInstance &db, transaction_t transaction_id_p, transaction_t start_time_p);
22
+
23
+ DatabaseInstance *db;
24
+ ClientContext *context;
25
+ Transaction *transaction;
26
+ transaction_t transaction_id;
27
+ transaction_t start_time;
28
+
29
+ ClientContext &GetContext();
30
+ };
31
+
32
+ } // namespace duckdb
@@ -0,0 +1,27 @@
1
+ //===----------------------------------------------------------------------===//
2
+ // DuckDB
3
+ //
4
+ // duckdb/catalog/dependency_list.hpp
5
+ //
6
+ //
7
+ //===----------------------------------------------------------------------===//
8
+
9
+ #pragma once
10
+
11
+ #include "duckdb/common/common.hpp"
12
+ #include "duckdb/common/unordered_set.hpp"
13
+
14
+ namespace duckdb {
15
+ class CatalogEntry;
16
+
17
+ //! The DependencyList
18
+ class DependencyList {
19
+ friend class DependencyManager;
20
+
21
+ public:
22
+ DUCKDB_API void AddDependency(CatalogEntry *entry);
23
+
24
+ private:
25
+ unordered_set<CatalogEntry *> set;
26
+ };
27
+ } // namespace duckdb
@@ -11,12 +11,14 @@
11
11
  #include "duckdb/catalog/catalog_entry.hpp"
12
12
  #include "duckdb/catalog/catalog_set.hpp"
13
13
  #include "duckdb/catalog/dependency.hpp"
14
+ #include "duckdb/catalog/catalog_transaction.hpp"
14
15
 
15
16
  #include <functional>
16
17
 
17
18
  namespace duckdb {
18
19
  class Catalog;
19
20
  class ClientContext;
21
+ class DependencyList;
20
22
 
21
23
  //! The DependencyManager is in charge of managing dependencies between catalog entries
22
24
  class DependencyManager {
@@ -31,7 +33,7 @@ public:
31
33
  //! Scans all dependencies, returning pairs of (object, dependent)
32
34
  void Scan(const std::function<void(CatalogEntry *, CatalogEntry *, DependencyType)> &callback);
33
35
 
34
- void AddOwnership(ClientContext &context, CatalogEntry *owner, CatalogEntry *entry);
36
+ void AddOwnership(CatalogTransaction transaction, CatalogEntry *owner, CatalogEntry *entry);
35
37
 
36
38
  private:
37
39
  Catalog &catalog;
@@ -43,9 +45,9 @@ private:
43
45
  unordered_map<CatalogEntry *, unordered_set<CatalogEntry *>> dependencies_map;
44
46
 
45
47
  private:
46
- void AddObject(ClientContext &context, CatalogEntry *object, unordered_set<CatalogEntry *> &dependencies);
47
- void DropObject(ClientContext &context, CatalogEntry *object, bool cascade);
48
- void AlterObject(ClientContext &context, CatalogEntry *old_obj, CatalogEntry *new_obj);
48
+ void AddObject(CatalogTransaction transaction, CatalogEntry *object, DependencyList &dependencies);
49
+ void DropObject(CatalogTransaction transaction, CatalogEntry *object, bool cascade);
50
+ void AlterObject(CatalogTransaction transaction, CatalogEntry *old_obj, CatalogEntry *new_obj);
49
51
  void EraseObjectInternal(CatalogEntry *object);
50
52
  };
51
53
  } // namespace duckdb
@@ -12,6 +12,7 @@
12
12
 
13
13
  namespace duckdb {
14
14
  class Allocator;
15
+ class AttachedDatabase;
15
16
  class ClientContext;
16
17
  class DatabaseInstance;
17
18
  class ExecutionContext;
@@ -91,6 +92,7 @@ public:
91
92
  }
92
93
  static Allocator &Get(ClientContext &context);
93
94
  static Allocator &Get(DatabaseInstance &db);
95
+ static Allocator &Get(AttachedDatabase &db);
94
96
 
95
97
  PrivateAllocatorData *GetPrivateData() {
96
98
  return private_data.get();
@@ -137,6 +139,7 @@ void DestroyObject(T *ptr) {
137
139
  struct BufferAllocator {
138
140
  DUCKDB_API static Allocator &Get(ClientContext &context);
139
141
  DUCKDB_API static Allocator &Get(DatabaseInstance &db);
142
+ DUCKDB_API static Allocator &Get(AttachedDatabase &db);
140
143
  };
141
144
 
142
145
  } // namespace duckdb
@@ -43,9 +43,14 @@ using data_ptr = unique_ptr<char[]>;
43
43
  using std::make_shared;
44
44
 
45
45
  // NOTE: there is a copy of this in the Postgres' parser grammar (gram.y)
46
- #define DEFAULT_SCHEMA "main"
47
- #define TEMP_SCHEMA "temp"
48
- #define INVALID_SCHEMA ""
46
+ #define DEFAULT_SCHEMA "main"
47
+ #define INVALID_SCHEMA ""
48
+ #define INVALID_CATALOG ""
49
+ #define SYSTEM_CATALOG "system"
50
+ #define TEMP_CATALOG "temp"
51
+
52
+ DUCKDB_API bool IsInvalidSchema(const string &str);
53
+ DUCKDB_API bool IsInvalidCatalog(const string &str);
49
54
 
50
55
  //! a saner size_t for loop indices etc
51
56
  typedef uint64_t idx_t;
@@ -25,6 +25,7 @@ enum class CatalogType : uint8_t {
25
25
  SEQUENCE_ENTRY = 6,
26
26
  COLLATION_ENTRY = 7,
27
27
  TYPE_ENTRY = 8,
28
+ DATABASE_ENTRY = 9,
28
29
 
29
30
  // functions
30
31
  TABLE_FUNCTION_ENTRY = 25,
@@ -77,6 +77,7 @@ enum class LogicalOperatorType : uint8_t {
77
77
  LOGICAL_PRAGMA = 133,
78
78
  LOGICAL_TRANSACTION = 134,
79
79
  LOGICAL_CREATE_TYPE = 135,
80
+ LOGICAL_ATTACH = 136,
80
81
 
81
82
  // -----------------------------
82
83
  // Explain
@@ -84,6 +84,7 @@ enum class PhysicalOperatorType : uint8_t {
84
84
  PRAGMA,
85
85
  TRANSACTION,
86
86
  CREATE_TYPE,
87
+ ATTACH,
87
88
 
88
89
  // -----------------------------
89
90
  // Helpers
@@ -9,6 +9,7 @@
9
9
  #pragma once
10
10
 
11
11
  #include "duckdb/common/constants.hpp"
12
+ #include "duckdb/common/unordered_set.hpp"
12
13
 
13
14
  namespace duckdb {
14
15
 
@@ -41,7 +42,8 @@ enum class StatementType : uint8_t {
41
42
  LOAD_STATEMENT, // LOAD statement type
42
43
  RELATION_STATEMENT,
43
44
  EXTENSION_STATEMENT,
44
- LOGICAL_PLAN_STATEMENT
45
+ LOGICAL_PLAN_STATEMENT,
46
+ ATTACH_STATEMENT
45
47
 
46
48
  };
47
49
 
@@ -58,12 +60,12 @@ string StatementReturnTypeToString(StatementReturnType type);
58
60
  //! A struct containing various properties of a SQL statement
59
61
  struct StatementProperties {
60
62
  StatementProperties()
61
- : read_only(true), requires_valid_transaction(true), allow_stream_result(false), bound_all_parameters(true),
63
+ : requires_valid_transaction(true), allow_stream_result(false), bound_all_parameters(true),
62
64
  return_type(StatementReturnType::QUERY_RESULT), parameter_count(0) {
63
65
  }
64
66
 
65
- //! Whether or not the statement is a read-only statement, or whether it can result in changes to the database
66
- bool read_only;
67
+ //! The set of databases this statement will modify
68
+ unordered_set<string> modified_databases;
67
69
  //! Whether or not the statement requires a valid transaction. Almost all statements require this, with the
68
70
  //! exception of
69
71
  bool requires_valid_transaction;
@@ -75,6 +77,10 @@ struct StatementProperties {
75
77
  StatementReturnType return_type;
76
78
  //! The number of prepared statement parameters
77
79
  idx_t parameter_count;
80
+
81
+ bool IsReadOnly() {
82
+ return modified_databases.empty();
83
+ }
78
84
  };
79
85
 
80
86
  } // namespace duckdb
@@ -22,6 +22,7 @@
22
22
  #undef RemoveDirectory
23
23
 
24
24
  namespace duckdb {
25
+ class AttachedDatabase;
25
26
  class ClientContext;
26
27
  class DatabaseInstance;
27
28
  class FileOpener;
@@ -107,6 +108,7 @@ public:
107
108
  DUCKDB_API static constexpr FileCompressionType DEFAULT_COMPRESSION = FileCompressionType::UNCOMPRESSED;
108
109
  DUCKDB_API static FileSystem &GetFileSystem(ClientContext &context);
109
110
  DUCKDB_API static FileSystem &GetFileSystem(DatabaseInstance &db);
111
+ DUCKDB_API static FileSystem &Get(AttachedDatabase &db);
110
112
  DUCKDB_API static FileOpener *GetFileOpener(ClientContext &context);
111
113
 
112
114
  DUCKDB_API virtual unique_ptr<FileHandle> OpenFile(const string &path, uint8_t flags,
@@ -121,6 +121,9 @@ public:
121
121
  //! Convert a string to lowercase
122
122
  DUCKDB_API static string Lower(const string &str);
123
123
 
124
+ //! Case insensitive equals
125
+ DUCKDB_API static bool CIEquals(const string &l1, const string &l2);
126
+
124
127
  //! Format a string using printf semantics
125
128
  template <typename... Args>
126
129
  static string Format(const string fmt_str, Args... params) {
@@ -51,14 +51,14 @@ class ART : public Index {
51
51
  public:
52
52
  ART(const vector<column_t> &column_ids, TableIOManager &table_io_manager,
53
53
  const vector<unique_ptr<Expression>> &unbound_expressions, IndexConstraintType constraint_type,
54
- DatabaseInstance &db, idx_t block_id = DConstants::INVALID_INDEX,
54
+ AttachedDatabase &db, idx_t block_id = DConstants::INVALID_INDEX,
55
55
  idx_t block_offset = DConstants::INVALID_INDEX);
56
56
  ~ART() override;
57
57
 
58
58
  //! Root of the tree
59
59
  Node *tree;
60
60
 
61
- DatabaseInstance &db;
61
+ AttachedDatabase &db;
62
62
 
63
63
  public:
64
64
  //! Initialize a scan on the index with the given expression and column ids
@@ -0,0 +1,33 @@
1
+ //===----------------------------------------------------------------------===//
2
+ // DuckDB
3
+ //
4
+ // duckdb/execution/operator/schema/physical_attach.hpp
5
+ //
6
+ //
7
+ //===----------------------------------------------------------------------===//
8
+
9
+ #pragma once
10
+
11
+ #include "duckdb/execution/physical_operator.hpp"
12
+ #include "duckdb/parser/parsed_data/attach_info.hpp"
13
+
14
+ namespace duckdb {
15
+
16
+ //! PhysicalLoad represents an extension LOAD operation
17
+ class PhysicalAttach : public PhysicalOperator {
18
+ public:
19
+ explicit PhysicalAttach(unique_ptr<AttachInfo> info, idx_t estimated_cardinality)
20
+ : PhysicalOperator(PhysicalOperatorType::ATTACH, {LogicalType::BOOLEAN}, estimated_cardinality),
21
+ info(move(info)) {
22
+ }
23
+
24
+ unique_ptr<AttachInfo> info;
25
+
26
+ public:
27
+ // Source interface
28
+ unique_ptr<GlobalSourceState> GetGlobalSourceState(ClientContext &context) const override;
29
+ void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
30
+ LocalSourceState &lstate) const override;
31
+ };
32
+
33
+ } // namespace duckdb
@@ -13,6 +13,7 @@
13
13
  #include "duckdb/planner/logical_operator.hpp"
14
14
  #include "duckdb/planner/logical_tokens.hpp"
15
15
  #include "duckdb/planner/operator/logical_limit_percent.hpp"
16
+ #include "duckdb/catalog/dependency_list.hpp"
16
17
  #include "duckdb/common/unordered_map.hpp"
17
18
  #include "duckdb/common/unordered_set.hpp"
18
19
 
@@ -27,7 +28,7 @@ public:
27
28
  explicit PhysicalPlanGenerator(ClientContext &context);
28
29
  ~PhysicalPlanGenerator();
29
30
 
30
- unordered_set<CatalogEntry *> dependencies;
31
+ DependencyList dependencies;
31
32
  //! Recursive CTEs require at least one ChunkScan, referencing the working_table.
32
33
  //! This data structure is used to establish it.
33
34
  unordered_map<idx_t, std::shared_ptr<ColumnDataCollection>> recursive_cte_tables;
@@ -9,6 +9,7 @@
9
9
  #pragma once
10
10
 
11
11
  #include "duckdb/function/aggregate_function.hpp"
12
+ #include "duckdb/function/built_in_functions.hpp"
12
13
 
13
14
  namespace duckdb {
14
15
 
@@ -11,6 +11,7 @@
11
11
  #include "duckdb/function/aggregate_function.hpp"
12
12
  #include "duckdb/function/function_set.hpp"
13
13
  #include "duckdb/common/types/null_value.hpp"
14
+ #include "duckdb/function/built_in_functions.hpp"
14
15
 
15
16
  namespace duckdb {
16
17
 
@@ -10,6 +10,7 @@
10
10
 
11
11
  #include "duckdb/function/aggregate_function.hpp"
12
12
  #include "duckdb/function/function_set.hpp"
13
+ #include "duckdb/function/built_in_functions.hpp"
13
14
 
14
15
  namespace duckdb {
15
16
 
@@ -10,6 +10,7 @@
10
10
 
11
11
  #include "duckdb/function/aggregate_function.hpp"
12
12
  #include "duckdb/function/function_set.hpp"
13
+ #include "duckdb/function/built_in_functions.hpp"
13
14
 
14
15
  namespace duckdb {
15
16
 
@@ -11,6 +11,7 @@
11
11
  #include "duckdb/function/aggregate_function.hpp"
12
12
  #include "duckdb/function/function_set.hpp"
13
13
  #include "duckdb/common/types/null_value.hpp"
14
+ #include "duckdb/function/built_in_functions.hpp"
14
15
 
15
16
  namespace duckdb {
16
17
  struct RegrAvgxFun {
@@ -0,0 +1,78 @@
1
+ //===----------------------------------------------------------------------===//
2
+ // DuckDB
3
+ //
4
+ // duckdb/function/built_in_functions.hpp
5
+ //
6
+ //
7
+ //===----------------------------------------------------------------------===//
8
+
9
+ #pragma once
10
+
11
+ #include "duckdb/function/function.hpp"
12
+ #include "duckdb/catalog/catalog_transaction.hpp"
13
+
14
+ namespace duckdb {
15
+
16
+ class BuiltinFunctions {
17
+ public:
18
+ BuiltinFunctions(CatalogTransaction transaction, Catalog &catalog);
19
+ ~BuiltinFunctions();
20
+
21
+ //! Initialize a catalog with all built-in functions
22
+ void Initialize();
23
+
24
+ public:
25
+ void AddFunction(AggregateFunctionSet set);
26
+ void AddFunction(AggregateFunction function);
27
+ void AddFunction(ScalarFunctionSet set);
28
+ void AddFunction(PragmaFunction function);
29
+ void AddFunction(const string &name, PragmaFunctionSet functions);
30
+ void AddFunction(ScalarFunction function);
31
+ void AddFunction(const vector<string> &names, ScalarFunction function);
32
+ void AddFunction(TableFunctionSet set);
33
+ void AddFunction(TableFunction function);
34
+ void AddFunction(CopyFunction function);
35
+
36
+ void AddCollation(string name, ScalarFunction function, bool combinable = false,
37
+ bool not_required_for_equality = false);
38
+
39
+ private:
40
+ CatalogTransaction transaction;
41
+ Catalog &catalog;
42
+
43
+ private:
44
+ template <class T>
45
+ void Register() {
46
+ T::RegisterFunction(*this);
47
+ }
48
+
49
+ // table-producing functions
50
+ void RegisterTableScanFunctions();
51
+ void RegisterSQLiteFunctions();
52
+ void RegisterReadFunctions();
53
+ void RegisterTableFunctions();
54
+ void RegisterArrowFunctions();
55
+
56
+ // aggregates
57
+ void RegisterAlgebraicAggregates();
58
+ void RegisterDistributiveAggregates();
59
+ void RegisterNestedAggregates();
60
+ void RegisterHolisticAggregates();
61
+ void RegisterRegressiveAggregates();
62
+
63
+ // scalar functions
64
+ void RegisterDateFunctions();
65
+ void RegisterEnumFunctions();
66
+ void RegisterGenericFunctions();
67
+ void RegisterMathFunctions();
68
+ void RegisterOperators();
69
+ void RegisterStringFunctions();
70
+ void RegisterNestedFunctions();
71
+ void RegisterSequenceFunctions();
72
+ void RegisterTrigonometricsFunctions();
73
+
74
+ // pragmas
75
+ void RegisterPragmaFunctions();
76
+ };
77
+
78
+ } // namespace duckdb
@@ -148,65 +148,4 @@ public:
148
148
  DUCKDB_API string ToString() override;
149
149
  };
150
150
 
151
- class BuiltinFunctions {
152
- public:
153
- BuiltinFunctions(ClientContext &transaction, Catalog &catalog);
154
-
155
- //! Initialize a catalog with all built-in functions
156
- void Initialize();
157
-
158
- public:
159
- void AddFunction(AggregateFunctionSet set);
160
- void AddFunction(AggregateFunction function);
161
- void AddFunction(ScalarFunctionSet set);
162
- void AddFunction(PragmaFunction function);
163
- void AddFunction(const string &name, PragmaFunctionSet functions);
164
- void AddFunction(ScalarFunction function);
165
- void AddFunction(const vector<string> &names, ScalarFunction function);
166
- void AddFunction(TableFunctionSet set);
167
- void AddFunction(TableFunction function);
168
- void AddFunction(CopyFunction function);
169
-
170
- void AddCollation(string name, ScalarFunction function, bool combinable = false,
171
- bool not_required_for_equality = false);
172
-
173
- private:
174
- ClientContext &context;
175
- Catalog &catalog;
176
-
177
- private:
178
- template <class T>
179
- void Register() {
180
- T::RegisterFunction(*this);
181
- }
182
-
183
- // table-producing functions
184
- void RegisterTableScanFunctions();
185
- void RegisterSQLiteFunctions();
186
- void RegisterReadFunctions();
187
- void RegisterTableFunctions();
188
- void RegisterArrowFunctions();
189
-
190
- // aggregates
191
- void RegisterAlgebraicAggregates();
192
- void RegisterDistributiveAggregates();
193
- void RegisterNestedAggregates();
194
- void RegisterHolisticAggregates();
195
- void RegisterRegressiveAggregates();
196
-
197
- // scalar functions
198
- void RegisterDateFunctions();
199
- void RegisterEnumFunctions();
200
- void RegisterGenericFunctions();
201
- void RegisterMathFunctions();
202
- void RegisterOperators();
203
- void RegisterStringFunctions();
204
- void RegisterNestedFunctions();
205
- void RegisterSequenceFunctions();
206
- void RegisterTrigonometricsFunctions();
207
-
208
- // pragmas
209
- void RegisterPragmaFunctions();
210
- };
211
-
212
151
  } // namespace duckdb
@@ -47,8 +47,7 @@ public:
47
47
  // note: original_arguments are optional (can be list of size 0)
48
48
  auto original_arguments = reader.ReadRequiredSerializableList<LogicalType, LogicalType>();
49
49
 
50
- auto &catalog = Catalog::GetCatalog(context);
51
- auto func_catalog = catalog.GetEntry(context, type, DEFAULT_SCHEMA, name);
50
+ auto func_catalog = Catalog::GetEntry(context, type, INVALID_CATALOG, DEFAULT_SCHEMA, name);
52
51
  if (!func_catalog || func_catalog->type != type) {
53
52
  throw InternalException("Cant find catalog entry for function %s", name);
54
53
  }
@@ -9,6 +9,7 @@
9
9
  #pragma once
10
10
 
11
11
  #include "duckdb/function/pragma_function.hpp"
12
+ #include "duckdb/function/built_in_functions.hpp"
12
13
 
13
14
  namespace duckdb {
14
15
 
@@ -9,6 +9,7 @@
9
9
  #pragma once
10
10
 
11
11
  #include "duckdb/function/function_set.hpp"
12
+ #include "duckdb/function/built_in_functions.hpp"
12
13
 
13
14
  namespace duckdb {
14
15
 
@@ -10,6 +10,7 @@
10
10
 
11
11
  #include "duckdb/function/scalar_function.hpp"
12
12
  #include "duckdb/function/function_set.hpp"
13
+ #include "duckdb/function/built_in_functions.hpp"
13
14
 
14
15
  namespace duckdb {
15
16