mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-24 18:55:04 +08:00
Fixed backend crashing bug in apply_typmod()
Jan
This commit is contained in:
parent
e3a5ac283b
commit
c1855793df
@ -5,7 +5,7 @@
|
||||
*
|
||||
* 1998 Jan Wieck
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.6 1999/01/04 11:20:33 wieck Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.7 1999/01/04 12:53:23 wieck Exp $
|
||||
*
|
||||
* ----------
|
||||
*/
|
||||
@ -2377,7 +2377,7 @@ apply_typmod(NumericVar *var, int32 typmod)
|
||||
}
|
||||
|
||||
i = scale + var->weight + 1;
|
||||
if (var->ndigits > i)
|
||||
if (i >= 0 && var->ndigits > i)
|
||||
{
|
||||
long carry = (var->digits[i] > 4) ? 1 : 0;
|
||||
|
||||
@ -2396,6 +2396,10 @@ apply_typmod(NumericVar *var, int32 typmod)
|
||||
var->weight++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var->ndigits = MAX(0, MIN(i, var->ndigits));
|
||||
}
|
||||
|
||||
var->rscale = scale;
|
||||
var->dscale = scale;
|
||||
|
Loading…
Reference in New Issue
Block a user