From 760f763c9ff8cf955c02afeec9210afdfb1841c6 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Tue, 3 Oct 2006 21:25:56 +0000 Subject: [PATCH] Improve numeric overflow error message. David Fetter --- src/backend/utils/adt/numeric.c | 5 +++-- src/test/regress/expected/numeric.out | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/backend/utils/adt/numeric.c b/src/backend/utils/adt/numeric.c index 7be72cd61e..f9138956d8 100644 --- a/src/backend/utils/adt/numeric.c +++ b/src/backend/utils/adt/numeric.c @@ -3217,11 +3217,12 @@ apply_typmod(NumericVar *var, int32 typmod) ereport(ERROR, (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), errmsg("numeric field overflow"), - errdetail("A field with precision %d, scale %d must have an absolute value less than %s%d.", + errdetail("A field with precision %d, scale %d must round to an absolute value less than %s%d.", precision, scale, /* Display 10^0 as 1 */ maxdigits ? "10^" : "", - maxdigits ? maxdigits : 1))); + maxdigits ? maxdigits : 1 + ))); break; } ddigits -= DEC_DIGITS; diff --git a/src/test/regress/expected/numeric.out b/src/test/regress/expected/numeric.out index 08a4841458..96c70a8a09 100644 --- a/src/test/regress/expected/numeric.out +++ b/src/test/regress/expected/numeric.out @@ -688,12 +688,12 @@ INSERT INTO fract_only VALUES (1, '0.0'); INSERT INTO fract_only VALUES (2, '0.1'); INSERT INTO fract_only VALUES (3, '1.0'); -- should fail ERROR: numeric field overflow -DETAIL: A field with precision 4, scale 4 must have an absolute value less than 1. +DETAIL: A field with precision 4, scale 4 must round to an absolute value less than 1. INSERT INTO fract_only VALUES (4, '-0.9999'); INSERT INTO fract_only VALUES (5, '0.99994'); INSERT INTO fract_only VALUES (6, '0.99995'); -- should fail ERROR: numeric field overflow -DETAIL: A field with precision 4, scale 4 must have an absolute value less than 1. +DETAIL: A field with precision 4, scale 4 must round to an absolute value less than 1. INSERT INTO fract_only VALUES (7, '0.00001'); INSERT INTO fract_only VALUES (8, '0.00017'); SELECT * FROM fract_only; -- 2.39.5