duckdb 0.7.2-dev2740.0 → 0.7.2-dev2867.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.
- package/binding.gyp +21 -13
- package/package.json +1 -1
- package/src/duckdb/extension/icu/icu-datepart.cpp +51 -1
- package/src/duckdb/extension/icu/icu-strptime.cpp +1 -1
- package/src/duckdb/extension/json/include/json_functions.hpp +35 -37
- package/src/duckdb/extension/json/include/json_scan.hpp +1 -1
- package/src/duckdb/extension/json/include/json_transform.hpp +1 -1
- package/src/duckdb/extension/json/json-extension.cpp +10 -20
- package/src/duckdb/extension/json/json_functions/copy_json.cpp +2 -2
- package/src/duckdb/extension/json/json_functions/json_array_length.cpp +2 -3
- package/src/duckdb/extension/json/json_functions/json_contains.cpp +2 -2
- package/src/duckdb/extension/json/json_functions/json_create.cpp +20 -20
- package/src/duckdb/extension/json/json_functions/json_extract.cpp +4 -6
- package/src/duckdb/extension/json/json_functions/json_keys.cpp +2 -3
- package/src/duckdb/extension/json/json_functions/json_merge_patch.cpp +2 -2
- package/src/duckdb/extension/json/json_functions/json_serialize_sql.cpp +8 -8
- package/src/duckdb/extension/json/json_functions/json_structure.cpp +2 -2
- package/src/duckdb/extension/json/json_functions/json_transform.cpp +4 -4
- package/src/duckdb/extension/json/json_functions/json_type.cpp +2 -3
- package/src/duckdb/extension/json/json_functions/json_valid.cpp +2 -2
- package/src/duckdb/extension/json/json_functions/read_json.cpp +6 -6
- package/src/duckdb/extension/json/json_functions/read_json_objects.cpp +4 -4
- package/src/duckdb/extension/json/json_functions.cpp +6 -6
- package/src/duckdb/extension/parquet/parquet-extension.cpp +16 -28
- package/src/duckdb/src/catalog/catalog_entry/pragma_function_catalog_entry.cpp +1 -2
- package/src/duckdb/src/catalog/catalog_entry/scalar_function_catalog_entry.cpp +1 -1
- package/src/duckdb/src/catalog/catalog_entry/scalar_macro_catalog_entry.cpp +2 -2
- package/src/duckdb/src/catalog/catalog_entry/table_function_catalog_entry.cpp +1 -2
- package/src/duckdb/src/catalog/catalog_transaction.cpp +4 -0
- package/src/duckdb/src/catalog/duck_catalog.cpp +8 -1
- package/src/duckdb/src/common/enums/date_part_specifier.cpp +82 -0
- package/src/duckdb/src/common/local_file_system.cpp +1 -3
- package/src/duckdb/src/common/multi_file_reader.cpp +11 -8
- package/src/duckdb/src/common/types/vector.cpp +136 -3
- package/src/duckdb/src/{function → core_functions}/aggregate/algebraic/avg.cpp +9 -12
- package/src/duckdb/src/core_functions/aggregate/algebraic/corr.cpp +13 -0
- package/src/duckdb/src/core_functions/aggregate/algebraic/covar.cpp +21 -0
- package/src/duckdb/src/core_functions/aggregate/algebraic/stddev.cpp +34 -0
- package/src/duckdb/src/{function → core_functions}/aggregate/distributive/approx_count.cpp +3 -3
- package/src/duckdb/src/{function → core_functions}/aggregate/distributive/arg_min_max.cpp +7 -23
- package/src/duckdb/src/{function → core_functions}/aggregate/distributive/bitagg.cpp +10 -10
- package/src/duckdb/src/{function → core_functions}/aggregate/distributive/bitstring_agg.cpp +4 -4
- package/src/duckdb/src/{function → core_functions}/aggregate/distributive/bool.cpp +1 -17
- package/src/duckdb/src/{function → core_functions}/aggregate/distributive/entropy.cpp +5 -4
- package/src/duckdb/src/{function → core_functions}/aggregate/distributive/kurtosis.cpp +5 -6
- package/src/duckdb/src/{function → core_functions}/aggregate/distributive/minmax.cpp +5 -5
- package/src/duckdb/src/{function → core_functions}/aggregate/distributive/product.cpp +2 -11
- package/src/duckdb/src/{function → core_functions}/aggregate/distributive/skew.cpp +5 -6
- package/src/duckdb/src/{function → core_functions}/aggregate/distributive/string_agg.cpp +4 -6
- package/src/duckdb/src/{function → core_functions}/aggregate/distributive/sum.cpp +38 -46
- package/src/duckdb/src/{function → core_functions}/aggregate/holistic/approximate_quantile.cpp +4 -5
- package/src/duckdb/src/{function → core_functions}/aggregate/holistic/mode.cpp +4 -5
- package/src/duckdb/src/{function → core_functions}/aggregate/holistic/quantile.cpp +31 -23
- package/src/duckdb/src/{function → core_functions}/aggregate/holistic/reservoir_quantile.cpp +4 -5
- package/src/duckdb/src/{function → core_functions}/aggregate/nested/histogram.cpp +4 -4
- package/src/duckdb/src/{function → core_functions}/aggregate/nested/list.cpp +6 -10
- package/src/duckdb/src/{function → core_functions}/aggregate/regression/regr_avg.cpp +7 -11
- package/src/duckdb/src/{function → core_functions}/aggregate/regression/regr_count.cpp +4 -4
- package/src/duckdb/src/{function → core_functions}/aggregate/regression/regr_intercept.cpp +5 -8
- package/src/duckdb/src/{function → core_functions}/aggregate/regression/regr_r2.cpp +5 -7
- package/src/duckdb/src/{function → core_functions}/aggregate/regression/regr_slope.cpp +5 -7
- package/src/duckdb/src/{function → core_functions}/aggregate/regression/regr_sxx_syy.cpp +8 -12
- package/src/duckdb/src/{function → core_functions}/aggregate/regression/regr_sxy.cpp +6 -8
- package/src/duckdb/src/core_functions/core_functions.cpp +50 -0
- package/src/duckdb/src/core_functions/function_list.cpp +352 -0
- package/src/duckdb/src/{function → core_functions}/scalar/bit/bitstring.cpp +12 -15
- package/src/duckdb/src/{function → core_functions}/scalar/blob/base64.cpp +6 -6
- package/src/duckdb/src/{function → core_functions}/scalar/blob/encode.cpp +7 -6
- package/src/duckdb/src/{function → core_functions}/scalar/date/age.cpp +3 -3
- package/src/duckdb/src/{function → core_functions}/scalar/date/current.cpp +8 -8
- package/src/duckdb/src/{function → core_functions}/scalar/date/date_diff.cpp +3 -6
- package/src/duckdb/src/{function → core_functions}/scalar/date/date_part.cpp +144 -148
- package/src/duckdb/src/{function → core_functions}/scalar/date/date_sub.cpp +3 -6
- package/src/duckdb/src/{function → core_functions}/scalar/date/date_trunc.cpp +3 -6
- package/src/duckdb/src/{function → core_functions}/scalar/date/epoch.cpp +7 -8
- package/src/duckdb/src/{function → core_functions}/scalar/date/make_date.cpp +14 -14
- package/src/duckdb/src/core_functions/scalar/date/strftime.cpp +251 -0
- package/src/duckdb/src/{function → core_functions}/scalar/date/time_bucket.cpp +4 -5
- package/src/duckdb/src/{function → core_functions}/scalar/date/to_interval.cpp +39 -19
- package/src/duckdb/src/{function/scalar/enum/enum_functions_implementation.cpp → core_functions/scalar/enum/enum_functions.cpp} +18 -22
- package/src/duckdb/src/{function → core_functions}/scalar/generic/alias.cpp +4 -4
- package/src/duckdb/src/{function → core_functions}/scalar/generic/current_setting.cpp +4 -5
- package/src/duckdb/src/{function → core_functions}/scalar/generic/error.cpp +4 -4
- package/src/duckdb/src/{function → core_functions}/scalar/generic/hash.cpp +4 -4
- package/src/duckdb/src/{function → core_functions}/scalar/generic/least.cpp +8 -9
- package/src/duckdb/src/{function → core_functions}/scalar/generic/stats.cpp +4 -4
- package/src/duckdb/src/{function/scalar/system → core_functions/scalar/generic}/system_functions.cpp +24 -13
- package/src/duckdb/src/{function → core_functions}/scalar/generic/typeof.cpp +4 -4
- package/src/duckdb/src/{function → core_functions}/scalar/list/array_slice.cpp +3 -13
- package/src/duckdb/src/{function → core_functions}/scalar/list/flatten.cpp +5 -5
- package/src/duckdb/src/{function → core_functions}/scalar/list/list_aggregates.cpp +2 -13
- package/src/duckdb/src/{function → core_functions}/scalar/list/list_lambdas.cpp +9 -24
- package/src/duckdb/src/{function → core_functions}/scalar/list/list_sort.cpp +8 -22
- package/src/duckdb/src/{function → core_functions}/scalar/list/list_value.cpp +4 -5
- package/src/duckdb/src/{function → core_functions}/scalar/list/range.cpp +8 -6
- package/src/duckdb/src/{function → core_functions}/scalar/map/cardinality.cpp +5 -4
- package/src/duckdb/src/{function → core_functions}/scalar/map/map.cpp +6 -63
- package/src/duckdb/src/{function → core_functions}/scalar/map/map_entries.cpp +5 -4
- package/src/duckdb/src/{function → core_functions}/scalar/map/map_extract.cpp +22 -7
- package/src/duckdb/src/{function → core_functions}/scalar/map/map_from_entries.cpp +6 -5
- package/src/duckdb/src/{function → core_functions}/scalar/map/map_keys_values.cpp +8 -7
- package/src/duckdb/src/{function → core_functions}/scalar/math/numeric.cpp +110 -138
- package/src/duckdb/src/{function → core_functions}/scalar/operators/bitwise.cpp +19 -20
- package/src/duckdb/src/{function/scalar/math → core_functions/scalar/random}/random.cpp +5 -6
- package/src/duckdb/src/{function/scalar/math → core_functions/scalar/random}/setseed.cpp +3 -3
- package/src/duckdb/src/{function → core_functions}/scalar/string/ascii.cpp +4 -5
- package/src/duckdb/src/{function → core_functions}/scalar/string/bar.cpp +4 -4
- package/src/duckdb/src/{function → core_functions}/scalar/string/chr.cpp +5 -6
- package/src/duckdb/src/{function → core_functions}/scalar/string/damerau_levenshtein.cpp +4 -6
- package/src/duckdb/src/{function/scalar/string/mismatches.cpp → core_functions/scalar/string/hamming.cpp} +3 -12
- package/src/duckdb/src/{function → core_functions}/scalar/string/hex.cpp +15 -25
- package/src/duckdb/src/{function → core_functions}/scalar/string/instr.cpp +6 -13
- package/src/duckdb/src/{function → core_functions}/scalar/string/jaccard.cpp +3 -6
- package/src/duckdb/src/{function → core_functions}/scalar/string/jaro_winkler.cpp +7 -6
- package/src/duckdb/src/{function → core_functions}/scalar/string/left_right.cpp +18 -11
- package/src/duckdb/src/{function → core_functions}/scalar/string/levenshtein.cpp +3 -12
- package/src/duckdb/src/{function → core_functions}/scalar/string/md5.cpp +15 -21
- package/src/duckdb/src/{function → core_functions}/scalar/string/pad.cpp +7 -13
- package/src/duckdb/src/{function → core_functions}/scalar/string/printf.cpp +10 -10
- package/src/duckdb/src/{function → core_functions}/scalar/string/repeat.cpp +3 -6
- package/src/duckdb/src/{function → core_functions}/scalar/string/replace.cpp +4 -7
- package/src/duckdb/src/{function → core_functions}/scalar/string/reverse.cpp +3 -3
- package/src/duckdb/src/{function → core_functions}/scalar/string/starts_with.cpp +4 -8
- package/src/duckdb/src/{function → core_functions}/scalar/string/string_split.cpp +11 -11
- package/src/duckdb/src/{function → core_functions}/scalar/string/translate.cpp +4 -7
- package/src/duckdb/src/{function → core_functions}/scalar/string/trim.cpp +19 -14
- package/src/duckdb/src/core_functions/scalar/string/unicode.cpp +28 -0
- package/src/duckdb/src/{function → core_functions}/scalar/struct/struct_insert.cpp +4 -4
- package/src/duckdb/src/{function → core_functions}/scalar/struct/struct_pack.cpp +3 -4
- package/src/duckdb/src/{function → core_functions}/scalar/union/union_extract.cpp +4 -8
- package/src/duckdb/src/{function → core_functions}/scalar/union/union_tag.cpp +4 -8
- package/src/duckdb/src/{function → core_functions}/scalar/union/union_value.cpp +4 -59
- package/src/duckdb/src/execution/operator/persistent/base_csv_reader.cpp +1 -1
- package/src/duckdb/src/execution/operator/persistent/buffered_csv_reader.cpp +1 -1
- package/src/duckdb/src/execution/operator/persistent/parallel_csv_reader.cpp +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_create_type.cpp +11 -2
- package/src/duckdb/src/function/aggregate/distributive_functions.cpp +0 -17
- package/src/duckdb/src/function/cast/string_cast.cpp +1 -1
- package/src/duckdb/src/function/function.cpp +0 -8
- package/src/duckdb/src/function/function_set.cpp +25 -0
- package/src/duckdb/src/function/scalar/generic_functions.cpp +1 -9
- package/src/duckdb/src/function/scalar/nested_functions.cpp +0 -22
- package/src/duckdb/src/function/scalar/operators.cpp +0 -6
- package/src/duckdb/src/function/scalar/{date/strftime.cpp → strftime_format.cpp} +1 -249
- package/src/duckdb/src/function/scalar/string/length.cpp +0 -19
- package/src/duckdb/src/function/scalar/string_functions.cpp +0 -40
- package/src/duckdb/src/function/scalar/system/aggregate_export.cpp +5 -0
- package/src/duckdb/src/function/table/arrow_conversion.cpp +1 -1
- package/src/duckdb/src/function/table/read_csv.cpp +7 -4
- package/src/duckdb/src/function/table/system/duckdb_functions.cpp +27 -40
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/aggregate_function_catalog_entry.hpp +3 -3
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/function_entry.hpp +33 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/macro_catalog_entry.hpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/pragma_function_catalog_entry.hpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/scalar_function_catalog_entry.hpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_function_catalog_entry.hpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog_transaction.hpp +2 -0
- package/src/duckdb/src/include/duckdb/common/algorithm.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/multi_file_reader.hpp +5 -4
- package/src/duckdb/src/include/duckdb/common/types/vector.hpp +11 -1
- package/src/duckdb/src/include/duckdb/{function → core_functions}/aggregate/algebraic/corr.hpp +3 -4
- package/src/duckdb/src/include/duckdb/{function → core_functions}/aggregate/algebraic/covar.hpp +1 -1
- package/src/duckdb/src/include/duckdb/{function → core_functions}/aggregate/algebraic/stddev.hpp +1 -1
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/algebraic_functions.hpp +124 -0
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/distributive_functions.hpp +229 -0
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/holistic_functions.hpp +85 -0
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/nested_functions.hpp +41 -0
- package/src/duckdb/src/include/duckdb/{function → core_functions}/aggregate/regression/regr_count.hpp +3 -4
- package/src/duckdb/src/include/duckdb/{function → core_functions}/aggregate/regression/regr_slope.hpp +2 -2
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/regression_functions.hpp +97 -0
- package/src/duckdb/src/include/duckdb/{function → core_functions}/aggregate/sum_helpers.hpp +1 -1
- package/src/duckdb/src/include/duckdb/{function/scalar/uuid_functions.hpp → core_functions/core_functions.hpp} +7 -5
- package/src/duckdb/src/include/duckdb/core_functions/function_list.hpp +33 -0
- package/src/duckdb/src/include/duckdb/core_functions/scalar/bit_functions.hpp +52 -0
- package/src/duckdb/src/include/duckdb/core_functions/scalar/blob_functions.hpp +58 -0
- package/src/duckdb/src/include/duckdb/core_functions/scalar/date_functions.hpp +544 -0
- package/src/duckdb/src/include/duckdb/core_functions/scalar/enum_functions.hpp +61 -0
- package/src/duckdb/src/include/duckdb/core_functions/scalar/generic_functions.hpp +142 -0
- package/src/duckdb/src/include/duckdb/core_functions/scalar/list_functions.hpp +220 -0
- package/src/duckdb/src/include/duckdb/core_functions/scalar/map_functions.hpp +85 -0
- package/src/duckdb/src/include/duckdb/core_functions/scalar/math_functions.hpp +394 -0
- package/src/duckdb/src/include/duckdb/core_functions/scalar/operators_functions.hpp +70 -0
- package/src/duckdb/src/include/duckdb/core_functions/scalar/random_functions.hpp +49 -0
- package/src/duckdb/src/include/duckdb/core_functions/scalar/string_functions.hpp +439 -0
- package/src/duckdb/src/include/duckdb/core_functions/scalar/struct_functions.hpp +40 -0
- package/src/duckdb/src/include/duckdb/core_functions/scalar/union_functions.hpp +43 -0
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/base_csv_reader.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_reader_options.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_type.hpp +4 -0
- package/src/duckdb/src/include/duckdb/function/aggregate/distributive_functions.hpp +0 -85
- package/src/duckdb/src/include/duckdb/function/built_in_functions.hpp +0 -8
- package/src/duckdb/src/include/duckdb/function/function_set.hpp +7 -2
- package/src/duckdb/src/include/duckdb/function/scalar/generic_functions.hpp +1 -36
- package/src/duckdb/src/include/duckdb/function/scalar/nested_functions.hpp +0 -120
- package/src/duckdb/src/include/duckdb/function/scalar/operators.hpp +0 -24
- package/src/duckdb/src/include/duckdb/function/scalar/string_functions.hpp +1 -97
- package/src/duckdb/src/include/duckdb/function/table/read_csv.hpp +1 -1
- package/src/duckdb/src/include/duckdb/main/database.hpp +1 -0
- package/src/duckdb/src/include/duckdb/main/database_manager.hpp +3 -0
- package/src/duckdb/src/include/duckdb/main/extension_helper.hpp +0 -2
- package/src/duckdb/src/include/duckdb/main/extension_util.hpp +48 -0
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_function_info.hpp +6 -0
- package/src/duckdb/src/include/duckdb/parser/tableref/pivotref.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/transformer.hpp +5 -1
- package/src/duckdb/src/main/attached_database.cpp +5 -3
- package/src/duckdb/src/main/database.cpp +34 -37
- package/src/duckdb/src/main/extension/extension_helper.cpp +1 -0
- package/src/duckdb/src/main/extension/extension_load.cpp +61 -38
- package/src/duckdb/src/main/extension/extension_util.cpp +90 -0
- package/src/duckdb/src/parser/transform/statement/transform_create_function.cpp +1 -4
- package/src/duckdb/src/parser/transform/statement/transform_create_view.cpp +2 -4
- package/src/duckdb/src/parser/transform/statement/transform_pivot_stmt.cpp +43 -24
- package/src/duckdb/src/parser/transform/tableref/transform_pivot.cpp +3 -0
- package/src/duckdb/src/planner/binder/statement/bind_create.cpp +17 -28
- package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +6 -7
- package/src/duckdb/third_party/fmt/format.cc +0 -5
- package/src/duckdb/third_party/fmt/include/fmt/core.h +10 -12
- package/src/duckdb/third_party/fmt/include/fmt/format-inl.h +2 -33
- package/src/duckdb/third_party/fmt/include/fmt/format.h +61 -24
- package/src/duckdb/third_party/fmt/include/fmt/printf.h +15 -1
- package/src/duckdb/third_party/libpg_query/include/nodes/parsenodes.hpp +1 -0
- package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +10735 -10674
- package/src/duckdb/ub_src_common_enums.cpp +2 -0
- package/src/duckdb/ub_src_core_functions.cpp +4 -0
- package/src/duckdb/ub_src_core_functions_aggregate_algebraic.cpp +8 -0
- package/src/duckdb/ub_src_core_functions_aggregate_distributive.cpp +24 -0
- package/src/duckdb/ub_src_core_functions_aggregate_holistic.cpp +8 -0
- package/src/duckdb/ub_src_core_functions_aggregate_nested.cpp +4 -0
- package/src/duckdb/ub_src_core_functions_aggregate_regression.cpp +14 -0
- package/src/duckdb/ub_src_core_functions_scalar_bit.cpp +2 -0
- package/src/duckdb/ub_src_core_functions_scalar_blob.cpp +4 -0
- package/src/duckdb/ub_src_core_functions_scalar_date.cpp +22 -0
- package/src/duckdb/ub_src_core_functions_scalar_enum.cpp +2 -0
- package/src/duckdb/ub_src_core_functions_scalar_generic.cpp +16 -0
- package/src/duckdb/ub_src_core_functions_scalar_list.cpp +14 -0
- package/src/duckdb/ub_src_core_functions_scalar_map.cpp +12 -0
- package/src/duckdb/ub_src_core_functions_scalar_math.cpp +2 -0
- package/src/duckdb/ub_src_core_functions_scalar_operators.cpp +2 -0
- package/src/duckdb/ub_src_core_functions_scalar_random.cpp +4 -0
- package/src/duckdb/ub_src_core_functions_scalar_string.cpp +44 -0
- package/src/duckdb/ub_src_core_functions_scalar_struct.cpp +4 -0
- package/src/duckdb/ub_src_core_functions_scalar_union.cpp +6 -0
- package/src/duckdb/ub_src_function_aggregate.cpp +0 -8
- package/src/duckdb/ub_src_function_aggregate_distributive.cpp +0 -24
- package/src/duckdb/ub_src_function_scalar.cpp +2 -8
- package/src/duckdb/ub_src_function_scalar_generic.cpp +0 -14
- package/src/duckdb/ub_src_function_scalar_list.cpp +0 -14
- package/src/duckdb/ub_src_function_scalar_operators.cpp +0 -2
- package/src/duckdb/ub_src_function_scalar_string.cpp +0 -42
- package/src/duckdb/ub_src_function_scalar_struct.cpp +0 -4
- package/src/duckdb/ub_src_function_scalar_system.cpp +0 -2
- package/src/duckdb/ub_src_main_extension.cpp +2 -0
- package/src/duckdb/src/function/aggregate/algebraic/corr.cpp +0 -14
- package/src/duckdb/src/function/aggregate/algebraic/covar.cpp +0 -25
- package/src/duckdb/src/function/aggregate/algebraic/stddev.cpp +0 -54
- package/src/duckdb/src/function/aggregate/algebraic_functions.cpp +0 -21
- package/src/duckdb/src/function/aggregate/holistic_functions.cpp +0 -12
- package/src/duckdb/src/function/aggregate/nested_functions.cpp +0 -10
- package/src/duckdb/src/function/aggregate/regression_functions.cpp +0 -21
- package/src/duckdb/src/function/scalar/date_functions.cpp +0 -22
- package/src/duckdb/src/function/scalar/enum_functions.cpp +0 -13
- package/src/duckdb/src/function/scalar/math_functions.cpp +0 -50
- package/src/duckdb/src/function/scalar/trigonometrics_functions.cpp +0 -18
- package/src/duckdb/src/include/duckdb/function/aggregate/algebraic_functions.hpp +0 -56
- package/src/duckdb/src/include/duckdb/function/aggregate/holistic_functions.hpp +0 -33
- package/src/duckdb/src/include/duckdb/function/aggregate/nested_functions.hpp +0 -26
- package/src/duckdb/src/include/duckdb/function/aggregate/regression_functions.hpp +0 -53
- package/src/duckdb/src/include/duckdb/function/scalar/bit_functions.hpp +0 -32
- package/src/duckdb/src/include/duckdb/function/scalar/blob_functions.hpp +0 -24
- package/src/duckdb/src/include/duckdb/function/scalar/date_functions.hpp +0 -73
- package/src/duckdb/src/include/duckdb/function/scalar/enum_functions.hpp +0 -37
- package/src/duckdb/src/include/duckdb/function/scalar/math_functions.hpp +0 -137
- package/src/duckdb/src/include/duckdb/function/scalar/trigonometric_functions.hpp +0 -49
- package/src/duckdb/ub_src_function_aggregate_algebraic.cpp +0 -8
- package/src/duckdb/ub_src_function_aggregate_holistic.cpp +0 -8
- package/src/duckdb/ub_src_function_aggregate_nested.cpp +0 -4
- package/src/duckdb/ub_src_function_aggregate_regression.cpp +0 -14
- package/src/duckdb/ub_src_function_scalar_bit.cpp +0 -2
- package/src/duckdb/ub_src_function_scalar_blob.cpp +0 -4
- package/src/duckdb/ub_src_function_scalar_date.cpp +0 -22
- package/src/duckdb/ub_src_function_scalar_enum.cpp +0 -2
- package/src/duckdb/ub_src_function_scalar_map.cpp +0 -12
- package/src/duckdb/ub_src_function_scalar_math.cpp +0 -6
- package/src/duckdb/ub_src_function_scalar_union.cpp +0 -6
- /package/src/duckdb/src/include/duckdb/function/scalar/{strftime.hpp → strftime_format.hpp} +0 -0
@@ -4,6 +4,10 @@
|
|
4
4
|
#include "duckdb/main/error_manager.hpp"
|
5
5
|
#include "mbedtls_wrapper.hpp"
|
6
6
|
|
7
|
+
#ifndef DUCKDB_NO_THREADS
|
8
|
+
#include <thread>
|
9
|
+
#endif // DUCKDB_NO_THREADS
|
10
|
+
|
7
11
|
#ifdef WASM_LOADABLE_EXTENSIONS
|
8
12
|
#include <emscripten.h>
|
9
13
|
#endif
|
@@ -15,7 +19,7 @@ namespace duckdb {
|
|
15
19
|
//===--------------------------------------------------------------------===//
|
16
20
|
typedef void (*ext_init_fun_t)(DatabaseInstance &);
|
17
21
|
typedef const char *(*ext_version_fun_t)(void);
|
18
|
-
typedef
|
22
|
+
typedef bool (*ext_is_storage_t)(void);
|
19
23
|
|
20
24
|
template <class T>
|
21
25
|
static T LoadFunctionFromDLL(void *dll, const string &function_name, const string &filename) {
|
@@ -26,6 +30,16 @@ static T LoadFunctionFromDLL(void *dll, const string &function_name, const strin
|
|
26
30
|
return (T)function;
|
27
31
|
}
|
28
32
|
|
33
|
+
void ComputeSHA256(FileHandle *handle, const idx_t start, const idx_t end, std::string *res) {
|
34
|
+
const idx_t len = end - start;
|
35
|
+
string file_content;
|
36
|
+
file_content.resize(len);
|
37
|
+
handle->Read((void *)file_content.data(), len, start);
|
38
|
+
|
39
|
+
// Invoke MbedTls function to actually compute sha256
|
40
|
+
*res = duckdb_mbedtls::MbedTlsWrapper::ComputeSha256Hash(file_content);
|
41
|
+
}
|
42
|
+
|
29
43
|
bool ExtensionHelper::TryInitialLoad(DBConfig &config, FileOpener *opener, const string &extension,
|
30
44
|
ExtensionInitResult &result, string &error) {
|
31
45
|
if (!config.options.enable_external_access) {
|
@@ -70,15 +84,45 @@ bool ExtensionHelper::TryInitialLoad(DBConfig &config, FileOpener *opener, const
|
|
70
84
|
|
71
85
|
auto signature_offset = handle->GetFileSize() - signature.size();
|
72
86
|
|
87
|
+
const idx_t maxLenChunks = 1024 * 1024;
|
88
|
+
const idx_t numChunks = (signature_offset + maxLenChunks - 1) / maxLenChunks;
|
89
|
+
std::vector<std::string> chunks(numChunks);
|
90
|
+
std::vector<idx_t> splits(numChunks + 1);
|
91
|
+
|
92
|
+
splits.back() = signature_offset;
|
93
|
+
for (idx_t i = 0; i < chunks.size(); i++) {
|
94
|
+
splits[i] = maxLenChunks * i;
|
95
|
+
}
|
96
|
+
|
97
|
+
#ifndef DUCKDB_NO_THREADS
|
98
|
+
std::vector<std::thread> threads;
|
99
|
+
threads.reserve(numChunks);
|
100
|
+
for (idx_t i = 0; i < numChunks; i++) {
|
101
|
+
threads.emplace_back(ComputeSHA256, handle.get(), splits[i], splits[i + 1], &chunks[i]);
|
102
|
+
}
|
103
|
+
|
104
|
+
for (auto &thread : threads) {
|
105
|
+
thread.join();
|
106
|
+
}
|
107
|
+
#else
|
108
|
+
for (idx_t i = 0; i < numChunks; i++) {
|
109
|
+
ComputeSHA256(handle.get(), splits[i], splits[i + 1], &chunks[i]);
|
110
|
+
}
|
111
|
+
#endif // DUCKDB_NO_THREADS
|
112
|
+
|
73
113
|
string file_content;
|
74
|
-
file_content.
|
75
|
-
|
114
|
+
file_content.reserve(256 * numChunks);
|
115
|
+
|
116
|
+
for (auto &chunk : chunks) {
|
117
|
+
file_content += chunk;
|
118
|
+
}
|
119
|
+
|
120
|
+
string hash;
|
121
|
+
ComputeSHA256(handle.get(), 0, file_content.size(), &hash);
|
76
122
|
|
77
123
|
// TODO maybe we should do a stream read / hash update here
|
78
124
|
handle->Read((void *)signature.data(), signature.size(), signature_offset);
|
79
125
|
|
80
|
-
auto hash = duckdb_mbedtls::MbedTlsWrapper::ComputeSha256Hash(file_content);
|
81
|
-
|
82
126
|
bool any_valid = false;
|
83
127
|
for (auto &key : ExtensionHelper::GetPublicKeys()) {
|
84
128
|
if (duckdb_mbedtls::MbedTlsWrapper::IsValidSha256Signature(key, signature, hash)) {
|
@@ -157,7 +201,18 @@ ExtensionInitResult ExtensionHelper::InitialLoad(DBConfig &config, FileOpener *o
|
|
157
201
|
string error;
|
158
202
|
ExtensionInitResult result;
|
159
203
|
if (!TryInitialLoad(config, opener, extension, result, error)) {
|
160
|
-
|
204
|
+
if (!ExtensionHelper::AllowAutoInstall(extension)) {
|
205
|
+
throw IOException(error);
|
206
|
+
}
|
207
|
+
// the extension load failed - try installing the extension
|
208
|
+
if (!config.file_system) {
|
209
|
+
throw InternalException("Attempting to install an extension without a file system");
|
210
|
+
}
|
211
|
+
ExtensionHelper::InstallExtension(config, *config.file_system, extension, false);
|
212
|
+
// try loading again
|
213
|
+
if (!TryInitialLoad(config, nullptr, extension, result, error)) {
|
214
|
+
throw IOException(error);
|
215
|
+
}
|
161
216
|
}
|
162
217
|
return result;
|
163
218
|
}
|
@@ -207,38 +262,6 @@ void ExtensionHelper::LoadExternalExtension(ClientContext &context, const string
|
|
207
262
|
LoadExternalExtension(DatabaseInstance::GetDatabase(context), FileSystem::GetFileOpener(context), extension);
|
208
263
|
}
|
209
264
|
|
210
|
-
void ExtensionHelper::StorageInit(string &extension, DBConfig &config) {
|
211
|
-
extension = ExtensionHelper::ApplyExtensionAlias(extension);
|
212
|
-
ExtensionInitResult res;
|
213
|
-
string error;
|
214
|
-
if (!TryInitialLoad(config, nullptr, extension, res, error)) {
|
215
|
-
if (!ExtensionHelper::AllowAutoInstall(extension)) {
|
216
|
-
throw IOException(error);
|
217
|
-
}
|
218
|
-
// the extension load failed - try installing the extension
|
219
|
-
if (!config.file_system) {
|
220
|
-
throw InternalException("Attempting to install an extension without a file system");
|
221
|
-
}
|
222
|
-
ExtensionHelper::InstallExtension(config, *config.file_system, extension, false);
|
223
|
-
// try loading again
|
224
|
-
if (!TryInitialLoad(config, nullptr, extension, res, error)) {
|
225
|
-
throw IOException(error);
|
226
|
-
}
|
227
|
-
}
|
228
|
-
auto storage_fun_name = res.basename + "_storage_init";
|
229
|
-
|
230
|
-
ext_storage_init_t storage_init_fun;
|
231
|
-
storage_init_fun = LoadFunctionFromDLL<ext_storage_init_t>(res.lib_hdl, storage_fun_name, res.filename);
|
232
|
-
|
233
|
-
try {
|
234
|
-
(*storage_init_fun)(config);
|
235
|
-
} catch (std::exception &e) {
|
236
|
-
throw InvalidInputException(
|
237
|
-
"Storage initialization function \"%s\" from file \"%s\" threw an exception: \"%s\"", storage_fun_name,
|
238
|
-
res.filename, e.what());
|
239
|
-
}
|
240
|
-
}
|
241
|
-
|
242
265
|
string ExtensionHelper::ExtractExtensionPrefixFromPath(const string &path) {
|
243
266
|
auto first_colon = path.find(':');
|
244
267
|
if (first_colon == string::npos || first_colon < 2) { // needs to be at least two characters because windows c: ...
|
@@ -0,0 +1,90 @@
|
|
1
|
+
#include "duckdb/main/extension_util.hpp"
|
2
|
+
#include "duckdb/function/scalar_function.hpp"
|
3
|
+
#include "duckdb/parser/parsed_data/create_type_info.hpp"
|
4
|
+
#include "duckdb/parser/parsed_data/create_copy_function_info.hpp"
|
5
|
+
#include "duckdb/parser/parsed_data/create_pragma_function_info.hpp"
|
6
|
+
#include "duckdb/parser/parsed_data/create_scalar_function_info.hpp"
|
7
|
+
#include "duckdb/parser/parsed_data/create_table_function_info.hpp"
|
8
|
+
#include "duckdb/parser/parsed_data/create_macro_info.hpp"
|
9
|
+
#include "duckdb/catalog/catalog.hpp"
|
10
|
+
#include "duckdb/main/config.hpp"
|
11
|
+
|
12
|
+
namespace duckdb {
|
13
|
+
|
14
|
+
void ExtensionUtil::RegisterFunction(DatabaseInstance &db, ScalarFunctionSet set) {
|
15
|
+
D_ASSERT(!set.name.empty());
|
16
|
+
CreateScalarFunctionInfo info(std::move(set));
|
17
|
+
auto &system_catalog = Catalog::GetSystemCatalog(db);
|
18
|
+
auto data = CatalogTransaction::GetSystemTransaction(db);
|
19
|
+
system_catalog.CreateFunction(data, info);
|
20
|
+
}
|
21
|
+
|
22
|
+
void ExtensionUtil::RegisterFunction(DatabaseInstance &db, ScalarFunction function) {
|
23
|
+
D_ASSERT(!function.name.empty());
|
24
|
+
ScalarFunctionSet set(function.name);
|
25
|
+
set.AddFunction(std::move(function));
|
26
|
+
RegisterFunction(db, std::move(set));
|
27
|
+
}
|
28
|
+
|
29
|
+
void ExtensionUtil::RegisterFunction(DatabaseInstance &db, TableFunction function) {
|
30
|
+
D_ASSERT(!function.name.empty());
|
31
|
+
TableFunctionSet set(function.name);
|
32
|
+
set.AddFunction(std::move(function));
|
33
|
+
RegisterFunction(db, std::move(set));
|
34
|
+
}
|
35
|
+
|
36
|
+
void ExtensionUtil::RegisterFunction(DatabaseInstance &db, TableFunctionSet function) {
|
37
|
+
D_ASSERT(!function.name.empty());
|
38
|
+
CreateTableFunctionInfo info(std::move(function));
|
39
|
+
auto &system_catalog = Catalog::GetSystemCatalog(db);
|
40
|
+
auto data = CatalogTransaction::GetSystemTransaction(db);
|
41
|
+
system_catalog.CreateFunction(data, info);
|
42
|
+
}
|
43
|
+
|
44
|
+
void ExtensionUtil::RegisterFunction(DatabaseInstance &db, PragmaFunction function) {
|
45
|
+
D_ASSERT(!function.name.empty());
|
46
|
+
PragmaFunctionSet set(function.name);
|
47
|
+
set.AddFunction(std::move(function));
|
48
|
+
RegisterFunction(db, std::move(set));
|
49
|
+
}
|
50
|
+
|
51
|
+
void ExtensionUtil::RegisterFunction(DatabaseInstance &db, PragmaFunctionSet function) {
|
52
|
+
D_ASSERT(!function.name.empty());
|
53
|
+
auto function_name = function.name;
|
54
|
+
CreatePragmaFunctionInfo info(std::move(function_name), std::move(function));
|
55
|
+
auto &system_catalog = Catalog::GetSystemCatalog(db);
|
56
|
+
auto data = CatalogTransaction::GetSystemTransaction(db);
|
57
|
+
system_catalog.CreatePragmaFunction(data, info);
|
58
|
+
}
|
59
|
+
|
60
|
+
void ExtensionUtil::RegisterFunction(DatabaseInstance &db, CopyFunction function) {
|
61
|
+
CreateCopyFunctionInfo info(std::move(function));
|
62
|
+
auto &system_catalog = Catalog::GetSystemCatalog(db);
|
63
|
+
auto data = CatalogTransaction::GetSystemTransaction(db);
|
64
|
+
system_catalog.CreateCopyFunction(data, info);
|
65
|
+
}
|
66
|
+
|
67
|
+
void ExtensionUtil::RegisterFunction(DatabaseInstance &db, CreateMacroInfo &info) {
|
68
|
+
auto &system_catalog = Catalog::GetSystemCatalog(db);
|
69
|
+
auto data = CatalogTransaction::GetSystemTransaction(db);
|
70
|
+
system_catalog.CreateFunction(data, info);
|
71
|
+
}
|
72
|
+
|
73
|
+
void ExtensionUtil::RegisterType(DatabaseInstance &db, string type_name, LogicalType type) {
|
74
|
+
D_ASSERT(!type_name.empty());
|
75
|
+
CreateTypeInfo info(std::move(type_name), std::move(type));
|
76
|
+
info.temporary = true;
|
77
|
+
info.internal = true;
|
78
|
+
auto &system_catalog = Catalog::GetSystemCatalog(db);
|
79
|
+
auto data = CatalogTransaction::GetSystemTransaction(db);
|
80
|
+
system_catalog.CreateType(data, info);
|
81
|
+
}
|
82
|
+
|
83
|
+
void ExtensionUtil::RegisterCastFunction(DatabaseInstance &db, const LogicalType &source, const LogicalType &target,
|
84
|
+
BoundCastInfo function, int64_t implicit_cast_cost) {
|
85
|
+
auto &config = DBConfig::GetConfig(db);
|
86
|
+
auto &casts = config.GetCastFunctions();
|
87
|
+
casts.RegisterCastFunction(source, target, std::move(function), implicit_cast_cost);
|
88
|
+
}
|
89
|
+
|
90
|
+
} // namespace duckdb
|
@@ -29,10 +29,7 @@ unique_ptr<CreateStatement> Transformer::TransformCreateFunction(duckdb_libpgque
|
|
29
29
|
auto query_node = TransformSelect(stmt->query, true)->node->Copy();
|
30
30
|
macro_func = make_uniq<TableMacroFunction>(std::move(query_node));
|
31
31
|
}
|
32
|
-
|
33
|
-
throw ParserException("Cannot use PIVOT statement syntax in a macro. Use the SQL standard PIVOT syntax in the "
|
34
|
-
"FROM clause instead.");
|
35
|
-
}
|
32
|
+
PivotEntryCheck("macro");
|
36
33
|
|
37
34
|
auto info =
|
38
35
|
make_uniq<CreateMacroInfo>((stmt->function ? CatalogType::MACRO_ENTRY : CatalogType::TABLE_MACRO_ENTRY));
|
@@ -26,10 +26,8 @@ unique_ptr<CreateStatement> Transformer::TransformCreateView(duckdb_libpgquery::
|
|
26
26
|
info->on_conflict = TransformOnConflict(stmt->onconflict);
|
27
27
|
|
28
28
|
info->query = TransformSelect(stmt->query, false);
|
29
|
-
|
30
|
-
|
31
|
-
"FROM clause instead.");
|
32
|
-
}
|
29
|
+
|
30
|
+
PivotEntryCheck("view");
|
33
31
|
|
34
32
|
if (stmt->aliases && stmt->aliases->length > 0) {
|
35
33
|
for (auto c = stmt->aliases->head; c != nullptr; c = lnext(c)) {
|
@@ -18,33 +18,45 @@
|
|
18
18
|
|
19
19
|
namespace duckdb {
|
20
20
|
|
21
|
-
void Transformer::AddPivotEntry(string enum_name, unique_ptr<SelectNode> base, unique_ptr<ParsedExpression> column
|
21
|
+
void Transformer::AddPivotEntry(string enum_name, unique_ptr<SelectNode> base, unique_ptr<ParsedExpression> column,
|
22
|
+
unique_ptr<QueryNode> subquery) {
|
22
23
|
if (parent) {
|
23
|
-
parent->AddPivotEntry(std::move(enum_name), std::move(base), std::move(column));
|
24
|
+
parent->AddPivotEntry(std::move(enum_name), std::move(base), std::move(column), std::move(subquery));
|
24
25
|
return;
|
25
26
|
}
|
26
27
|
auto result = make_uniq<CreatePivotEntry>();
|
27
28
|
result->enum_name = std::move(enum_name);
|
28
29
|
result->base = std::move(base);
|
29
30
|
result->column = std::move(column);
|
31
|
+
result->subquery = std::move(subquery);
|
30
32
|
|
31
33
|
pivot_entries.push_back(std::move(result));
|
32
34
|
}
|
33
35
|
|
34
36
|
bool Transformer::HasPivotEntries() {
|
35
|
-
|
36
|
-
return parent->HasPivotEntries();
|
37
|
-
}
|
38
|
-
return !pivot_entries.empty();
|
37
|
+
return !GetPivotEntries().empty();
|
39
38
|
}
|
40
39
|
|
41
40
|
idx_t Transformer::PivotEntryCount() {
|
41
|
+
return GetPivotEntries().size();
|
42
|
+
}
|
43
|
+
|
44
|
+
vector<unique_ptr<Transformer::CreatePivotEntry>> &Transformer::GetPivotEntries() {
|
42
45
|
if (parent) {
|
43
|
-
return parent->
|
46
|
+
return parent->GetPivotEntries();
|
44
47
|
}
|
45
|
-
return pivot_entries
|
48
|
+
return pivot_entries;
|
46
49
|
}
|
47
50
|
|
51
|
+
void Transformer::PivotEntryCheck(const string &type) {
|
52
|
+
auto &entries = GetPivotEntries();
|
53
|
+
if (!entries.empty()) {
|
54
|
+
throw ParserException(
|
55
|
+
"PIVOT statements with pivot elements extracted from the data cannot be used in %ss.\nIn order to use "
|
56
|
+
"PIVOT in a %s the PIVOT values must be manually specified, e.g.:\nPIVOT ... ON %s IN (val1, val2, ...)",
|
57
|
+
type, type, entries[0]->column->ToString());
|
58
|
+
}
|
59
|
+
}
|
48
60
|
unique_ptr<SQLStatement> Transformer::GenerateCreateEnumStmt(unique_ptr<CreatePivotEntry> entry) {
|
49
61
|
auto result = make_uniq<CreateStatement>();
|
50
62
|
auto info = make_uniq<CreateTypeInfo>();
|
@@ -57,23 +69,30 @@ unique_ptr<SQLStatement> Transformer::GenerateCreateEnumStmt(unique_ptr<CreatePi
|
|
57
69
|
info->on_conflict = OnCreateConflict::REPLACE_ON_CONFLICT;
|
58
70
|
|
59
71
|
// generate the query that will result in the enum creation
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
72
|
+
unique_ptr<QueryNode> subselect;
|
73
|
+
if (!entry->subquery) {
|
74
|
+
auto select_node = std::move(entry->base);
|
75
|
+
auto columnref = entry->column->Copy();
|
76
|
+
auto cast = make_uniq<CastExpression>(LogicalType::VARCHAR, std::move(columnref));
|
77
|
+
select_node->select_list.push_back(std::move(cast));
|
78
|
+
|
79
|
+
auto is_not_null =
|
80
|
+
make_uniq<OperatorExpression>(ExpressionType::OPERATOR_IS_NOT_NULL, std::move(entry->column));
|
81
|
+
select_node->where_clause = std::move(is_not_null);
|
82
|
+
|
83
|
+
// order by the column
|
84
|
+
select_node->modifiers.push_back(make_uniq<DistinctModifier>());
|
85
|
+
auto modifier = make_uniq<OrderModifier>();
|
86
|
+
modifier->orders.emplace_back(OrderType::ASCENDING, OrderByNullType::ORDER_DEFAULT,
|
87
|
+
make_uniq<ConstantExpression>(Value::INTEGER(1)));
|
88
|
+
select_node->modifiers.push_back(std::move(modifier));
|
89
|
+
subselect = std::move(select_node);
|
90
|
+
} else {
|
91
|
+
subselect = std::move(entry->subquery);
|
92
|
+
}
|
74
93
|
|
75
94
|
auto select = make_uniq<SelectStatement>();
|
76
|
-
select->node = std::move(
|
95
|
+
select->node = std::move(subselect);
|
77
96
|
info->query = std::move(select);
|
78
97
|
info->type = LogicalType::INVALID;
|
79
98
|
|
@@ -150,7 +169,7 @@ unique_ptr<QueryNode> Transformer::TransformPivotStatement(duckdb_libpgquery::PG
|
|
150
169
|
auto new_select = make_uniq<SelectNode>();
|
151
170
|
ExtractCTEsRecursive(new_select->cte_map);
|
152
171
|
new_select->from_table = source->Copy();
|
153
|
-
AddPivotEntry(enum_name, std::move(new_select), col.pivot_expressions[0]->Copy());
|
172
|
+
AddPivotEntry(enum_name, std::move(new_select), col.pivot_expressions[0]->Copy(), std::move(col.subquery));
|
154
173
|
col.pivot_enum = enum_name;
|
155
174
|
}
|
156
175
|
|
@@ -59,6 +59,9 @@ PivotColumn Transformer::TransformPivotColumn(duckdb_libpgquery::PGPivot *pivot)
|
|
59
59
|
col.entries.push_back(std::move(entry));
|
60
60
|
}
|
61
61
|
}
|
62
|
+
if (pivot->subquery) {
|
63
|
+
col.subquery = TransformSelectNode(reinterpret_cast<duckdb_libpgquery::PGSelectStmt *>(pivot->subquery));
|
64
|
+
}
|
62
65
|
if (pivot->pivot_enum) {
|
63
66
|
col.pivot_enum = pivot->pivot_enum;
|
64
67
|
}
|
@@ -8,6 +8,8 @@
|
|
8
8
|
#include "duckdb/parser/expression/constant_expression.hpp"
|
9
9
|
#include "duckdb/parser/expression/function_expression.hpp"
|
10
10
|
#include "duckdb/parser/expression/subquery_expression.hpp"
|
11
|
+
#include "duckdb/planner/expression/bound_cast_expression.hpp"
|
12
|
+
#include "duckdb/planner/expression/bound_columnref_expression.hpp"
|
11
13
|
#include "duckdb/parser/parsed_data/create_index_info.hpp"
|
12
14
|
#include "duckdb/parser/parsed_data/create_macro_info.hpp"
|
13
15
|
#include "duckdb/parser/parsed_data/create_view_info.hpp"
|
@@ -24,6 +26,7 @@
|
|
24
26
|
#include "duckdb/planner/operator/logical_create_table.hpp"
|
25
27
|
#include "duckdb/planner/operator/logical_get.hpp"
|
26
28
|
#include "duckdb/planner/operator/logical_distinct.hpp"
|
29
|
+
#include "duckdb/planner/operator/logical_projection.hpp"
|
27
30
|
#include "duckdb/planner/parsed_data/bound_create_table_info.hpp"
|
28
31
|
#include "duckdb/planner/query_node/bound_select_node.hpp"
|
29
32
|
#include "duckdb/planner/tableref/bound_basetableref.hpp"
|
@@ -605,41 +608,27 @@ BoundStatement Binder::Bind(CreateStatement &stmt) {
|
|
605
608
|
}
|
606
609
|
case CatalogType::TYPE_ENTRY: {
|
607
610
|
auto &schema = BindCreateSchema(*stmt.info);
|
608
|
-
auto &create_type_info =
|
611
|
+
auto &create_type_info = stmt.info->Cast<CreateTypeInfo>();
|
609
612
|
result.plan = make_uniq<LogicalCreate>(LogicalOperatorType::LOGICAL_CREATE_TYPE, std::move(stmt.info), &schema);
|
610
613
|
if (create_type_info.query) {
|
611
614
|
// CREATE TYPE mood AS ENUM (SELECT 'happy')
|
612
|
-
auto &select_stmt = create_type_info.query->Cast<SelectStatement>();
|
613
|
-
auto &query_node = *select_stmt.node;
|
614
|
-
|
615
|
-
// We always add distinct modifier implicitly
|
616
|
-
bool need_to_add = true;
|
617
|
-
if (!query_node.modifiers.empty()) {
|
618
|
-
if (query_node.modifiers[0]->type == ResultModifierType::DISTINCT_MODIFIER) {
|
619
|
-
// There are cases where the same column is grouped repeatedly
|
620
|
-
// CREATE TYPE mood AS ENUM (SELECT DISTINCT ON(x) x FROM test);
|
621
|
-
// When we push into a constant expression
|
622
|
-
// => CREATE TYPE mood AS ENUM (SELECT DISTINCT ON(x, x) x FROM test);
|
623
|
-
auto &distinct_modifier = (DistinctModifier &)*query_node.modifiers[0];
|
624
|
-
if (distinct_modifier.distinct_on_targets.empty()) {
|
625
|
-
need_to_add = false;
|
626
|
-
}
|
627
|
-
}
|
628
|
-
}
|
629
|
-
|
630
|
-
// Add distinct modifier
|
631
|
-
if (need_to_add) {
|
632
|
-
auto distinct_modifier = make_uniq<DistinctModifier>();
|
633
|
-
query_node.modifiers.emplace(query_node.modifiers.begin(), std::move(distinct_modifier));
|
634
|
-
}
|
635
|
-
|
636
615
|
auto query_obj = Bind(*create_type_info.query);
|
637
616
|
auto query = std::move(query_obj.plan);
|
638
617
|
|
639
618
|
auto &sql_types = query_obj.types;
|
640
|
-
if (sql_types.size() != 1
|
619
|
+
if (sql_types.size() != 1) {
|
641
620
|
// add cast expression?
|
642
|
-
throw BinderException("The query must return
|
621
|
+
throw BinderException("The query must return a single column");
|
622
|
+
}
|
623
|
+
if (sql_types[0].id() != LogicalType::VARCHAR) {
|
624
|
+
// push a projection casting to varchar
|
625
|
+
vector<unique_ptr<Expression>> select_list;
|
626
|
+
auto ref = make_uniq<BoundColumnRefExpression>(sql_types[0], query->GetColumnBindings()[0]);
|
627
|
+
auto cast_expr = BoundCastExpression::AddCastToType(context, std::move(ref), LogicalType::VARCHAR);
|
628
|
+
select_list.push_back(std::move(cast_expr));
|
629
|
+
auto proj = make_uniq<LogicalProjection>(GenerateTableIndex(), std::move(select_list));
|
630
|
+
proj->AddChild(std::move(query));
|
631
|
+
query = std::move(proj);
|
643
632
|
}
|
644
633
|
|
645
634
|
result.plan->AddChild(std::move(query));
|
@@ -660,7 +649,7 @@ BoundStatement Binder::Bind(CreateStatement &stmt) {
|
|
660
649
|
}
|
661
650
|
case CatalogType::DATABASE_ENTRY: {
|
662
651
|
// not supported in DuckDB yet but allow extensions to intercept and implement this functionality
|
663
|
-
auto &base =
|
652
|
+
auto &base = stmt.info->Cast<CreateDatabaseInfo>();
|
664
653
|
string database_name = base.name;
|
665
654
|
string source_path = base.path;
|
666
655
|
|
@@ -25,7 +25,7 @@
|
|
25
25
|
namespace duckdb {
|
26
26
|
|
27
27
|
static void CreateColumnDependencyManager(BoundCreateTableInfo &info) {
|
28
|
-
auto &base =
|
28
|
+
auto &base = info.base->Cast<CreateTableInfo>();
|
29
29
|
for (auto &col : base.columns.Logical()) {
|
30
30
|
if (!col.Generated()) {
|
31
31
|
continue;
|
@@ -35,13 +35,12 @@ static void CreateColumnDependencyManager(BoundCreateTableInfo &info) {
|
|
35
35
|
}
|
36
36
|
|
37
37
|
static void BindCheckConstraint(Binder &binder, BoundCreateTableInfo &info, const unique_ptr<Constraint> &cond) {
|
38
|
-
auto &base =
|
38
|
+
auto &base = info.base->Cast<CreateTableInfo>();
|
39
39
|
|
40
40
|
auto bound_constraint = make_uniq<BoundCheckConstraint>();
|
41
41
|
// check constraint: bind the expression
|
42
42
|
CheckBinder check_binder(binder, binder.context, base.table, base.columns, bound_constraint->bound_columns);
|
43
43
|
auto &check = cond->Cast<CheckConstraint>();
|
44
|
-
;
|
45
44
|
// create a copy of the unbound expression because the binding destroys the constraint
|
46
45
|
auto unbound_expression = check.expression->Copy();
|
47
46
|
// now bind the constraint and create a new BoundCheckConstraint
|
@@ -52,7 +51,7 @@ static void BindCheckConstraint(Binder &binder, BoundCreateTableInfo &info, cons
|
|
52
51
|
}
|
53
52
|
|
54
53
|
static void BindConstraints(Binder &binder, BoundCreateTableInfo &info) {
|
55
|
-
auto &base =
|
54
|
+
auto &base = info.base->Cast<CreateTableInfo>();
|
56
55
|
|
57
56
|
bool has_primary_key = false;
|
58
57
|
logical_index_set_t not_null_columns;
|
@@ -155,7 +154,7 @@ static void BindConstraints(Binder &binder, BoundCreateTableInfo &info) {
|
|
155
154
|
}
|
156
155
|
|
157
156
|
void Binder::BindGeneratedColumns(BoundCreateTableInfo &info) {
|
158
|
-
auto &base =
|
157
|
+
auto &base = info.base->Cast<CreateTableInfo>();
|
159
158
|
|
160
159
|
vector<string> names;
|
161
160
|
vector<LogicalType> types;
|
@@ -252,7 +251,7 @@ static void ExtractDependencies(BoundCreateTableInfo &info) {
|
|
252
251
|
}
|
253
252
|
}
|
254
253
|
unique_ptr<BoundCreateTableInfo> Binder::BindCreateTableInfo(unique_ptr<CreateInfo> info, SchemaCatalogEntry &schema) {
|
255
|
-
auto &base = (
|
254
|
+
auto &base = info->Cast<CreateTableInfo>();
|
256
255
|
auto result = make_uniq<BoundCreateTableInfo>(schema, std::move(info));
|
257
256
|
if (base.query) {
|
258
257
|
// construct the result object
|
@@ -305,7 +304,7 @@ unique_ptr<BoundCreateTableInfo> Binder::BindCreateTableInfo(unique_ptr<CreateIn
|
|
305
304
|
}
|
306
305
|
|
307
306
|
unique_ptr<BoundCreateTableInfo> Binder::BindCreateTableInfo(unique_ptr<CreateInfo> info) {
|
308
|
-
auto &base = (
|
307
|
+
auto &base = info->Cast<CreateTableInfo>();
|
309
308
|
auto &schema = BindCreateSchema(base);
|
310
309
|
return BindCreateTableInfo(std::move(info), schema);
|
311
310
|
}
|
@@ -128,11 +128,6 @@ int (*instantiate_format_float)(double, int, internal::float_specs,
|
|
128
128
|
internal::buffer<char>&) =
|
129
129
|
internal::format_float;
|
130
130
|
|
131
|
-
#ifndef FMT_STATIC_THOUSANDS_SEPARATOR
|
132
|
-
template FMT_API internal::locale_ref::locale_ref(const std::locale& loc);
|
133
|
-
template FMT_API std::locale internal::locale_ref::get<std::locale>() const;
|
134
|
-
#endif
|
135
|
-
|
136
131
|
// Explicit instantiations for char.
|
137
132
|
|
138
133
|
template FMT_API std::string internal::grouping_impl<char>(locale_ref);
|
@@ -62,15 +62,9 @@
|
|
62
62
|
|
63
63
|
// Check if relaxed C++14 constexpr is supported.
|
64
64
|
// GCC doesn't allow throw in constexpr until version 6 (bug 67371).
|
65
|
-
#ifndef FMT_USE_CONSTEXPR
|
66
|
-
# define FMT_USE_CONSTEXPR \
|
67
|
-
(FMT_HAS_FEATURE(cxx_relaxed_constexpr) || FMT_MSC_VER >= 1910 || \
|
68
|
-
(FMT_GCC_VERSION >= 600 && __cplusplus >= 201402L)) && \
|
69
|
-
!FMT_NVCC
|
70
|
-
#endif
|
71
65
|
#if FMT_USE_CONSTEXPR
|
72
|
-
# define FMT_CONSTEXPR
|
73
|
-
# define FMT_CONSTEXPR_DECL
|
66
|
+
# define FMT_CONSTEXPR inline
|
67
|
+
# define FMT_CONSTEXPR_DECL
|
74
68
|
#else
|
75
69
|
# define FMT_CONSTEXPR inline
|
76
70
|
# define FMT_CONSTEXPR_DECL
|
@@ -323,6 +317,10 @@ template <typename Char> class basic_string_view {
|
|
323
317
|
size_ -= n;
|
324
318
|
}
|
325
319
|
|
320
|
+
std::string to_string() {
|
321
|
+
return std::string((char *) data(), size());
|
322
|
+
}
|
323
|
+
|
326
324
|
// Lexicographically compare this string reference to other.
|
327
325
|
int compare(basic_string_view other) const {
|
328
326
|
size_t str_size = size_ < other.size_ ? size_ : other.size_;
|
@@ -416,7 +414,7 @@ template <typename S>
|
|
416
414
|
struct is_compile_string : std::is_base_of<compile_string, S> {};
|
417
415
|
|
418
416
|
template <typename S, FMT_ENABLE_IF(is_compile_string<S>::value)>
|
419
|
-
|
417
|
+
FMT_CONSTEXPR basic_string_view<typename S::char_type> to_string_view(const S& s) {
|
420
418
|
return s;
|
421
419
|
}
|
422
420
|
|
@@ -442,7 +440,7 @@ struct error_handler {
|
|
442
440
|
FMT_CONSTEXPR error_handler(const error_handler&) = default;
|
443
441
|
|
444
442
|
// This function is intentionally not constexpr to give a compile-time error.
|
445
|
-
FMT_NORETURN FMT_API void on_error(
|
443
|
+
FMT_NORETURN FMT_API void on_error(std::string message);
|
446
444
|
};
|
447
445
|
} // namespace internal
|
448
446
|
|
@@ -520,7 +518,7 @@ class basic_format_parse_context : private ErrorHandler {
|
|
520
518
|
|
521
519
|
FMT_CONSTEXPR void check_arg_id(basic_string_view<Char>) {}
|
522
520
|
|
523
|
-
FMT_CONSTEXPR void on_error(
|
521
|
+
FMT_CONSTEXPR void on_error(std::string message) {
|
524
522
|
ErrorHandler::on_error(message);
|
525
523
|
}
|
526
524
|
|
@@ -1158,7 +1156,7 @@ template <typename OutputIt, typename Char> class basic_format_context {
|
|
1158
1156
|
format_arg arg(basic_string_view<char_type> name);
|
1159
1157
|
|
1160
1158
|
internal::error_handler error_handler() { return {}; }
|
1161
|
-
void on_error(
|
1159
|
+
void on_error(std::string message) { error_handler().on_error(message); }
|
1162
1160
|
|
1163
1161
|
// Returns an iterator to the beginning of the output range.
|
1164
1162
|
iterator out() { return out_; }
|
@@ -17,10 +17,6 @@
|
|
17
17
|
#include <cstdarg>
|
18
18
|
#include <cstring> // for std::memmove
|
19
19
|
#include <cwchar>
|
20
|
-
#if !defined(FMT_STATIC_THOUSANDS_SEPARATOR)
|
21
|
-
# include <locale>
|
22
|
-
#endif
|
23
|
-
|
24
20
|
#if FMT_EXCEPTIONS
|
25
21
|
# define FMT_TRY try
|
26
22
|
# define FMT_CATCH(x) catch (x)
|
@@ -162,45 +158,18 @@ FMT_FUNC void report_error(format_func func, int error_code,
|
|
162
158
|
}
|
163
159
|
} // namespace internal
|
164
160
|
|
165
|
-
#if !defined(FMT_STATIC_THOUSANDS_SEPARATOR)
|
166
|
-
namespace internal {
|
167
|
-
|
168
|
-
template <typename Locale>
|
169
|
-
locale_ref::locale_ref(const Locale& loc) : locale_(&loc) {
|
170
|
-
static_assert(std::is_same<Locale, std::locale>::value, "");
|
171
|
-
}
|
172
|
-
|
173
|
-
template <typename Locale> Locale locale_ref::get() const {
|
174
|
-
static_assert(std::is_same<Locale, std::locale>::value, "");
|
175
|
-
return locale_ ? *static_cast<const std::locale*>(locale_) : std::locale();
|
176
|
-
}
|
177
|
-
|
178
|
-
template <typename Char> FMT_FUNC std::string grouping_impl(locale_ref loc) {
|
179
|
-
return std::use_facet<std::numpunct<Char>>(loc.get<std::locale>()).grouping();
|
180
|
-
}
|
181
|
-
template <typename Char> FMT_FUNC Char thousands_sep_impl(locale_ref loc) {
|
182
|
-
return std::use_facet<std::numpunct<Char>>(loc.get<std::locale>())
|
183
|
-
.thousands_sep();
|
184
|
-
}
|
185
|
-
template <typename Char> FMT_FUNC Char decimal_point_impl(locale_ref loc) {
|
186
|
-
return std::use_facet<std::numpunct<Char>>(loc.get<std::locale>())
|
187
|
-
.decimal_point();
|
188
|
-
}
|
189
|
-
} // namespace internal
|
190
|
-
#else
|
191
161
|
template <typename Char>
|
192
162
|
FMT_FUNC std::string internal::grouping_impl(locale_ref) {
|
193
163
|
return "\03";
|
194
164
|
}
|
195
165
|
template <typename Char>
|
196
166
|
FMT_FUNC Char internal::thousands_sep_impl(locale_ref) {
|
197
|
-
return
|
167
|
+
return ',';
|
198
168
|
}
|
199
169
|
template <typename Char>
|
200
170
|
FMT_FUNC Char internal::decimal_point_impl(locale_ref) {
|
201
171
|
return '.';
|
202
172
|
}
|
203
|
-
#endif
|
204
173
|
|
205
174
|
namespace internal {
|
206
175
|
|
@@ -1203,7 +1172,7 @@ template <> struct formatter<internal::bigint> {
|
|
1203
1172
|
}
|
1204
1173
|
};
|
1205
1174
|
|
1206
|
-
FMT_FUNC void internal::error_handler::on_error(
|
1175
|
+
FMT_FUNC void internal::error_handler::on_error(std::string message) {
|
1207
1176
|
FMT_THROW(duckdb::Exception(message));
|
1208
1177
|
}
|
1209
1178
|
|