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
@@ -7,21 +7,27 @@
7
7
  #include "duckdb/main/database.hpp"
8
8
  #include "duckdb/parser/expression/constant_expression.hpp"
9
9
  #include "duckdb/catalog/mapping_value.hpp"
10
+ #include "duckdb/catalog/dependency_list.hpp"
10
11
 
11
12
  namespace duckdb {
12
13
 
13
14
  DependencyManager::DependencyManager(Catalog &catalog) : catalog(catalog) {
14
15
  }
15
16
 
16
- void DependencyManager::AddObject(ClientContext &context, CatalogEntry *object,
17
- unordered_set<CatalogEntry *> &dependencies) {
17
+ void DependencyManager::AddObject(CatalogTransaction transaction, CatalogEntry *object, DependencyList &dependencies) {
18
18
  // check for each object in the sources if they were not deleted yet
19
- for (auto &dependency : dependencies) {
19
+ for (auto &dependency : dependencies.set) {
20
20
  CatalogEntry *catalog_entry;
21
+ if (dependency->catalog != object->catalog) {
22
+ throw DependencyException(
23
+ "Error adding dependency for object \"%s\" - dependency \"%s\" is in catalog "
24
+ "\"%s\", which does not match the catalog \"%s\".\nCross catalog dependencies are not supported.",
25
+ object->name, dependency->name, dependency->catalog->GetName(), object->catalog->GetName());
26
+ }
21
27
  if (!dependency->set) {
22
28
  throw InternalException("Dependency has no set");
23
29
  }
24
- if (!dependency->set->GetEntryInternal(context, dependency->name, nullptr, catalog_entry)) {
30
+ if (!dependency->set->GetEntryInternal(transaction, dependency->name, nullptr, catalog_entry)) {
25
31
  throw InternalException("Dependency has already been deleted?");
26
32
  }
27
33
  }
@@ -29,15 +35,15 @@ void DependencyManager::AddObject(ClientContext &context, CatalogEntry *object,
29
35
  auto dependency_type = object->type == CatalogType::INDEX_ENTRY ? DependencyType::DEPENDENCY_AUTOMATIC
30
36
  : DependencyType::DEPENDENCY_REGULAR;
31
37
  // add the object to the dependents_map of each object that it depends on
32
- for (auto &dependency : dependencies) {
38
+ for (auto &dependency : dependencies.set) {
33
39
  dependents_map[dependency].insert(Dependency(object, dependency_type));
34
40
  }
35
41
  // create the dependents map for this object: it starts out empty
36
42
  dependents_map[object] = dependency_set_t();
37
- dependencies_map[object] = dependencies;
43
+ dependencies_map[object] = dependencies.set;
38
44
  }
39
45
 
40
- void DependencyManager::DropObject(ClientContext &context, CatalogEntry *object, bool cascade) {
46
+ void DependencyManager::DropObject(CatalogTransaction transaction, CatalogEntry *object, bool cascade) {
41
47
  D_ASSERT(dependents_map.find(object) != dependents_map.end());
42
48
 
43
49
  // first check the objects that depend on this object
@@ -45,13 +51,13 @@ void DependencyManager::DropObject(ClientContext &context, CatalogEntry *object,
45
51
  for (auto &dep : dependent_objects) {
46
52
  // look up the entry in the catalog set
47
53
  auto &catalog_set = *dep.entry->set;
48
- auto mapping_value = catalog_set.GetMapping(context, dep.entry->name, true /* get_latest */);
54
+ auto mapping_value = catalog_set.GetMapping(transaction, dep.entry->name, true /* get_latest */);
49
55
  if (mapping_value == nullptr) {
50
56
  continue;
51
57
  }
52
58
  CatalogEntry *dependency_entry;
53
59
 
54
- if (!catalog_set.GetEntryInternal(context, mapping_value->index, dependency_entry)) {
60
+ if (!catalog_set.GetEntryInternal(transaction, mapping_value->index, dependency_entry)) {
55
61
  // the dependent object was already deleted, no conflict
56
62
  continue;
57
63
  }
@@ -59,7 +65,7 @@ void DependencyManager::DropObject(ClientContext &context, CatalogEntry *object,
59
65
  if (cascade || dep.dependency_type == DependencyType::DEPENDENCY_AUTOMATIC ||
60
66
  dep.dependency_type == DependencyType::DEPENDENCY_OWNS) {
61
67
  // cascade: drop the dependent object
62
- catalog_set.DropEntryInternal(context, mapping_value->index.Copy(), *dependency_entry, cascade);
68
+ catalog_set.DropEntryInternal(transaction, mapping_value->index.Copy(), *dependency_entry, cascade);
63
69
  } else {
64
70
  // no cascade and there are objects that depend on this object: throw error
65
71
  throw DependencyException("Cannot drop entry \"%s\" because there are entries that "
@@ -69,7 +75,7 @@ void DependencyManager::DropObject(ClientContext &context, CatalogEntry *object,
69
75
  }
70
76
  }
71
77
 
72
- void DependencyManager::AlterObject(ClientContext &context, CatalogEntry *old_obj, CatalogEntry *new_obj) {
78
+ void DependencyManager::AlterObject(CatalogTransaction transaction, CatalogEntry *old_obj, CatalogEntry *new_obj) {
73
79
  D_ASSERT(dependents_map.find(old_obj) != dependents_map.end());
74
80
  D_ASSERT(dependencies_map.find(old_obj) != dependencies_map.end());
75
81
 
@@ -80,7 +86,7 @@ void DependencyManager::AlterObject(ClientContext &context, CatalogEntry *old_ob
80
86
  // look up the entry in the catalog set
81
87
  auto &catalog_set = *dep.entry->set;
82
88
  CatalogEntry *dependency_entry;
83
- if (!catalog_set.GetEntryInternal(context, dep.entry->name, nullptr, dependency_entry)) {
89
+ if (!catalog_set.GetEntryInternal(transaction, dep.entry->name, nullptr, dependency_entry)) {
84
90
  // the dependent object was already deleted, no conflict
85
91
  continue;
86
92
  }
@@ -182,7 +188,7 @@ void DependencyManager::Scan(const std::function<void(CatalogEntry *, CatalogEnt
182
188
  }
183
189
  }
184
190
 
185
- void DependencyManager::AddOwnership(ClientContext &context, CatalogEntry *owner, CatalogEntry *entry) {
191
+ void DependencyManager::AddOwnership(CatalogTransaction transaction, CatalogEntry *owner, CatalogEntry *entry) {
186
192
  // lock the catalog for writing
187
193
  lock_guard<mutex> write_lock(catalog.write_lock);
188
194
 
@@ -27,6 +27,14 @@ uint64_t NextPowerOfTwo(uint64_t v) {
27
27
  return v;
28
28
  }
29
29
 
30
+ bool IsInvalidSchema(const string &str) {
31
+ return str.empty();
32
+ }
33
+
34
+ bool IsInvalidCatalog(const string &str) {
35
+ return str.empty();
36
+ }
37
+
30
38
  bool IsRowIdColumnId(column_t column_id) {
31
39
  return column_id == COLUMN_IDENTIFIER_ROW_ID;
32
40
  }
@@ -15,6 +15,8 @@ string CatalogTypeToString(CatalogType type) {
15
15
  return "Table";
16
16
  case CatalogType::SCHEMA_ENTRY:
17
17
  return "Schema";
18
+ case CatalogType::DATABASE_ENTRY:
19
+ return "Database";
18
20
  case CatalogType::TABLE_FUNCTION_ENTRY:
19
21
  return "Table Function";
20
22
  case CatalogType::SCALAR_FUNCTION_ENTRY:
@@ -96,6 +96,8 @@ string LogicalOperatorToString(LogicalOperatorType type) {
96
96
  return "CREATE_VIEW";
97
97
  case LogicalOperatorType::LOGICAL_CREATE_SCHEMA:
98
98
  return "CREATE_SCHEMA";
99
+ case LogicalOperatorType::LOGICAL_ATTACH:
100
+ return "ATTACH";
99
101
  case LogicalOperatorType::LOGICAL_DROP:
100
102
  return "DROP";
101
103
  case LogicalOperatorType::LOGICAL_PRAGMA:
@@ -127,6 +127,8 @@ string PhysicalOperatorToString(PhysicalOperatorType type) {
127
127
  return "INOUT_FUNCTION";
128
128
  case PhysicalOperatorType::CREATE_TYPE:
129
129
  return "CREATE_TYPE";
130
+ case PhysicalOperatorType::ATTACH:
131
+ return "ATTACH";
130
132
  case PhysicalOperatorType::RESULT_COLLECTOR:
131
133
  return "RESULT_COLLECTOR";
132
134
  case PhysicalOperatorType::INVALID:
@@ -55,6 +55,8 @@ string StatementTypeToString(StatementType type) {
55
55
  return "EXTENSION";
56
56
  case StatementType::LOGICAL_PLAN_STATEMENT:
57
57
  return "LOGICAL_PLAN";
58
+ case StatementType::ATTACH_STATEMENT:
59
+ return "ATTACH";
58
60
  case StatementType::INVALID_STATEMENT:
59
61
  break;
60
62
  }
@@ -39,7 +39,7 @@ FileSystem::~FileSystem() {
39
39
  }
40
40
 
41
41
  FileSystem &FileSystem::GetFileSystem(ClientContext &context) {
42
- return *context.db->config.file_system;
42
+ return FileSystem::GetFileSystem(*context.db);
43
43
  }
44
44
 
45
45
  FileOpener *FileSystem::GetFileOpener(ClientContext &context) {
@@ -19,7 +19,7 @@ bool StringUtil::Contains(const string &haystack, const string &needle) {
19
19
 
20
20
  void StringUtil::LTrim(string &str) {
21
21
  auto it = str.begin();
22
- while (CharacterIsSpace(*it)) {
22
+ while (it != str.end() && CharacterIsSpace(*it)) {
23
23
  it++;
24
24
  }
25
25
  str.erase(str.begin(), it);
@@ -165,6 +165,10 @@ string StringUtil::Lower(const string &str) {
165
165
  return (copy);
166
166
  }
167
167
 
168
+ bool StringUtil::CIEquals(const string &l1, const string &l2) {
169
+ return StringUtil::Lower(l1) == StringUtil::Lower(l2);
170
+ }
171
+
168
172
  vector<string> StringUtil::Split(const string &input, const string &split) {
169
173
  vector<string> splits;
170
174
 
@@ -14,7 +14,7 @@ namespace duckdb {
14
14
 
15
15
  ART::ART(const vector<column_t> &column_ids, TableIOManager &table_io_manager,
16
16
  const vector<unique_ptr<Expression>> &unbound_expressions, IndexConstraintType constraint_type,
17
- DatabaseInstance &db, idx_t block_id, idx_t block_offset)
17
+ AttachedDatabase &db, idx_t block_id, idx_t block_offset)
18
18
  : Index(IndexType::ART, table_io_manager, column_ids, unbound_expressions, constraint_type), db(db),
19
19
  estimated_art_size(0), estimated_key_size(16) {
20
20
  if (!Radix::IsLittleEndian()) {
@@ -1,5 +1,6 @@
1
1
  #include "duckdb/execution/operator/helper/physical_transaction.hpp"
2
2
  #include "duckdb/main/client_context.hpp"
3
+ #include "duckdb/main/valid_checker.hpp"
3
4
 
4
5
  namespace duckdb {
5
6
 
@@ -98,9 +98,9 @@ unique_ptr<OperatorState> PhysicalIndexJoin::GetOperatorState(ExecutionContext &
98
98
 
99
99
  void PhysicalIndexJoin::Output(ExecutionContext &context, DataChunk &input, DataChunk &chunk,
100
100
  OperatorState &state_p) const {
101
- auto &transaction = Transaction::GetTransaction(context.client);
102
101
  auto &phy_tbl_scan = (PhysicalTableScan &)*children[1];
103
102
  auto &bind_tbl = (TableScanBindData &)*phy_tbl_scan.bind_data;
103
+ auto &transaction = Transaction::Get(context.client, *bind_tbl.table->catalog);
104
104
  auto &state = (IndexJoinOperatorState &)state_p;
105
105
 
106
106
  auto tbl = bind_tbl.table->storage.get();
@@ -264,8 +264,9 @@ unique_ptr<GlobalSinkState> PhysicalBatchInsert::GetGlobalSinkState(ClientContex
264
264
  if (info) {
265
265
  // CREATE TABLE AS
266
266
  D_ASSERT(!insert_table);
267
- auto &catalog = Catalog::GetCatalog(context);
268
- result->table = (TableCatalogEntry *)catalog.CreateTable(context, schema, info.get());
267
+ auto &catalog = *schema->catalog;
268
+ result->table =
269
+ (TableCatalogEntry *)catalog.CreateTable(catalog.GetCatalogTransaction(context), schema, info.get());
269
270
  } else {
270
271
  D_ASSERT(insert_table);
271
272
  result->table = insert_table;
@@ -37,7 +37,7 @@ SinkResultType PhysicalDelete::Sink(ExecutionContext &context, GlobalSinkState &
37
37
  auto &ustate = (DeleteLocalState &)lstate;
38
38
 
39
39
  // get rows and
40
- auto &transaction = Transaction::GetTransaction(context.client);
40
+ auto &transaction = Transaction::Get(context.client, table.db);
41
41
  auto &row_identifiers = input.data[row_id_index];
42
42
 
43
43
  vector<column_t> column_ids;
@@ -115,7 +115,7 @@ void PhysicalExport::GetData(ExecutionContext &context, DataChunk &chunk, Global
115
115
  vector<CatalogEntry *> indexes;
116
116
  vector<CatalogEntry *> macros;
117
117
 
118
- auto schema_list = Catalog::GetCatalog(ccontext).schemas->GetEntries<SchemaCatalogEntry>(context.client);
118
+ auto schema_list = Catalog::GetSchemas(ccontext, info->catalog);
119
119
  for (auto &schema : schema_list) {
120
120
  if (!schema->internal) {
121
121
  schemas.push_back(schema);
@@ -75,8 +75,9 @@ unique_ptr<GlobalSinkState> PhysicalInsert::GetGlobalSinkState(ClientContext &co
75
75
  if (info) {
76
76
  // CREATE TABLE AS
77
77
  D_ASSERT(!insert_table);
78
- auto &catalog = Catalog::GetCatalog(context);
79
- result->table = (TableCatalogEntry *)catalog.CreateTable(context, schema, info.get());
78
+ auto &catalog = *schema->catalog;
79
+ result->table =
80
+ (TableCatalogEntry *)catalog.CreateTable(catalog.GetCatalogTransaction(context), schema, info.get());
80
81
  } else {
81
82
  D_ASSERT(insert_table);
82
83
  result->table = insert_table;
@@ -188,7 +189,7 @@ void PhysicalInsert::Combine(ExecutionContext &context, GlobalSinkState &gstate_
188
189
  gstate.insert_count += append_count;
189
190
  auto table = gstate.table;
190
191
  table->storage->InitializeLocalAppend(gstate.append_state, context.client);
191
- auto &transaction = Transaction::GetTransaction(context.client);
192
+ auto &transaction = Transaction::Get(context.client, *table->catalog);
192
193
  lstate.local_collection->Scan(transaction, [&](DataChunk &insert_chunk) {
193
194
  table->storage->LocalAppend(gstate.append_state, *table, context.client, insert_chunk);
194
195
  return true;
@@ -25,7 +25,7 @@ void PhysicalAlter::GetData(ExecutionContext &context, DataChunk &chunk, GlobalS
25
25
  if (state.finished) {
26
26
  return;
27
27
  }
28
- auto &catalog = Catalog::GetCatalog(context.client);
28
+ auto &catalog = Catalog::GetCatalog(context.client, info->catalog);
29
29
  catalog.Alter(context.client, info.get());
30
30
  state.finished = true;
31
31
  }
@@ -0,0 +1,72 @@
1
+ #include "duckdb/execution/operator/schema/physical_attach.hpp"
2
+ #include "duckdb/parser/parsed_data/attach_info.hpp"
3
+ #include "duckdb/catalog/catalog.hpp"
4
+ #include "duckdb/main/database_manager.hpp"
5
+ #include "duckdb/main/attached_database.hpp"
6
+ #include "duckdb/main/database.hpp"
7
+
8
+ namespace duckdb {
9
+
10
+ //===--------------------------------------------------------------------===//
11
+ // Source
12
+ //===--------------------------------------------------------------------===//
13
+ class AttachSourceState : public GlobalSourceState {
14
+ public:
15
+ AttachSourceState() : finished(false) {
16
+ }
17
+
18
+ bool finished;
19
+ };
20
+
21
+ unique_ptr<GlobalSourceState> PhysicalAttach::GetGlobalSourceState(ClientContext &context) const {
22
+ return make_unique<AttachSourceState>();
23
+ }
24
+
25
+ void PhysicalAttach::GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
26
+ LocalSourceState &lstate) const {
27
+ auto &state = (AttachSourceState &)gstate;
28
+ if (state.finished) {
29
+ return;
30
+ }
31
+ // parse the options
32
+ auto &config = DBConfig::GetConfig(context.client);
33
+ AccessMode access_mode = config.options.access_mode;
34
+ for (auto &entry : info->options) {
35
+ if (entry.first == "readonly" || entry.first == "read_only") {
36
+ auto read_only = BooleanValue::Get(entry.second.DefaultCastAs(LogicalType::BOOLEAN));
37
+ if (read_only) {
38
+ access_mode = AccessMode::READ_ONLY;
39
+ } else {
40
+ access_mode = AccessMode::READ_WRITE;
41
+ }
42
+ } else if (entry.first == "read_write" || entry.first == "read_write") {
43
+ auto read_only = !BooleanValue::Get(entry.second.DefaultCastAs(LogicalType::BOOLEAN));
44
+ if (read_only) {
45
+ access_mode = AccessMode::READ_ONLY;
46
+ } else {
47
+ access_mode = AccessMode::READ_WRITE;
48
+ }
49
+ } else {
50
+ throw BinderException("Unrecognized option for attach \"%s\"", entry.first);
51
+ }
52
+ }
53
+ // attach the database
54
+ auto name = info->name;
55
+ auto path = info->path;
56
+ auto &db = DatabaseInstance::GetDatabase(context.client);
57
+ if (name.empty()) {
58
+ name = AttachedDatabase::ExtractDatabaseName(path);
59
+ }
60
+ auto &db_manager = DatabaseManager::Get(context.client);
61
+ auto existing_db = db_manager.GetDatabaseFromPath(context.client, path);
62
+ if (existing_db) {
63
+ throw BinderException("Database \"%s\" is already attached with alias \"%s\"", path, existing_db->GetName());
64
+ }
65
+ auto new_db = make_unique<AttachedDatabase>(db, Catalog::GetSystemCatalog(context.client), name, path, access_mode);
66
+ new_db->Initialize();
67
+
68
+ db_manager.AddDatabase(context.client, move(new_db));
69
+ state.finished = true;
70
+ }
71
+
72
+ } // namespace duckdb
@@ -26,7 +26,8 @@ void PhysicalCreateFunction::GetData(ExecutionContext &context, DataChunk &chunk
26
26
  if (state.finished) {
27
27
  return;
28
28
  }
29
- Catalog::GetCatalog(context.client).CreateFunction(context.client, info.get());
29
+ auto &catalog = Catalog::GetCatalog(context.client, info->catalog);
30
+ catalog.CreateFunction(context.client, info.get());
30
31
  state.finished = true;
31
32
  }
32
33
 
@@ -6,6 +6,7 @@
6
6
  #include "duckdb/execution/expression_executor.hpp"
7
7
  #include "duckdb/main/client_context.hpp"
8
8
  #include "duckdb/storage/storage_manager.hpp"
9
+ #include "duckdb/main/database_manager.hpp"
9
10
 
10
11
  namespace duckdb {
11
12
 
@@ -38,14 +39,13 @@ public:
38
39
  };
39
40
 
40
41
  unique_ptr<GlobalSinkState> PhysicalCreateIndex::GetGlobalSinkState(ClientContext &context) const {
41
-
42
42
  auto state = make_unique<CreateIndexGlobalSinkState>();
43
43
 
44
44
  // create the global index
45
45
  switch (info->index_type) {
46
46
  case IndexType::ART: {
47
47
  state->global_index = make_unique<ART>(storage_ids, TableIOManager::Get(*table.storage), unbound_expressions,
48
- info->constraint_type, *context.db);
48
+ info->constraint_type, table.storage->db);
49
49
  break;
50
50
  }
51
51
  default:
@@ -64,7 +64,7 @@ unique_ptr<LocalSinkState> PhysicalCreateIndex::GetLocalSinkState(ExecutionConte
64
64
  switch (info->index_type) {
65
65
  case IndexType::ART: {
66
66
  state->local_index = make_unique<ART>(storage_ids, TableIOManager::Get(*table.storage), unbound_expressions,
67
- info->constraint_type, *context.client.db);
67
+ info->constraint_type, table.storage->db);
68
68
  break;
69
69
  }
70
70
  default:
@@ -24,7 +24,11 @@ void PhysicalCreateSchema::GetData(ExecutionContext &context, DataChunk &chunk,
24
24
  if (state.finished) {
25
25
  return;
26
26
  }
27
- Catalog::GetCatalog(context.client).CreateSchema(context.client, info.get());
27
+ auto &catalog = Catalog::GetCatalog(context.client, info->catalog);
28
+ if (catalog.IsSystemCatalog()) {
29
+ throw BinderException("Cannot create schema in system catalog");
30
+ }
31
+ catalog.CreateSchema(context.client, info.get());
28
32
  state.finished = true;
29
33
  }
30
34
 
@@ -24,7 +24,8 @@ void PhysicalCreateSequence::GetData(ExecutionContext &context, DataChunk &chunk
24
24
  if (state.finished) {
25
25
  return;
26
26
  }
27
- Catalog::GetCatalog(context.client).CreateSequence(context.client, info.get());
27
+ auto &catalog = Catalog::GetCatalog(context.client, info->catalog);
28
+ catalog.CreateSequence(context.client, info.get());
28
29
  state.finished = true;
29
30
  }
30
31
 
@@ -34,8 +34,8 @@ void PhysicalCreateTable::GetData(ExecutionContext &context, DataChunk &chunk, G
34
34
  if (state.finished) {
35
35
  return;
36
36
  }
37
- auto &catalog = Catalog::GetCatalog(context.client);
38
- catalog.CreateTable(context.client, schema, info.get());
37
+ auto &catalog = *schema->catalog;
38
+ catalog.CreateTable(catalog.GetCatalogTransaction(context.client), schema, info.get());
39
39
  state.finished = true;
40
40
  }
41
41
 
@@ -108,7 +108,7 @@ void PhysicalCreateType::GetData(ExecutionContext &context, DataChunk &chunk, Gl
108
108
  info->type = LogicalType::ENUM(info->name, result, total_row_count);
109
109
  }
110
110
 
111
- auto &catalog = Catalog::GetCatalog(context.client);
111
+ auto &catalog = Catalog::GetCatalog(context.client, info->catalog);
112
112
  catalog.CreateType(context.client, info.get());
113
113
  state.finished = true;
114
114
  }
@@ -24,7 +24,8 @@ void PhysicalCreateView::GetData(ExecutionContext &context, DataChunk &chunk, Gl
24
24
  if (state.finished) {
25
25
  return;
26
26
  }
27
- Catalog::GetCatalog(context.client).CreateView(context.client, info.get());
27
+ auto &catalog = Catalog::GetCatalog(context.client, info->catalog);
28
+ catalog.CreateView(context.client, info.get());
28
29
  state.finished = true;
29
30
  }
30
31
 
@@ -1,5 +1,6 @@
1
1
  #include "duckdb/execution/operator/schema/physical_drop.hpp"
2
2
  #include "duckdb/main/client_data.hpp"
3
+ #include "duckdb/main/database_manager.hpp"
3
4
 
4
5
  namespace duckdb {
5
6
 
@@ -33,10 +34,17 @@ void PhysicalDrop::GetData(ExecutionContext &context, DataChunk &chunk, GlobalSo
33
34
  }
34
35
  break;
35
36
  }
36
- default:
37
- Catalog::GetCatalog(context.client).DropEntry(context.client, info.get());
37
+ case CatalogType::DATABASE_ENTRY: {
38
+ auto &db_manager = DatabaseManager::Get(context.client);
39
+ db_manager.DetachDatabase(context.client, info->name, info->if_exists);
38
40
  break;
39
41
  }
42
+ default: {
43
+ auto &catalog = Catalog::GetCatalog(context.client, info->catalog);
44
+ catalog.DropEntry(context.client, info.get());
45
+ break;
46
+ }
47
+ }
40
48
  state.finished = true;
41
49
  }
42
50
 
@@ -18,12 +18,13 @@
18
18
 
19
19
  namespace duckdb {
20
20
 
21
- static bool CanPlanIndexJoin(Transaction &transaction, TableScanBindData *bind_data, PhysicalTableScan &scan) {
21
+ static bool CanPlanIndexJoin(ClientContext &context, TableScanBindData *bind_data, PhysicalTableScan &scan) {
22
22
  if (!bind_data) {
23
23
  // not a table scan
24
24
  return false;
25
25
  }
26
26
  auto table = bind_data->table;
27
+ auto &transaction = Transaction::Get(context, *table->catalog);
27
28
  auto &local_storage = LocalStorage::Get(transaction);
28
29
  if (local_storage.Find(table->storage.get())) {
29
30
  // transaction local appends: skip index join
@@ -146,7 +147,6 @@ static void CanUseIndexJoin(TableScanBindData *tbl, Expression &expr, Index **re
146
147
 
147
148
  void TransformIndexJoin(ClientContext &context, LogicalComparisonJoin &op, Index **left_index, Index **right_index,
148
149
  PhysicalOperator *left, PhysicalOperator *right) {
149
- auto &transaction = Transaction::GetTransaction(context);
150
150
  // check if one of the tables has an index on column
151
151
  if (op.join_type == JoinType::INNER && op.conditions.size() == 1) {
152
152
  // check if one of the children are table scans and if they have an index in the join attribute
@@ -154,14 +154,14 @@ void TransformIndexJoin(ClientContext &context, LogicalComparisonJoin &op, Index
154
154
  if (left->type == PhysicalOperatorType::TABLE_SCAN) {
155
155
  auto &tbl_scan = (PhysicalTableScan &)*left;
156
156
  auto tbl = dynamic_cast<TableScanBindData *>(tbl_scan.bind_data.get());
157
- if (CanPlanIndexJoin(transaction, tbl, tbl_scan)) {
157
+ if (CanPlanIndexJoin(context, tbl, tbl_scan)) {
158
158
  CanUseIndexJoin(tbl, *op.conditions[0].left, left_index);
159
159
  }
160
160
  }
161
161
  if (right->type == PhysicalOperatorType::TABLE_SCAN) {
162
162
  auto &tbl_scan = (PhysicalTableScan &)*right;
163
163
  auto tbl = dynamic_cast<TableScanBindData *>(tbl_scan.bind_data.get());
164
- if (CanPlanIndexJoin(transaction, tbl, tbl_scan)) {
164
+ if (CanPlanIndexJoin(context, tbl, tbl_scan)) {
165
165
  CanUseIndexJoin(tbl, *op.conditions[0].right, right_index);
166
166
  }
167
167
  }
@@ -25,7 +25,7 @@ unique_ptr<PhysicalOperator> PhysicalPlanGenerator::CreatePlan(LogicalCreateInde
25
25
  make_unique<PhysicalTableScan>(op.info->scan_types, op.function, move(op.bind_data), op.info->column_ids,
26
26
  op.info->names, move(table_filters), op.estimated_cardinality);
27
27
 
28
- dependencies.insert(&op.table);
28
+ dependencies.AddDependency(&op.table);
29
29
  op.info->column_ids.pop_back();
30
30
 
31
31
  D_ASSERT(op.info->scan_types.size() - 1 <= op.info->names.size());
@@ -14,9 +14,8 @@ namespace duckdb {
14
14
 
15
15
  unique_ptr<PhysicalOperator> PhysicalPlanGenerator::CreatePlan(LogicalCreateTable &op) {
16
16
  auto &create_info = (CreateTableInfo &)*op.info->base;
17
- auto &catalog = Catalog::GetCatalog(context);
18
- auto existing_entry =
19
- catalog.GetEntry(context, CatalogType::TABLE_ENTRY, create_info.schema, create_info.table, true);
17
+ auto &catalog = *op.info->schema->catalog;
18
+ auto existing_entry = catalog.GetEntry<TableCatalogEntry>(context, create_info.schema, create_info.table, true);
20
19
  bool replace = op.info->Base().on_conflict == OnCreateConflict::REPLACE_ON_CONFLICT;
21
20
  if ((!existing_entry || replace) && !op.children.empty()) {
22
21
  auto plan = CreatePlan(*op.children[0]);
@@ -16,7 +16,7 @@ unique_ptr<PhysicalOperator> PhysicalPlanGenerator::CreatePlan(LogicalDelete &op
16
16
  // get the index of the row_id column
17
17
  auto &bound_ref = (BoundReferenceExpression &)*op.expressions[0];
18
18
 
19
- dependencies.insert(op.table);
19
+ dependencies.AddDependency(op.table);
20
20
  auto del = make_unique<PhysicalDelete>(op.types, *op.table, *op.table->storage, bound_ref.index,
21
21
  op.estimated_cardinality, op.return_chunk);
22
22
  del->children.push_back(move(plan));
@@ -50,7 +50,7 @@ unique_ptr<PhysicalOperator> PhysicalPlanGenerator::CreatePlan(LogicalInsert &op
50
50
  D_ASSERT(op.children.size() == 1);
51
51
  plan = CreatePlan(*op.children[0]);
52
52
  }
53
- dependencies.insert(op.table);
53
+ dependencies.AddDependency(op.table);
54
54
 
55
55
  bool parallel_streaming_insert = !PreserveInsertionOrder(*plan);
56
56
  bool use_batch_index = UseBatchIndex(*plan);
@@ -2,6 +2,7 @@
2
2
  #include "duckdb/execution/operator/helper/physical_transaction.hpp"
3
3
  #include "duckdb/execution/operator/helper/physical_vacuum.hpp"
4
4
  #include "duckdb/execution/operator/schema/physical_alter.hpp"
5
+ #include "duckdb/execution/operator/schema/physical_attach.hpp"
5
6
  #include "duckdb/execution/operator/schema/physical_create_schema.hpp"
6
7
  #include "duckdb/execution/operator/schema/physical_create_sequence.hpp"
7
8
  #include "duckdb/execution/operator/schema/physical_create_view.hpp"
@@ -33,6 +34,9 @@ unique_ptr<PhysicalOperator> PhysicalPlanGenerator::CreatePlan(LogicalSimple &op
33
34
  }
34
35
  case LogicalOperatorType::LOGICAL_LOAD:
35
36
  return make_unique<PhysicalLoad>(unique_ptr_cast<ParseInfo, LoadInfo>(move(op.info)), op.estimated_cardinality);
37
+ case LogicalOperatorType::LOGICAL_ATTACH:
38
+ return make_unique<PhysicalAttach>(unique_ptr_cast<ParseInfo, AttachInfo>(move(op.info)),
39
+ op.estimated_cardinality);
36
40
  default:
37
41
  throw NotImplementedException("Unimplemented type for logical simple operator");
38
42
  }
@@ -10,7 +10,7 @@ unique_ptr<PhysicalOperator> PhysicalPlanGenerator::CreatePlan(LogicalUpdate &op
10
10
 
11
11
  auto plan = CreatePlan(*op.children[0]);
12
12
 
13
- dependencies.insert(op.table);
13
+ dependencies.AddDependency(op.table);
14
14
  auto update = make_unique<PhysicalUpdate>(op.types, *op.table, *op.table->storage, op.columns, move(op.expressions),
15
15
  move(op.bound_defaults), op.estimated_cardinality, op.return_chunk);
16
16
 
@@ -13,7 +13,7 @@ namespace duckdb {
13
13
 
14
14
  class DependencyExtractor : public LogicalOperatorVisitor {
15
15
  public:
16
- explicit DependencyExtractor(unordered_set<CatalogEntry *> &dependencies) : dependencies(dependencies) {
16
+ explicit DependencyExtractor(DependencyList &dependencies) : dependencies(dependencies) {
17
17
  }
18
18
 
19
19
  protected:
@@ -26,7 +26,7 @@ protected:
26
26
  }
27
27
 
28
28
  private:
29
- unordered_set<CatalogEntry *> &dependencies;
29
+ DependencyList &dependencies;
30
30
  };
31
31
 
32
32
  PhysicalPlanGenerator::PhysicalPlanGenerator(ClientContext &context) : context(context) {
@@ -180,6 +180,7 @@ unique_ptr<PhysicalOperator> PhysicalPlanGenerator::CreatePlan(LogicalOperator &
180
180
  case LogicalOperatorType::LOGICAL_DROP:
181
181
  case LogicalOperatorType::LOGICAL_VACUUM:
182
182
  case LogicalOperatorType::LOGICAL_LOAD:
183
+ case LogicalOperatorType::LOGICAL_ATTACH:
183
184
  plan = CreatePlan((LogicalSimple &)op);
184
185
  break;
185
186
  case LogicalOperatorType::LOGICAL_RECURSIVE_CTE: