duckdb 0.8.1-dev96.0 → 0.8.2-dev1.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 (243) hide show
  1. package/binding.gyp +8 -8
  2. package/package.json +3 -1
  3. package/src/duckdb/extension/icu/icu-datepart.cpp +1 -1
  4. package/src/duckdb/extension/icu/icu-extension.cpp +1 -1
  5. package/src/duckdb/extension/icu/icu-makedate.cpp +5 -4
  6. package/src/duckdb/extension/icu/icu-strptime.cpp +1 -1
  7. package/src/duckdb/extension/icu/third_party/icu/i18n/nfsubs.cpp +0 -2
  8. package/src/duckdb/extension/json/buffered_json_reader.cpp +23 -14
  9. package/src/duckdb/extension/json/include/buffered_json_reader.hpp +6 -6
  10. package/src/duckdb/extension/json/include/json_common.hpp +12 -2
  11. package/src/duckdb/extension/json/include/json_scan.hpp +5 -2
  12. package/src/duckdb/extension/json/json_functions/json_contains.cpp +5 -0
  13. package/src/duckdb/extension/json/json_functions/json_create.cpp +10 -10
  14. package/src/duckdb/extension/json/json_functions/json_merge_patch.cpp +2 -2
  15. package/src/duckdb/extension/json/json_functions/json_serialize_sql.cpp +2 -2
  16. package/src/duckdb/extension/json/json_functions/json_structure.cpp +5 -3
  17. package/src/duckdb/extension/json/json_functions/json_transform.cpp +11 -11
  18. package/src/duckdb/extension/json/json_functions/read_json.cpp +2 -1
  19. package/src/duckdb/extension/json/json_functions.cpp +6 -3
  20. package/src/duckdb/extension/json/json_scan.cpp +43 -27
  21. package/src/duckdb/extension/parquet/column_reader.cpp +5 -1
  22. package/src/duckdb/extension/parquet/include/decode_utils.hpp +6 -0
  23. package/src/duckdb/extension/parquet/parquet-extension.cpp +26 -1
  24. package/src/duckdb/src/catalog/catalog.cpp +5 -17
  25. package/src/duckdb/src/catalog/catalog_entry/duck_table_entry.cpp +7 -1
  26. package/src/duckdb/src/catalog/catalog_entry/table_catalog_entry.cpp +121 -0
  27. package/src/duckdb/src/catalog/catalog_search_path.cpp +49 -12
  28. package/src/duckdb/src/catalog/default/default_types.cpp +9 -84
  29. package/src/duckdb/src/common/adbc/adbc.cpp +118 -12
  30. package/src/duckdb/src/common/adbc/driver_manager.cpp +0 -20
  31. package/src/duckdb/src/common/arrow/arrow_converter.cpp +11 -12
  32. package/src/duckdb/src/common/arrow/arrow_wrapper.cpp +4 -3
  33. package/src/duckdb/src/common/exception.cpp +4 -1
  34. package/src/duckdb/src/common/exception_format_value.cpp +24 -15
  35. package/src/duckdb/src/common/multi_file_reader.cpp +3 -0
  36. package/src/duckdb/src/common/random_engine.cpp +1 -1
  37. package/src/duckdb/src/common/types/row/row_data_collection_scanner.cpp +5 -4
  38. package/src/duckdb/src/common/types/row/tuple_data_scatter_gather.cpp +44 -7
  39. package/src/duckdb/src/common/types/time.cpp +2 -8
  40. package/src/duckdb/src/common/types/timestamp.cpp +37 -1
  41. package/src/duckdb/src/common/types/value.cpp +1 -0
  42. package/src/duckdb/src/common/types.cpp +4 -0
  43. package/src/duckdb/src/core_functions/aggregate/algebraic/avg.cpp +30 -33
  44. package/src/duckdb/src/core_functions/aggregate/algebraic/covar.cpp +0 -4
  45. package/src/duckdb/src/core_functions/aggregate/distributive/approx_count.cpp +30 -33
  46. package/src/duckdb/src/core_functions/aggregate/distributive/arg_min_max.cpp +52 -65
  47. package/src/duckdb/src/core_functions/aggregate/distributive/bitagg.cpp +48 -48
  48. package/src/duckdb/src/core_functions/aggregate/distributive/bitstring_agg.cpp +39 -40
  49. package/src/duckdb/src/core_functions/aggregate/distributive/bool.cpp +32 -32
  50. package/src/duckdb/src/core_functions/aggregate/distributive/entropy.cpp +34 -34
  51. package/src/duckdb/src/core_functions/aggregate/distributive/kurtosis.cpp +30 -31
  52. package/src/duckdb/src/core_functions/aggregate/distributive/minmax.cpp +88 -100
  53. package/src/duckdb/src/core_functions/aggregate/distributive/product.cpp +17 -17
  54. package/src/duckdb/src/core_functions/aggregate/distributive/skew.cpp +25 -27
  55. package/src/duckdb/src/core_functions/aggregate/distributive/string_agg.cpp +37 -38
  56. package/src/duckdb/src/core_functions/aggregate/distributive/sum.cpp +22 -22
  57. package/src/duckdb/src/core_functions/aggregate/holistic/approximate_quantile.cpp +44 -80
  58. package/src/duckdb/src/core_functions/aggregate/holistic/mode.cpp +49 -51
  59. package/src/duckdb/src/core_functions/aggregate/holistic/quantile.cpp +104 -122
  60. package/src/duckdb/src/core_functions/aggregate/holistic/reservoir_quantile.cpp +57 -93
  61. package/src/duckdb/src/core_functions/aggregate/nested/histogram.cpp +22 -23
  62. package/src/duckdb/src/core_functions/aggregate/nested/list.cpp +18 -19
  63. package/src/duckdb/src/core_functions/aggregate/regression/regr_avg.cpp +16 -18
  64. package/src/duckdb/src/core_functions/aggregate/regression/regr_intercept.cpp +22 -25
  65. package/src/duckdb/src/core_functions/aggregate/regression/regr_r2.cpp +19 -24
  66. package/src/duckdb/src/core_functions/aggregate/regression/regr_sxx_syy.cpp +18 -23
  67. package/src/duckdb/src/core_functions/aggregate/regression/regr_sxy.cpp +14 -18
  68. package/src/duckdb/src/core_functions/function_list.cpp +1 -0
  69. package/src/duckdb/src/core_functions/scalar/date/date_part.cpp +1 -1
  70. package/src/duckdb/src/core_functions/scalar/date/make_date.cpp +3 -0
  71. package/src/duckdb/src/core_functions/scalar/generic/system_functions.cpp +14 -0
  72. package/src/duckdb/src/core_functions/scalar/list/array_slice.cpp +1 -1
  73. package/src/duckdb/src/core_functions/scalar/list/list_aggregates.cpp +23 -6
  74. package/src/duckdb/src/core_functions/scalar/list/list_lambdas.cpp +1 -2
  75. package/src/duckdb/src/core_functions/scalar/map/map_concat.cpp +3 -0
  76. package/src/duckdb/src/core_functions/scalar/math/numeric.cpp +3 -3
  77. package/src/duckdb/src/execution/index/art/art.cpp +80 -7
  78. package/src/duckdb/src/execution/index/art/fixed_size_allocator.cpp +20 -1
  79. package/src/duckdb/src/execution/index/art/leaf.cpp +11 -11
  80. package/src/duckdb/src/execution/index/art/leaf_segment.cpp +10 -0
  81. package/src/duckdb/src/execution/index/art/node.cpp +48 -35
  82. package/src/duckdb/src/execution/index/art/node16.cpp +3 -0
  83. package/src/duckdb/src/execution/index/art/node256.cpp +1 -0
  84. package/src/duckdb/src/execution/index/art/node4.cpp +3 -0
  85. package/src/duckdb/src/execution/index/art/node48.cpp +2 -0
  86. package/src/duckdb/src/execution/index/art/prefix.cpp +2 -0
  87. package/src/duckdb/src/execution/join_hashtable.cpp +2 -0
  88. package/src/duckdb/src/execution/operator/aggregate/physical_window.cpp +26 -9
  89. package/src/duckdb/src/execution/operator/helper/physical_reset.cpp +5 -2
  90. package/src/duckdb/src/execution/operator/helper/physical_set.cpp +5 -1
  91. package/src/duckdb/src/execution/operator/join/physical_iejoin.cpp +3 -6
  92. package/src/duckdb/src/execution/operator/projection/physical_tableinout_function.cpp +1 -0
  93. package/src/duckdb/src/execution/operator/projection/physical_unnest.cpp +8 -3
  94. package/src/duckdb/src/execution/operator/schema/physical_attach.cpp +0 -1
  95. package/src/duckdb/src/execution/operator/schema/physical_create_index.cpp +29 -3
  96. package/src/duckdb/src/execution/reservoir_sample.cpp +18 -4
  97. package/src/duckdb/src/function/aggregate/distributive/count.cpp +159 -21
  98. package/src/duckdb/src/function/aggregate/distributive/first.cpp +67 -74
  99. package/src/duckdb/src/function/aggregate/sorted_aggregate_function.cpp +7 -7
  100. package/src/duckdb/src/function/cast/list_casts.cpp +2 -4
  101. package/src/duckdb/src/function/pragma/pragma_queries.cpp +33 -23
  102. package/src/duckdb/src/function/scalar/list/list_extract.cpp +1 -1
  103. package/src/duckdb/src/function/scalar/operators/arithmetic.cpp +1 -1
  104. package/src/duckdb/src/function/scalar/string/regexp/regexp_util.cpp +6 -2
  105. package/src/duckdb/src/function/scalar/system/aggregate_export.cpp +2 -2
  106. package/src/duckdb/src/function/table/arrow.cpp +2 -2
  107. package/src/duckdb/src/function/table/checkpoint.cpp +3 -0
  108. package/src/duckdb/src/function/table/read_csv.cpp +15 -17
  109. package/src/duckdb/src/function/table/repeat.cpp +3 -0
  110. package/src/duckdb/src/function/table/repeat_row.cpp +8 -1
  111. package/src/duckdb/src/function/table/system/pragma_storage_info.cpp +4 -4
  112. package/src/duckdb/src/function/table/system/test_vector_types.cpp +81 -25
  113. package/src/duckdb/src/function/table/table_scan.cpp +2 -2
  114. package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
  115. package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +0 -3
  116. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_table_entry.hpp +2 -0
  117. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_catalog_entry.hpp +11 -1
  118. package/src/duckdb/src/include/duckdb/catalog/catalog_search_path.hpp +8 -2
  119. package/src/duckdb/src/include/duckdb/catalog/default/builtin_types/types.hpp +97 -0
  120. package/src/duckdb/src/include/duckdb/common/arrow/arrow_appender.hpp +1 -1
  121. package/src/duckdb/src/include/duckdb/common/arrow/arrow_converter.hpp +2 -3
  122. package/src/duckdb/src/include/duckdb/common/arrow/arrow_options.hpp +8 -1
  123. package/src/duckdb/src/include/duckdb/common/arrow/result_arrow_wrapper.hpp +0 -1
  124. package/src/duckdb/src/include/duckdb/common/bit_utils.hpp +16 -22
  125. package/src/duckdb/src/include/duckdb/common/exception.hpp +3 -0
  126. package/src/duckdb/src/include/duckdb/common/types/time.hpp +2 -0
  127. package/src/duckdb/src/include/duckdb/common/types/timestamp.hpp +4 -14
  128. package/src/duckdb/src/include/duckdb/common/vector_operations/aggregate_executor.hpp +92 -57
  129. package/src/duckdb/src/include/duckdb/core_functions/aggregate/algebraic/corr.hpp +20 -24
  130. package/src/duckdb/src/include/duckdb/core_functions/aggregate/algebraic/covar.hpp +36 -39
  131. package/src/duckdb/src/include/duckdb/core_functions/aggregate/algebraic/stddev.hpp +57 -53
  132. package/src/duckdb/src/include/duckdb/core_functions/aggregate/regression/regr_count.hpp +8 -9
  133. package/src/duckdb/src/include/duckdb/core_functions/aggregate/regression/regr_slope.hpp +16 -18
  134. package/src/duckdb/src/include/duckdb/core_functions/aggregate/sum_helpers.hpp +7 -8
  135. package/src/duckdb/src/include/duckdb/core_functions/scalar/generic_functions.hpp +9 -0
  136. package/src/duckdb/src/include/duckdb/core_functions/scalar/map_functions.hpp +2 -6
  137. package/src/duckdb/src/include/duckdb/core_functions/scalar/string_functions.hpp +16 -36
  138. package/src/duckdb/src/include/duckdb/execution/index/art/art.hpp +10 -4
  139. package/src/duckdb/src/include/duckdb/execution/index/art/fixed_size_allocator.hpp +3 -0
  140. package/src/duckdb/src/include/duckdb/execution/index/art/leaf.hpp +1 -1
  141. package/src/duckdb/src/include/duckdb/execution/index/art/leaf_segment.hpp +2 -0
  142. package/src/duckdb/src/include/duckdb/execution/index/art/node.hpp +13 -3
  143. package/src/duckdb/src/include/duckdb/execution/index/art/node48.hpp +1 -0
  144. package/src/duckdb/src/include/duckdb/function/aggregate_function.hpp +9 -30
  145. package/src/duckdb/src/include/duckdb/function/aggregate_state.hpp +95 -0
  146. package/src/duckdb/src/include/duckdb/function/function_serialization.hpp +4 -2
  147. package/src/duckdb/src/include/duckdb/function/scalar/nested_functions.hpp +1 -1
  148. package/src/duckdb/src/include/duckdb/function/scalar_function.hpp +2 -1
  149. package/src/duckdb/src/include/duckdb/function/table_function.hpp +3 -2
  150. package/src/duckdb/src/include/duckdb/main/attached_database.hpp +4 -1
  151. package/src/duckdb/src/include/duckdb/main/capi/capi_internal.hpp +3 -1
  152. package/src/duckdb/src/include/duckdb/main/config.hpp +5 -0
  153. package/src/duckdb/src/include/duckdb/main/database_manager.hpp +1 -0
  154. package/src/duckdb/src/include/duckdb/main/extension_entries.hpp +142 -136
  155. package/src/duckdb/src/include/duckdb/main/query_result.hpp +6 -0
  156. package/src/duckdb/src/include/duckdb/main/settings.hpp +19 -0
  157. package/src/duckdb/src/include/duckdb/optimizer/unnest_rewriter.hpp +4 -0
  158. package/src/duckdb/src/include/duckdb/parallel/meta_pipeline.hpp +12 -3
  159. package/src/duckdb/src/include/duckdb/parser/parser.hpp +2 -0
  160. package/src/duckdb/src/include/duckdb/parser/tableref/emptytableref.hpp +1 -1
  161. package/src/duckdb/src/include/duckdb/parser/tableref/pivotref.hpp +2 -2
  162. package/src/duckdb/src/include/duckdb/parser/transformer.hpp +0 -2
  163. package/src/duckdb/src/include/duckdb/planner/bind_context.hpp +1 -1
  164. package/src/duckdb/src/include/duckdb/planner/bound_result_modifier.hpp +3 -0
  165. package/src/duckdb/src/include/duckdb/planner/expression_binder.hpp +1 -1
  166. package/src/duckdb/src/include/duckdb/planner/logical_operator.hpp +5 -0
  167. package/src/duckdb/src/include/duckdb/planner/operator/logical_copy_to_file.hpp +6 -2
  168. package/src/duckdb/src/include/duckdb/planner/operator/logical_execute.hpp +4 -0
  169. package/src/duckdb/src/include/duckdb/planner/operator/logical_explain.hpp +5 -1
  170. package/src/duckdb/src/include/duckdb/planner/operator/logical_get.hpp +5 -1
  171. package/src/duckdb/src/include/duckdb/planner/operator/logical_pragma.hpp +6 -2
  172. package/src/duckdb/src/include/duckdb/planner/operator/logical_prepare.hpp +4 -0
  173. package/src/duckdb/src/include/duckdb/storage/compression/chimp/algorithm/byte_reader.hpp +4 -0
  174. package/src/duckdb/src/include/duckdb/storage/data_table.hpp +1 -1
  175. package/src/duckdb/src/include/duckdb/storage/in_memory_block_manager.hpp +13 -13
  176. package/src/duckdb/src/include/duckdb/storage/index.hpp +4 -2
  177. package/src/duckdb/src/include/duckdb/storage/storage_extension.hpp +0 -6
  178. package/src/duckdb/src/include/duckdb/storage/table/column_data.hpp +1 -1
  179. package/src/duckdb/src/include/duckdb/storage/table/list_column_data.hpp +2 -1
  180. package/src/duckdb/src/include/duckdb/storage/table/row_group.hpp +2 -2
  181. package/src/duckdb/src/include/duckdb/storage/table/row_group_collection.hpp +2 -1
  182. package/src/duckdb/src/include/duckdb/storage/table/standard_column_data.hpp +2 -1
  183. package/src/duckdb/src/include/duckdb/storage/table/struct_column_data.hpp +2 -1
  184. package/src/duckdb/src/include/duckdb/storage/table_storage_info.hpp +0 -2
  185. package/src/duckdb/src/main/attached_database.cpp +8 -0
  186. package/src/duckdb/src/main/capi/arrow-c.cpp +4 -4
  187. package/src/duckdb/src/main/capi/config-c.cpp +2 -5
  188. package/src/duckdb/src/main/client_context.cpp +4 -3
  189. package/src/duckdb/src/main/config.cpp +2 -0
  190. package/src/duckdb/src/main/database.cpp +1 -0
  191. package/src/duckdb/src/main/database_manager.cpp +21 -0
  192. package/src/duckdb/src/main/query_result.cpp +6 -2
  193. package/src/duckdb/src/main/settings/settings.cpp +41 -6
  194. package/src/duckdb/src/optimizer/unnest_rewriter.cpp +27 -16
  195. package/src/duckdb/src/parallel/executor.cpp +38 -14
  196. package/src/duckdb/src/parallel/meta_pipeline.cpp +17 -3
  197. package/src/duckdb/src/parser/column_definition.cpp +5 -8
  198. package/src/duckdb/src/parser/parsed_data/create_info.cpp +0 -3
  199. package/src/duckdb/src/parser/parser.cpp +95 -35
  200. package/src/duckdb/src/parser/transform/expression/transform_function.cpp +1 -0
  201. package/src/duckdb/src/parser/transform/expression/transform_operator.cpp +3 -0
  202. package/src/duckdb/src/parser/transform/helpers/nodetype_to_string.cpp +0 -2
  203. package/src/duckdb/src/parser/transform/statement/transform_drop.cpp +0 -3
  204. package/src/duckdb/src/parser/transform/tableref/transform_pivot.cpp +3 -0
  205. package/src/duckdb/src/parser/transformer.cpp +0 -2
  206. package/src/duckdb/src/planner/bind_context.cpp +3 -4
  207. package/src/duckdb/src/planner/binder/expression/bind_function_expression.cpp +0 -2
  208. package/src/duckdb/src/planner/binder/expression/bind_positional_reference_expression.cpp +8 -3
  209. package/src/duckdb/src/planner/binder/query_node/bind_select_node.cpp +31 -15
  210. package/src/duckdb/src/planner/binder/statement/bind_create.cpp +0 -27
  211. package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +18 -1
  212. package/src/duckdb/src/planner/binder/statement/bind_drop.cpp +0 -25
  213. package/src/duckdb/src/planner/binder/statement/bind_update.cpp +2 -114
  214. package/src/duckdb/src/planner/binder/tableref/bind_pivot.cpp +6 -1
  215. package/src/duckdb/src/planner/binder/tableref/bind_table_function.cpp +5 -0
  216. package/src/duckdb/src/planner/bound_result_modifier.cpp +14 -0
  217. package/src/duckdb/src/planner/expression/bound_aggregate_expression.cpp +6 -5
  218. package/src/duckdb/src/planner/expression/bound_default_expression.cpp +7 -1
  219. package/src/duckdb/src/planner/expression.cpp +3 -0
  220. package/src/duckdb/src/planner/expression_binder.cpp +3 -2
  221. package/src/duckdb/src/planner/operator/logical_distinct.cpp +5 -4
  222. package/src/duckdb/src/planner/operator/logical_pivot.cpp +14 -2
  223. package/src/duckdb/src/planner/planner.cpp +5 -15
  224. package/src/duckdb/src/storage/data_table.cpp +10 -8
  225. package/src/duckdb/src/storage/index.cpp +13 -0
  226. package/src/duckdb/src/storage/storage_manager.cpp +6 -0
  227. package/src/duckdb/src/storage/table/column_data.cpp +7 -3
  228. package/src/duckdb/src/storage/table/list_column_data.cpp +5 -4
  229. package/src/duckdb/src/storage/table/row_group.cpp +4 -3
  230. package/src/duckdb/src/storage/table/row_group_collection.cpp +6 -3
  231. package/src/duckdb/src/storage/table/standard_column_data.cpp +4 -3
  232. package/src/duckdb/src/storage/table/struct_column_data.cpp +4 -3
  233. package/src/duckdb/src/storage/wal_replay.cpp +4 -5
  234. package/src/duckdb/third_party/libpg_query/include/nodes/nodes.hpp +0 -1
  235. package/src/duckdb/third_party/libpg_query/include/nodes/parsenodes.hpp +0 -14
  236. package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +12828 -12956
  237. package/src/duckdb/third_party/zstd/compress/zstd_compress.cpp +3 -0
  238. package/src/duckdb/third_party/zstd/include/zstd/compress/zstd_cwksp.h +4 -0
  239. package/src/duckdb/ub_extension_icu_third_party_icu_i18n.cpp +5 -5
  240. package/src/duckdb/ub_src_parser_transform_statement.cpp +0 -2
  241. package/test/extension.test.ts +11 -0
  242. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_database_info.hpp +0 -46
  243. package/src/duckdb/src/parser/transform/statement/transform_create_database.cpp +0 -27
@@ -7,30 +7,30 @@ namespace duckdb {
7
7
 
8
8
  struct BaseCountFunction {
9
9
  template <class STATE>
10
- static void Initialize(STATE *state) {
11
- *state = 0;
10
+ static void Initialize(STATE &state) {
11
+ state = 0;
12
12
  }
13
13
 
14
14
  template <class STATE, class OP>
15
- static void Combine(const STATE &source, STATE *target, AggregateInputData &) {
16
- *target += source;
15
+ static void Combine(const STATE &source, STATE &target, AggregateInputData &) {
16
+ target += source;
17
17
  }
18
18
 
19
19
  template <class T, class STATE>
20
- static void Finalize(Vector &result, AggregateInputData &, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
21
- target[idx] = *state;
20
+ static void Finalize(STATE &state, T &target, AggregateFinalizeData &finalize_data) {
21
+ target = state;
22
22
  }
23
23
  };
24
24
 
25
25
  struct CountStarFunction : public BaseCountFunction {
26
26
  template <class STATE, class OP>
27
- static void Operation(STATE *state, AggregateInputData &, idx_t idx) {
28
- *state += 1;
27
+ static void Operation(STATE &state, AggregateInputData &, idx_t idx) {
28
+ state += 1;
29
29
  }
30
30
 
31
31
  template <class STATE, class OP>
32
- static void ConstantOperation(STATE *state, AggregateInputData &, idx_t count) {
33
- *state += count;
32
+ static void ConstantOperation(STATE &state, AggregateInputData &, idx_t count) {
33
+ state += count;
34
34
  }
35
35
 
36
36
  template <typename RESULT_TYPE>
@@ -55,27 +55,165 @@ struct CountStarFunction : public BaseCountFunction {
55
55
  };
56
56
 
57
57
  struct CountFunction : public BaseCountFunction {
58
- template <class INPUT_TYPE, class STATE, class OP>
59
- static void Operation(STATE *state, AggregateInputData &, const INPUT_TYPE *input, ValidityMask &mask, idx_t idx) {
60
- *state += 1;
58
+ using STATE = int64_t;
59
+
60
+ static void Operation(STATE &state) {
61
+ state += 1;
61
62
  }
62
63
 
63
- template <class INPUT_TYPE, class STATE, class OP>
64
- static void ConstantOperation(STATE *state, AggregateInputData &, const INPUT_TYPE *input, ValidityMask &mask,
65
- idx_t count) {
66
- *state += count;
64
+ static void ConstantOperation(STATE &state, idx_t count) {
65
+ state += count;
67
66
  }
68
67
 
69
68
  static bool IgnoreNull() {
70
69
  return true;
71
70
  }
71
+
72
+ static inline void CountFlatLoop(STATE **__restrict states, ValidityMask &mask, idx_t count) {
73
+ if (!mask.AllValid()) {
74
+ idx_t base_idx = 0;
75
+ auto entry_count = ValidityMask::EntryCount(count);
76
+ for (idx_t entry_idx = 0; entry_idx < entry_count; entry_idx++) {
77
+ auto validity_entry = mask.GetValidityEntry(entry_idx);
78
+ idx_t next = MinValue<idx_t>(base_idx + ValidityMask::BITS_PER_VALUE, count);
79
+ if (ValidityMask::AllValid(validity_entry)) {
80
+ // all valid: perform operation
81
+ for (; base_idx < next; base_idx++) {
82
+ CountFunction::Operation(*states[base_idx]);
83
+ }
84
+ } else if (ValidityMask::NoneValid(validity_entry)) {
85
+ // nothing valid: skip all
86
+ base_idx = next;
87
+ continue;
88
+ } else {
89
+ // partially valid: need to check individual elements for validity
90
+ idx_t start = base_idx;
91
+ for (; base_idx < next; base_idx++) {
92
+ if (ValidityMask::RowIsValid(validity_entry, base_idx - start)) {
93
+ CountFunction::Operation(*states[base_idx]);
94
+ }
95
+ }
96
+ }
97
+ }
98
+ } else {
99
+ for (idx_t i = 0; i < count; i++) {
100
+ CountFunction::Operation(*states[i]);
101
+ }
102
+ }
103
+ }
104
+
105
+ static inline void CountScatterLoop(STATE **__restrict states, const SelectionVector &isel,
106
+ const SelectionVector &ssel, ValidityMask &mask, idx_t count) {
107
+ if (!mask.AllValid()) {
108
+ // potential NULL values
109
+ for (idx_t i = 0; i < count; i++) {
110
+ auto idx = isel.get_index(i);
111
+ auto sidx = ssel.get_index(i);
112
+ if (mask.RowIsValid(idx)) {
113
+ CountFunction::Operation(*states[sidx]);
114
+ }
115
+ }
116
+ } else {
117
+ // quick path: no NULL values
118
+ for (idx_t i = 0; i < count; i++) {
119
+ auto sidx = ssel.get_index(i);
120
+ CountFunction::Operation(*states[sidx]);
121
+ }
122
+ }
123
+ }
124
+
125
+ static void CountScatter(Vector inputs[], AggregateInputData &aggr_input_data, idx_t input_count, Vector &states,
126
+ idx_t count) {
127
+ auto &input = inputs[0];
128
+ if (input.GetVectorType() == VectorType::FLAT_VECTOR && states.GetVectorType() == VectorType::FLAT_VECTOR) {
129
+ auto sdata = FlatVector::GetData<STATE *>(states);
130
+ CountFlatLoop(sdata, FlatVector::Validity(input), count);
131
+ } else {
132
+ UnifiedVectorFormat idata, sdata;
133
+ input.ToUnifiedFormat(count, idata);
134
+ states.ToUnifiedFormat(count, sdata);
135
+ CountScatterLoop(reinterpret_cast<STATE **>(sdata.data), *idata.sel, *sdata.sel, idata.validity, count);
136
+ }
137
+ }
138
+
139
+ static inline void CountFlatUpdateLoop(STATE &result, ValidityMask &mask, idx_t count) {
140
+ idx_t base_idx = 0;
141
+ auto entry_count = ValidityMask::EntryCount(count);
142
+ for (idx_t entry_idx = 0; entry_idx < entry_count; entry_idx++) {
143
+ auto validity_entry = mask.GetValidityEntry(entry_idx);
144
+ idx_t next = MinValue<idx_t>(base_idx + ValidityMask::BITS_PER_VALUE, count);
145
+ if (ValidityMask::AllValid(validity_entry)) {
146
+ // all valid
147
+ result += next - base_idx;
148
+ base_idx = next;
149
+ } else if (ValidityMask::NoneValid(validity_entry)) {
150
+ // nothing valid: skip all
151
+ base_idx = next;
152
+ continue;
153
+ } else {
154
+ // partially valid: need to check individual elements for validity
155
+ idx_t start = base_idx;
156
+ for (; base_idx < next; base_idx++) {
157
+ if (ValidityMask::RowIsValid(validity_entry, base_idx - start)) {
158
+ result++;
159
+ }
160
+ }
161
+ }
162
+ }
163
+ }
164
+
165
+ static inline void CountUpdateLoop(STATE &result, ValidityMask &mask, idx_t count,
166
+ const SelectionVector &sel_vector) {
167
+ if (mask.AllValid()) {
168
+ // no NULL values
169
+ result += count;
170
+ return;
171
+ }
172
+ for (idx_t i = 0; i < count; i++) {
173
+ auto idx = sel_vector.get_index(i);
174
+ if (mask.RowIsValid(idx)) {
175
+ result++;
176
+ }
177
+ }
178
+ }
179
+
180
+ static void CountUpdate(Vector inputs[], AggregateInputData &, idx_t input_count, data_ptr_t state_p, idx_t count) {
181
+ auto &input = inputs[0];
182
+ auto &result = *reinterpret_cast<STATE *>(state_p);
183
+ switch (input.GetVectorType()) {
184
+ case VectorType::CONSTANT_VECTOR: {
185
+ if (!ConstantVector::IsNull(input)) {
186
+ // if the constant is not null increment the state
187
+ result += count;
188
+ }
189
+ break;
190
+ }
191
+ case VectorType::FLAT_VECTOR: {
192
+ CountFlatUpdateLoop(result, FlatVector::Validity(input), count);
193
+ break;
194
+ }
195
+ case VectorType::SEQUENCE_VECTOR: {
196
+ // sequence vectors cannot have NULL values
197
+ result += count;
198
+ break;
199
+ }
200
+ default: {
201
+ UnifiedVectorFormat idata;
202
+ input.ToUnifiedFormat(count, idata);
203
+ CountUpdateLoop(result, idata.validity, count, *idata.sel);
204
+ break;
205
+ }
206
+ }
207
+ }
72
208
  };
73
209
 
74
210
  AggregateFunction CountFun::GetFunction() {
75
- auto fun = AggregateFunction::UnaryAggregate<int64_t, int64_t, int64_t, CountFunction>(
76
- LogicalType(LogicalTypeId::ANY), LogicalType::BIGINT);
211
+ AggregateFunction fun({LogicalType(LogicalTypeId::ANY)}, LogicalType::BIGINT, AggregateFunction::StateSize<int64_t>,
212
+ AggregateFunction::StateInitialize<int64_t, CountFunction>, CountFunction::CountScatter,
213
+ AggregateFunction::StateCombine<int64_t, CountFunction>,
214
+ AggregateFunction::StateFinalize<int64_t, int64_t, CountFunction>,
215
+ FunctionNullHandling::SPECIAL_HANDLING, CountFunction::CountUpdate);
77
216
  fun.name = "count";
78
- fun.null_handling = FunctionNullHandling::SPECIAL_HANDLING;
79
217
  fun.order_dependent = AggregateOrderDependent::NOT_ORDER_DEPENDENT;
80
218
  return fun;
81
219
  }
@@ -83,7 +221,7 @@ AggregateFunction CountFun::GetFunction() {
83
221
  static void CountStarSerialize(FieldWriter &writer, const FunctionData *bind_data, const AggregateFunction &function) {
84
222
  }
85
223
 
86
- static unique_ptr<FunctionData> CountStarDeserialize(ClientContext &context, FieldReader &reader,
224
+ static unique_ptr<FunctionData> CountStarDeserialize(PlanDeserializationState &state, FieldReader &reader,
87
225
  AggregateFunction &function) {
88
226
  return nullptr;
89
227
  }
@@ -14,9 +14,9 @@ struct FirstState {
14
14
 
15
15
  struct FirstFunctionBase {
16
16
  template <class STATE>
17
- static void Initialize(STATE *state) {
18
- state->is_set = false;
19
- state->is_null = false;
17
+ static void Initialize(STATE &state) {
18
+ state.is_set = false;
19
+ state.is_null = false;
20
20
  }
21
21
 
22
22
  static bool IgnoreNull() {
@@ -27,40 +27,40 @@ struct FirstFunctionBase {
27
27
  template <bool LAST, bool SKIP_NULLS>
28
28
  struct FirstFunction : public FirstFunctionBase {
29
29
  template <class INPUT_TYPE, class STATE, class OP>
30
- static void Operation(STATE *state, AggregateInputData &, const INPUT_TYPE *input, ValidityMask &mask, idx_t idx) {
31
- if (LAST || !state->is_set) {
32
- if (!mask.RowIsValid(idx)) {
30
+ static void Operation(STATE &state, const INPUT_TYPE &input, AggregateUnaryInput &unary_input) {
31
+ if (LAST || !state.is_set) {
32
+ if (!unary_input.RowIsValid()) {
33
33
  if (!SKIP_NULLS) {
34
- state->is_set = true;
34
+ state.is_set = true;
35
35
  }
36
- state->is_null = true;
36
+ state.is_null = true;
37
37
  } else {
38
- state->is_set = true;
39
- state->is_null = false;
40
- state->value = input[idx];
38
+ state.is_set = true;
39
+ state.is_null = false;
40
+ state.value = input;
41
41
  }
42
42
  }
43
43
  }
44
44
 
45
45
  template <class INPUT_TYPE, class STATE, class OP>
46
- static void ConstantOperation(STATE *state, AggregateInputData &aggr_input_data, const INPUT_TYPE *input,
47
- ValidityMask &mask, idx_t count) {
48
- Operation<INPUT_TYPE, STATE, OP>(state, aggr_input_data, input, mask, 0);
46
+ static void ConstantOperation(STATE &state, const INPUT_TYPE &input, AggregateUnaryInput &unary_input,
47
+ idx_t count) {
48
+ Operation<INPUT_TYPE, STATE, OP>(state, input, unary_input);
49
49
  }
50
50
 
51
51
  template <class STATE, class OP>
52
- static void Combine(const STATE &source, STATE *target, AggregateInputData &) {
53
- if (!target->is_set) {
54
- *target = source;
52
+ static void Combine(const STATE &source, STATE &target, AggregateInputData &) {
53
+ if (!target.is_set) {
54
+ target = source;
55
55
  }
56
56
  }
57
57
 
58
58
  template <class T, class STATE>
59
- static void Finalize(Vector &result, AggregateInputData &, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
60
- if (!state->is_set || state->is_null) {
61
- mask.SetInvalid(idx);
59
+ static void Finalize(STATE &state, T &target, AggregateFinalizeData &finalize_data) {
60
+ if (!state.is_set || state.is_null) {
61
+ finalize_data.ReturnNull();
62
62
  } else {
63
- target[idx] = state->value;
63
+ target = state.value;
64
64
  }
65
65
  }
66
66
  };
@@ -68,65 +68,64 @@ struct FirstFunction : public FirstFunctionBase {
68
68
  template <bool LAST, bool SKIP_NULLS>
69
69
  struct FirstFunctionString : public FirstFunctionBase {
70
70
  template <class STATE>
71
- static void SetValue(STATE *state, AggregateInputData &input_data, string_t value, bool is_null) {
72
- if (LAST && state->is_set) {
73
- Destroy(input_data, state);
71
+ static void SetValue(STATE &state, AggregateInputData &input_data, string_t value, bool is_null) {
72
+ if (LAST && state.is_set) {
73
+ Destroy(state, input_data);
74
74
  }
75
75
  if (is_null) {
76
76
  if (!SKIP_NULLS) {
77
- state->is_set = true;
78
- state->is_null = true;
77
+ state.is_set = true;
78
+ state.is_null = true;
79
79
  }
80
80
  } else {
81
- state->is_set = true;
82
- state->is_null = false;
81
+ state.is_set = true;
82
+ state.is_null = false;
83
83
  if (value.IsInlined()) {
84
- state->value = value;
84
+ state.value = value;
85
85
  } else {
86
86
  // non-inlined string, need to allocate space for it
87
87
  auto len = value.GetSize();
88
88
  auto ptr = new char[len];
89
89
  memcpy(ptr, value.GetData(), len);
90
90
 
91
- state->value = string_t(ptr, len);
91
+ state.value = string_t(ptr, len);
92
92
  }
93
93
  }
94
94
  }
95
95
 
96
96
  template <class INPUT_TYPE, class STATE, class OP>
97
- static void Operation(STATE *state, AggregateInputData &input_data, const INPUT_TYPE *input, ValidityMask &mask,
98
- idx_t idx) {
99
- if (LAST || !state->is_set) {
100
- SetValue(state, input_data, input[idx], !mask.RowIsValid(idx));
97
+ static void Operation(STATE &state, const INPUT_TYPE &input, AggregateUnaryInput &unary_input) {
98
+ if (LAST || !state.is_set) {
99
+ SetValue(state, unary_input.input, input, !unary_input.RowIsValid());
101
100
  }
102
101
  }
103
102
 
104
103
  template <class INPUT_TYPE, class STATE, class OP>
105
- static void ConstantOperation(STATE *state, AggregateInputData &aggr_input_data, const INPUT_TYPE *input,
106
- ValidityMask &mask, idx_t count) {
107
- Operation<INPUT_TYPE, STATE, OP>(state, aggr_input_data, input, mask, 0);
104
+ static void ConstantOperation(STATE &state, const INPUT_TYPE &input, AggregateUnaryInput &unary_input,
105
+ idx_t count) {
106
+ Operation<INPUT_TYPE, STATE, OP>(state, input, unary_input);
108
107
  }
109
108
 
110
109
  template <class STATE, class OP>
111
- static void Combine(const STATE &source, STATE *target, AggregateInputData &input_data) {
112
- if (source.is_set && (LAST || !target->is_set)) {
110
+ static void Combine(const STATE &source, STATE &target, AggregateInputData &input_data) {
111
+ if (source.is_set && (LAST || !target.is_set)) {
113
112
  SetValue(target, input_data, source.value, source.is_null);
114
113
  }
115
114
  }
116
115
 
117
116
  template <class T, class STATE>
118
- static void Finalize(Vector &result, AggregateInputData &, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
119
- if (!state->is_set || state->is_null) {
120
- mask.SetInvalid(idx);
117
+ static void Finalize(STATE &state, T &target, AggregateFinalizeData &finalize_data) {
118
+ if (!state.is_set || state.is_null) {
119
+ finalize_data.ReturnNull();
121
120
  } else {
122
- target[idx] = StringVector::AddStringOrBlob(result, state->value);
121
+ target = StringVector::AddStringOrBlob(finalize_data.result, state.value);
123
122
  }
124
123
  }
125
124
 
126
125
  template <class STATE>
127
- static void Destroy(AggregateInputData &aggr_input_data, STATE *state) {
128
- if (state->is_set && !state->is_null && !state->value.IsInlined()) {
129
- delete[] state->value.GetData();
126
+ static void Destroy(STATE &state, AggregateInputData &aggr_input_data) {
127
+ if (state.is_set && !state.is_null && !state.value.IsInlined()) {
128
+ delete[] state.value.GetData();
130
129
  }
131
130
  }
132
131
  };
@@ -138,14 +137,14 @@ struct FirstStateVector {
138
137
  template <bool LAST, bool SKIP_NULLS>
139
138
  struct FirstVectorFunction {
140
139
  template <class STATE>
141
- static void Initialize(STATE *state) {
142
- state->value = nullptr;
140
+ static void Initialize(STATE &state) {
141
+ state.value = nullptr;
143
142
  }
144
143
 
145
144
  template <class STATE>
146
- static void Destroy(AggregateInputData &aggr_input_data, STATE *state) {
147
- if (state->value) {
148
- delete state->value;
145
+ static void Destroy(STATE &state, AggregateInputData &aggr_input_data) {
146
+ if (state.value) {
147
+ delete state.value;
149
148
  }
150
149
  }
151
150
  static bool IgnoreNull() {
@@ -153,14 +152,14 @@ struct FirstVectorFunction {
153
152
  }
154
153
 
155
154
  template <class STATE>
156
- static void SetValue(STATE *state, Vector &input, const idx_t idx) {
157
- if (!state->value) {
158
- state->value = new Vector(input.GetType());
159
- state->value->SetVectorType(VectorType::CONSTANT_VECTOR);
155
+ static void SetValue(STATE &state, Vector &input, const idx_t idx) {
156
+ if (!state.value) {
157
+ state.value = new Vector(input.GetType());
158
+ state.value->SetVectorType(VectorType::CONSTANT_VECTOR);
160
159
  }
161
160
  sel_t selv = idx;
162
161
  SelectionVector sel(&selv);
163
- VectorOperations::Copy(input, *state->value, sel, 1, 0, 0);
162
+ VectorOperations::Copy(input, *state.value, sel, 1, 0, 0);
164
163
  }
165
164
 
166
165
  static void Update(Vector inputs[], AggregateInputData &, idx_t input_count, Vector &state_vector, idx_t count) {
@@ -177,33 +176,26 @@ struct FirstVectorFunction {
177
176
  if (SKIP_NULLS && !idata.validity.RowIsValid(idx)) {
178
177
  continue;
179
178
  }
180
- auto state = states[sdata.sel->get_index(i)];
181
- if (LAST || !state->value) {
179
+ auto &state = *states[sdata.sel->get_index(i)];
180
+ if (LAST || !state.value) {
182
181
  SetValue(state, input, i);
183
182
  }
184
183
  }
185
184
  }
186
185
 
187
186
  template <class STATE, class OP>
188
- static void Combine(const STATE &source, STATE *target, AggregateInputData &) {
189
- if (source.value && (LAST || !target->value)) {
187
+ static void Combine(const STATE &source, STATE &target, AggregateInputData &) {
188
+ if (source.value && (LAST || !target.value)) {
190
189
  SetValue(target, *source.value, 0);
191
190
  }
192
191
  }
193
192
 
194
- template <class T, class STATE>
195
- static void Finalize(Vector &result, AggregateInputData &, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
196
- if (!state->value) {
197
- // we need to use FlatVector::SetNull here
198
- // since for STRUCT columns only setting the validity mask of the struct is incorrect
199
- // as for a struct column, we need to also set ALL child columns to NULL
200
- if (result.GetVectorType() == VectorType::CONSTANT_VECTOR) {
201
- ConstantVector::SetNull(result, true);
202
- } else {
203
- FlatVector::SetNull(result, idx, true);
204
- }
193
+ template <class STATE>
194
+ static void Finalize(STATE &state, AggregateFinalizeData &finalize_data) {
195
+ if (!state.value) {
196
+ finalize_data.ReturnNull();
205
197
  } else {
206
- VectorOperations::Copy(*state->value, result, 1, 0, idx);
198
+ VectorOperations::Copy(*state.value, finalize_data.result, 1, 0, finalize_data.result_idx);
207
199
  }
208
200
  }
209
201
 
@@ -289,7 +281,7 @@ static AggregateFunction GetFirstFunction(const LogicalType &type) {
289
281
  return AggregateFunction({type}, type, AggregateFunction::StateSize<FirstStateVector>,
290
282
  AggregateFunction::StateInitialize<FirstStateVector, OP>, OP::Update,
291
283
  AggregateFunction::StateCombine<FirstStateVector, OP>,
292
- AggregateFunction::StateFinalize<FirstStateVector, void, OP>, nullptr, OP::Bind,
284
+ AggregateFunction::StateVoidFinalize<FirstStateVector, OP>, nullptr, OP::Bind,
293
285
  AggregateFunction::StateDestroy<FirstStateVector, OP>, nullptr, nullptr);
294
286
  }
295
287
  }
@@ -305,8 +297,9 @@ template <bool LAST, bool SKIP_NULLS>
305
297
  unique_ptr<FunctionData> BindDecimalFirst(ClientContext &context, AggregateFunction &function,
306
298
  vector<unique_ptr<Expression>> &arguments) {
307
299
  auto decimal_type = arguments[0]->return_type;
300
+ auto name = std::move(function.name);
308
301
  function = GetFirstFunction<LAST, SKIP_NULLS>(decimal_type);
309
- function.name = "first";
302
+ function.name = std::move(name);
310
303
  function.return_type = decimal_type;
311
304
  return nullptr;
312
305
  }
@@ -253,13 +253,13 @@ struct SortedAggregateState {
253
253
 
254
254
  struct SortedAggregateFunction {
255
255
  template <typename STATE>
256
- static void Initialize(STATE *state) {
257
- new (state) STATE();
256
+ static void Initialize(STATE &state) {
257
+ new (&state) STATE();
258
258
  }
259
259
 
260
260
  template <typename STATE>
261
- static void Destroy(AggregateInputData &aggr_input_data, STATE *state) {
262
- state->~STATE();
261
+ static void Destroy(STATE &state, AggregateInputData &aggr_input_data) {
262
+ state.~STATE();
263
263
  }
264
264
 
265
265
  static void ProjectInputs(Vector inputs[], const SortedAggregateBindData &order_bind, idx_t input_count,
@@ -345,10 +345,10 @@ struct SortedAggregateFunction {
345
345
  }
346
346
 
347
347
  template <class STATE, class OP>
348
- static void Combine(const STATE &source, STATE *target, AggregateInputData &aggr_input_data) {
348
+ static void Combine(const STATE &source, STATE &target, AggregateInputData &aggr_input_data) {
349
349
  auto &order_bind = aggr_input_data.bind_data->Cast<SortedAggregateBindData>();
350
350
  auto &other = const_cast<STATE &>(source);
351
- target->Combine(order_bind, other);
351
+ target.Combine(order_bind, other);
352
352
  }
353
353
 
354
354
  static void Window(Vector inputs[], const ValidityMask &filter_mask, AggregateInputData &aggr_input_data,
@@ -519,7 +519,7 @@ struct SortedAggregateFunction {
519
519
  static void Serialize(FieldWriter &writer, const FunctionData *bind_data, const AggregateFunction &function) {
520
520
  throw NotImplementedException("FIXME: serialize sorted aggregate not supported");
521
521
  }
522
- static unique_ptr<FunctionData> Deserialize(ClientContext &context, FieldReader &reader,
522
+ static unique_ptr<FunctionData> Deserialize(PlanDeserializationState &state, FieldReader &reader,
523
523
  AggregateFunction &function) {
524
524
  throw NotImplementedException("FIXME: deserialize sorted aggregate not supported");
525
525
  }
@@ -51,12 +51,10 @@ bool ListCast::ListToListCast(Vector &source, Vector &result, idx_t count, CastP
51
51
  auto &append_vector = ListVector::GetEntry(result);
52
52
 
53
53
  CastParameters child_parameters(parameters, cast_data.child_cast_info.cast_data, parameters.local_state);
54
- if (!cast_data.child_cast_info.function(source_cc, append_vector, source_size, child_parameters)) {
55
- return false;
56
- }
54
+ bool all_succeeded = cast_data.child_cast_info.function(source_cc, append_vector, source_size, child_parameters);
57
55
  ListVector::SetListSize(result, source_size);
58
56
  D_ASSERT(ListVector::GetListSize(result) == source_size);
59
- return true;
57
+ return all_succeeded;
60
58
  }
61
59
 
62
60
  static bool ListToVarcharCast(Vector &source, Vector &result, idx_t count, CastParameters &parameters) {
@@ -18,21 +18,18 @@ string PragmaTableInfo(ClientContext &context, const FunctionParameters &paramet
18
18
  }
19
19
 
20
20
  string PragmaShowTables(ClientContext &context, const FunctionParameters &parameters) {
21
- auto catalog = DatabaseManager::GetDefaultDatabase(context);
22
- auto schema = ClientData::Get(context).catalog_search_path->GetDefault().schema;
23
- schema = (schema == INVALID_SCHEMA) ? DEFAULT_SCHEMA : schema; // NOLINT
24
-
25
- auto where_clause = StringUtil::Format("where ((database_name = '%s') and (schema_name = '%s'))", catalog, schema);
26
21
  // clang-format off
27
- auto pragma_query = StringUtil::Format(R"EOF(
22
+ return R"EOF(
28
23
  with "tables" as
29
24
  (
30
25
  SELECT table_name as "name"
31
- FROM duckdb_tables %s
26
+ FROM duckdb_tables
27
+ where in_search_path(database_name, schema_name)
32
28
  ), "views" as
33
29
  (
34
30
  SELECT view_name as "name"
35
- FROM duckdb_views %s
31
+ FROM duckdb_views
32
+ where in_search_path(database_name, schema_name)
36
33
  ), db_objects as
37
34
  (
38
35
  SELECT "name" FROM "tables"
@@ -41,26 +38,39 @@ string PragmaShowTables(ClientContext &context, const FunctionParameters &parame
41
38
  )
42
39
  SELECT "name"
43
40
  FROM db_objects
44
- ORDER BY "name";)EOF", where_clause, where_clause);
41
+ ORDER BY "name";)EOF";
45
42
  // clang-format on
46
-
47
- return pragma_query;
48
43
  }
49
44
 
50
45
  string PragmaShowTablesExpanded(ClientContext &context, const FunctionParameters &parameters) {
51
46
  return R"(
52
- SELECT
53
- t.database_name AS database,
54
- t.schema_name AS schema,
55
- t.table_name,
56
- LIST(c.column_name order by c.column_index) AS column_names,
57
- LIST(c.data_type order by c.column_index) AS column_types,
58
- FIRST(t.temporary) AS temporary,
59
- FROM duckdb_tables t
60
- JOIN duckdb_columns c
61
- USING (table_oid)
62
- GROUP BY t.database_name, t.schema_name, t.table_name
63
- ORDER BY t.database_name, t.schema_name, t.table_name;
47
+ SELECT
48
+ t.database_name AS database,
49
+ t.schema_name AS schema,
50
+ t.table_name AS name,
51
+ LIST(c.column_name order by c.column_index) AS column_names,
52
+ LIST(c.data_type order by c.column_index) AS column_types,
53
+ FIRST(t.temporary) AS temporary,
54
+ FROM duckdb_tables t
55
+ JOIN duckdb_columns c
56
+ USING (table_oid)
57
+ GROUP BY database, schema, name
58
+
59
+ UNION ALL
60
+
61
+ SELECT
62
+ v.database_name AS database,
63
+ v.schema_name AS schema,
64
+ v.view_name AS name,
65
+ LIST(c.column_name order by c.column_index) AS column_names,
66
+ LIST(c.data_type order by c.column_index) AS column_types,
67
+ FIRST(v.temporary) AS temporary,
68
+ FROM duckdb_views v
69
+ JOIN duckdb_columns c
70
+ ON (v.view_oid=c.table_oid)
71
+ GROUP BY database, schema, name
72
+
73
+ ORDER BY database, schema, name
64
74
  )";
65
75
  }
66
76
 
@@ -56,7 +56,7 @@ void ListExtractTemplate(idx_t count, UnifiedVectorFormat &list_data, UnifiedVec
56
56
 
57
57
  idx_t child_offset;
58
58
  if (offsets_entry < 0) {
59
- if ((idx_t)-offsets_entry > list_entry.length) {
59
+ if (offsets_entry < -int64_t(list_entry.length)) {
60
60
  result_mask.SetInvalid(i);
61
61
  continue;
62
62
  }
@@ -257,7 +257,7 @@ static void SerializeDecimalArithmetic(FieldWriter &writer, const FunctionData *
257
257
 
258
258
  // TODO this is partially duplicated from the bind
259
259
  template <class OP, class OPOVERFLOWCHECK, bool IS_SUBTRACT = false>
260
- unique_ptr<FunctionData> DeserializeDecimalArithmetic(ClientContext &context, FieldReader &reader,
260
+ unique_ptr<FunctionData> DeserializeDecimalArithmetic(PlanDeserializationState &state, FieldReader &reader,
261
261
  ScalarFunction &bound_function) {
262
262
  // re-change the function pointers
263
263
  auto check_overflow = reader.ReadRequired<bool>();
@@ -69,9 +69,13 @@ void ParseRegexOptions(ClientContext &context, Expression &expr, RE2::Options &t
69
69
  throw InvalidInputException("Regex options field must be a constant");
70
70
  }
71
71
  Value options_str = ExpressionExecutor::EvaluateScalar(context, expr);
72
- if (!options_str.IsNull() && options_str.type().id() == LogicalTypeId::VARCHAR) {
73
- ParseRegexOptions(StringValue::Get(options_str), target, global_replace);
72
+ if (options_str.IsNull()) {
73
+ throw InvalidInputException("Regex options field must not be NULL");
74
74
  }
75
+ if (options_str.type().id() != LogicalTypeId::VARCHAR) {
76
+ throw InvalidInputException("Regex options field must be a string");
77
+ }
78
+ ParseRegexOptions(StringValue::Get(options_str), target, global_replace);
75
79
  }
76
80
 
77
81
  } // namespace regexp_util