duckdb 0.6.2-dev781.0 → 0.6.2-dev891.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (320) hide show
  1. package/binding.gyp +1 -1
  2. package/package.json +1 -1
  3. package/src/connection.cpp +2 -1
  4. package/src/duckdb/extension/icu/icu-dateadd.cpp +3 -3
  5. package/src/duckdb/extension/icu/icu-datepart.cpp +3 -3
  6. package/src/duckdb/extension/icu/icu-datesub.cpp +2 -2
  7. package/src/duckdb/extension/icu/icu-datetrunc.cpp +1 -1
  8. package/src/duckdb/extension/icu/icu-extension.cpp +1 -1
  9. package/src/duckdb/extension/icu/icu-makedate.cpp +1 -1
  10. package/src/duckdb/extension/icu/icu-strptime.cpp +2 -2
  11. package/src/duckdb/extension/icu/icu-timezone.cpp +6 -5
  12. package/src/duckdb/extension/json/json-extension.cpp +1 -1
  13. package/src/duckdb/extension/parquet/column_reader.cpp +7 -0
  14. package/src/duckdb/extension/parquet/parquet-extension.cpp +1 -1
  15. package/src/duckdb/src/catalog/catalog.cpp +516 -177
  16. package/src/duckdb/src/catalog/catalog_entry/index_catalog_entry.cpp +1 -0
  17. package/src/duckdb/src/catalog/catalog_entry/schema_catalog_entry.cpp +66 -49
  18. package/src/duckdb/src/catalog/catalog_entry/table_catalog_entry.cpp +15 -16
  19. package/src/duckdb/src/catalog/catalog_entry/view_catalog_entry.cpp +1 -1
  20. package/src/duckdb/src/catalog/catalog_entry.cpp +6 -2
  21. package/src/duckdb/src/catalog/catalog_search_path.cpp +177 -22
  22. package/src/duckdb/src/catalog/catalog_set.cpp +134 -72
  23. package/src/duckdb/src/catalog/catalog_transaction.cpp +28 -0
  24. package/src/duckdb/src/catalog/default/default_views.cpp +4 -4
  25. package/src/duckdb/src/catalog/dependency_list.cpp +13 -0
  26. package/src/duckdb/src/catalog/dependency_manager.cpp +19 -13
  27. package/src/duckdb/src/common/constants.cpp +8 -0
  28. package/src/duckdb/src/common/enums/catalog_type.cpp +2 -0
  29. package/src/duckdb/src/common/enums/logical_operator_type.cpp +2 -0
  30. package/src/duckdb/src/common/enums/physical_operator_type.cpp +2 -0
  31. package/src/duckdb/src/common/enums/statement_type.cpp +2 -0
  32. package/src/duckdb/src/common/file_system.cpp +1 -1
  33. package/src/duckdb/src/common/string_util.cpp +5 -1
  34. package/src/duckdb/src/execution/index/art/art.cpp +1 -1
  35. package/src/duckdb/src/execution/operator/helper/physical_transaction.cpp +1 -0
  36. package/src/duckdb/src/execution/operator/join/physical_index_join.cpp +1 -1
  37. package/src/duckdb/src/execution/operator/persistent/physical_batch_insert.cpp +3 -2
  38. package/src/duckdb/src/execution/operator/persistent/physical_delete.cpp +1 -1
  39. package/src/duckdb/src/execution/operator/persistent/physical_export.cpp +1 -1
  40. package/src/duckdb/src/execution/operator/persistent/physical_insert.cpp +4 -3
  41. package/src/duckdb/src/execution/operator/schema/physical_alter.cpp +1 -1
  42. package/src/duckdb/src/execution/operator/schema/physical_attach.cpp +72 -0
  43. package/src/duckdb/src/execution/operator/schema/physical_create_function.cpp +2 -1
  44. package/src/duckdb/src/execution/operator/schema/physical_create_index.cpp +3 -3
  45. package/src/duckdb/src/execution/operator/schema/physical_create_schema.cpp +5 -1
  46. package/src/duckdb/src/execution/operator/schema/physical_create_sequence.cpp +2 -1
  47. package/src/duckdb/src/execution/operator/schema/physical_create_table.cpp +2 -2
  48. package/src/duckdb/src/execution/operator/schema/physical_create_type.cpp +1 -1
  49. package/src/duckdb/src/execution/operator/schema/physical_create_view.cpp +2 -1
  50. package/src/duckdb/src/execution/operator/schema/physical_drop.cpp +10 -2
  51. package/src/duckdb/src/execution/physical_plan/plan_comparison_join.cpp +4 -4
  52. package/src/duckdb/src/execution/physical_plan/plan_create_index.cpp +1 -1
  53. package/src/duckdb/src/execution/physical_plan/plan_create_table.cpp +2 -3
  54. package/src/duckdb/src/execution/physical_plan/plan_delete.cpp +1 -1
  55. package/src/duckdb/src/execution/physical_plan/plan_insert.cpp +1 -1
  56. package/src/duckdb/src/execution/physical_plan/plan_simple.cpp +4 -0
  57. package/src/duckdb/src/execution/physical_plan/plan_update.cpp +1 -1
  58. package/src/duckdb/src/execution/physical_plan_generator.cpp +3 -2
  59. package/src/duckdb/src/function/built_in_functions.cpp +88 -0
  60. package/src/duckdb/src/function/function.cpp +0 -79
  61. package/src/duckdb/src/function/function_binder.cpp +2 -1
  62. package/src/duckdb/src/function/pragma/pragma_queries.cpp +10 -1
  63. package/src/duckdb/src/function/scalar/date/current.cpp +2 -2
  64. package/src/duckdb/src/function/scalar/list/list_aggregates.cpp +3 -2
  65. package/src/duckdb/src/function/scalar/sequence/nextval.cpp +14 -17
  66. package/src/duckdb/src/function/scalar/system/aggregate_export.cpp +2 -2
  67. package/src/duckdb/src/function/scalar/system/system_functions.cpp +7 -4
  68. package/src/duckdb/src/function/table/checkpoint.cpp +37 -4
  69. package/src/duckdb/src/function/table/read_csv.cpp +1 -1
  70. package/src/duckdb/src/function/table/system/duckdb_columns.cpp +32 -25
  71. package/src/duckdb/src/function/table/system/duckdb_constraints.cpp +26 -22
  72. package/src/duckdb/src/function/table/system/duckdb_dependencies.cpp +1 -1
  73. package/src/duckdb/src/function/table/system/duckdb_extensions.cpp +1 -1
  74. package/src/duckdb/src/function/table/system/duckdb_functions.cpp +22 -15
  75. package/src/duckdb/src/function/table/system/duckdb_indexes.cpp +25 -18
  76. package/src/duckdb/src/function/table/system/duckdb_schemas.cpp +16 -8
  77. package/src/duckdb/src/function/table/system/duckdb_sequences.cpp +26 -19
  78. package/src/duckdb/src/function/table/system/duckdb_tables.cpp +24 -17
  79. package/src/duckdb/src/function/table/system/duckdb_types.cpp +22 -16
  80. package/src/duckdb/src/function/table/system/duckdb_views.cpp +20 -13
  81. package/src/duckdb/src/function/table/system/pragma_collations.cpp +3 -4
  82. package/src/duckdb/src/function/table/system/pragma_database_list.cpp +20 -12
  83. package/src/duckdb/src/function/table/system/pragma_database_size.cpp +39 -24
  84. package/src/duckdb/src/function/table/system/pragma_storage_info.cpp +1 -7
  85. package/src/duckdb/src/function/table/system/pragma_table_info.cpp +3 -2
  86. package/src/duckdb/src/function/table/system_functions.cpp +0 -1
  87. package/src/duckdb/src/function/table/table_scan.cpp +13 -10
  88. package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
  89. package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +102 -81
  90. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/aggregate_function_catalog_entry.hpp +4 -0
  91. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/collate_catalog_entry.hpp +4 -0
  92. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/copy_function_catalog_entry.hpp +4 -0
  93. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/index_catalog_entry.hpp +4 -0
  94. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/pragma_function_catalog_entry.hpp +4 -0
  95. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/scalar_function_catalog_entry.hpp +4 -0
  96. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/scalar_macro_catalog_entry.hpp +4 -0
  97. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/schema_catalog_entry.hpp +21 -14
  98. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/sequence_catalog_entry.hpp +4 -0
  99. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_catalog_entry.hpp +4 -0
  100. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_function_catalog_entry.hpp +4 -0
  101. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_macro_catalog_entry.hpp +4 -0
  102. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/type_catalog_entry.hpp +4 -0
  103. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/view_catalog_entry.hpp +4 -0
  104. package/src/duckdb/src/include/duckdb/catalog/catalog_entry.hpp +2 -0
  105. package/src/duckdb/src/include/duckdb/catalog/catalog_search_path.hpp +30 -11
  106. package/src/duckdb/src/include/duckdb/catalog/catalog_set.hpp +35 -20
  107. package/src/duckdb/src/include/duckdb/catalog/catalog_transaction.hpp +32 -0
  108. package/src/duckdb/src/include/duckdb/catalog/dependency_list.hpp +27 -0
  109. package/src/duckdb/src/include/duckdb/catalog/dependency_manager.hpp +6 -4
  110. package/src/duckdb/src/include/duckdb/common/allocator.hpp +3 -0
  111. package/src/duckdb/src/include/duckdb/common/constants.hpp +8 -3
  112. package/src/duckdb/src/include/duckdb/common/enums/catalog_type.hpp +1 -0
  113. package/src/duckdb/src/include/duckdb/common/enums/logical_operator_type.hpp +1 -0
  114. package/src/duckdb/src/include/duckdb/common/enums/physical_operator_type.hpp +1 -0
  115. package/src/duckdb/src/include/duckdb/common/enums/statement_type.hpp +10 -4
  116. package/src/duckdb/src/include/duckdb/common/file_system.hpp +2 -0
  117. package/src/duckdb/src/include/duckdb/common/string_util.hpp +3 -0
  118. package/src/duckdb/src/include/duckdb/execution/index/art/art.hpp +2 -2
  119. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_attach.hpp +33 -0
  120. package/src/duckdb/src/include/duckdb/execution/physical_plan_generator.hpp +2 -1
  121. package/src/duckdb/src/include/duckdb/function/aggregate/algebraic_functions.hpp +1 -0
  122. package/src/duckdb/src/include/duckdb/function/aggregate/distributive_functions.hpp +1 -0
  123. package/src/duckdb/src/include/duckdb/function/aggregate/holistic_functions.hpp +1 -0
  124. package/src/duckdb/src/include/duckdb/function/aggregate/nested_functions.hpp +1 -0
  125. package/src/duckdb/src/include/duckdb/function/aggregate/regression_functions.hpp +1 -0
  126. package/src/duckdb/src/include/duckdb/function/built_in_functions.hpp +78 -0
  127. package/src/duckdb/src/include/duckdb/function/function.hpp +0 -61
  128. package/src/duckdb/src/include/duckdb/function/function_serialization.hpp +1 -2
  129. package/src/duckdb/src/include/duckdb/function/pragma/pragma_functions.hpp +1 -0
  130. package/src/duckdb/src/include/duckdb/function/scalar/blob_functions.hpp +1 -0
  131. package/src/duckdb/src/include/duckdb/function/scalar/date_functions.hpp +1 -0
  132. package/src/duckdb/src/include/duckdb/function/scalar/enum_functions.hpp +1 -0
  133. package/src/duckdb/src/include/duckdb/function/scalar/generic_functions.hpp +1 -0
  134. package/src/duckdb/src/include/duckdb/function/scalar/math_functions.hpp +1 -0
  135. package/src/duckdb/src/include/duckdb/function/scalar/nested_functions.hpp +1 -0
  136. package/src/duckdb/src/include/duckdb/function/scalar/operators.hpp +1 -0
  137. package/src/duckdb/src/include/duckdb/function/scalar/regexp.hpp +1 -0
  138. package/src/duckdb/src/include/duckdb/function/scalar/sequence_functions.hpp +1 -0
  139. package/src/duckdb/src/include/duckdb/function/scalar/string_functions.hpp +1 -0
  140. package/src/duckdb/src/include/duckdb/function/scalar/trigonometric_functions.hpp +1 -0
  141. package/src/duckdb/src/include/duckdb/function/scalar/uuid_functions.hpp +1 -0
  142. package/src/duckdb/src/include/duckdb/function/scalar_function.hpp +2 -1
  143. package/src/duckdb/src/include/duckdb/function/table/arrow.hpp +1 -0
  144. package/src/duckdb/src/include/duckdb/function/table/range.hpp +1 -0
  145. package/src/duckdb/src/include/duckdb/function/table/read_csv.hpp +1 -0
  146. package/src/duckdb/src/include/duckdb/function/table/summary.hpp +1 -0
  147. package/src/duckdb/src/include/duckdb/function/table/system_functions.hpp +1 -4
  148. package/src/duckdb/src/include/duckdb/function/table/table_scan.hpp +1 -0
  149. package/src/duckdb/src/include/duckdb/function/table_function.hpp +2 -1
  150. package/src/duckdb/src/include/duckdb/main/attached_database.hpp +64 -0
  151. package/src/duckdb/src/include/duckdb/main/client_context.hpp +3 -3
  152. package/src/duckdb/src/include/duckdb/main/client_data.hpp +2 -1
  153. package/src/duckdb/src/include/duckdb/main/config.hpp +3 -0
  154. package/src/duckdb/src/include/duckdb/main/database.hpp +6 -6
  155. package/src/duckdb/src/include/duckdb/main/database_manager.hpp +69 -0
  156. package/src/duckdb/src/include/duckdb/main/settings.hpp +10 -0
  157. package/src/duckdb/src/include/duckdb/main/valid_checker.hpp +2 -2
  158. package/src/duckdb/src/include/duckdb/parser/expression/function_expression.hpp +3 -1
  159. package/src/duckdb/src/include/duckdb/parser/expression/window_expression.hpp +3 -1
  160. package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_function_info.hpp +2 -2
  161. package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_info.hpp +18 -1
  162. package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_table_info.hpp +53 -56
  163. package/src/duckdb/src/include/duckdb/parser/parsed_data/attach_info.hpp +39 -0
  164. package/src/duckdb/src/include/duckdb/parser/parsed_data/copy_info.hpp +4 -1
  165. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_aggregate_function_info.hpp +3 -18
  166. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_collation_info.hpp +4 -13
  167. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_copy_function_info.hpp +3 -12
  168. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_index_info.hpp +1 -1
  169. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_info.hpp +5 -3
  170. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_pragma_function_info.hpp +3 -14
  171. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_table_function_info.hpp +3 -19
  172. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_table_info.hpp +3 -1
  173. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_view_info.hpp +7 -34
  174. package/src/duckdb/src/include/duckdb/parser/parsed_data/drop_info.hpp +7 -1
  175. package/src/duckdb/src/include/duckdb/parser/parsed_data/exported_table_data.hpp +3 -0
  176. package/src/duckdb/src/include/duckdb/parser/parser_extension.hpp +2 -2
  177. package/src/duckdb/src/include/duckdb/parser/qualified_name.hpp +10 -2
  178. package/src/duckdb/src/include/duckdb/parser/query_error_context.hpp +2 -2
  179. package/src/duckdb/src/include/duckdb/parser/statement/attach_statement.hpp +29 -0
  180. package/src/duckdb/src/include/duckdb/parser/statement/export_statement.hpp +1 -0
  181. package/src/duckdb/src/include/duckdb/parser/statement/insert_statement.hpp +2 -0
  182. package/src/duckdb/src/include/duckdb/parser/statement/list.hpp +1 -0
  183. package/src/duckdb/src/include/duckdb/parser/tableref/basetableref.hpp +4 -1
  184. package/src/duckdb/src/include/duckdb/parser/tokens.hpp +1 -0
  185. package/src/duckdb/src/include/duckdb/parser/transformer.hpp +2 -0
  186. package/src/duckdb/src/include/duckdb/planner/bind_context.hpp +2 -0
  187. package/src/duckdb/src/include/duckdb/planner/binder.hpp +11 -1
  188. package/src/duckdb/src/include/duckdb/planner/parsed_data/bound_create_table_info.hpp +2 -1
  189. package/src/duckdb/src/include/duckdb/storage/buffer_manager.hpp +1 -0
  190. package/src/duckdb/src/include/duckdb/storage/checkpoint_manager.hpp +13 -6
  191. package/src/duckdb/src/include/duckdb/storage/data_table.hpp +10 -2
  192. package/src/duckdb/src/include/duckdb/storage/single_file_block_manager.hpp +2 -2
  193. package/src/duckdb/src/include/duckdb/storage/statistics/base_statistics.hpp +2 -2
  194. package/src/duckdb/src/include/duckdb/storage/storage_manager.hpp +9 -12
  195. package/src/duckdb/src/include/duckdb/storage/table/data_table_info.hpp +3 -7
  196. package/src/duckdb/src/include/duckdb/storage/table/row_group.hpp +5 -6
  197. package/src/duckdb/src/include/duckdb/storage/write_ahead_log.hpp +9 -7
  198. package/src/duckdb/src/include/duckdb/transaction/local_storage.hpp +3 -1
  199. package/src/duckdb/src/include/duckdb/transaction/meta_transaction.hpp +64 -0
  200. package/src/duckdb/src/include/duckdb/transaction/transaction.hpp +14 -23
  201. package/src/duckdb/src/include/duckdb/transaction/transaction_context.hpp +12 -8
  202. package/src/duckdb/src/include/duckdb/transaction/transaction_manager.hpp +5 -10
  203. package/src/duckdb/src/include/duckdb/transaction/undo_buffer.hpp +1 -1
  204. package/src/duckdb/src/main/attached_database.cpp +97 -0
  205. package/src/duckdb/src/main/capi/table_function-c.cpp +1 -1
  206. package/src/duckdb/src/main/client_context.cpp +28 -22
  207. package/src/duckdb/src/main/client_data.cpp +5 -2
  208. package/src/duckdb/src/main/config.cpp +1 -0
  209. package/src/duckdb/src/main/database.cpp +54 -40
  210. package/src/duckdb/src/main/database_manager.cpp +95 -0
  211. package/src/duckdb/src/main/materialized_query_result.cpp +1 -1
  212. package/src/duckdb/src/main/prepared_statement_data.cpp +1 -2
  213. package/src/duckdb/src/main/query_result.cpp +4 -4
  214. package/src/duckdb/src/main/settings/settings.cpp +22 -6
  215. package/src/duckdb/src/main/stream_query_result.cpp +1 -1
  216. package/src/duckdb/src/parser/expression/columnref_expression.cpp +9 -3
  217. package/src/duckdb/src/parser/expression/function_expression.cpp +15 -13
  218. package/src/duckdb/src/parser/expression/window_expression.cpp +6 -4
  219. package/src/duckdb/src/parser/parsed_data/alter_function_info.cpp +7 -7
  220. package/src/duckdb/src/parser/parsed_data/alter_info.cpp +12 -2
  221. package/src/duckdb/src/parser/parsed_data/alter_table_info.cpp +96 -98
  222. package/src/duckdb/src/parser/parsed_data/create_aggregate_function_info.cpp +27 -0
  223. package/src/duckdb/src/parser/parsed_data/create_collation_info.cpp +23 -0
  224. package/src/duckdb/src/parser/parsed_data/create_copy_function_info.cpp +21 -0
  225. package/src/duckdb/src/parser/parsed_data/create_info.cpp +3 -0
  226. package/src/duckdb/src/parser/parsed_data/create_pragma_function_info.cpp +23 -0
  227. package/src/duckdb/src/parser/parsed_data/create_scalar_function_info.cpp +3 -1
  228. package/src/duckdb/src/parser/parsed_data/create_table_function_info.cpp +28 -0
  229. package/src/duckdb/src/parser/parsed_data/create_table_info.cpp +9 -3
  230. package/src/duckdb/src/parser/parsed_data/create_view_info.cpp +49 -0
  231. package/src/duckdb/src/parser/statement/attach_statement.cpp +15 -0
  232. package/src/duckdb/src/parser/statement/insert_statement.cpp +6 -2
  233. package/src/duckdb/src/parser/tableref/basetableref.cpp +9 -4
  234. package/src/duckdb/src/parser/transform/constraint/transform_constraint.cpp +15 -13
  235. package/src/duckdb/src/parser/transform/expression/transform_function.cpp +17 -7
  236. package/src/duckdb/src/parser/transform/expression/transform_operator.cpp +4 -9
  237. package/src/duckdb/src/parser/transform/helpers/nodetype_to_string.cpp +4 -0
  238. package/src/duckdb/src/parser/transform/statement/transform_alter_sequence.cpp +5 -4
  239. package/src/duckdb/src/parser/transform/statement/transform_alter_table.cpp +8 -10
  240. package/src/duckdb/src/parser/transform/statement/transform_attach.cpp +32 -0
  241. package/src/duckdb/src/parser/transform/statement/transform_checkpoint.cpp +7 -2
  242. package/src/duckdb/src/parser/transform/statement/transform_copy.cpp +1 -0
  243. package/src/duckdb/src/parser/transform/statement/transform_create_function.cpp +1 -0
  244. package/src/duckdb/src/parser/transform/statement/transform_create_schema.cpp +1 -0
  245. package/src/duckdb/src/parser/transform/statement/transform_create_sequence.cpp +1 -0
  246. package/src/duckdb/src/parser/transform/statement/transform_create_table.cpp +5 -5
  247. package/src/duckdb/src/parser/transform/statement/transform_create_table_as.cpp +1 -0
  248. package/src/duckdb/src/parser/transform/statement/transform_create_type.cpp +6 -13
  249. package/src/duckdb/src/parser/transform/statement/transform_create_view.cpp +6 -6
  250. package/src/duckdb/src/parser/transform/statement/transform_drop.cpp +11 -2
  251. package/src/duckdb/src/parser/transform/statement/transform_export.cpp +5 -1
  252. package/src/duckdb/src/parser/transform/statement/transform_insert.cpp +1 -0
  253. package/src/duckdb/src/parser/transform/statement/transform_rename.cpp +12 -36
  254. package/src/duckdb/src/parser/transform/statement/transform_show.cpp +3 -1
  255. package/src/duckdb/src/parser/transform/statement/transform_use.cpp +21 -0
  256. package/src/duckdb/src/parser/transform/tableref/transform_base_tableref.cpp +11 -3
  257. package/src/duckdb/src/parser/transformer.cpp +4 -0
  258. package/src/duckdb/src/planner/bind_context.cpp +11 -2
  259. package/src/duckdb/src/planner/binder/expression/bind_cast_expression.cpp +1 -1
  260. package/src/duckdb/src/planner/binder/expression/bind_columnref_expression.cpp +43 -13
  261. package/src/duckdb/src/planner/binder/expression/bind_comparison_expression.cpp +1 -1
  262. package/src/duckdb/src/planner/binder/expression/bind_function_expression.cpp +2 -3
  263. package/src/duckdb/src/planner/binder/expression/bind_window_expression.cpp +2 -3
  264. package/src/duckdb/src/planner/binder/statement/bind_attach.cpp +20 -0
  265. package/src/duckdb/src/planner/binder/statement/bind_copy.cpp +7 -4
  266. package/src/duckdb/src/planner/binder/statement/bind_create.cpp +79 -27
  267. package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +11 -7
  268. package/src/duckdb/src/planner/binder/statement/bind_delete.cpp +1 -1
  269. package/src/duckdb/src/planner/binder/statement/bind_drop.cpp +13 -5
  270. package/src/duckdb/src/planner/binder/statement/bind_export.cpp +6 -3
  271. package/src/duckdb/src/planner/binder/statement/bind_extension.cpp +1 -1
  272. package/src/duckdb/src/planner/binder/statement/bind_insert.cpp +3 -2
  273. package/src/duckdb/src/planner/binder/statement/bind_pragma.cpp +2 -2
  274. package/src/duckdb/src/planner/binder/statement/bind_prepare.cpp +0 -2
  275. package/src/duckdb/src/planner/binder/statement/bind_simple.cpp +11 -6
  276. package/src/duckdb/src/planner/binder/statement/bind_update.cpp +1 -1
  277. package/src/duckdb/src/planner/binder/tableref/bind_basetableref.cpp +10 -6
  278. package/src/duckdb/src/planner/binder/tableref/bind_table_function.cpp +2 -4
  279. package/src/duckdb/src/planner/binder.cpp +17 -2
  280. package/src/duckdb/src/planner/logical_operator.cpp +5 -12
  281. package/src/duckdb/src/planner/operator/logical_copy_to_file.cpp +3 -4
  282. package/src/duckdb/src/planner/operator/logical_create.cpp +1 -4
  283. package/src/duckdb/src/planner/operator/logical_create_index.cpp +2 -2
  284. package/src/duckdb/src/planner/operator/logical_delete.cpp +2 -3
  285. package/src/duckdb/src/planner/operator/logical_insert.cpp +1 -1
  286. package/src/duckdb/src/planner/operator/logical_update.cpp +1 -1
  287. package/src/duckdb/src/planner/parsed_data/bound_create_table_info.cpp +1 -1
  288. package/src/duckdb/src/planner/planner.cpp +3 -2
  289. package/src/duckdb/src/planner/pragma_handler.cpp +1 -1
  290. package/src/duckdb/src/storage/buffer_manager.cpp +5 -0
  291. package/src/duckdb/src/storage/checkpoint_manager.cpp +10 -17
  292. package/src/duckdb/src/storage/data_table.cpp +34 -24
  293. package/src/duckdb/src/storage/local_storage.cpp +7 -3
  294. package/src/duckdb/src/storage/single_file_block_manager.cpp +3 -3
  295. package/src/duckdb/src/storage/storage_manager.cpp +25 -42
  296. package/src/duckdb/src/storage/table/column_data.cpp +2 -1
  297. package/src/duckdb/src/storage/table/row_group.cpp +7 -2
  298. package/src/duckdb/src/storage/wal_replay.cpp +6 -22
  299. package/src/duckdb/src/storage/write_ahead_log.cpp +3 -3
  300. package/src/duckdb/src/transaction/meta_transaction.cpp +106 -0
  301. package/src/duckdb/src/transaction/transaction.cpp +21 -21
  302. package/src/duckdb/src/transaction/transaction_context.cpp +44 -8
  303. package/src/duckdb/src/transaction/transaction_manager.cpp +20 -20
  304. package/src/duckdb/src/transaction/undo_buffer.cpp +1 -3
  305. package/src/duckdb/third_party/libpg_query/include/nodes/nodes.hpp +2 -0
  306. package/src/duckdb/third_party/libpg_query/include/nodes/parsenodes.hpp +27 -1
  307. package/src/duckdb/third_party/libpg_query/include/parser/gram.hpp +99 -97
  308. package/src/duckdb/third_party/libpg_query/include/parser/kwlist.hpp +1 -0
  309. package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +15206 -14793
  310. package/src/duckdb/ub_src_catalog.cpp +4 -0
  311. package/src/duckdb/ub_src_execution_operator_schema.cpp +2 -0
  312. package/src/duckdb/ub_src_function.cpp +2 -0
  313. package/src/duckdb/ub_src_function_table_system.cpp +0 -2
  314. package/src/duckdb/ub_src_main.cpp +4 -0
  315. package/src/duckdb/ub_src_parser_parsed_data.cpp +12 -0
  316. package/src/duckdb/ub_src_parser_statement.cpp +2 -0
  317. package/src/duckdb/ub_src_parser_transform_statement.cpp +4 -0
  318. package/src/duckdb/ub_src_planner_binder_statement.cpp +2 -0
  319. package/src/duckdb/ub_src_transaction.cpp +2 -0
  320. package/src/duckdb/src/function/table/system/pragma_functions.cpp +0 -120
