PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <ctype.h>
#include <float.h>
#include <limits.h>
#include <math.h>
#include "catalog/pg_type.h"
#include "common/hashfn.h"
#include "common/int.h"
#include "funcapi.h"
#include "lib/hyperloglog.h"
#include "libpq/pqformat.h"
#include "miscadmin.h"
#include "nodes/nodeFuncs.h"
#include "nodes/supportnodes.h"
#include "utils/array.h"
#include "utils/builtins.h"
#include "utils/guc.h"
#include "utils/numeric.h"
#include "utils/pg_lsn.h"
#include "utils/sortsupport.h"
Go to the source code of this file.
Data Structures | |
struct | NumericShort |
struct | NumericLong |
union | NumericChoice |
struct | NumericData |
struct | NumericVar |
struct | generate_series_numeric_fctx |
struct | NumericSortSupport |
struct | NumericSumAccum |
struct | NumericAggState |
struct | Int8TransTypeData |
Typedefs | |
typedef int16 | NumericDigit |
typedef struct NumericVar | NumericVar |
typedef struct NumericSumAccum | NumericSumAccum |
typedef struct NumericAggState | NumericAggState |
typedef NumericAggState | PolyNumAggState |
typedef struct Int8TransTypeData | Int8TransTypeData |
Variables | |
static const NumericDigit | const_zero_data [1] = {0} |
static const NumericVar | const_zero |
static const NumericDigit | const_one_data [1] = {1} |
static const NumericVar | const_one |
static const NumericVar | const_minus_one |
static const NumericDigit | const_two_data [1] = {2} |
static const NumericVar | const_two |
static const NumericDigit | const_zero_point_nine_data [1] = {9000} |
static const NumericVar | const_zero_point_nine |
static const NumericDigit | const_one_point_one_data [2] = {1, 1000} |
static const NumericVar | const_one_point_one |
static const NumericVar | const_nan |
static const NumericVar | const_pinf |
static const NumericVar | const_ninf |
static const int | round_powers [4] = {0, 1000, 100, 10} |
#define digitbuf_alloc | ( | ndigits | ) | ((NumericDigit *) palloc((ndigits) * sizeof(NumericDigit))) |
#define digitbuf_free | ( | buf | ) |
#define init_var | ( | v | ) | memset(v, 0, sizeof(NumericVar)) |
#define makePolyNumAggState makeNumericAggState |
#define makePolyNumAggStateCurrentContext makeNumericAggStateCurrentContext |
#define NA_TOTAL_COUNT | ( | na | ) | ((na)->N + (na)->NaNcount + (na)->pInfcount + (na)->nInfcount) |
#define NUMERIC_ABBREV_BITS (SIZEOF_DATUM * BITS_PER_BYTE) |
#define NUMERIC_ABBREV_NAN NumericAbbrevGetDatum(PG_INT32_MIN) |
#define NUMERIC_ABBREV_NINF NumericAbbrevGetDatum(PG_INT32_MAX) |
#define NUMERIC_ABBREV_PINF NumericAbbrevGetDatum(-PG_INT32_MAX) |
#define NUMERIC_CAN_BE_SHORT | ( | scale, | |
weight | |||
) |
#define NUMERIC_DIGITS | ( | num | ) |
#define NUMERIC_DSCALE | ( | n | ) |
#define NUMERIC_DSCALE_MAX NUMERIC_DSCALE_MASK |
#define NUMERIC_EXT_FLAGBITS | ( | n | ) | ((n)->choice.n_header & NUMERIC_EXT_SIGN_MASK) |
#define NUMERIC_EXT_SIGN_MASK 0xF000 /* high bits plus NaN/Inf flag bits */ |
#define NUMERIC_FLAGBITS | ( | n | ) | ((n)->choice.n_header & NUMERIC_SIGN_MASK) |
#define NUMERIC_HEADER_IS_SHORT | ( | n | ) | (((n)->choice.n_header & 0x8000) != 0) |
#define NUMERIC_HEADER_SIZE | ( | n | ) |
#define NUMERIC_IS_INF | ( | n | ) | (((n)->choice.n_header & ~NUMERIC_INF_SIGN_MASK) == NUMERIC_PINF) |
#define NUMERIC_IS_NAN | ( | n | ) | ((n)->choice.n_header == NUMERIC_NAN) |
#define NUMERIC_IS_NINF | ( | n | ) | ((n)->choice.n_header == NUMERIC_NINF) |
#define NUMERIC_IS_PINF | ( | n | ) | ((n)->choice.n_header == NUMERIC_PINF) |
#define NUMERIC_IS_SHORT | ( | n | ) | (NUMERIC_FLAGBITS(n) == NUMERIC_SHORT) |
#define NUMERIC_IS_SPECIAL | ( | n | ) | (NUMERIC_FLAGBITS(n) == NUMERIC_SPECIAL) |
#define NUMERIC_NDIGITS | ( | num | ) | ((VARSIZE(num) - NUMERIC_HEADER_SIZE(num)) / sizeof(NumericDigit)) |
#define NUMERIC_SHORT_DSCALE_MAX (NUMERIC_SHORT_DSCALE_MASK >> NUMERIC_SHORT_DSCALE_SHIFT) |
#define NUMERIC_SHORT_WEIGHT_MAX NUMERIC_SHORT_WEIGHT_MASK |
#define NUMERIC_SHORT_WEIGHT_MIN (-(NUMERIC_SHORT_WEIGHT_MASK+1)) |
#define NUMERIC_SIGN | ( | n | ) |
#define NUMERIC_WEIGHT | ( | n | ) |
typedef struct Int8TransTypeData Int8TransTypeData |
typedef struct NumericAggState NumericAggState |
typedef int16 NumericDigit |
typedef struct NumericSumAccum NumericSumAccum |
typedef struct NumericVar NumericVar |
typedef NumericAggState PolyNumAggState |
|
static |
Definition at line 11729 of file numeric.c.
References accum_sum_carry(), accum_sum_rescale(), i, NBASE, NumericSumAccum::neg_digits, NumericSumAccum::num_uncarried, NUMERIC_POS, NumericSumAccum::pos_digits, val, and NumericSumAccum::weight.
Referenced by accum_sum_combine(), do_numeric_accum(), do_numeric_discard(), int8_avg_deserialize(), numeric_avg_deserialize(), numeric_deserialize(), and numeric_poly_deserialize().
|
static |
Definition at line 11777 of file numeric.c.
References Assert(), NumericSumAccum::have_carry_space, i, NBASE, NumericSumAccum::ndigits, NumericSumAccum::neg_digits, NumericSumAccum::num_uncarried, and NumericSumAccum::pos_digits.
Referenced by accum_sum_add(), and accum_sum_final().
|
static |
Definition at line 12007 of file numeric.c.
References accum_sum_add(), accum_sum_final(), free_var(), and init_var.
Referenced by int8_avg_combine(), numeric_avg_combine(), numeric_combine(), and numeric_poly_combine().
|
static |
Definition at line 11990 of file numeric.c.
References NumericSumAccum::dscale, NumericSumAccum::ndigits, NumericSumAccum::neg_digits, NumericSumAccum::num_uncarried, palloc(), NumericSumAccum::pos_digits, and NumericSumAccum::weight.
Referenced by int8_avg_combine(), numeric_avg_combine(), numeric_combine(), and numeric_poly_combine().
|
static |
Definition at line 11939 of file numeric.c.
References accum_sum_carry(), add_var(), Assert(), NumericVar::buf, const_zero, digitbuf_alloc, NumericVar::digits, NumericVar::dscale, NumericSumAccum::dscale, i, init_var, NBASE, NumericVar::ndigits, NumericSumAccum::ndigits, NumericSumAccum::neg_digits, NUMERIC_NEG, NUMERIC_POS, NumericSumAccum::pos_digits, set_var_from_var(), NumericVar::sign, strip_var(), NumericVar::weight, and NumericSumAccum::weight.
Referenced by accum_sum_combine(), int8_avg_serialize(), numeric_avg(), numeric_avg_serialize(), numeric_poly_serialize(), numeric_serialize(), numeric_stddev_internal(), and numeric_sum().
|
static |
Definition at line 11850 of file numeric.c.
References Assert(), NumericSumAccum::dscale, NumericSumAccum::have_carry_space, NumericSumAccum::ndigits, NumericSumAccum::neg_digits, palloc0(), pfree(), NumericSumAccum::pos_digits, val, and NumericSumAccum::weight.
Referenced by accum_sum_add().
|
static |
Definition at line 11713 of file numeric.c.
References NumericSumAccum::dscale, i, NumericSumAccum::ndigits, NumericSumAccum::neg_digits, and NumericSumAccum::pos_digits.
Referenced by do_numeric_discard().
|
static |
Definition at line 11337 of file numeric.c.
References Assert(), NumericVar::buf, digitbuf_alloc, digitbuf_free, NumericVar::digits, NumericVar::dscale, i, Max, NBASE, NumericVar::ndigits, strip_var(), and NumericVar::weight.
|
static |
Definition at line 8353 of file numeric.c.
References add_abs(), cmp_abs(), NumericVar::dscale, Max, NUMERIC_NEG, NUMERIC_POS, NumericVar::sign, sub_abs(), and zero_var().
Referenced by accum_sum_final(), ceil_var(), compute_bucket(), div_mod_var(), exp_var(), generate_series_step_numeric(), in_range_numeric_numeric(), ln_var(), numeric_add_opt_error(), numeric_inc(), set_var_from_non_decimal_integer_str(), sqrt_var(), and width_bucket_numeric().
|
static |
Definition at line 6875 of file numeric.c.
References NumericVar::buf, digitbuf_alloc, digitbuf_free, NumericVar::digits, and NumericVar::ndigits.
Referenced by div_var(), div_var_fast(), int64_to_numericvar(), mul_var(), numeric_recv(), numericvar_deserialize(), set_var_from_num(), set_var_from_str(), and sqrt_var().
|
static |
Definition at line 7829 of file numeric.c.
References DEC_DIGITS, NumericVar::digits, NumericVar::dscale, ereturn, errcode(), errdetail(), errmsg(), i, is_valid_numeric_typmod(), maxdigits, NumericVar::ndigits, numeric_typmod_precision(), numeric_typmod_scale(), round_var(), scale, and NumericVar::weight.
Referenced by numeric(), numeric_in(), and numeric_recv().
Definition at line 7914 of file numeric.c.
References Assert(), ereturn, errcode(), errdetail(), errmsg(), is_valid_numeric_typmod(), NUMERIC_IS_NAN, NUMERIC_IS_SPECIAL, numeric_typmod_precision(), numeric_typmod_scale(), and scale.
Referenced by numeric(), numeric_in(), and numeric_recv().
|
static |
Definition at line 9867 of file numeric.c.
References add_var(), cmp_var(), const_one, free_var(), init_var, NUMERIC_POS, set_var_from_var(), NumericVar::sign, and trunc_var().
Referenced by numeric_ceil().
|
static |
Definition at line 11259 of file numeric.c.
References cmp_abs_common(), NumericVar::digits, NumericVar::ndigits, and NumericVar::weight.
Referenced by add_var(), div_mod_var(), gcd_var(), and sub_var().
|
static |
Definition at line 11273 of file numeric.c.
Referenced by cmp_abs(), and cmp_var_common().
Definition at line 2504 of file numeric.c.
References cmp_var_common(), NUMERIC_DIGITS, NUMERIC_IS_NAN, NUMERIC_IS_NINF, NUMERIC_IS_PINF, NUMERIC_IS_SPECIAL, NUMERIC_NDIGITS, NUMERIC_SIGN, and NUMERIC_WEIGHT.
Referenced by numeric_cmp(), numeric_eq(), numeric_fast_cmp(), numeric_ge(), numeric_gt(), numeric_larger(), numeric_le(), numeric_lt(), numeric_ne(), numeric_smaller(), and width_bucket_numeric().
|
static |
Definition at line 8295 of file numeric.c.
References cmp_var_common(), NumericVar::digits, NumericVar::ndigits, NumericVar::sign, and NumericVar::weight.
Referenced by ceil_var(), compute_bucket(), estimate_ln_dweight(), floor_var(), generate_series_step_numeric(), in_range_numeric_numeric(), ln_var(), numeric_power(), numeric_stddev_internal(), power_var(), and sqrt_var().
|
static |
Definition at line 8310 of file numeric.c.
References cmp_abs_common(), NUMERIC_NEG, and NUMERIC_POS.
Referenced by cmp_numerics(), and cmp_var().
|
static |
Definition at line 1916 of file numeric.c.
References add_var(), cmp_var(), const_one, div_var(), NumericVar::dscale, floor_var(), free_var(), init_var_from_num(), mul_var(), select_div_scale(), set_var_from_var(), and sub_var().
Referenced by width_bucket_numeric().
|
static |
Definition at line 9797 of file numeric.c.
References add_var(), cmp_abs(), const_one, div_var_fast(), NumericVar::dscale, free_var(), init_var, mul_var(), NumericVar::ndigits, set_var_from_var(), NumericVar::sign, and sub_var().
Referenced by sqrt_var().
|
static |
Definition at line 8799 of file numeric.c.
References alloc_var(), Assert(), DEC_DIGITS, NumericVar::digits, div_var_int(), NumericVar::dscale, ereport, errcode(), errmsg(), ERROR, HALF_NBASE, i, j, Max, NBASE, NumericVar::ndigits, NUMERIC_NEG, NUMERIC_POS, palloc0(), pfree(), round_var(), NumericVar::sign, strip_var(), trunc_var(), NumericVar::weight, and zero_var().
Referenced by compute_bucket(), get_str_from_var_sci(), mod_var(), numeric_div_opt_error(), numeric_div_trunc(), numeric_lcm(), numeric_stddev_internal(), and power_var_int().
|
static |
Definition at line 9107 of file numeric.c.
References alloc_var(), Assert(), DEC_DIGITS, NumericVar::digits, DIV_GUARD_DIGITS, div_var_int(), NumericVar::dscale, ereport, errcode(), errmsg(), ERROR, i, Min, NBASE, NumericVar::ndigits, NUMERIC_NEG, NUMERIC_POS, palloc0(), pfree(), round_var(), NumericVar::sign, strip_var(), trunc_var(), NumericVar::weight, and zero_var().
Referenced by div_mod_var(), ln_var(), log_var(), and power_var_int().
|
static |
Definition at line 9471 of file numeric.c.
References NumericVar::buf, DEC_DIGITS, digitbuf_alloc, digitbuf_free, NumericVar::digits, NumericVar::dscale, ereport, errcode(), errmsg(), ERROR, i, Max, NBASE, NumericVar::ndigits, NUMERIC_NEG, NUMERIC_POS, round_var(), NumericVar::sign, strip_var(), trunc_var(), NumericVar::weight, and zero_var().
Referenced by div_var(), div_var_fast(), exp_var(), and ln_var().
|
static |
Definition at line 4779 of file numeric.c.
References accum_sum_add(), NumericVar::dscale, init_var, init_var_from_num(), MemoryContextSwitchTo(), mul_var(), newval, NUMERIC_IS_NINF, NUMERIC_IS_PINF, and NUMERIC_IS_SPECIAL.
Referenced by int2_accum(), int4_accum(), int8_accum(), int8_avg_accum(), numeric_accum(), and numeric_avg_accum().
|
static |
Definition at line 4849 of file numeric.c.
References accum_sum_add(), accum_sum_reset(), Assert(), NumericVar::dscale, init_var, init_var_from_num(), MemoryContextSwitchTo(), mul_var(), newval, NUMERIC_IS_NINF, NUMERIC_IS_PINF, NUMERIC_IS_SPECIAL, NUMERIC_NEG, NUMERIC_POS, and NumericVar::sign.
Referenced by int2_accum_inv(), int4_accum_inv(), int8_accum_inv(), int8_avg_accum_inv(), and numeric_accum_inv().
Definition at line 7685 of file numeric.c.
References palloc(), res, and VARSIZE.
Referenced by numeric(), numeric_abs(), numeric_ceil(), numeric_exp(), numeric_floor(), numeric_inc(), numeric_ln(), numeric_mod_opt_error(), numeric_round(), numeric_sqrt(), numeric_trim_scale(), numeric_trunc(), numeric_uminus(), and numeric_uplus().
|
static |
Definition at line 10593 of file numeric.c.
References cmp_var(), const_one, const_one_point_one, const_zero_point_nine, DEC_DIGITS, NumericVar::digits, digits, free_var(), init_var, ln_var(), NBASE, NumericVar::ndigits, NUMERIC_POS, NumericVar::sign, sub_var(), NumericVar::weight, and x.
Referenced by log_var(), numeric_ln(), and power_var().
|
static |
Definition at line 10464 of file numeric.c.
References add_var(), arg, const_one, DEC_DIGITS, div_var_int(), NumericVar::dscale, ereport, errcode(), errmsg(), ERROR, free_var(), init_var, Max, mul_var(), NumericVar::ndigits, NUMERIC_MAX_RESULT_SCALE, NUMERIC_MIN_DISPLAY_SCALE, numericvar_to_double_no_overflow(), round_var(), set_var_from_var(), val, NumericVar::weight, x, and zero_var().
Referenced by numeric_exp(), and power_var().
Datum float4_numeric | ( | PG_FUNCTION_ARGS | ) |
Definition at line 4609 of file numeric.c.
References buf, const_nan, const_ninf, const_pinf, free_var(), init_var, make_result(), PG_GETARG_FLOAT4, PG_RETURN_NUMERIC, res, set_var_from_str(), snprintf, and val.
Datum float8_numeric | ( | PG_FUNCTION_ARGS | ) |
Definition at line 4515 of file numeric.c.
References buf, const_nan, const_ninf, const_pinf, free_var(), init_var, make_result(), PG_GETARG_FLOAT8, PG_RETURN_NUMERIC, res, set_var_from_str(), snprintf, and val.
Referenced by executeItemOptUnwrapTarget(), and SV_to_JsonbValue().
|
static |
Definition at line 9891 of file numeric.c.
References cmp_var(), const_one, free_var(), init_var, NUMERIC_NEG, set_var_from_var(), NumericVar::sign, sub_var(), and trunc_var().
Referenced by compute_bucket(), and numeric_floor().
|
static |
Definition at line 6891 of file numeric.c.
References NumericVar::buf, digitbuf_free, NumericVar::digits, NUMERIC_NAN, and NumericVar::sign.
Referenced by accum_sum_combine(), ceil_var(), compute_bucket(), div_mod_var(), estimate_ln_dweight(), exp_var(), float4_numeric(), float8_numeric(), floor_var(), gcd_var(), get_str_from_var_sci(), in_range_numeric_numeric(), int64_div_fast_to_numeric(), int64_to_numeric(), int8_avg_deserialize(), int8_avg_serialize(), ln_var(), log_var(), mod_var(), numeric(), numeric_add_opt_error(), numeric_avg(), numeric_avg_deserialize(), numeric_avg_serialize(), numeric_ceil(), numeric_deserialize(), numeric_div_opt_error(), numeric_div_trunc(), numeric_exp(), numeric_fac(), numeric_floor(), numeric_gcd(), numeric_in(), numeric_inc(), numeric_lcm(), numeric_ln(), numeric_log(), numeric_min_scale(), numeric_mod_opt_error(), numeric_mul_opt_error(), numeric_poly_avg(), numeric_poly_deserialize(), numeric_poly_serialize(), numeric_poly_sum(), numeric_power(), numeric_recv(), numeric_round(), numeric_serialize(), numeric_sqrt(), numeric_stddev_internal(), numeric_sub_opt_error(), numeric_sum(), numeric_trim_scale(), numeric_trunc(), numericvar_to_int64(), numericvar_to_uint64(), power_var(), power_var_int(), set_var_from_non_decimal_integer_str(), sqrt_var(), and width_bucket_numeric().
|
static |
Definition at line 9914 of file numeric.c.
References CHECK_FOR_INTERRUPTS, cmp(), cmp_abs(), NumericVar::dscale, free_var(), init_var, Max, mod_var(), NumericVar::ndigits, NUMERIC_POS, set_var_from_var(), and NumericVar::sign.
Referenced by numeric_gcd(), and numeric_lcm().
Datum generate_series_numeric | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1685 of file numeric.c.
References generate_series_step_numeric().
Datum generate_series_step_numeric | ( | PG_FUNCTION_ARGS | ) |
Definition at line 1691 of file numeric.c.
References add_var(), cmp_var(), const_one, const_zero, generate_series_numeric_fctx::current, ereport, errcode(), errmsg(), ERROR, init_var, init_var_from_num(), make_result(), MemoryContextSwitchTo(), FuncCallContext::multi_call_memory_ctx, NUMERIC_IS_NAN, NUMERIC_IS_SPECIAL, NUMERIC_NEG, NUMERIC_POS, NumericGetDatum(), palloc(), PG_GETARG_NUMERIC, PG_NARGS, set_var_from_num(), set_var_from_var(), NumericVar::sign, SRF_FIRSTCALL_INIT, SRF_IS_FIRSTCALL, SRF_PERCALL_SETUP, SRF_RETURN_DONE, SRF_RETURN_NEXT, generate_series_numeric_fctx::step, generate_series_numeric_fctx::stop, and FuncCallContext::user_fctx.
Referenced by generate_series_numeric().
|
static |
Definition at line 4135 of file numeric.c.
References DEC_DIGITS, NumericVar::digits, NumericVar::ndigits, and NumericVar::weight.
Referenced by numeric_min_scale(), and numeric_trim_scale().
|
static |
Definition at line 7416 of file numeric.c.
References DEC_DIGITS, NumericVar::digits, NumericVar::dscale, i, NumericVar::ndigits, NUMERIC_NEG, palloc(), NumericVar::sign, generate_unaccent_rules::str, and NumericVar::weight.
Referenced by get_str_from_var_sci(), numeric_normalize(), numeric_out(), and numericvar_to_double_no_overflow().
|
static |
Definition at line 7569 of file numeric.c.
References DEC_DIGITS, NumericVar::digits, div_var(), free_var(), get_str_from_var(), init_var, len, NumericVar::ndigits, palloc(), pfree(), power_ten_int(), snprintf, generate_unaccent_rules::str, and NumericVar::weight.
Referenced by numeric_out_sci().
Datum hash_numeric | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2696 of file numeric.c.
References Assert(), digits, hash_any(), i, sort-test::key, NUMERIC_DIGITS, NUMERIC_IS_SPECIAL, NUMERIC_NDIGITS, NUMERIC_WEIGHT, PG_GETARG_NUMERIC, PG_RETURN_DATUM, and PG_RETURN_UINT32.
Referenced by JsonbHashScalarValue().
Datum hash_numeric_extended | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2776 of file numeric.c.
References Assert(), DatumGetUInt64(), digits, hash_any_extended(), i, sort-test::key, NUMERIC_DIGITS, NUMERIC_IS_SPECIAL, NUMERIC_NDIGITS, NUMERIC_WEIGHT, PG_GETARG_INT64, PG_GETARG_NUMERIC, PG_RETURN_DATUM, PG_RETURN_UINT64, and UInt64GetDatum().
Referenced by JsonbHashScalarValueExtended().
Datum in_range_numeric_numeric | ( | PG_FUNCTION_ARGS | ) |
Definition at line 2561 of file numeric.c.
References add_var(), Assert(), cmp_var(), ereport, errcode(), errmsg(), ERROR, free_var(), init_var, init_var_from_num(), NUMERIC_IS_NAN, NUMERIC_IS_NINF, NUMERIC_IS_PINF, NUMERIC_IS_SPECIAL, NUMERIC_NEG, NUMERIC_SIGN, PG_FREE_IF_COPY, PG_GETARG_BOOL, PG_GETARG_NUMERIC, PG_RETURN_BOOL, sub_var(), and val.
|
static |
Definition at line 7373 of file numeric.c.
References generate_unaccent_rules::dest, NUMERIC_DIGITS, NUMERIC_DSCALE, NUMERIC_NDIGITS, NUMERIC_SIGN, and NUMERIC_WEIGHT.
Referenced by compute_bucket(), do_numeric_accum(), do_numeric_discard(), generate_series_step_numeric(), in_range_numeric_numeric(), numeric_abbrev_convert(), numeric_add_opt_error(), numeric_ceil(), numeric_div_opt_error(), numeric_div_trunc(), numeric_exp(), numeric_float8_no_overflow(), numeric_floor(), numeric_gcd(), numeric_inc(), numeric_int2(), numeric_int4_opt_error(), numeric_int8(), numeric_is_integral(), numeric_lcm(), numeric_ln(), numeric_log(), numeric_min_scale(), numeric_mod_opt_error(), numeric_mul_opt_error(), numeric_normalize(), numeric_out(), numeric_out_sci(), numeric_pg_lsn(), numeric_power(), numeric_send(), numeric_sqrt(), numeric_sub_opt_error(), and numeric_trim_scale().
Datum int2_accum | ( | PG_FUNCTION_ARGS | ) |
Definition at line 5472 of file numeric.c.
References do_numeric_accum(), int64_to_numeric(), makePolyNumAggState, PG_ARGISNULL, PG_GETARG_INT16, PG_GETARG_POINTER, and PG_RETURN_POINTER.
Datum int2_accum_inv | ( | PG_FUNCTION_ARGS | ) |
Definition at line 5896 of file numeric.c.
References do_numeric_discard(), elog(), ERROR, int64_to_numeric(), PG_ARGISNULL, PG_GETARG_INT16, PG_GETARG_POINTER, and PG_RETURN_POINTER.
Datum int2_avg_accum | ( | PG_FUNCTION_ARGS | ) |
Definition at line 6579 of file numeric.c.
References AggCheckCallContext(), ARR_DATA_PTR, ARR_HASNULL, ARR_OVERHEAD_NONULLS, ARR_SIZE, Int8TransTypeData::count, elog(), ERROR, newval, PG_GETARG_ARRAYTYPE_P, PG_GETARG_ARRAYTYPE_P_COPY, PG_GETARG_INT16, PG_RETURN_ARRAYTYPE_P, and Int8TransTypeData::sum.
Datum int2_avg_accum_inv | ( | PG_FUNCTION_ARGS | ) |
Definition at line 6666 of file numeric.c.
References AggCheckCallContext(), ARR_DATA_PTR, ARR_HASNULL, ARR_OVERHEAD_NONULLS, ARR_SIZE, Int8TransTypeData::count, elog(), ERROR, newval, PG_GETARG_ARRAYTYPE_P, PG_GETARG_ARRAYTYPE_P_COPY, PG_GETARG_INT16, PG_RETURN_ARRAYTYPE_P, and Int8TransTypeData::sum.
Datum int2_numeric | ( | PG_FUNCTION_ARGS | ) |
Definition at line 4466 of file numeric.c.
References int64_to_numeric(), PG_GETARG_INT16, PG_RETURN_NUMERIC, and val.
Datum int2_sum | ( | PG_FUNCTION_ARGS | ) |
Definition at line 6430 of file numeric.c.
References AggCheckCallContext(), newval, PG_ARGISNULL, PG_GETARG_INT16, PG_GETARG_INT64, PG_GETARG_POINTER, PG_RETURN_INT64, PG_RETURN_NULL, and PG_RETURN_POINTER.
Datum int2int4_sum | ( | PG_FUNCTION_ARGS | ) |
Definition at line 6749 of file numeric.c.
References ARR_DATA_PTR, ARR_HASNULL, ARR_OVERHEAD_NONULLS, ARR_SIZE, Int8TransTypeData::count, elog(), ERROR, Int64GetDatumFast, PG_GETARG_ARRAYTYPE_P, PG_RETURN_DATUM, PG_RETURN_NULL, and Int8TransTypeData::sum.
Datum int4_accum | ( | PG_FUNCTION_ARGS | ) |
Definition at line 5495 of file numeric.c.
References do_numeric_accum(), int64_to_numeric(), makePolyNumAggState, PG_ARGISNULL, PG_GETARG_INT32, PG_GETARG_POINTER, and PG_RETURN_POINTER.
Datum int4_accum_inv | ( | PG_FUNCTION_ARGS | ) |
Definition at line 5921 of file numeric.c.
References do_numeric_discard(), elog(), ERROR, int64_to_numeric(), PG_ARGISNULL, PG_GETARG_INT32, PG_GETARG_POINTER, and PG_RETURN_POINTER.
Datum int4_avg_accum | ( | PG_FUNCTION_ARGS | ) |
Definition at line 6607 of file numeric.c.
References AggCheckCallContext(), ARR_DATA_PTR, ARR_HASNULL, ARR_OVERHEAD_NONULLS, ARR_SIZE, Int8TransTypeData::count, elog(), ERROR, newval, PG_GETARG_ARRAYTYPE_P, PG_GETARG_ARRAYTYPE_P_COPY, PG_GETARG_INT32, PG_RETURN_ARRAYTYPE_P, and Int8TransTypeData::sum.
Datum int4_avg_accum_inv | ( | PG_FUNCTION_ARGS | ) |
Definition at line 6694 of file numeric.c.
References AggCheckCallContext(), ARR_DATA_PTR, ARR_HASNULL, ARR_OVERHEAD_NONULLS, ARR_SIZE, Int8TransTypeData::count, elog(), ERROR, newval, PG_GETARG_ARRAYTYPE_P, PG_GETARG_ARRAYTYPE_P_COPY, PG_GETARG_INT32, PG_RETURN_ARRAYTYPE_P, and Int8TransTypeData::sum.
Datum int4_avg_combine | ( | PG_FUNCTION_ARGS | ) |
Definition at line 6635 of file numeric.c.
References AggCheckCallContext(), ARR_DATA_PTR, ARR_HASNULL, ARR_OVERHEAD_NONULLS, ARR_SIZE, Int8TransTypeData::count, elog(), ERROR, PG_GETARG_ARRAYTYPE_P, PG_RETURN_ARRAYTYPE_P, and Int8TransTypeData::sum.
Datum int4_numeric | ( | PG_FUNCTION_ARGS | ) |
Definition at line 4338 of file numeric.c.
References int64_to_numeric(), PG_GETARG_INT32, PG_RETURN_NUMERIC, and val.
Datum int4_sum | ( | PG_FUNCTION_ARGS | ) |
Definition at line 6479 of file numeric.c.
References AggCheckCallContext(), newval, PG_ARGISNULL, PG_GETARG_INT32, PG_GETARG_INT64, PG_GETARG_POINTER, PG_RETURN_INT64, PG_RETURN_NULL, and PG_RETURN_POINTER.
Numeric int64_div_fast_to_numeric | ( | int64 | val1, |
int | log10val2 | ||
) |
Definition at line 4253 of file numeric.c.
References DEC_DIGITS, NumericVar::dscale, free_var(), init_var, int64_to_numericvar(), lengthof, make_result(), mul_var(), pg_mul_s64_overflow(), res, StaticAssertDecl, unlikely, and NumericVar::weight.
Referenced by interval_part_common(), time_part_common(), timestamp_part_common(), timestamptz_part_common(), and timetz_part_common().
Numeric int64_to_numeric | ( | int64 | val | ) |
Definition at line 4232 of file numeric.c.
References free_var(), init_var, int64_to_numericvar(), make_result(), res, and val.
Referenced by cash_numeric(), executeItemOptUnwrapTarget(), executeKeyValueMethod(), extract_date(), gbt_numeric_penalty(), int2_accum(), int2_accum_inv(), int2_numeric(), int4_accum(), int4_accum_inv(), int4_numeric(), int8_accum(), int8_accum_inv(), int8_avg(), int8_avg_accum(), int8_avg_accum_inv(), int8_numeric(), int8_sum(), int8_to_char(), interval_part_common(), numeric_avg(), numeric_cash(), numeric_half_rounded(), numeric_poly_avg(), numeric_to_char(), numeric_to_number(), numeric_truncated_divide(), pg_size_bytes(), pg_size_pretty_numeric(), SV_to_JsonbValue(), time_part_common(), timestamp_part_common(), timestamptz_part_common(), and timetz_part_common().
|
static |
Definition at line 8026 of file numeric.c.
References alloc_var(), DEC_DIGITS, NumericVar::digits, NumericVar::dscale, NBASE, NumericVar::ndigits, NUMERIC_NEG, NUMERIC_POS, NumericVar::sign, val, and NumericVar::weight.
Referenced by int64_div_fast_to_numeric(), int64_to_numeric(), numeric_fac(), numeric_stddev_internal(), set_var_from_non_decimal_integer_str(), sqrt_var(), and width_bucket_numeric().
Datum int8_accum | ( | PG_FUNCTION_ARGS | ) |
Definition at line 5518 of file numeric.c.
References do_numeric_accum(), int64_to_numeric(), makeNumericAggState(), PG_ARGISNULL, PG_GETARG_INT64, PG_GETARG_POINTER, and PG_RETURN_POINTER.
Datum int8_accum_inv | ( | PG_FUNCTION_ARGS | ) |
Definition at line 5946 of file numeric.c.
References do_numeric_discard(), elog(), ERROR, int64_to_numeric(), PG_ARGISNULL, PG_GETARG_INT64, PG_GETARG_POINTER, and PG_RETURN_POINTER.
Datum int8_avg | ( | PG_FUNCTION_ARGS | ) |
Definition at line 6722 of file numeric.c.
References ARR_DATA_PTR, ARR_HASNULL, ARR_OVERHEAD_NONULLS, ARR_SIZE, Int8TransTypeData::count, DirectFunctionCall2, elog(), ERROR, int64_to_numeric(), numeric_div(), NumericGetDatum(), PG_GETARG_ARRAYTYPE_P, PG_RETURN_DATUM, PG_RETURN_NULL, and Int8TransTypeData::sum.
Datum int8_avg_accum | ( | PG_FUNCTION_ARGS | ) |
Definition at line 5714 of file numeric.c.
References do_numeric_accum(), int64_to_numeric(), makePolyNumAggState, PG_ARGISNULL, PG_GETARG_INT64, PG_GETARG_POINTER, and PG_RETURN_POINTER.
Datum int8_avg_accum_inv | ( | PG_FUNCTION_ARGS | ) |
Definition at line 5967 of file numeric.c.
References do_numeric_discard(), elog(), ERROR, int64_to_numeric(), PG_ARGISNULL, PG_GETARG_INT64, PG_GETARG_POINTER, and PG_RETURN_POINTER.
Datum int8_avg_combine | ( | PG_FUNCTION_ARGS | ) |
Definition at line 5741 of file numeric.c.
References accum_sum_combine(), accum_sum_copy(), AggCheckCallContext(), elog(), ERROR, makePolyNumAggState, MemoryContextSwitchTo(), NumericAggState::N, PG_ARGISNULL, PG_GETARG_POINTER, PG_RETURN_POINTER, and NumericAggState::sumX.
Datum int8_avg_deserialize | ( | PG_FUNCTION_ARGS | ) |
Definition at line 5850 of file numeric.c.
References accum_sum_add(), AggCheckCallContext(), buf, elog(), ERROR, free_var(), init_var, initReadOnlyStringInfo(), makePolyNumAggStateCurrentContext, NumericAggState::N, numericvar_deserialize(), PG_GETARG_BYTEA_PP, PG_RETURN_POINTER, pq_getmsgend(), pq_getmsgint64(), NumericAggState::sumX, VARDATA_ANY, and VARSIZE_ANY_EXHDR.
Datum int8_avg_serialize | ( | PG_FUNCTION_ARGS | ) |