Skip to content

Commit bb885dd

Browse files
Jan WieckJan Wieck
authored andcommitted
Check for NUMERIC overflow a second time after rounding
Jan
1 parent 0d5c832 commit bb885dd

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/backend/utils/adt/numeric.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* 1998 Jan Wieck
77
*
8-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.12 1999/05/04 15:50:24 thomas Exp $
8+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.13 1999/05/10 18:17:44 wieck Exp $
99
*
1010
* ----------
1111
*/
@@ -2399,6 +2399,19 @@ apply_typmod(NumericVar *var, int32 typmod)
23992399
var->ndigits = MAX(0, MIN(i, var->ndigits));
24002400
}
24012401

2402+
/* ----------
2403+
* Check for overflow again - rounding could have raised the
2404+
* weight.
2405+
* ----------
2406+
*/
2407+
if (var->weight >= maxweight)
2408+
{
2409+
free_allvars();
2410+
elog(ERROR, "overflow on numeric "
2411+
"ABS(value) >= 10^%d for field with precision %d scale %d",
2412+
var->weight, precision, scale);
2413+
}
2414+
24022415
var->rscale = scale;
24032416
var->dscale = scale;
24042417
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy