Check for NUMERIC overflow a second time after rounding
authorJan Wieck <JanWieck@Yahoo.com>
Mon, 10 May 1999 18:17:44 +0000 (18:17 +0000)
committerJan Wieck <JanWieck@Yahoo.com>
Mon, 10 May 1999 18:17:44 +0000 (18:17 +0000)
Jan

src/backend/utils/adt/numeric.c

index a84c330c56785306f38c7cb1a0b51d9a976be52c..7b185b4e518fbd9185c1242f447aa3f9ca7c3862 100644 (file)
@@ -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;
 }