Commit bb885dd1 authored by Jan Wieck's avatar Jan Wieck

Check for NUMERIC overflow a second time after rounding

Jan
parent 0d5c8323
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* *
* 1998 Jan Wieck * 1998 Jan Wieck
* *
* $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.12 1999/05/04 15:50:24 thomas Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.13 1999/05/10 18:17:44 wieck Exp $
* *
* ---------- * ----------
*/ */
...@@ -2399,6 +2399,19 @@ apply_typmod(NumericVar *var, int32 typmod) ...@@ -2399,6 +2399,19 @@ apply_typmod(NumericVar *var, int32 typmod)
var->ndigits = MAX(0, MIN(i, var->ndigits)); var->ndigits = MAX(0, MIN(i, var->ndigits));
} }
/* ----------
* Check for overflow again - rounding could have raised the
* weight.
* ----------
*/
if (var->weight >= maxweight)
{
free_allvars();
elog(ERROR, "overflow on numeric "
"ABS(value) >= 10^%d for field with precision %d scale %d",
var->weight, precision, scale);
}
var->rscale = scale; var->rscale = scale;
var->dscale = scale; var->dscale = scale;
} }
......
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