Remove long unused code behind a #if 0
authorPeter Eisentraut <peter@eisentraut.org>
Mon, 2 Mar 2020 07:55:31 +0000 (08:55 +0100)
committerPeter Eisentraut <peter@eisentraut.org>
Mon, 2 Mar 2020 07:55:31 +0000 (08:55 +0100)
Author: Vignesh C <vignesh21@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/CALDaNm3sn4yOq-4rogb-CfE0EYw6b3mVzz8+DnS9BNRwPnhngw@mail.gmail.com

src/interfaces/ecpg/pgtypeslib/numeric.c

index b6ca2d3252fdd1a85f2e508b6fa7b525a7e4311d..060fad7867d43a9074d3272f9d9530dd179dc473 100644 (file)
          } while (0)
 
 
-#if 0
-/* ----------
- * apply_typmod() -
- *
- * Do bounds checking and rounding according to the attributes
- * typmod field.
- * ----------
- */
-static int
-apply_typmod(numeric *var, long typmod)
-{
-   int         precision;
-   int         scale;
-   int         maxweight;
-   int         i;
-
-   /* Do nothing if we have a default typmod (-1) */
-   if (typmod < (long) (VARHDRSZ))
-       return 0;
-
-   typmod -= VARHDRSZ;
-   precision = (typmod >> 16) & 0xffff;
-   scale = typmod & 0xffff;
-   maxweight = precision - scale;
-
-   /* Round to target scale */
-   i = scale + var->weight + 1;
-   if (i >= 0 && var->ndigits > i)
-   {
-       int         carry = (var->digits[i] > 4) ? 1 : 0;
-
-       var->ndigits = i;
-
-       while (carry)
-       {
-           carry += var->digits[--i];
-           var->digits[i] = carry % 10;
-           carry /= 10;
-       }
-
-       if (i < 0)
-       {
-           var->digits--;
-           var->ndigits++;
-           var->weight++;
-       }
-   }
-   else
-       var->ndigits = Max(0, Min(i, var->ndigits));
-
-   /*
-    * Check for overflow - note we can't do this before rounding, because
-    * rounding could raise the weight.  Also note that the var's weight could
-    * be inflated by leading zeroes, which will be stripped before storage
-    * but perhaps might not have been yet. In any case, we must recognize a
-    * true zero, whose weight doesn't mean anything.
-    */
-   if (var->weight >= maxweight)
-   {
-       /* Determine true weight; and check for all-zero result */
-       int         tweight = var->weight;
-
-       for (i = 0; i < var->ndigits; i++)
-       {
-           if (var->digits[i])
-               break;
-           tweight--;
-       }
-
-       if (tweight >= maxweight && i < var->ndigits)
-       {
-           errno = PGTYPES_NUM_OVERFLOW;
-           return -1;
-       }
-   }
-
-   var->rscale = scale;
-   var->dscale = scale;
-   return 0;
-}
-#endif
-
 /* ----------
  * alloc_var() -
  *