diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2004-10-04 14:42:48 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2004-10-04 14:42:48 +0000 |
commit | 4171bb869f234281a13bb862d3b1e577bf336242 (patch) | |
tree | e8193f7be04ddd942f13811ef9bbe0494d24920d /src/backend/utils/adt/numeric.c | |
parent | 24201b4bc60e46e8de031fb5911af32bdb412d43 (diff) | |
download | postgresql-4171bb869f234281a13bb862d3b1e577bf336242.tar.gz postgresql-4171bb869f234281a13bb862d3b1e577bf336242.zip |
Detect overflow in integer arithmetic operators (integer, smallint, and
bigint variants). Clean up some inconsistencies in error message wording.
Fix scanint8 to allow trailing whitespace in INT64_MIN case. Update
int8-exp-three-digits.out, which seems to have been ignored by the last
couple of people to modify the int8 regression test, and remove
int8-exp-three-digits-win32.out which is thereby exposed as redundant.
Diffstat (limited to 'src/backend/utils/adt/numeric.c')
-rw-r--r-- | src/backend/utils/adt/numeric.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/backend/utils/adt/numeric.c b/src/backend/utils/adt/numeric.c index 9c8abfb365a..f99fb897153 100644 --- a/src/backend/utils/adt/numeric.c +++ b/src/backend/utils/adt/numeric.c @@ -14,7 +14,7 @@ * Copyright (c) 1998-2004, PostgreSQL Global Development Group * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/numeric.c,v 1.79 2004/08/30 02:54:39 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/numeric.c,v 1.80 2004/10/04 14:42:46 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1826,7 +1826,7 @@ numeric_int8(PG_FUNCTION_ARGS) if (NUMERIC_IS_NAN(num)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot convert NaN to integer"))); + errmsg("cannot convert NaN to bigint"))); /* Convert to variable format and thence to int8 */ init_var(&x); @@ -1835,7 +1835,7 @@ numeric_int8(PG_FUNCTION_ARGS) if (!numericvar_to_int8(&x, &result)) ereport(ERROR, (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), - errmsg("integer out of range"))); + errmsg("bigint out of range"))); free_var(&x); @@ -1874,7 +1874,7 @@ numeric_int2(PG_FUNCTION_ARGS) if (NUMERIC_IS_NAN(num)) ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), - errmsg("cannot convert NaN to integer"))); + errmsg("cannot convert NaN to smallint"))); /* Convert to variable format and thence to int8 */ init_var(&x); @@ -1883,7 +1883,7 @@ numeric_int2(PG_FUNCTION_ARGS) if (!numericvar_to_int8(&x, &val)) ereport(ERROR, (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), - errmsg("integer out of range"))); + errmsg("smallint out of range"))); free_var(&x); @@ -1894,7 +1894,7 @@ numeric_int2(PG_FUNCTION_ARGS) if ((int64) result != val) ereport(ERROR, (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), - errmsg("integer out of range"))); + errmsg("smallint out of range"))); PG_RETURN_INT16(result); } |