duckdb 0.8.2-dev1862.0 → 0.8.2-dev2044.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 (283) hide show
  1. package/binding.gyp +9 -9
  2. package/package.json +1 -1
  3. package/src/duckdb/src/catalog/catalog.cpp +1 -1
  4. package/src/duckdb/src/catalog/catalog_entry/index_catalog_entry.cpp +17 -41
  5. package/src/duckdb/src/catalog/catalog_entry/macro_catalog_entry.cpp +2 -10
  6. package/src/duckdb/src/catalog/catalog_entry/schema_catalog_entry.cpp +4 -14
  7. package/src/duckdb/src/catalog/catalog_entry/sequence_catalog_entry.cpp +11 -28
  8. package/src/duckdb/src/catalog/catalog_entry/table_catalog_entry.cpp +11 -38
  9. package/src/duckdb/src/catalog/catalog_entry/view_catalog_entry.cpp +11 -27
  10. package/src/duckdb/src/catalog/catalog_entry.cpp +25 -1
  11. package/src/duckdb/src/common/enum_util.cpp +187 -0
  12. package/src/duckdb/src/common/extra_type_info.cpp +1 -2
  13. package/src/duckdb/src/common/serializer/binary_deserializer.cpp +3 -0
  14. package/src/duckdb/src/common/serializer/binary_serializer.cpp +4 -4
  15. package/src/duckdb/src/common/types/column/column_data_collection.cpp +43 -0
  16. package/src/duckdb/src/common/types/hugeint.cpp +40 -0
  17. package/src/duckdb/src/common/types/vector.cpp +1 -1
  18. package/src/duckdb/src/common/types.cpp +0 -12
  19. package/src/duckdb/src/core_functions/function_list.cpp +1 -0
  20. package/src/duckdb/src/core_functions/scalar/string/to_base.cpp +66 -0
  21. package/src/duckdb/src/execution/operator/aggregate/physical_hash_aggregate.cpp +14 -11
  22. package/src/duckdb/src/execution/operator/aggregate/physical_perfecthash_aggregate.cpp +6 -4
  23. package/src/duckdb/src/execution/operator/aggregate/physical_ungrouped_aggregate.cpp +14 -12
  24. package/src/duckdb/src/execution/operator/aggregate/physical_window.cpp +6 -4
  25. package/src/duckdb/src/execution/operator/helper/physical_batch_collector.cpp +8 -6
  26. package/src/duckdb/src/execution/operator/helper/physical_explain_analyze.cpp +2 -2
  27. package/src/duckdb/src/execution/operator/helper/physical_limit.cpp +5 -3
  28. package/src/duckdb/src/execution/operator/helper/physical_materialized_collector.cpp +7 -5
  29. package/src/duckdb/src/execution/operator/helper/physical_vacuum.cpp +7 -5
  30. package/src/duckdb/src/execution/operator/join/physical_asof_join.cpp +5 -4
  31. package/src/duckdb/src/execution/operator/join/physical_blockwise_nl_join.cpp +2 -2
  32. package/src/duckdb/src/execution/operator/join/physical_delim_join.cpp +13 -6
  33. package/src/duckdb/src/execution/operator/join/physical_hash_join.cpp +7 -5
  34. package/src/duckdb/src/execution/operator/join/physical_iejoin.cpp +7 -5
  35. package/src/duckdb/src/execution/operator/join/physical_nested_loop_join.cpp +7 -4
  36. package/src/duckdb/src/execution/operator/join/physical_piecewise_merge_join.cpp +8 -6
  37. package/src/duckdb/src/execution/operator/order/physical_order.cpp +7 -5
  38. package/src/duckdb/src/execution/operator/order/physical_top_n.cpp +7 -5
  39. package/src/duckdb/src/execution/operator/persistent/physical_batch_copy_to_file.cpp +8 -6
  40. package/src/duckdb/src/execution/operator/persistent/physical_batch_insert.cpp +8 -7
  41. package/src/duckdb/src/execution/operator/persistent/physical_copy_to_file.cpp +8 -6
  42. package/src/duckdb/src/execution/operator/persistent/physical_fixed_batch_copy.cpp +11 -9
  43. package/src/duckdb/src/execution/operator/persistent/physical_insert.cpp +10 -10
  44. package/src/duckdb/src/execution/operator/persistent/physical_update.cpp +4 -2
  45. package/src/duckdb/src/execution/operator/schema/physical_create_index.cpp +7 -6
  46. package/src/duckdb/src/execution/physical_operator.cpp +3 -2
  47. package/src/duckdb/src/execution/physical_plan/plan_comparison_join.cpp +1 -1
  48. package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
  49. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/index_catalog_entry.hpp +1 -2
  50. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/macro_catalog_entry.hpp +1 -4
  51. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/schema_catalog_entry.hpp +2 -5
  52. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/sequence_catalog_entry.hpp +1 -6
  53. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_catalog_entry.hpp +2 -11
  54. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/view_catalog_entry.hpp +2 -5
  55. package/src/duckdb/src/include/duckdb/catalog/catalog_entry.hpp +14 -0
  56. package/src/duckdb/src/include/duckdb/common/bitpacking.hpp +70 -55
  57. package/src/duckdb/src/include/duckdb/common/constants.hpp +2 -0
  58. package/src/duckdb/src/include/duckdb/common/enum_util.hpp +40 -0
  59. package/src/duckdb/src/include/duckdb/common/enums/index_type.hpp +1 -1
  60. package/src/duckdb/src/include/duckdb/common/enums/operator_result_type.hpp +5 -1
  61. package/src/duckdb/src/include/duckdb/common/hugeint.hpp +15 -0
  62. package/src/duckdb/src/include/duckdb/common/index_vector.hpp +12 -0
  63. package/src/duckdb/src/include/duckdb/common/limits.hpp +52 -149
  64. package/src/duckdb/src/include/duckdb/common/numeric_utils.hpp +48 -0
  65. package/src/duckdb/src/include/duckdb/common/serializer/binary_deserializer.hpp +28 -4
  66. package/src/duckdb/src/include/duckdb/common/serializer/binary_serializer.hpp +12 -5
  67. package/src/duckdb/src/include/duckdb/common/serializer/deserialization_data.hpp +110 -0
  68. package/src/duckdb/src/include/duckdb/common/serializer/format_deserializer.hpp +46 -1
  69. package/src/duckdb/src/include/duckdb/common/serializer/format_serializer.hpp +23 -21
  70. package/src/duckdb/src/include/duckdb/common/serializer/serialization_traits.hpp +12 -4
  71. package/src/duckdb/src/include/duckdb/common/types/column/column_data_collection.hpp +3 -0
  72. package/src/duckdb/src/include/duckdb/core_functions/aggregate/distributive_functions.hpp +1 -1
  73. package/src/duckdb/src/include/duckdb/core_functions/scalar/operators_functions.hpp +1 -1
  74. package/src/duckdb/src/include/duckdb/core_functions/scalar/string_functions.hpp +9 -0
  75. package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_hash_aggregate.hpp +3 -3
  76. package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_perfecthash_aggregate.hpp +1 -1
  77. package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_ungrouped_aggregate.hpp +3 -3
  78. package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_window.hpp +2 -2
  79. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_batch_collector.hpp +2 -2
  80. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_explain_analyze.hpp +1 -1
  81. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_limit.hpp +1 -1
  82. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_materialized_collector.hpp +1 -1
  83. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_vacuum.hpp +2 -2
  84. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_asof_join.hpp +2 -2
  85. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_blockwise_nl_join.hpp +1 -1
  86. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_delim_join.hpp +2 -2
  87. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_hash_join.hpp +2 -2
  88. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_iejoin.hpp +2 -2
  89. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_nested_loop_join.hpp +2 -2
  90. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_piecewise_merge_join.hpp +2 -2
  91. package/src/duckdb/src/include/duckdb/execution/operator/order/physical_order.hpp +2 -2
  92. package/src/duckdb/src/include/duckdb/execution/operator/order/physical_top_n.hpp +2 -2
  93. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_batch_copy_to_file.hpp +2 -2
  94. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_batch_insert.hpp +2 -2
  95. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_copy_to_file.hpp +2 -2
  96. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_fixed_batch_copy.hpp +2 -2
  97. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_insert.hpp +2 -2
  98. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_update.hpp +1 -1
  99. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_index.hpp +2 -2
  100. package/src/duckdb/src/include/duckdb/execution/physical_operator.hpp +3 -3
  101. package/src/duckdb/src/include/duckdb/execution/physical_operator_states.hpp +11 -0
  102. package/src/duckdb/src/include/duckdb/function/macro_function.hpp +3 -0
  103. package/src/duckdb/src/include/duckdb/function/scalar_macro_function.hpp +3 -0
  104. package/src/duckdb/src/include/duckdb/function/table_macro_function.hpp +3 -0
  105. package/src/duckdb/src/include/duckdb/main/extension_entries.hpp +3 -0
  106. package/src/duckdb/src/include/duckdb/parallel/pipeline.hpp +0 -3
  107. package/src/duckdb/src/include/duckdb/parallel/pipeline_executor.hpp +3 -2
  108. package/src/duckdb/src/include/duckdb/parser/column_definition.hpp +6 -5
  109. package/src/duckdb/src/include/duckdb/parser/column_list.hpp +4 -0
  110. package/src/duckdb/src/include/duckdb/parser/constraint.hpp +5 -0
  111. package/src/duckdb/src/include/duckdb/parser/constraints/check_constraint.hpp +3 -0
  112. package/src/duckdb/src/include/duckdb/parser/constraints/foreign_key_constraint.hpp +6 -0
  113. package/src/duckdb/src/include/duckdb/parser/constraints/not_null_constraint.hpp +3 -0
  114. package/src/duckdb/src/include/duckdb/parser/constraints/unique_constraint.hpp +6 -0
  115. package/src/duckdb/src/include/duckdb/parser/expression/between_expression.hpp +1 -1
  116. package/src/duckdb/src/include/duckdb/parser/expression/case_expression.hpp +1 -1
  117. package/src/duckdb/src/include/duckdb/parser/expression/cast_expression.hpp +1 -1
  118. package/src/duckdb/src/include/duckdb/parser/expression/collate_expression.hpp +1 -1
  119. package/src/duckdb/src/include/duckdb/parser/expression/columnref_expression.hpp +1 -1
  120. package/src/duckdb/src/include/duckdb/parser/expression/comparison_expression.hpp +1 -1
  121. package/src/duckdb/src/include/duckdb/parser/expression/conjunction_expression.hpp +1 -1
  122. package/src/duckdb/src/include/duckdb/parser/expression/constant_expression.hpp +1 -1
  123. package/src/duckdb/src/include/duckdb/parser/expression/default_expression.hpp +1 -1
  124. package/src/duckdb/src/include/duckdb/parser/expression/function_expression.hpp +1 -1
  125. package/src/duckdb/src/include/duckdb/parser/expression/lambda_expression.hpp +1 -1
  126. package/src/duckdb/src/include/duckdb/parser/expression/operator_expression.hpp +1 -1
  127. package/src/duckdb/src/include/duckdb/parser/expression/parameter_expression.hpp +1 -1
  128. package/src/duckdb/src/include/duckdb/parser/expression/positional_reference_expression.hpp +1 -1
  129. package/src/duckdb/src/include/duckdb/parser/expression/star_expression.hpp +1 -1
  130. package/src/duckdb/src/include/duckdb/parser/expression/subquery_expression.hpp +1 -1
  131. package/src/duckdb/src/include/duckdb/parser/expression/window_expression.hpp +1 -1
  132. package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_info.hpp +12 -1
  133. package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_table_info.hpp +66 -2
  134. package/src/duckdb/src/include/duckdb/parser/parsed_data/attach_info.hpp +8 -1
  135. package/src/duckdb/src/include/duckdb/parser/parsed_data/copy_info.hpp +8 -1
  136. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_index_info.hpp +4 -1
  137. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_info.hpp +9 -2
  138. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_macro_info.hpp +3 -0
  139. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_schema_info.hpp +3 -0
  140. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_sequence_info.hpp +3 -0
  141. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_table_info.hpp +3 -0
  142. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_type_info.hpp +3 -0
  143. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_view_info.hpp +3 -0
  144. package/src/duckdb/src/include/duckdb/parser/parsed_data/detach_info.hpp +7 -0
  145. package/src/duckdb/src/include/duckdb/parser/parsed_data/drop_info.hpp +7 -0
  146. package/src/duckdb/src/include/duckdb/parser/parsed_data/exported_table_data.hpp +7 -0
  147. package/src/duckdb/src/include/duckdb/parser/parsed_data/load_info.hpp +13 -3
  148. package/src/duckdb/src/include/duckdb/parser/parsed_data/parse_info.hpp +22 -0
  149. package/src/duckdb/src/include/duckdb/parser/parsed_data/pragma_info.hpp +10 -0
  150. package/src/duckdb/src/include/duckdb/parser/parsed_data/show_select_info.hpp +7 -0
  151. package/src/duckdb/src/include/duckdb/parser/parsed_data/transaction_info.hpp +10 -0
  152. package/src/duckdb/src/include/duckdb/parser/parsed_data/vacuum_info.hpp +10 -0
  153. package/src/duckdb/src/include/duckdb/planner/bound_constraint.hpp +0 -8
  154. package/src/duckdb/src/include/duckdb/planner/bound_result_modifier.hpp +6 -0
  155. package/src/duckdb/src/include/duckdb/planner/column_binding.hpp +5 -0
  156. package/src/duckdb/src/include/duckdb/planner/expression/bound_between_expression.hpp +6 -0
  157. package/src/duckdb/src/include/duckdb/planner/expression/bound_case_expression.hpp +6 -0
  158. package/src/duckdb/src/include/duckdb/planner/expression/bound_cast_expression.hpp +6 -0
  159. package/src/duckdb/src/include/duckdb/planner/expression/bound_columnref_expression.hpp +3 -0
  160. package/src/duckdb/src/include/duckdb/planner/expression/bound_comparison_expression.hpp +3 -0
  161. package/src/duckdb/src/include/duckdb/planner/expression/bound_conjunction_expression.hpp +3 -0
  162. package/src/duckdb/src/include/duckdb/planner/expression/bound_constant_expression.hpp +3 -0
  163. package/src/duckdb/src/include/duckdb/planner/expression/bound_default_expression.hpp +3 -0
  164. package/src/duckdb/src/include/duckdb/planner/expression/bound_lambda_expression.hpp +3 -1
  165. package/src/duckdb/src/include/duckdb/planner/expression/bound_lambdaref_expression.hpp +3 -0
  166. package/src/duckdb/src/include/duckdb/planner/expression/bound_operator_expression.hpp +3 -0
  167. package/src/duckdb/src/include/duckdb/planner/expression/bound_parameter_data.hpp +5 -2
  168. package/src/duckdb/src/include/duckdb/planner/expression/bound_parameter_expression.hpp +7 -0
  169. package/src/duckdb/src/include/duckdb/planner/expression/bound_reference_expression.hpp +3 -0
  170. package/src/duckdb/src/include/duckdb/planner/expression/bound_unnest_expression.hpp +3 -0
  171. package/src/duckdb/src/include/duckdb/planner/expression/list.hpp +1 -0
  172. package/src/duckdb/src/include/duckdb/planner/expression.hpp +3 -0
  173. package/src/duckdb/src/include/duckdb/planner/joinside.hpp +3 -0
  174. package/src/duckdb/src/include/duckdb/planner/logical_operator.hpp +3 -0
  175. package/src/duckdb/src/include/duckdb/planner/operator/logical_aggregate.hpp +3 -0
  176. package/src/duckdb/src/include/duckdb/planner/operator/logical_any_join.hpp +3 -0
  177. package/src/duckdb/src/include/duckdb/planner/operator/logical_column_data_get.hpp +4 -0
  178. package/src/duckdb/src/include/duckdb/planner/operator/logical_comparison_join.hpp +9 -2
  179. package/src/duckdb/src/include/duckdb/planner/operator/logical_create.hpp +9 -6
  180. package/src/duckdb/src/include/duckdb/planner/operator/logical_create_index.hpp +2 -16
  181. package/src/duckdb/src/include/duckdb/planner/operator/logical_create_table.hpp +10 -6
  182. package/src/duckdb/src/include/duckdb/planner/operator/logical_cross_product.hpp +3 -0
  183. package/src/duckdb/src/include/duckdb/planner/operator/logical_cteref.hpp +2 -0
  184. package/src/duckdb/src/include/duckdb/planner/operator/logical_delete.hpp +7 -0
  185. package/src/duckdb/src/include/duckdb/planner/operator/logical_delim_get.hpp +3 -0
  186. package/src/duckdb/src/include/duckdb/planner/operator/logical_distinct.hpp +6 -10
  187. package/src/duckdb/src/include/duckdb/planner/operator/logical_dummy_scan.hpp +2 -0
  188. package/src/duckdb/src/include/duckdb/planner/operator/logical_empty_result.hpp +2 -0
  189. package/src/duckdb/src/include/duckdb/planner/operator/logical_explain.hpp +4 -0
  190. package/src/duckdb/src/include/duckdb/planner/operator/logical_expression_get.hpp +3 -0
  191. package/src/duckdb/src/include/duckdb/planner/operator/logical_filter.hpp +3 -0
  192. package/src/duckdb/src/include/duckdb/planner/operator/logical_insert.hpp +6 -0
  193. package/src/duckdb/src/include/duckdb/planner/operator/logical_limit.hpp +3 -0
  194. package/src/duckdb/src/include/duckdb/planner/operator/logical_limit_percent.hpp +3 -0
  195. package/src/duckdb/src/include/duckdb/planner/operator/logical_materialized_cte.hpp +5 -2
  196. package/src/duckdb/src/include/duckdb/planner/operator/logical_order.hpp +7 -35
  197. package/src/duckdb/src/include/duckdb/planner/operator/logical_pivot.hpp +6 -0
  198. package/src/duckdb/src/include/duckdb/planner/operator/logical_positional_join.hpp +3 -0
  199. package/src/duckdb/src/include/duckdb/planner/operator/logical_projection.hpp +3 -0
  200. package/src/duckdb/src/include/duckdb/planner/operator/logical_recursive_cte.hpp +5 -3
  201. package/src/duckdb/src/include/duckdb/planner/operator/logical_reset.hpp +4 -0
  202. package/src/duckdb/src/include/duckdb/planner/operator/logical_sample.hpp +6 -0
  203. package/src/duckdb/src/include/duckdb/planner/operator/logical_set.hpp +4 -0
  204. package/src/duckdb/src/include/duckdb/planner/operator/logical_set_operation.hpp +4 -0
  205. package/src/duckdb/src/include/duckdb/planner/operator/logical_show.hpp +3 -0
  206. package/src/duckdb/src/include/duckdb/planner/operator/logical_simple.hpp +3 -0
  207. package/src/duckdb/src/include/duckdb/planner/operator/logical_top_n.hpp +4 -0
  208. package/src/duckdb/src/include/duckdb/planner/operator/logical_unnest.hpp +2 -0
  209. package/src/duckdb/src/include/duckdb/planner/operator/logical_update.hpp +6 -0
  210. package/src/duckdb/src/include/duckdb/planner/operator/logical_window.hpp +3 -0
  211. package/src/duckdb/src/include/duckdb/planner/tableref/bound_pivotref.hpp +3 -0
  212. package/src/duckdb/src/main/relation/join_relation.cpp +1 -1
  213. package/src/duckdb/src/optimizer/deliminator.cpp +5 -3
  214. package/src/duckdb/src/parallel/pipeline.cpp +0 -17
  215. package/src/duckdb/src/parallel/pipeline_executor.cpp +26 -7
  216. package/src/duckdb/src/parallel/pipeline_finish_event.cpp +55 -1
  217. package/src/duckdb/src/parser/column_definition.cpp +20 -32
  218. package/src/duckdb/src/parser/column_list.cpp +8 -0
  219. package/src/duckdb/src/parser/constraints/foreign_key_constraint.cpp +3 -0
  220. package/src/duckdb/src/parser/constraints/unique_constraint.cpp +3 -0
  221. package/src/duckdb/src/parser/expression/case_expression.cpp +0 -12
  222. package/src/duckdb/src/parser/parsed_data/alter_info.cpp +5 -2
  223. package/src/duckdb/src/parser/parsed_data/alter_table_info.cpp +38 -0
  224. package/src/duckdb/src/parser/parsed_data/create_index_info.cpp +3 -1
  225. package/src/duckdb/src/parser/parsed_data/create_sequence_info.cpp +2 -0
  226. package/src/duckdb/src/parser/parsed_data/detach_info.cpp +1 -1
  227. package/src/duckdb/src/parser/parsed_data/drop_info.cpp +1 -1
  228. package/src/duckdb/src/parser/parsed_data/sample_options.cpp +0 -18
  229. package/src/duckdb/src/parser/parsed_data/transaction_info.cpp +4 -1
  230. package/src/duckdb/src/parser/parsed_data/vacuum_info.cpp +1 -1
  231. package/src/duckdb/src/parser/query_node.cpp +0 -10
  232. package/src/duckdb/src/parser/result_modifier.cpp +0 -13
  233. package/src/duckdb/src/parser/statement/select_statement.cpp +0 -10
  234. package/src/duckdb/src/parser/tableref/pivotref.cpp +0 -16
  235. package/src/duckdb/src/parser/transform/statement/transform_create_index.cpp +5 -4
  236. package/src/duckdb/src/planner/binder/query_node/plan_subquery.cpp +1 -1
  237. package/src/duckdb/src/planner/binder/statement/bind_create.cpp +6 -1
  238. package/src/duckdb/src/planner/binder/tableref/bind_basetableref.cpp +13 -3
  239. package/src/duckdb/src/planner/expression/bound_between_expression.cpp +4 -0
  240. package/src/duckdb/src/planner/expression/bound_cast_expression.cpp +13 -6
  241. package/src/duckdb/src/planner/expression/bound_parameter_expression.cpp +20 -12
  242. package/src/duckdb/src/planner/logical_operator.cpp +13 -1
  243. package/src/duckdb/src/planner/operator/logical_comparison_join.cpp +16 -2
  244. package/src/duckdb/src/planner/operator/logical_create.cpp +14 -0
  245. package/src/duckdb/src/planner/operator/logical_create_index.cpp +20 -0
  246. package/src/duckdb/src/planner/operator/logical_create_table.cpp +16 -0
  247. package/src/duckdb/src/planner/operator/logical_delete.cpp +9 -2
  248. package/src/duckdb/src/planner/operator/logical_delim_join.cpp +2 -4
  249. package/src/duckdb/src/planner/operator/logical_distinct.cpp +13 -0
  250. package/src/duckdb/src/planner/operator/logical_explain.cpp +1 -1
  251. package/src/duckdb/src/planner/operator/logical_insert.cpp +8 -2
  252. package/src/duckdb/src/planner/operator/logical_materialized_cte.cpp +3 -2
  253. package/src/duckdb/src/planner/operator/logical_order.cpp +39 -0
  254. package/src/duckdb/src/planner/operator/logical_pivot.cpp +3 -0
  255. package/src/duckdb/src/planner/operator/logical_recursive_cte.cpp +5 -5
  256. package/src/duckdb/src/planner/operator/logical_sample.cpp +3 -0
  257. package/src/duckdb/src/planner/operator/logical_update.cpp +8 -2
  258. package/src/duckdb/src/planner/parsed_data/bound_create_table_info.cpp +4 -2
  259. package/src/duckdb/src/planner/planner.cpp +11 -0
  260. package/src/duckdb/src/storage/checkpoint_manager.cpp +23 -23
  261. package/src/duckdb/src/storage/compression/bitpacking.cpp +87 -63
  262. package/src/duckdb/src/storage/compression/bitpacking_hugeint.cpp +295 -0
  263. package/src/duckdb/src/storage/serialization/serialize_constraint.cpp +98 -0
  264. package/src/duckdb/src/storage/serialization/serialize_create_info.cpp +188 -0
  265. package/src/duckdb/src/storage/serialization/serialize_expression.cpp +274 -0
  266. package/src/duckdb/src/storage/serialization/serialize_logical_operator.cpp +729 -0
  267. package/src/duckdb/src/storage/serialization/serialize_macro_function.cpp +62 -0
  268. package/src/duckdb/src/storage/serialization/serialize_nodes.cpp +242 -0
  269. package/src/duckdb/src/storage/serialization/serialize_parse_info.cpp +419 -0
  270. package/src/duckdb/src/storage/serialization/serialize_parsed_expression.cpp +40 -38
  271. package/src/duckdb/src/storage/serialization/serialize_query_node.cpp +36 -36
  272. package/src/duckdb/src/storage/serialization/serialize_result_modifier.cpp +25 -14
  273. package/src/duckdb/src/storage/serialization/serialize_statement.cpp +22 -0
  274. package/src/duckdb/src/storage/serialization/serialize_tableref.cpp +47 -47
  275. package/src/duckdb/src/storage/serialization/serialize_types.cpp +25 -25
  276. package/src/duckdb/src/storage/storage_info.cpp +3 -2
  277. package/src/duckdb/src/storage/wal_replay.cpp +20 -19
  278. package/src/duckdb/ub_extension_icu_third_party_icu_i18n.cpp +6 -6
  279. package/src/duckdb/ub_src_core_functions_scalar_string.cpp +2 -0
  280. package/src/duckdb/ub_src_parser.cpp +0 -2
  281. package/src/duckdb/ub_src_storage_compression.cpp +2 -0
  282. package/src/duckdb/ub_src_storage_serialization.cpp +16 -0
  283. package/src/duckdb/src/parser/common_table_expression_info.cpp +0 -21
@@ -13,28 +13,14 @@ ColumnDefinition::ColumnDefinition(string name_p, LogicalType type_p)
13
13
 
14
14
  ColumnDefinition::ColumnDefinition(string name_p, LogicalType type_p, unique_ptr<ParsedExpression> expression,
15
15
  TableColumnType category)
16
- : name(std::move(name_p)), type(std::move(type_p)), category(category) {
17
- switch (category) {
18
- case TableColumnType::STANDARD: {
19
- default_value = std::move(expression);
20
- break;
21
- }
22
- case TableColumnType::GENERATED: {
23
- generated_expression = std::move(expression);
24
- break;
25
- }
26
- default: {
27
- throw InternalException("Type not implemented for TableColumnType");
28
- }
29
- }
16
+ : name(std::move(name_p)), type(std::move(type_p)), category(category), expression(std::move(expression)) {
30
17
  }
31
18
 
32
19
  ColumnDefinition ColumnDefinition::Copy() const {
33
20
  ColumnDefinition copy(name, type);
34
21
  copy.oid = oid;
35
22
  copy.storage_oid = storage_oid;
36
- copy.SetDefaultValue(default_value ? default_value->Copy() : nullptr);
37
- copy.generated_expression = generated_expression ? generated_expression->Copy() : nullptr;
23
+ copy.expression = expression ? expression->Copy() : nullptr;
38
24
  copy.compression_type = compression_type;
39
25
  copy.category = category;
40
26
  return copy;
@@ -44,11 +30,7 @@ void ColumnDefinition::Serialize(Serializer &serializer) const {
44
30
  FieldWriter writer(serializer);
45
31
  writer.WriteString(name);
46
32
  writer.WriteSerializable(type);
47
- if (Generated()) {
48
- writer.WriteOptional(generated_expression);
49
- } else {
50
- writer.WriteOptional(default_value);
51
- }
33
+ writer.WriteOptional(expression);
52
34
  writer.WriteField<TableColumnType>(category);
53
35
  writer.WriteField<duckdb::CompressionType>(compression_type);
54
36
  writer.Finalize();
@@ -69,11 +51,17 @@ ColumnDefinition ColumnDefinition::Deserialize(Deserializer &source) {
69
51
  }
70
52
 
71
53
  const unique_ptr<ParsedExpression> &ColumnDefinition::DefaultValue() const {
72
- return default_value;
54
+ if (Generated()) {
55
+ throw InternalException("Calling DefaultValue() on a generated column");
56
+ }
57
+ return expression;
73
58
  }
74
59
 
75
60
  void ColumnDefinition::SetDefaultValue(unique_ptr<ParsedExpression> default_value) {
76
- this->default_value = std::move(default_value);
61
+ if (Generated()) {
62
+ throw InternalException("Calling SetDefaultValue() on a generated column");
63
+ }
64
+ this->expression = std::move(default_value);
77
65
  }
78
66
 
79
67
  const LogicalType &ColumnDefinition::Type() const {
@@ -168,7 +156,7 @@ static void InnerGetListOfDependencies(ParsedExpression &expr, vector<string> &d
168
156
 
169
157
  void ColumnDefinition::GetListOfDependencies(vector<string> &dependencies) const {
170
158
  D_ASSERT(Generated());
171
- InnerGetListOfDependencies(*generated_expression, dependencies);
159
+ InnerGetListOfDependencies(*expression, dependencies);
172
160
  }
173
161
 
174
162
  string ColumnDefinition::GetName() const {
@@ -179,28 +167,28 @@ LogicalType ColumnDefinition::GetType() const {
179
167
  return type;
180
168
  }
181
169
 
182
- void ColumnDefinition::SetGeneratedExpression(unique_ptr<ParsedExpression> expression) {
170
+ void ColumnDefinition::SetGeneratedExpression(unique_ptr<ParsedExpression> new_expr) {
183
171
  category = TableColumnType::GENERATED;
184
172
 
185
- if (expression->HasSubquery()) {
173
+ if (new_expr->HasSubquery()) {
186
174
  throw ParserException("Expression of generated column \"%s\" contains a subquery, which isn't allowed", name);
187
175
  }
188
176
 
189
- VerifyColumnRefs(*expression);
177
+ VerifyColumnRefs(*new_expr);
190
178
  if (type.id() == LogicalTypeId::ANY) {
191
- generated_expression = std::move(expression);
179
+ expression = std::move(new_expr);
192
180
  return;
193
181
  }
194
182
  // Always wrap the expression in a cast, that way we can always update the cast when we change the type
195
183
  // Except if the type is LogicalType::ANY (no type specified)
196
- generated_expression = make_uniq_base<ParsedExpression, CastExpression>(type, std::move(expression));
184
+ expression = make_uniq_base<ParsedExpression, CastExpression>(type, std::move(new_expr));
197
185
  }
198
186
 
199
187
  void ColumnDefinition::ChangeGeneratedExpressionType(const LogicalType &type) {
200
188
  D_ASSERT(Generated());
201
189
  // First time the type is set, add a cast around the expression
202
190
  D_ASSERT(this->type.id() == LogicalTypeId::ANY);
203
- generated_expression = make_uniq_base<ParsedExpression, CastExpression>(type, std::move(generated_expression));
191
+ expression = make_uniq_base<ParsedExpression, CastExpression>(type, std::move(expression));
204
192
  // Every generated expression should be wrapped in a cast on creation
205
193
  // D_ASSERT(generated_expression->type == ExpressionType::OPERATOR_CAST);
206
194
  // auto &cast_expr = generated_expression->Cast<CastExpression>();
@@ -210,12 +198,12 @@ void ColumnDefinition::ChangeGeneratedExpressionType(const LogicalType &type) {
210
198
 
211
199
  const ParsedExpression &ColumnDefinition::GeneratedExpression() const {
212
200
  D_ASSERT(Generated());
213
- return *generated_expression;
201
+ return *expression;
214
202
  }
215
203
 
216
204
  ParsedExpression &ColumnDefinition::GeneratedExpressionMutable() {
217
205
  D_ASSERT(Generated());
218
- return *generated_expression;
206
+ return *expression;
219
207
  }
220
208
 
221
209
  } // namespace duckdb
@@ -6,6 +6,14 @@ namespace duckdb {
6
6
 
7
7
  ColumnList::ColumnList(bool allow_duplicate_names) : allow_duplicate_names(allow_duplicate_names) {
8
8
  }
9
+
10
+ ColumnList::ColumnList(vector<ColumnDefinition> columns, bool allow_duplicate_names)
11
+ : allow_duplicate_names(allow_duplicate_names) {
12
+ for (auto &col : columns) {
13
+ AddColumn(std::move(col));
14
+ }
15
+ }
16
+
9
17
  void ColumnList::AddColumn(ColumnDefinition column) {
10
18
  auto oid = columns.size();
11
19
  if (!column.Generated()) {
@@ -6,6 +6,9 @@
6
6
 
7
7
  namespace duckdb {
8
8
 
9
+ ForeignKeyConstraint::ForeignKeyConstraint() : Constraint(ConstraintType::FOREIGN_KEY) {
10
+ }
11
+
9
12
  ForeignKeyConstraint::ForeignKeyConstraint(vector<string> pk_columns, vector<string> fk_columns, ForeignKeyInfo info)
10
13
  : Constraint(ConstraintType::FOREIGN_KEY), pk_columns(std::move(pk_columns)), fk_columns(std::move(fk_columns)),
11
14
  info(std::move(info)) {
@@ -6,6 +6,9 @@
6
6
 
7
7
  namespace duckdb {
8
8
 
9
+ UniqueConstraint::UniqueConstraint() : Constraint(ConstraintType::UNIQUE), index(DConstants::INVALID_INDEX) {
10
+ }
11
+
9
12
  UniqueConstraint::UniqueConstraint(LogicalIndex index, bool is_primary_key)
10
13
  : Constraint(ConstraintType::UNIQUE), index(index), is_primary_key(is_primary_key) {
11
14
  }
@@ -8,18 +8,6 @@
8
8
 
9
9
  namespace duckdb {
10
10
 
11
- void CaseCheck::FormatSerialize(FormatSerializer &serializer) const {
12
- serializer.WriteProperty("when_expr", when_expr);
13
- serializer.WriteProperty("then_expr", then_expr);
14
- }
15
-
16
- CaseCheck CaseCheck::FormatDeserialize(FormatDeserializer &deserializer) {
17
- CaseCheck check;
18
- deserializer.ReadProperty("when_expr", check.when_expr);
19
- deserializer.ReadProperty("then_expr", check.then_expr);
20
- return check;
21
- }
22
-
23
11
  CaseExpression::CaseExpression() : ParsedExpression(ExpressionType::CASE_EXPR, ExpressionClass::CASE) {
24
12
  }
25
13
 
@@ -8,8 +8,11 @@
8
8
  namespace duckdb {
9
9
 
10
10
  AlterInfo::AlterInfo(AlterType type, string catalog_p, string schema_p, string name_p, OnEntryNotFound if_not_found)
11
- : type(type), if_not_found(if_not_found), catalog(std::move(catalog_p)), schema(std::move(schema_p)),
12
- name(std::move(name_p)), allow_internal(false) {
11
+ : ParseInfo(TYPE), type(type), if_not_found(if_not_found), catalog(std::move(catalog_p)),
12
+ schema(std::move(schema_p)), name(std::move(name_p)), allow_internal(false) {
13
+ }
14
+
15
+ AlterInfo::AlterInfo(AlterType type) : ParseInfo(TYPE), type(type) {
13
16
  }
14
17
 
15
18
  AlterInfo::~AlterInfo() {
@@ -33,6 +33,9 @@ void ChangeOwnershipInfo::Serialize(FieldWriter &writer) const {
33
33
  //===--------------------------------------------------------------------===//
34
34
  // AlterTableInfo
35
35
  //===--------------------------------------------------------------------===//
36
+ AlterTableInfo::AlterTableInfo(AlterTableType type) : AlterInfo(AlterType::ALTER_TABLE), alter_table_type(type) {
37
+ }
38
+
36
39
  AlterTableInfo::AlterTableInfo(AlterTableType type, AlterEntryData data)
37
40
  : AlterInfo(AlterType::ALTER_TABLE, std::move(data.catalog), std::move(data.schema), std::move(data.name),
38
41
  data.if_not_found),
@@ -94,6 +97,10 @@ RenameColumnInfo::RenameColumnInfo(AlterEntryData data, string old_name_p, strin
94
97
  : AlterTableInfo(AlterTableType::RENAME_COLUMN, std::move(data)), old_name(std::move(old_name_p)),
95
98
  new_name(std::move(new_name_p)) {
96
99
  }
100
+
101
+ RenameColumnInfo::RenameColumnInfo() : AlterTableInfo(AlterTableType::RENAME_COLUMN) {
102
+ }
103
+
97
104
  RenameColumnInfo::~RenameColumnInfo() {
98
105
  }
99
106
 
@@ -115,9 +122,13 @@ unique_ptr<AlterInfo> RenameColumnInfo::Deserialize(FieldReader &reader, AlterEn
115
122
  //===--------------------------------------------------------------------===//
116
123
  // RenameTableInfo
117
124
  //===--------------------------------------------------------------------===//
125
+ RenameTableInfo::RenameTableInfo() : AlterTableInfo(AlterTableType::RENAME_TABLE) {
126
+ }
127
+
118
128
  RenameTableInfo::RenameTableInfo(AlterEntryData data, string new_name_p)
119
129
  : AlterTableInfo(AlterTableType::RENAME_TABLE, std::move(data)), new_table_name(std::move(new_name_p)) {
120
130
  }
131
+
121
132
  RenameTableInfo::~RenameTableInfo() {
122
133
  }
123
134
 
@@ -137,6 +148,10 @@ unique_ptr<AlterInfo> RenameTableInfo::Deserialize(FieldReader &reader, AlterEnt
137
148
  //===--------------------------------------------------------------------===//
138
149
  // AddColumnInfo
139
150
  //===--------------------------------------------------------------------===//
151
+ AddColumnInfo::AddColumnInfo(ColumnDefinition new_column_p)
152
+ : AlterTableInfo(AlterTableType::ADD_COLUMN), new_column(std::move(new_column_p)) {
153
+ }
154
+
140
155
  AddColumnInfo::AddColumnInfo(AlterEntryData data, ColumnDefinition new_column, bool if_column_not_exists)
141
156
  : AlterTableInfo(AlterTableType::ADD_COLUMN, std::move(data)), new_column(std::move(new_column)),
142
157
  if_column_not_exists(if_column_not_exists) {
@@ -163,6 +178,9 @@ unique_ptr<AlterInfo> AddColumnInfo::Deserialize(FieldReader &reader, AlterEntry
163
178
  //===--------------------------------------------------------------------===//
164
179
  // RemoveColumnInfo
165
180
  //===--------------------------------------------------------------------===//
181
+ RemoveColumnInfo::RemoveColumnInfo() : AlterTableInfo(AlterTableType::REMOVE_COLUMN) {
182
+ }
183
+
166
184
  RemoveColumnInfo::RemoveColumnInfo(AlterEntryData data, string removed_column, bool if_column_exists, bool cascade)
167
185
  : AlterTableInfo(AlterTableType::REMOVE_COLUMN, std::move(data)), removed_column(std::move(removed_column)),
168
186
  if_column_exists(if_column_exists), cascade(cascade) {
@@ -190,6 +208,9 @@ unique_ptr<AlterInfo> RemoveColumnInfo::Deserialize(FieldReader &reader, AlterEn
190
208
  //===--------------------------------------------------------------------===//
191
209
  // ChangeColumnTypeInfo
192
210
  //===--------------------------------------------------------------------===//
211
+ ChangeColumnTypeInfo::ChangeColumnTypeInfo() : AlterTableInfo(AlterTableType::ALTER_COLUMN_TYPE) {
212
+ }
213
+
193
214
  ChangeColumnTypeInfo::ChangeColumnTypeInfo(AlterEntryData data, string column_name, LogicalType target_type,
194
215
  unique_ptr<ParsedExpression> expression)
195
216
  : AlterTableInfo(AlterTableType::ALTER_COLUMN_TYPE, std::move(data)), column_name(std::move(column_name)),
@@ -220,6 +241,9 @@ unique_ptr<AlterInfo> ChangeColumnTypeInfo::Deserialize(FieldReader &reader, Alt
220
241
  //===--------------------------------------------------------------------===//
221
242
  // SetDefaultInfo
222
243
  //===--------------------------------------------------------------------===//
244
+ SetDefaultInfo::SetDefaultInfo() : AlterTableInfo(AlterTableType::SET_DEFAULT) {
245
+ }
246
+
223
247
  SetDefaultInfo::SetDefaultInfo(AlterEntryData data, string column_name_p, unique_ptr<ParsedExpression> new_default)
224
248
  : AlterTableInfo(AlterTableType::SET_DEFAULT, std::move(data)), column_name(std::move(column_name_p)),
225
249
  expression(std::move(new_default)) {
@@ -246,6 +270,9 @@ unique_ptr<AlterInfo> SetDefaultInfo::Deserialize(FieldReader &reader, AlterEntr
246
270
  //===--------------------------------------------------------------------===//
247
271
  // SetNotNullInfo
248
272
  //===--------------------------------------------------------------------===//
273
+ SetNotNullInfo::SetNotNullInfo() : AlterTableInfo(AlterTableType::SET_NOT_NULL) {
274
+ }
275
+
249
276
  SetNotNullInfo::SetNotNullInfo(AlterEntryData data, string column_name_p)
250
277
  : AlterTableInfo(AlterTableType::SET_NOT_NULL, std::move(data)), column_name(std::move(column_name_p)) {
251
278
  }
@@ -268,6 +295,9 @@ unique_ptr<AlterInfo> SetNotNullInfo::Deserialize(FieldReader &reader, AlterEntr
268
295
  //===--------------------------------------------------------------------===//
269
296
  // DropNotNullInfo
270
297
  //===--------------------------------------------------------------------===//
298
+ DropNotNullInfo::DropNotNullInfo() : AlterTableInfo(AlterTableType::DROP_NOT_NULL) {
299
+ }
300
+
271
301
  DropNotNullInfo::DropNotNullInfo(AlterEntryData data, string column_name_p)
272
302
  : AlterTableInfo(AlterTableType::DROP_NOT_NULL, std::move(data)), column_name(std::move(column_name_p)) {
273
303
  }
@@ -290,6 +320,9 @@ unique_ptr<AlterInfo> DropNotNullInfo::Deserialize(FieldReader &reader, AlterEnt
290
320
  //===--------------------------------------------------------------------===//
291
321
  // AlterForeignKeyInfo
292
322
  //===--------------------------------------------------------------------===//
323
+ AlterForeignKeyInfo::AlterForeignKeyInfo() : AlterTableInfo(AlterTableType::FOREIGN_KEY_CONSTRAINT) {
324
+ }
325
+
293
326
  AlterForeignKeyInfo::AlterForeignKeyInfo(AlterEntryData data, string fk_table, vector<string> pk_columns,
294
327
  vector<string> fk_columns, vector<PhysicalIndex> pk_keys,
295
328
  vector<PhysicalIndex> fk_keys, AlterForeignKeyType type_p)
@@ -328,6 +361,9 @@ unique_ptr<AlterInfo> AlterForeignKeyInfo::Deserialize(FieldReader &reader, Alte
328
361
  //===--------------------------------------------------------------------===//
329
362
  // Alter View
330
363
  //===--------------------------------------------------------------------===//
364
+ AlterViewInfo::AlterViewInfo(AlterViewType type) : AlterInfo(AlterType::ALTER_VIEW) {
365
+ }
366
+
331
367
  AlterViewInfo::AlterViewInfo(AlterViewType type, AlterEntryData data)
332
368
  : AlterInfo(AlterType::ALTER_VIEW, std::move(data.catalog), std::move(data.schema), std::move(data.name),
333
369
  data.if_not_found),
@@ -368,6 +404,8 @@ unique_ptr<AlterInfo> AlterViewInfo::Deserialize(FieldReader &reader) {
368
404
  //===--------------------------------------------------------------------===//
369
405
  // RenameViewInfo
370
406
  //===--------------------------------------------------------------------===//
407
+ RenameViewInfo::RenameViewInfo() : AlterViewInfo(AlterViewType::RENAME_VIEW) {
408
+ }
371
409
  RenameViewInfo::RenameViewInfo(AlterEntryData data, string new_name_p)
372
410
  : AlterViewInfo(AlterViewType::RENAME_VIEW, std::move(data)), new_view_name(std::move(new_name_p)) {
373
411
  }
@@ -11,7 +11,7 @@ unique_ptr<CreateInfo> CreateIndexInfo::Copy() const {
11
11
  result->index_type = index_type;
12
12
  result->index_name = index_name;
13
13
  result->constraint_type = constraint_type;
14
- result->table = unique_ptr_cast<TableRef, BaseTableRef>(table->Copy());
14
+ result->table = table;
15
15
  for (auto &expr : expressions) {
16
16
  result->expressions.push_back(expr->Copy());
17
17
  }
@@ -28,6 +28,7 @@ unique_ptr<CreateInfo> CreateIndexInfo::Copy() const {
28
28
  void CreateIndexInfo::SerializeInternal(Serializer &serializer) const {
29
29
  FieldWriter writer(serializer);
30
30
  writer.WriteField(index_type);
31
+ writer.WriteString(table);
31
32
  writer.WriteString(index_name);
32
33
  writer.WriteField(constraint_type);
33
34
 
@@ -45,6 +46,7 @@ unique_ptr<CreateIndexInfo> CreateIndexInfo::Deserialize(Deserializer &deseriali
45
46
 
46
47
  FieldReader reader(deserializer);
47
48
  result->index_type = reader.ReadRequired<IndexType>();
49
+ result->table = reader.ReadRequired<string>();
48
50
  result->index_name = reader.ReadRequired<string>();
49
51
  result->constraint_type = reader.ReadRequired<IndexConstraintType>();
50
52
 
@@ -27,6 +27,7 @@ unique_ptr<CreateInfo> CreateSequenceInfo::Copy() const {
27
27
  void CreateSequenceInfo::SerializeInternal(Serializer &serializer) const {
28
28
  FieldWriter writer(serializer);
29
29
  writer.WriteString(name);
30
+ writer.WriteString(schema);
30
31
  writer.WriteField(usage_count);
31
32
  writer.WriteField(increment);
32
33
  writer.WriteField(min_value);
@@ -42,6 +43,7 @@ unique_ptr<CreateSequenceInfo> CreateSequenceInfo::Deserialize(Deserializer &des
42
43
 
43
44
  FieldReader reader(deserializer);
44
45
  result->name = reader.ReadRequired<string>();
46
+ result->schema = reader.ReadRequired<string>();
45
47
  result->usage_count = reader.ReadRequired<uint64_t>();
46
48
  result->increment = reader.ReadRequired<int64_t>();
47
49
  result->min_value = reader.ReadRequired<int64_t>();
@@ -3,7 +3,7 @@
3
3
 
4
4
  namespace duckdb {
5
5
 
6
- DetachInfo::DetachInfo() {
6
+ DetachInfo::DetachInfo() : ParseInfo(TYPE) {
7
7
  }
8
8
 
9
9
  unique_ptr<DetachInfo> DetachInfo::Copy() const {
@@ -2,7 +2,7 @@
2
2
 
3
3
  namespace duckdb {
4
4
 
5
- DropInfo::DropInfo() : catalog(INVALID_CATALOG), schema(INVALID_SCHEMA), cascade(false) {
5
+ DropInfo::DropInfo() : ParseInfo(TYPE), catalog(INVALID_CATALOG), schema(INVALID_SCHEMA), cascade(false) {
6
6
  }
7
7
 
8
8
  unique_ptr<DropInfo> DropInfo::Copy() const {
@@ -19,24 +19,6 @@ void SampleOptions::Serialize(Serializer &serializer) {
19
19
  writer.Finalize();
20
20
  }
21
21
 
22
- void SampleOptions::FormatSerialize(FormatSerializer &serializer) const {
23
- serializer.WriteProperty("sample_size", sample_size);
24
- serializer.WriteProperty("is_percentage", is_percentage);
25
- serializer.WriteProperty("method", method);
26
- serializer.WriteProperty("seed", seed);
27
- }
28
-
29
- unique_ptr<SampleOptions> SampleOptions::FormatDeserialize(FormatDeserializer &deserializer) {
30
- auto result = make_uniq<SampleOptions>();
31
-
32
- deserializer.ReadProperty("sample_size", result->sample_size);
33
- deserializer.ReadProperty("is_percentage", result->is_percentage);
34
- deserializer.ReadProperty("method", result->method);
35
- deserializer.ReadProperty("seed", result->seed);
36
-
37
- return result;
38
- }
39
-
40
22
  unique_ptr<SampleOptions> SampleOptions::Deserialize(Deserializer &source) {
41
23
  auto result = make_uniq<SampleOptions>();
42
24
 
@@ -3,7 +3,10 @@
3
3
 
4
4
  namespace duckdb {
5
5
 
6
- TransactionInfo::TransactionInfo(TransactionType type) : type(type) {
6
+ TransactionInfo::TransactionInfo() : ParseInfo(TYPE) {
7
+ }
8
+
9
+ TransactionInfo::TransactionInfo(TransactionType type) : ParseInfo(TYPE), type(type) {
7
10
  }
8
11
 
9
12
  void TransactionInfo::Serialize(Serializer &serializer) const {
@@ -3,7 +3,7 @@
3
3
 
4
4
  namespace duckdb {
5
5
 
6
- VacuumInfo::VacuumInfo(VacuumOptions options) : options(options), has_table(false) {
6
+ VacuumInfo::VacuumInfo(VacuumOptions options) : ParseInfo(TYPE), options(options), has_table(false) {
7
7
  }
8
8
 
9
9
  unique_ptr<VacuumInfo> VacuumInfo::Copy() {
@@ -75,16 +75,6 @@ string CommonTableExpressionMap::ToString() const {
75
75
  return result;
76
76
  }
77
77
 
78
- void CommonTableExpressionMap::FormatSerialize(FormatSerializer &serializer) const {
79
- serializer.WriteProperty("map", map);
80
- }
81
-
82
- CommonTableExpressionMap CommonTableExpressionMap::FormatDeserialize(FormatDeserializer &deserializer) {
83
- auto result = CommonTableExpressionMap();
84
- deserializer.ReadProperty("map", result.map);
85
- return result;
86
- }
87
-
88
78
  string QueryNode::ResultModifiersToString() const {
89
79
  string result;
90
80
  for (idx_t modifier_idx = 0; modifier_idx < modifiers.size(); modifier_idx++) {
@@ -179,19 +179,6 @@ void OrderByNode::Serialize(Serializer &serializer) const {
179
179
  writer.Finalize();
180
180
  }
181
181
 
182
- void OrderByNode::FormatSerialize(FormatSerializer &serializer) const {
183
- serializer.WriteProperty("type", type);
184
- serializer.WriteProperty("null_order", null_order);
185
- serializer.WriteProperty("expression", expression);
186
- }
187
-
188
- OrderByNode OrderByNode::FormatDeserialize(FormatDeserializer &deserializer) {
189
- auto type = deserializer.ReadProperty<OrderType>("type");
190
- auto null_order = deserializer.ReadProperty<OrderByNullType>("null_order");
191
- auto expression = deserializer.ReadProperty<unique_ptr<ParsedExpression>>("expression");
192
- return OrderByNode(type, null_order, std::move(expression));
193
- }
194
-
195
182
  OrderByNode OrderByNode::Deserialize(Deserializer &source) {
196
183
  FieldReader reader(source);
197
184
  auto type = reader.ReadRequired<OrderType>();
@@ -17,22 +17,12 @@ void SelectStatement::Serialize(Serializer &serializer) const {
17
17
  node->Serialize(serializer);
18
18
  }
19
19
 
20
- void SelectStatement::FormatSerialize(FormatSerializer &serializer) const {
21
- serializer.WriteProperty("node", node);
22
- }
23
-
24
20
  unique_ptr<SelectStatement> SelectStatement::Deserialize(Deserializer &source) {
25
21
  auto result = make_uniq<SelectStatement>();
26
22
  result->node = QueryNode::Deserialize(source);
27
23
  return result;
28
24
  }
29
25
 
30
- unique_ptr<SelectStatement> SelectStatement::FormatDeserialize(FormatDeserializer &deserializer) {
31
- auto result = make_uniq<SelectStatement>();
32
- deserializer.ReadProperty("node", result->node);
33
- return result;
34
- }
35
-
36
26
  bool SelectStatement::Equals(const SQLStatement &other_p) const {
37
27
  if (type != other_p.type) {
38
28
  return false;
@@ -130,13 +130,6 @@ void PivotColumn::Serialize(Serializer &serializer) const {
130
130
  writer.Finalize();
131
131
  }
132
132
 
133
- void PivotColumn::FormatSerialize(FormatSerializer &serializer) const {
134
- serializer.WriteProperty("pivot_expressions", pivot_expressions);
135
- serializer.WriteProperty("unpivot_names", unpivot_names);
136
- serializer.WriteProperty("entries", entries);
137
- serializer.WriteProperty("pivot_enum", pivot_enum);
138
- }
139
-
140
133
  PivotColumn PivotColumn::Deserialize(Deserializer &source) {
141
134
  PivotColumn result;
142
135
  FieldReader reader(source);
@@ -148,15 +141,6 @@ PivotColumn PivotColumn::Deserialize(Deserializer &source) {
148
141
  return result;
149
142
  }
150
143
 
151
- PivotColumn PivotColumn::FormatDeserialize(FormatDeserializer &source) {
152
- PivotColumn result;
153
- source.ReadProperty("pivot_expressions", result.pivot_expressions);
154
- source.ReadProperty("unpivot_names", result.unpivot_names);
155
- source.ReadProperty("entries", result.entries);
156
- source.ReadProperty("pivot_enum", result.pivot_enum);
157
- return result;
158
- }
159
-
160
144
  //===--------------------------------------------------------------------===//
161
145
  // PivotColumnEntry
162
146
  //===--------------------------------------------------------------------===//
@@ -57,12 +57,13 @@ unique_ptr<CreateStatement> Transformer::TransformCreateIndex(duckdb_libpgquery:
57
57
  info->expressions = TransformIndexParameters(*stmt.indexParams, stmt.relation->relname);
58
58
 
59
59
  info->index_type = StringToIndexType(string(stmt.accessMethod));
60
- auto tableref = make_uniq<BaseTableRef>();
61
- tableref->table_name = stmt.relation->relname;
62
60
  if (stmt.relation->schemaname) {
63
- tableref->schema_name = stmt.relation->schemaname;
61
+ info->schema = stmt.relation->schemaname;
64
62
  }
65
- info->table = std::move(tableref);
63
+ if (stmt.relation->catalogname) {
64
+ info->catalog = stmt.relation->catalogname;
65
+ }
66
+ info->table = stmt.relation->relname;
66
67
  if (stmt.idxname) {
67
68
  info->index_name = stmt.idxname;
68
69
  } else {
@@ -160,7 +160,7 @@ CreateDuplicateEliminatedJoin(const vector<CorrelatedColumnInfo> &correlated_col
160
160
  for (idx_t i = 0; i < correlated_columns.size(); i++) {
161
161
  auto &col = correlated_columns[i];
162
162
  delim_join->duplicate_eliminated_columns.push_back(make_uniq<BoundColumnRefExpression>(col.type, col.binding));
163
- delim_join->delim_types.push_back(col.type);
163
+ delim_join->mark_types.push_back(col.type);
164
164
  }
165
165
  return delim_join;
166
166
  }
@@ -529,7 +529,12 @@ BoundStatement Binder::Bind(CreateStatement &stmt) {
529
529
  auto &base = stmt.info->Cast<CreateIndexInfo>();
530
530
 
531
531
  // visit the table reference
532
- auto bound_table = Bind(*base.table);
532
+ auto table_ref = make_uniq<BaseTableRef>();
533
+ table_ref->catalog_name = base.catalog;
534
+ table_ref->schema_name = base.schema;
535
+ table_ref->table_name = base.table;
536
+
537
+ auto bound_table = Bind(*table_ref);
533
538
  if (bound_table->type != TableReferenceType::BASE_TABLE) {
534
539
  throw BinderException("Can only create an index over a base table!");
535
540
  }
@@ -21,15 +21,25 @@ unique_ptr<BoundTableRef> Binder::Bind(BaseTableRef &ref) {
21
21
  QueryErrorContext error_context(root_statement, ref.query_location);
22
22
  // CTEs and views are also referred to using BaseTableRefs, hence need to distinguish here
23
23
  // check if the table name refers to a CTE
24
- auto found_cte = FindCTE(ref.table_name, ref.table_name == alias);
24
+
25
+ // CTE name should never be qualified (i.e. schema_name should be empty)
26
+ optional_ptr<CommonTableExpressionInfo> found_cte = nullptr;
27
+ if (ref.schema_name.empty()) {
28
+ found_cte = FindCTE(ref.table_name, ref.table_name == alias);
29
+ }
30
+
25
31
  if (found_cte) {
26
32
  // Check if there is a CTE binding in the BindContext
27
33
  auto &cte = *found_cte;
28
34
  auto ctebinding = bind_context.GetCTEBinding(ref.table_name);
29
35
  if (!ctebinding) {
30
36
  if (CTEIsAlreadyBound(cte)) {
31
- throw BinderException("Circular reference to CTE \"%s\", use WITH RECURSIVE to use recursive CTEs",
32
- ref.table_name);
37
+ throw BinderException(
38
+ "Circular reference to CTE \"%s\", There are two possible solutions. \n1. use WITH RECURSIVE to "
39
+ "use recursive CTEs. \n2. If "
40
+ "you want to use the TABLE name \"%s\" the same as the CTE name, please explicitly add "
41
+ "\"SCHEMA\" before table name. You can try \"main.%s\" (main is the duckdb default schema)",
42
+ ref.table_name, ref.table_name, ref.table_name);
33
43
  }
34
44
  // Move CTE to subquery and bind recursively
35
45
  SubqueryRef subquery(unique_ptr_cast<SQLStatement, SelectStatement>(cte.query->Copy()));
@@ -4,6 +4,10 @@
4
4
 
5
5
  namespace duckdb {
6
6
 
7
+ BoundBetweenExpression::BoundBetweenExpression()
8
+ : Expression(ExpressionType::COMPARE_BETWEEN, ExpressionClass::BOUND_BETWEEN, LogicalType::BOOLEAN) {
9
+ }
10
+
7
11
  BoundBetweenExpression::BoundBetweenExpression(unique_ptr<Expression> input, unique_ptr<Expression> lower,
8
12
  unique_ptr<Expression> upper, bool lower_inclusive, bool upper_inclusive)
9
13
  : Expression(ExpressionType::COMPARE_BETWEEN, ExpressionClass::BOUND_BETWEEN, LogicalType::BOOLEAN),
@@ -8,12 +8,25 @@
8
8
 
9
9
  namespace duckdb {
10
10
 
11
+ static BoundCastInfo BindCastFunction(ClientContext &context, const LogicalType &source, const LogicalType &target) {
12
+ auto &cast_functions = DBConfig::GetConfig(context).GetCastFunctions();
13
+ GetCastFunctionInput input(context);
14
+ return cast_functions.GetCastFunction(source, target, input);
15
+ }
16
+
11
17
  BoundCastExpression::BoundCastExpression(unique_ptr<Expression> child_p, LogicalType target_type_p,
12
18
  BoundCastInfo bound_cast_p, bool try_cast_p)
13
19
  : Expression(ExpressionType::OPERATOR_CAST, ExpressionClass::BOUND_CAST, std::move(target_type_p)),
14
20
  child(std::move(child_p)), try_cast(try_cast_p), bound_cast(std::move(bound_cast_p)) {
15
21
  }
16
22
 
23
+ BoundCastExpression::BoundCastExpression(ClientContext &context, unique_ptr<Expression> child_p,
24
+ LogicalType target_type_p)
25
+ : Expression(ExpressionType::OPERATOR_CAST, ExpressionClass::BOUND_CAST, std::move(target_type_p)),
26
+ child(std::move(child_p)), try_cast(false),
27
+ bound_cast(BindCastFunction(context, child->return_type, return_type)) {
28
+ }
29
+
17
30
  unique_ptr<Expression> AddCastExpressionInternal(unique_ptr<Expression> expr, const LogicalType &target_type,
18
31
  BoundCastInfo bound_cast, bool try_cast) {
19
32
  if (expr->return_type == target_type) {
@@ -30,12 +43,6 @@ unique_ptr<Expression> AddCastExpressionInternal(unique_ptr<Expression> expr, co
30
43
  return make_uniq<BoundCastExpression>(std::move(expr), target_type, std::move(bound_cast), try_cast);
31
44
  }
32
45
 
33
- static BoundCastInfo BindCastFunction(ClientContext &context, const LogicalType &source, const LogicalType &target) {
34
- auto &cast_functions = DBConfig::GetConfig(context).GetCastFunctions();
35
- GetCastFunctionInput input(context);
36
- return cast_functions.GetCastFunction(source, target, input);
37
- }
38
-
39
46
  unique_ptr<Expression> AddCastToTypeInternal(unique_ptr<Expression> expr, const LogicalType &target_type,
40
47
  CastFunctionSet &cast_functions, GetCastFunctionInput &get_input,
41
48
  bool try_cast) {