From b0b3187bb49c83a96904c21aa913b9409d121381 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 15 Jan 2000 23:44:17 +0000 Subject: [PATCH] Add some examples to numeric regress test to verify that recently-fixed problems are indeed fixed. --- src/test/regress/expected/numeric.out | 34 ++++++++++++++++++++++++++++++++++ src/test/regress/sql/numeric.sql | 18 ++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/src/test/regress/expected/numeric.out b/src/test/regress/expected/numeric.out index 0e17a35cf9..1f7901c701 100644 --- a/src/test/regress/expected/numeric.out +++ b/src/test/regress/expected/numeric.out @@ -660,3 +660,37 @@ SELECT t1.id1, t1.result, t2.expected -----+--------+---------- (0 rows) +-- ****************************** +-- * miscellaneous checks for things that have been broken in the past... +-- ****************************** +-- numeric AVG used to fail on some platforms +SELECT AVG(val) FROM num_data; + avg +---------------------- + -13430913.5922423207 +(1 row) + +-- Check for appropriate rounding and overflow +CREATE TABLE fract_only (id int, val numeric(4,4)); +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: overflow on numeric ABS(value) >= 10^0 for field with precision 4 scale 4 +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: overflow on numeric ABS(value) >= 10^0 for field with precision 4 scale 4 +INSERT INTO fract_only VALUES (7, '0.00001'); +INSERT INTO fract_only VALUES (8, '0.00017'); +SELECT * FROM fract_only; + id | val +----+--------- + 1 | 0.0000 + 2 | 0.1000 + 4 | -0.9999 + 5 | 0.9999 + 7 | 0.0000 + 8 | 0.0002 +(6 rows) + +DROP TABLE fract_only; diff --git a/src/test/regress/sql/numeric.sql b/src/test/regress/sql/numeric.sql index fdd7ade10c..7e9f333eb9 100644 --- a/src/test/regress/sql/numeric.sql +++ b/src/test/regress/sql/numeric.sql @@ -634,3 +634,21 @@ SELECT t1.id1, t1.result, t2.expected WHERE t1.id1 = t2.id AND t1.result != t2.expected; +-- ****************************** +-- * miscellaneous checks for things that have been broken in the past... +-- ****************************** +-- numeric AVG used to fail on some platforms +SELECT AVG(val) FROM num_data; + +-- Check for appropriate rounding and overflow +CREATE TABLE fract_only (id int, val numeric(4,4)); +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 +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 +INSERT INTO fract_only VALUES (7, '0.00001'); +INSERT INTO fract_only VALUES (8, '0.00017'); +SELECT * FROM fract_only; +DROP TABLE fract_only; -- 2.11.0