Commit d433b79b authored by Peter Eisentraut's avatar Peter Eisentraut

Remove long unused code behind a #if 0

Author: Vignesh C <vignesh21@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/CALDaNm3sn4yOq-4rogb-CfE0EYw6b3mVzz8+DnS9BNRwPnhngw@mail.gmail.com
parent 3b77dce8
...@@ -23,88 +23,6 @@ ...@@ -23,88 +23,6 @@
} while (0) } 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() - * alloc_var() -
* *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment