mirror of
https://github.com/postgres/postgres.git
synced 2025-05-08 07:21:33 +03:00
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
This commit is contained in:
parent
3b77dce863
commit
d433b79b89
@ -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() -
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user