From b8854604d3a5186dae9f6416f5dbf3d71445e2a2 Mon Sep 17 00:00:00 2001 From: Jan Wieck Date: Mon, 10 May 1999 18:17:44 +0000 Subject: [PATCH] Check for NUMERIC overflow a second time after rounding Jan --- src/backend/utils/adt/numeric.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/backend/utils/adt/numeric.c b/src/backend/utils/adt/numeric.c index a84c330c56..7b185b4e51 100644 --- a/src/backend/utils/adt/numeric.c +++ b/src/backend/utils/adt/numeric.c @@ -2399,6 +2399,19 @@ apply_typmod(NumericVar *var, int32 typmod) 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->dscale = scale; } -- 2.39.5