From: Tomas Vondra Date: Wed, 9 Nov 2016 04:51:18 +0000 (+0100) Subject: remove redefinition numericvar_to_int128 in numeric.c X-Git-Tag: XL_10_R1BETA1~518 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=fe8bb86a9d7c197f23ecad5ab444c34bfa8a08ca;p=postgres-xl.git remove redefinition numericvar_to_int128 in numeric.c --- diff --git a/src/backend/utils/adt/numeric.c b/src/backend/utils/adt/numeric.c index 295216ec9b..5a6a5fd058 100644 --- a/src/backend/utils/adt/numeric.c +++ b/src/backend/utils/adt/numeric.c @@ -6317,83 +6317,6 @@ numericvar_to_int64(NumericVar *var, int64 *result) return true; } -#ifdef XCP -#ifdef HAVE_INT128 -/* - * Convert numeric to int128, rounding if needed. - * - * If overflow, return FALSE (no error is raised). Return TRUE if okay. - */ -static bool -numericvar_to_int128(NumericVar *var, int128 *result) -{ - NumericDigit *digits; - int ndigits; - int weight; - int i; - int128 val, - oldval; - bool neg; - NumericVar rounded; - - /* Round to nearest integer */ - init_var(&rounded); - set_var_from_var(var, &rounded); - round_var(&rounded, 0); - - /* Check for zero input */ - strip_var(&rounded); - ndigits = rounded.ndigits; - if (ndigits == 0) - { - *result = 0; - free_var(&rounded); - return true; - } - - /* - * For input like 10000000000, we must treat stripped digits as real. So - * the loop assumes there are weight+1 digits before the decimal point. - */ - weight = rounded.weight; - Assert(weight >= 0 && ndigits <= weight + 1); - - /* Construct the result */ - digits = rounded.digits; - neg = (rounded.sign == NUMERIC_NEG); - val = digits[0]; - for (i = 1; i <= weight; i++) - { - oldval = val; - val *= NBASE; - if (i < ndigits) - val += digits[i]; - - /* - * The overflow check is a bit tricky because we want to accept - * INT128_MIN, which will overflow the positive accumulator. We can - * detect this case easily though because INT128_MIN is the only - * nonzero value for which -val == val (on a two's complement machine, - * anyway). - */ - if ((val / NBASE) != oldval) /* possible overflow? */ - { - if (!neg || (-val) != val || val == 0 || oldval < 0) - { - free_var(&rounded); - return false; - } - } - } - - free_var(&rounded); - - *result = neg ? -val : val; - return true; -} -#endif -#endif - /* * Convert int8 value to numeric. */