@@ -60,6 +60,12 @@ struct DuckDBConstraintsData : public GlobalTableFunctionState {
60
60
 
61
61
  static unique_ptr<FunctionData> DuckDBConstraintsBind(ClientContext &context, TableFunctionBindInput &input,
62
62
  vector<LogicalType> &return_types, vector<string> &names) {
63
+ names.emplace_back("database_name");
64
+ return_types.emplace_back(LogicalType::VARCHAR);
65
+
66
+ names.emplace_back("database_oid");
67
+ return_types.emplace_back(LogicalType::BIGINT);
68
+
63
69
  names.emplace_back("schema_name");
64
70
  return_types.emplace_back(LogicalType::VARCHAR);
65
71
 
@@ -98,13 +104,7 @@ unique_ptr<GlobalTableFunctionState> DuckDBConstraintsInit(ClientContext &contex
98
104
  auto result = make_unique<DuckDBConstraintsData>();
99
105
 
100
106
  // scan all the schemas for tables and collect them
101
- auto schemas = Catalog::GetCatalog(context).schemas->GetEntries<SchemaCatalogEntry>(context);
102
-
103
- sort(schemas.begin(), schemas.end(), [&](CatalogEntry *x, CatalogEntry *y) { return (x->name < y->name); });
104
-
105
- // check the temp schema as well
106
- auto temp_schema = SchemaCatalogEntry::GetTemporaryObjects(context);
107
- schemas.push_back(temp_schema);
107
+ auto schemas = Catalog::GetAllSchemas(context);
108
108
 
109
109
  for (auto &schema : schemas) {
110
110
  vector<CatalogEntry *> entries;
@@ -169,16 +169,20 @@ void DuckDBConstraintsFunction(ClientContext &context, TableFunctionInput &data_
169
169
  default:
170
170
  throw NotImplementedException("Unimplemented constraint for duckdb_constraints");
171
171
  }
172
- output.SetValue(5, count, Value(constraint_type));
173
172
 
173
+ idx_t col = 0;
174
+ // database_name, LogicalType::VARCHAR
175
+ output.SetValue(col++, count, Value(table.schema->catalog->GetName()));
176
+ // database_oid, LogicalType::BIGINT
177
+ output.SetValue(col++, count, Value::BIGINT(table.schema->catalog->GetOid()));
174
178
  // schema_name, LogicalType::VARCHAR
175
- output.SetValue(0, count, Value(table.schema->name));
179
+ output.SetValue(col++, count, Value(table.schema->name));
176
180
  // schema_oid, LogicalType::BIGINT
177
- output.SetValue(1, count, Value::BIGINT(table.schema->oid));
181
+ output.SetValue(col++, count, Value::BIGINT(table.schema->oid));
178
182
  // table_name, LogicalType::VARCHAR
179
- output.SetValue(2, count, Value(table.name));
183
+ output.SetValue(col++, count, Value(table.name));
180
184
  // table_oid, LogicalType::BIGINT
181
- output.SetValue(3, count, Value::BIGINT(table.oid));
185
+ output.SetValue(col++, count, Value::BIGINT(table.oid));
182
186
 
183
187
  // constraint_index, BIGINT
184
188
  auto &bound_constraint = (BoundConstraint &)*table.bound_constraints[data.constraint_offset];
@@ -193,9 +197,8 @@ void DuckDBConstraintsFunction(ClientContext &context, TableFunctionInput &data_
193
197
  const auto &bound_foreign_key = (const BoundForeignKeyConstraint &)bound_constraint;
194
198
  const auto &info = bound_foreign_key.info;
195
199
  // find the other table
196
- auto &catalog = Catalog::GetCatalog(context);
197
- auto table_entry = (TableCatalogEntry *)catalog.GetEntry(context, CatalogType::TABLE_ENTRY, info.schema,
198
- info.table, true);
200
+ auto table_entry =
201
+ Catalog::GetEntry<TableCatalogEntry>(context, INVALID_CATALOG, info.schema, info.table, true);
199
202
  if (!table_entry) {
200
203
  throw InternalException("dukdb_constraints: entry %s.%s referenced in foreign key not found",
201
204
  info.schema, info.table);
@@ -212,20 +215,21 @@ void DuckDBConstraintsFunction(ClientContext &context, TableFunctionInput &data_
212
215
  }
213
216
 
214
217
  if (uk_info.columns.empty()) {
215
- output.SetValue(4, count, Value::BIGINT(data.unique_constraint_offset++));
218
+ output.SetValue(col++, count, Value::BIGINT(data.unique_constraint_offset++));
216
219
  } else {
217
220
  auto known_unique_constraint_offset = data.known_fk_unique_constraint_offsets.find(uk_info);
218
221
  if (known_unique_constraint_offset == data.known_fk_unique_constraint_offsets.end()) {
219
222
  data.known_fk_unique_constraint_offsets.insert(make_pair(uk_info, data.unique_constraint_offset));
220
- output.SetValue(4, count, Value::BIGINT(data.unique_constraint_offset));
223
+ output.SetValue(col++, count, Value::BIGINT(data.unique_constraint_offset));
221
224
  data.unique_constraint_offset++;
222
225
  } else {
223
- output.SetValue(4, count, Value::BIGINT(known_unique_constraint_offset->second));
226
+ output.SetValue(col++, count, Value::BIGINT(known_unique_constraint_offset->second));
224
227
  }
225
228
  }
229
+ output.SetValue(col++, count, Value(constraint_type));
226
230
 
227
231
  // constraint_text, VARCHAR
228
- output.SetValue(6, count, Value(constraint->ToString()));
232
+ output.SetValue(col++, count, Value(constraint->ToString()));
229
233
 
230
234
  // expression, VARCHAR
231
235
  Value expression_text;
@@ -233,7 +237,7 @@ void DuckDBConstraintsFunction(ClientContext &context, TableFunctionInput &data_
233
237
  auto &check = (CheckConstraint &)*constraint;
234
238
  expression_text = Value(check.expression->ToString());
235
239
  }
236
- output.SetValue(7, count, expression_text);
240
+ output.SetValue(col++, count, expression_text);
237
241
 
238
242
  vector<LogicalIndex> column_index_list;
239
243
  switch (bound_constraint.type) {
@@ -275,10 +279,10 @@ void DuckDBConstraintsFunction(ClientContext &context, TableFunctionInput &data_
275
279
  }
276
280
 
277
281
  // constraint_column_indexes, LIST
278
- output.SetValue(8, count, Value::LIST(move(index_list)));
282
+ output.SetValue(col++, count, Value::LIST(move(index_list)));
279
283
 
280
284
  // constraint_column_names, LIST
281
- output.SetValue(9, count, Value::LIST(move(column_name_list)));
285
+ output.SetValue(col++, count, Value::LIST(move(column_name_list)));
282
286
 
283
287
  count++;
284
288
  }
@@ -51,7 +51,7 @@ unique_ptr<GlobalTableFunctionState> DuckDBDependenciesInit(ClientContext &conte
51
51
  auto result = make_unique<DuckDBDependenciesData>();
52
52
 
53
53
  // scan all the schemas and collect them
54
- auto &catalog = Catalog::GetCatalog(context);
54
+ auto &catalog = Catalog::GetCatalog(context, INVALID_CATALOG);
55
55
  auto &dependency_manager = catalog.GetDependencyManager();
56
56
  dependency_manager.Scan([&](CatalogEntry *obj, CatalogEntry *dependent, DependencyType type) {
57
57
  DependencyInformation info;
@@ -69,7 +69,7 @@ unique_ptr<GlobalTableFunctionState> DuckDBExtensionsInit(ClientContext &context
69
69
  info.description = extension.description;
70
70
  for (idx_t k = 0; k < alias_count; k++) {
71
71
  auto alias = ExtensionHelper::GetExtensionAlias(k);
72
- if (alias.extension == extension.name) {
72
+ if (info.name == alias.extension) {
73
73
  info.aliases.emplace_back(alias.alias);
74
74
  }
75
75
  }
@@ -28,6 +28,9 @@ struct DuckDBFunctionsData : public GlobalTableFunctionState {
28
28
 
29
29
  static unique_ptr<FunctionData> DuckDBFunctionsBind(ClientContext &context, TableFunctionBindInput &input,
30
30
  vector<LogicalType> &return_types, vector<string> &names) {
31
+ names.emplace_back("database_name");
32
+ return_types.emplace_back(LogicalType::VARCHAR);
33
+
31
34
  names.emplace_back("schema_name");
32
35
  return_types.emplace_back(LogicalType::VARCHAR);
33
36
 
@@ -81,11 +84,10 @@ unique_ptr<GlobalTableFunctionState> DuckDBFunctionsInit(ClientContext &context,
81
84
  auto result = make_unique<DuckDBFunctionsData>();
82
85
 
83
86
  // scan all the schemas for tables and collect themand collect them
84
- auto schemas = Catalog::GetCatalog(context).schemas->GetEntries<SchemaCatalogEntry>(context);
87
+ auto schemas = Catalog::GetAllSchemas(context);
85
88
  for (auto &schema : schemas) {
86
89
  ExtractFunctionsFromSchema(context, *schema, *result);
87
90
  };
88
- ExtractFunctionsFromSchema(context, *SchemaCatalogEntry::GetTemporaryObjects(context), *result);
89
91
 
90
92
  std::sort(result->entries.begin(), result->entries.end(),
91
93
  [&](CatalogEntry *a, CatalogEntry *b) { return (int)a->type < (int)b->type; });
@@ -420,41 +422,46 @@ struct PragmaFunctionExtractor {
420
422
  template <class T, class OP>
421
423
  bool ExtractFunctionData(StandardEntry *entry, idx_t function_idx, DataChunk &output, idx_t output_offset) {
422
424
  auto &function = (T &)*entry;
425
+ idx_t col = 0;
426
+
427
+ // database_name, LogicalType::VARCHAR
428
+ output.SetValue(col++, output_offset, Value(entry->schema->catalog->GetName()));
429
+
423
430
  // schema_name, LogicalType::VARCHAR
424
- output.SetValue(0, output_offset, Value(entry->schema->name));
431
+ output.SetValue(col++, output_offset, Value(entry->schema->name));
425
432
 
426
433
  // function_name, LogicalType::VARCHAR
427
- output.SetValue(1, output_offset, Value(entry->name));
434
+ output.SetValue(col++, output_offset, Value(entry->name));
428
435
 
429
436
  // function_type, LogicalType::VARCHAR
430
- output.SetValue(2, output_offset, Value(OP::GetFunctionType()));
437
+ output.SetValue(col++, output_offset, Value(OP::GetFunctionType()));
431
438
 
432
439
  // function_description, LogicalType::VARCHAR
433
- output.SetValue(3, output_offset, OP::GetFunctionDescription(function, function_idx));
440
+ output.SetValue(col++, output_offset, OP::GetFunctionDescription(function, function_idx));
434
441
 
435
442
  // return_type, LogicalType::VARCHAR
436
- output.SetValue(4, output_offset, OP::GetReturnType(function, function_idx));
443
+ output.SetValue(col++, output_offset, OP::GetReturnType(function, function_idx));
437
444
 
438
445
  // parameters, LogicalType::LIST(LogicalType::VARCHAR)
439
- output.SetValue(5, output_offset, OP::GetParameters(function, function_idx));
446
+ output.SetValue(col++, output_offset, OP::GetParameters(function, function_idx));
440
447
 
441
448
  // parameter_types, LogicalType::LIST(LogicalType::VARCHAR)
442
- output.SetValue(6, output_offset, OP::GetParameterTypes(function, function_idx));
449
+ output.SetValue(col++, output_offset, OP::GetParameterTypes(function, function_idx));
443
450
 
444
451
  // varargs, LogicalType::VARCHAR
445
- output.SetValue(7, output_offset, OP::GetVarArgs(function, function_idx));
452
+ output.SetValue(col++, output_offset, OP::GetVarArgs(function, function_idx));
446
453
 
447
454
  // macro_definition, LogicalType::VARCHAR
448
- output.SetValue(8, output_offset, OP::GetMacroDefinition(function, function_idx));
455
+ output.SetValue(col++, output_offset, OP::GetMacroDefinition(function, function_idx));
449
456
 
450
457
  // has_side_effects, LogicalType::BOOLEAN
451
- output.SetValue(9, output_offset, OP::HasSideEffects(function, function_idx));
458
+ output.SetValue(col++, output_offset, OP::HasSideEffects(function, function_idx));
452
459
 
453
460
  // internal, LogicalType::BOOLEAN
454
- output.SetValue(10, output_offset, Value::BOOLEAN(entry->internal));
461
+ output.SetValue(col++, output_offset, Value::BOOLEAN(entry->internal));
455
462
 
456
463
  // function_oid, LogicalType::BIGINT
457
- output.SetValue(11, output_offset, Value::BIGINT(entry->oid));
464
+ output.SetValue(col++, output_offset, Value::BIGINT(entry->oid));
458
465
 
459
466
  return function_idx + 1 == OP::FunctionCount(function);
460
467
  }
@@ -471,7 +478,7 @@ void DuckDBFunctionsFunction(ClientContext &context, TableFunctionInput &data_p,
471
478
  while (data.offset < data.entries.size() && count < STANDARD_VECTOR_SIZE) {
472
479
  auto &entry = data.entries[data.offset];
473
480
  auto standard_entry = (StandardEntry *)entry;
474
- bool finished = false;
481
+ bool finished;
475
482
 
476
483
  switch (entry->type) {
477
484
  case CatalogType::SCALAR_FUNCTION_ENTRY:
@@ -20,6 +20,12 @@ struct DuckDBIndexesData : public GlobalTableFunctionState {
20
20
 
21
21
  static unique_ptr<FunctionData> DuckDBIndexesBind(ClientContext &context, TableFunctionBindInput &input,
22
22
  vector<LogicalType> &return_types, vector<string> &names) {
23
+ names.emplace_back("database_name");
24
+ return_types.emplace_back(LogicalType::VARCHAR);
25
+
26
+ names.emplace_back("database_oid");
27
+ return_types.emplace_back(LogicalType::BIGINT);
28
+
23
29
  names.emplace_back("schema_name");
24
30
  return_types.emplace_back(LogicalType::VARCHAR);
25
31
 
@@ -56,15 +62,11 @@ static unique_ptr<FunctionData> DuckDBIndexesBind(ClientContext &context, TableF
56
62
  unique_ptr<GlobalTableFunctionState> DuckDBIndexesInit(ClientContext &context, TableFunctionInitInput &input) {
57
63
  auto result = make_unique<DuckDBIndexesData>();
58
64
 
59
- // scan all the schemas for tables and collect themand collect them
60
- auto schemas = Catalog::GetCatalog(context).schemas->GetEntries<SchemaCatalogEntry>(context);
65
+ // scan all the schemas for tables and collect them and collect them
66
+ auto schemas = Catalog::GetAllSchemas(context);
61
67
  for (auto &schema : schemas) {
62
68
  schema->Scan(context, CatalogType::INDEX_ENTRY, [&](CatalogEntry *entry) { result->entries.push_back(entry); });
63
69
  };
64
-
65
- // check the temp schema as well
66
- SchemaCatalogEntry::GetTemporaryObjects(context)->Scan(
67
- context, CatalogType::INDEX_ENTRY, [&](CatalogEntry *entry) { result->entries.push_back(entry); });
68
70
  return move(result);
69
71
  }
70
72
 
@@ -83,29 +85,34 @@ void DuckDBIndexesFunction(ClientContext &context, TableFunctionInput &data_p, D
83
85
  auto &index = (IndexCatalogEntry &)*entry;
84
86
  // return values:
85
87
 
88
+ idx_t col = 0;
89
+ // database_name, VARCHAR
90
+ output.SetValue(col++, count, index.catalog->GetName());
91
+ // database_oid, BIGINT
92
+ output.SetValue(col++, count, Value::BIGINT(index.catalog->GetOid()));
86
93
  // schema_name, VARCHAR
87
- output.SetValue(0, count, Value(index.schema->name));
94
+ output.SetValue(col++, count, Value(index.schema->name));
88
95
  // schema_oid, BIGINT
89
- output.SetValue(1, count, Value::BIGINT(index.schema->oid));
96
+ output.SetValue(col++, count, Value::BIGINT(index.schema->oid));
90
97
  // index_name, VARCHAR
91
- output.SetValue(2, count, Value(index.name));
98
+ output.SetValue(col++, count, Value(index.name));
92
99
  // index_oid, BIGINT
93
- output.SetValue(3, count, Value::BIGINT(index.oid));
100
+ output.SetValue(col++, count, Value::BIGINT(index.oid));
94
101
  // table_name, VARCHAR
95
- output.SetValue(4, count, Value(index.info->table));
102
+ output.SetValue(col++, count, Value(index.info->table));
96
103
  // table_oid, BIGINT
97
104
  // find the table in the catalog
98
- auto &catalog = Catalog::GetCatalog(context);
99
- auto table_entry = catalog.GetEntry(context, CatalogType::TABLE_ENTRY, index.info->schema, index.info->table);
100
- output.SetValue(5, count, Value::BIGINT(table_entry->oid));
105
+ auto table_entry =
106
+ index.schema->catalog->GetEntry<TableCatalogEntry>(context, index.info->schema, index.info->table);
107
+ output.SetValue(col++, count, Value::BIGINT(table_entry->oid));
101
108
  // is_unique, BOOLEAN
102
- output.SetValue(6, count, Value::BOOLEAN(index.index->IsUnique()));
109
+ output.SetValue(col++, count, Value::BOOLEAN(index.index->IsUnique()));
103
110
  // is_primary, BOOLEAN
104
- output.SetValue(7, count, Value::BOOLEAN(index.index->IsPrimary()));
111
+ output.SetValue(col++, count, Value::BOOLEAN(index.index->IsPrimary()));
105
112
  // expressions, VARCHAR
106
- output.SetValue(8, count, Value());
113
+ output.SetValue(col++, count, Value());
107
114
  // sql, VARCHAR
108
- output.SetValue(9, count, Value(index.ToSQL()));
115
+ output.SetValue(col++, count, Value(index.ToSQL()));
109
116
 
110
117
  count++;
111
118
  }
@@ -21,6 +21,12 @@ static unique_ptr<FunctionData> DuckDBSchemasBind(ClientContext &context, TableF
21
21
  names.emplace_back("oid");
22
22
  return_types.emplace_back(LogicalType::BIGINT);
23
23
 
24
+ names.emplace_back("database_name");
25
+ return_types.emplace_back(LogicalType::VARCHAR);
26
+
27
+ names.emplace_back("database_oid");
28
+ return_types.emplace_back(LogicalType::BIGINT);
29
+
24
30
  names.emplace_back("schema_name");
25
31
  return_types.emplace_back(LogicalType::VARCHAR);
26
32
 
@@ -37,10 +43,7 @@ unique_ptr<GlobalTableFunctionState> DuckDBSchemasInit(ClientContext &context, T
37
43
  auto result = make_unique<DuckDBSchemasData>();
38
44
 
39
45
  // scan all the schemas and collect them
40
- Catalog::GetCatalog(context).ScanSchemas(
41
- context, [&](CatalogEntry *entry) { result->entries.push_back((SchemaCatalogEntry *)entry); });
42
- // get the temp schema as well
43
- result->entries.push_back(SchemaCatalogEntry::GetTemporaryObjects(context));
46
+ result->entries = Catalog::GetAllSchemas(context);
44
47
 
45
48
  return move(result);
46
49
  }
@@ -58,14 +61,19 @@ void DuckDBSchemasFunction(ClientContext &context, TableFunctionInput &data_p, D
58
61
  auto &entry = data.entries[data.offset];
59
62
 
60
63
  // return values:
64
+ idx_t col = 0;
61
65
  // "oid", PhysicalType::BIGINT
62
- output.SetValue(0, count, Value::BIGINT(entry->oid));
66
+ output.SetValue(col++, count, Value::BIGINT(entry->oid));
67
+ // database_name, VARCHAR
68
+ output.SetValue(col++, count, entry->catalog->GetName());
69
+ // database_oid, BIGINT
70
+ output.SetValue(col++, count, Value::BIGINT(entry->catalog->GetOid()));
63
71
  // "schema_name", PhysicalType::VARCHAR
64
- output.SetValue(1, count, Value(entry->name));
72
+ output.SetValue(col++, count, Value(entry->name));
65
73
  // "internal", PhysicalType::BOOLEAN
66
- output.SetValue(2, count, Value::BOOLEAN(entry->internal));
74
+ output.SetValue(col++, count, Value::BOOLEAN(entry->internal));
67
75
  // "sql", PhysicalType::VARCHAR
68
- output.SetValue(3, count, Value());
76
+ output.SetValue(col++, count, Value());
69
77
 
70
78
  data.offset++;
71
79
  count++;
@@ -13,12 +13,18 @@ struct DuckDBSequencesData : public GlobalTableFunctionState {
13
13
  DuckDBSequencesData() : offset(0) {
14
14
  }
15
15
 
16
- vector<CatalogEntry *> entries;
16
+ vector<SequenceCatalogEntry *> entries;
17
17
  idx_t offset;
18
18
  };
19
19
 
20
20
  static unique_ptr<FunctionData> DuckDBSequencesBind(ClientContext &context, TableFunctionBindInput &input,
21
21
  vector<LogicalType> &return_types, vector<string> &names) {
22
+ names.emplace_back("database_name");
23
+ return_types.emplace_back(LogicalType::VARCHAR);
24
+
25
+ names.emplace_back("database_oid");
26
+ return_types.emplace_back(LogicalType::BIGINT);
27
+
22
28
  names.emplace_back("schema_name");
23
29
  return_types.emplace_back(LogicalType::VARCHAR);
24
30
 
@@ -62,15 +68,11 @@ unique_ptr<GlobalTableFunctionState> DuckDBSequencesInit(ClientContext &context,
62
68
  auto result = make_unique<DuckDBSequencesData>();
63
69
 
64
70
  // scan all the schemas for tables and collect themand collect them
65
- auto schemas = Catalog::GetCatalog(context).schemas->GetEntries<SchemaCatalogEntry>(context);
71
+ auto schemas = Catalog::GetAllSchemas(context);
66
72
  for (auto &schema : schemas) {
67
73
  schema->Scan(context, CatalogType::SEQUENCE_ENTRY,
68
- [&](CatalogEntry *entry) { result->entries.push_back(entry); });
74
+ [&](CatalogEntry *entry) { result->entries.push_back((SequenceCatalogEntry *)entry); });
69
75
  };
70
-
71
- // check the temp schema as well
72
- SchemaCatalogEntry::GetTemporaryObjects(context)->Scan(
73
- context, CatalogType::SEQUENCE_ENTRY, [&](CatalogEntry *entry) { result->entries.push_back(entry); });
74
76
  return move(result);
75
77
  }
76
78
 
@@ -88,30 +90,35 @@ void DuckDBSequencesFunction(ClientContext &context, TableFunctionInput &data_p,
88
90
 
89
91
  auto &seq = (SequenceCatalogEntry &)*entry;
90
92
  // return values:
93
+ idx_t col = 0;
94
+ // database_name, VARCHAR
95
+ output.SetValue(col++, count, entry->catalog->GetName());
96
+ // database_oid, BIGINT
97
+ output.SetValue(col++, count, Value::BIGINT(entry->catalog->GetOid()));
91
98
  // schema_name, VARCHAR
92
- output.SetValue(0, count, Value(seq.schema->name));
99
+ output.SetValue(col++, count, Value(seq.schema->name));
93
100
  // schema_oid, BIGINT
94
- output.SetValue(1, count, Value::BIGINT(seq.schema->oid));
101
+ output.SetValue(col++, count, Value::BIGINT(seq.schema->oid));
95
102
  // sequence_name, VARCHAR
96
- output.SetValue(2, count, Value(seq.name));
103
+ output.SetValue(col++, count, Value(seq.name));
97
104
  // sequence_oid, BIGINT
98
- output.SetValue(3, count, Value::BIGINT(seq.oid));
105
+ output.SetValue(col++, count, Value::BIGINT(seq.oid));
99
106
  // temporary, BOOLEAN
100
- output.SetValue(4, count, Value::BOOLEAN(seq.temporary));
107
+ output.SetValue(col++, count, Value::BOOLEAN(seq.temporary));
101
108
  // start_value, BIGINT
102
- output.SetValue(5, count, Value::BIGINT(seq.start_value));
109
+ output.SetValue(col++, count, Value::BIGINT(seq.start_value));
103
110
  // min_value, BIGINT
104
- output.SetValue(6, count, Value::BIGINT(seq.min_value));
111
+ output.SetValue(col++, count, Value::BIGINT(seq.min_value));
105
112
  // max_value, BIGINT
106
- output.SetValue(7, count, Value::BIGINT(seq.max_value));
113
+ output.SetValue(col++, count, Value::BIGINT(seq.max_value));
107
114
  // increment_by, BIGINT
108
- output.SetValue(8, count, Value::BIGINT(seq.increment));
115
+ output.SetValue(col++, count, Value::BIGINT(seq.increment));
109
116
  // cycle, BOOLEAN
110
- output.SetValue(9, count, Value::BOOLEAN(seq.cycle));
117
+ output.SetValue(col++, count, Value::BOOLEAN(seq.cycle));
111
118
  // last_value, BIGINT
112
- output.SetValue(10, count, seq.usage_count == 0 ? Value() : Value::BOOLEAN(seq.last_value));
119
+ output.SetValue(col++, count, seq.usage_count == 0 ? Value() : Value::BOOLEAN(seq.last_value));
113
120
  // sql, LogicalType::VARCHAR
114
- output.SetValue(11, count, Value(seq.ToSQL()));
121
+ output.SetValue(col++, count, Value(seq.ToSQL()));
115
122
 
116
123
  count++;
117
124
  }
@@ -22,6 +22,12 @@ struct DuckDBTablesData : public GlobalTableFunctionState {
22
22
 
23
23
  static unique_ptr<FunctionData> DuckDBTablesBind(ClientContext &context, TableFunctionBindInput &input,
24
24
  vector<LogicalType> &return_types, vector<string> &names) {
25
+ names.emplace_back("database_name");
26
+ return_types.emplace_back(LogicalType::VARCHAR);
27
+
28
+ names.emplace_back("database_oid");
29
+ return_types.emplace_back(LogicalType::BIGINT);
30
+
25
31
  names.emplace_back("schema_name");
26
32
  return_types.emplace_back(LogicalType::VARCHAR);
27
33
 
@@ -65,14 +71,10 @@ unique_ptr<GlobalTableFunctionState> DuckDBTablesInit(ClientContext &context, Ta
65
71
  auto result = make_unique<DuckDBTablesData>();
66
72
 
67
73
  // scan all the schemas for tables and collect themand collect them
68
- auto schemas = Catalog::GetCatalog(context).schemas->GetEntries<SchemaCatalogEntry>(context);
74
+ auto schemas = Catalog::GetAllSchemas(context);
69
75
  for (auto &schema : schemas) {
70
76
  schema->Scan(context, CatalogType::TABLE_ENTRY, [&](CatalogEntry *entry) { result->entries.push_back(entry); });
71
77
  };
72
-
73
- // check the temp schema as well
74
- SchemaCatalogEntry::GetTemporaryObjects(context)->Scan(
75
- context, CatalogType::TABLE_ENTRY, [&](CatalogEntry *entry) { result->entries.push_back(entry); });
76
78
  return move(result);
77
79
  }
78
80
 
@@ -115,30 +117,35 @@ void DuckDBTablesFunction(ClientContext &context, TableFunctionInput &data_p, Da
115
117
  }
116
118
  auto &table = (TableCatalogEntry &)*entry;
117
119
  // return values:
120
+ idx_t col = 0;
121
+ // database_name, VARCHAR
122
+ output.SetValue(col++, count, entry->catalog->GetName());
123
+ // database_oid, BIGINT
124
+ output.SetValue(col++, count, Value::BIGINT(entry->catalog->GetOid()));
118
125
  // schema_name, LogicalType::VARCHAR
119
- output.SetValue(0, count, Value(table.schema->name));
126
+ output.SetValue(col++, count, Value(table.schema->name));
120
127
  // schema_oid, LogicalType::BIGINT
121
- output.SetValue(1, count, Value::BIGINT(table.schema->oid));
128
+ output.SetValue(col++, count, Value::BIGINT(table.schema->oid));
122
129
  // table_name, LogicalType::VARCHAR
123
- output.SetValue(2, count, Value(table.name));
130
+ output.SetValue(col++, count, Value(table.name));
124
131
  // table_oid, LogicalType::BIGINT
125
- output.SetValue(3, count, Value::BIGINT(table.oid));
132
+ output.SetValue(col++, count, Value::BIGINT(table.oid));
126
133
  // internal, LogicalType::BOOLEAN
127
- output.SetValue(4, count, Value::BOOLEAN(table.internal));
134
+ output.SetValue(col++, count, Value::BOOLEAN(table.internal));
128
135
  // temporary, LogicalType::BOOLEAN
129
- output.SetValue(5, count, Value::BOOLEAN(table.temporary));
136
+ output.SetValue(col++, count, Value::BOOLEAN(table.temporary));
130
137
  // has_primary_key, LogicalType::BOOLEAN
131
- output.SetValue(6, count, Value::BOOLEAN(TableHasPrimaryKey(table)));
138
+ output.SetValue(col++, count, Value::BOOLEAN(TableHasPrimaryKey(table)));
132
139
  // estimated_size, LogicalType::BIGINT
133
- output.SetValue(7, count, Value::BIGINT(table.storage->info->cardinality.load()));
140
+ output.SetValue(col++, count, Value::BIGINT(table.storage->info->cardinality.load()));
134
141
  // column_count, LogicalType::BIGINT
135
- output.SetValue(8, count, Value::BIGINT(table.columns.LogicalColumnCount()));
142
+ output.SetValue(col++, count, Value::BIGINT(table.columns.LogicalColumnCount()));
136
143
  // index_count, LogicalType::BIGINT
137
- output.SetValue(9, count, Value::BIGINT(table.storage->info->indexes.Count()));
144
+ output.SetValue(col++, count, Value::BIGINT(table.storage->info->indexes.Count()));
138
145
  // check_constraint_count, LogicalType::BIGINT
139
- output.SetValue(10, count, Value::BIGINT(CheckConstraintCount(table)));
146
+ output.SetValue(col++, count, Value::BIGINT(CheckConstraintCount(table)));
140
147
  // sql, LogicalType::VARCHAR
141
- output.SetValue(11, count, Value(table.ToSQL()));
148
+ output.SetValue(col++, count, Value(table.ToSQL()));
142
149
 
143
150
  count++;
144
151
  }
@@ -20,6 +20,12 @@ struct DuckDBTypesData : public GlobalTableFunctionState {
20
20
 
21
21
  static unique_ptr<FunctionData> DuckDBTypesBind(ClientContext &context, TableFunctionBindInput &input,
22
22
  vector<LogicalType> &return_types, vector<string> &names) {
23
+ names.emplace_back("database_name");
24
+ return_types.emplace_back(LogicalType::VARCHAR);
25
+
26
+ names.emplace_back("database_oid");
27
+ return_types.emplace_back(LogicalType::BIGINT);
28
+
23
29
  names.emplace_back("schema_name");
24
30
  return_types.emplace_back(LogicalType::VARCHAR);
25
31
 
@@ -53,16 +59,11 @@ static unique_ptr<FunctionData> DuckDBTypesBind(ClientContext &context, TableFun
53
59
 
54
60
  unique_ptr<GlobalTableFunctionState> DuckDBTypesInit(ClientContext &context, TableFunctionInitInput &input) {
55
61
  auto result = make_unique<DuckDBTypesData>();
56
- auto schemas = Catalog::GetCatalog(context).schemas->GetEntries<SchemaCatalogEntry>(context);
62
+ auto schemas = Catalog::GetAllSchemas(context);
57
63
  for (auto &schema : schemas) {
58
64
  schema->Scan(context, CatalogType::TYPE_ENTRY,
59
65
  [&](CatalogEntry *entry) { result->entries.push_back((TypeCatalogEntry *)entry); });
60
66
  };
61
-
62
- // check the temp schema as well
63
- SchemaCatalogEntry::GetTemporaryObjects(context)->Scan(context, CatalogType::TYPE_ENTRY, [&](CatalogEntry *entry) {
64
- result->entries.push_back((TypeCatalogEntry *)entry);
65
- });
66
67
  return move(result);
67
68
  }
68
69
 
@@ -80,10 +81,15 @@ void DuckDBTypesFunction(ClientContext &context, TableFunctionInput &data_p, Dat
80
81
  auto &type = type_entry->user_type;
81
82
 
82
83
  // return values:
84
+ idx_t col = 0;
85
+ // database_name, VARCHAR
86
+ output.SetValue(col++, count, type_entry->catalog->GetName());
87
+ // database_oid, BIGINT
88
+ output.SetValue(col++, count, Value::BIGINT(type_entry->catalog->GetOid()));
83
89
  // schema_name, LogicalType::VARCHAR
84
- output.SetValue(0, count, Value(type_entry->schema->name));
90
+ output.SetValue(col++, count, Value(type_entry->schema->name));
85
91
  // schema_oid, LogicalType::BIGINT
86
- output.SetValue(1, count, Value::BIGINT(type_entry->schema->oid));
92
+ output.SetValue(col++, count, Value::BIGINT(type_entry->schema->oid));
87
93
  // type_oid, BIGINT
88
94
  int64_t oid;
89
95
  if (type_entry->internal) {
@@ -98,15 +104,15 @@ void DuckDBTypesFunction(ClientContext &context, TableFunctionInput &data_p, Dat
98
104
  } else {
99
105
  oid_val = Value();
100
106
  }
101
- output.SetValue(2, count, oid_val);
107
+ output.SetValue(col++, count, oid_val);
102
108
  // type_name, VARCHAR
103
- output.SetValue(3, count, Value(type_entry->name));
109
+ output.SetValue(col++, count, Value(type_entry->name));
104
110
  // type_size, BIGINT
105
111
  auto internal_type = type.InternalType();
106
- output.SetValue(4, count,
112
+ output.SetValue(col++, count,
107
113
  internal_type == PhysicalType::INVALID ? Value() : Value::BIGINT(GetTypeIdSize(internal_type)));
108
114
  // logical_type, VARCHAR
109
- output.SetValue(5, count, Value(LogicalTypeIdToString(type.id())));
115
+ output.SetValue(col++, count, Value(LogicalTypeIdToString(type.id())));
110
116
  // type_category, VARCHAR
111
117
  string category;
112
118
  switch (type.id()) {
@@ -151,9 +157,9 @@ void DuckDBTypesFunction(ClientContext &context, TableFunctionInput &data_p, Dat
151
157
  default:
152
158
  break;
153
159
  }
154
- output.SetValue(6, count, category.empty() ? Value() : Value(category));
160
+ output.SetValue(col++, count, category.empty() ? Value() : Value(category));
155
161
  // internal, BOOLEAN
156
- output.SetValue(7, count, Value::BOOLEAN(type_entry->internal));
162
+ output.SetValue(col++, count, Value::BOOLEAN(type_entry->internal));
157
163
  // labels, VARCHAR[]
158
164
  if (type.id() == LogicalTypeId::ENUM && type.AuxInfo()) {
159
165
  auto data = FlatVector::GetData<string_t>(EnumType::GetValuesInsertOrder(type));
@@ -164,9 +170,9 @@ void DuckDBTypesFunction(ClientContext &context, TableFunctionInput &data_p, Dat
164
170
  labels.emplace_back(data[i]);
165
171
  }
166
172
 
167
- output.SetValue(8, count, Value::LIST(labels));
173
+ output.SetValue(col++, count, Value::LIST(labels));
168
174
  } else {
169
- output.SetValue(8, count, Value());
175
+ output.SetValue(col++, count, Value());
170
176
  }
171
177
 
172
178
  count++;