remove redefinition numericvar_to_int128 in numeric.c
authorTomas Vondra <[email protected]>
Wed, 9 Nov 2016 04:51:18 +0000 (05:51 +0100)
committerTomas Vondra <[email protected]>
Wed, 9 Nov 2016 04:51:18 +0000 (05:51 +0100)
src/backend/utils/adt/numeric.c

index 295216ec9b787c82e3a5094d0b9e5559eb364973..5a6a5fd058737f41c4267332a38a6114fa885b8c 100644 (file)
@@ -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.
  */