Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb0b3187

Browse files
committed
Add some examples to numeric regress test to verify that recently-fixed
problems are indeed fixed.
1 parent3cb8c8d commitb0b3187

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

‎src/test/regress/expected/numeric.out

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,3 +660,37 @@ SELECT t1.id1, t1.result, t2.expected
660660
-----+--------+----------
661661
(0 rows)
662662

663+
-- ******************************
664+
-- * miscellaneous checks for things that have been broken in the past...
665+
-- ******************************
666+
-- numeric AVG used to fail on some platforms
667+
SELECT AVG(val) FROM num_data;
668+
avg
669+
----------------------
670+
-13430913.5922423207
671+
(1 row)
672+
673+
-- Check for appropriate rounding and overflow
674+
CREATE TABLE fract_only (id int, val numeric(4,4));
675+
INSERT INTO fract_only VALUES (1, '0.0');
676+
INSERT INTO fract_only VALUES (2, '0.1');
677+
INSERT INTO fract_only VALUES (3, '1.0');-- should fail
678+
ERROR: overflow on numeric ABS(value) >= 10^0 for field with precision 4 scale 4
679+
INSERT INTO fract_only VALUES (4, '-0.9999');
680+
INSERT INTO fract_only VALUES (5, '0.99994');
681+
INSERT INTO fract_only VALUES (6, '0.99995'); -- should fail
682+
ERROR: overflow on numeric ABS(value) >= 10^0 for field with precision 4 scale 4
683+
INSERT INTO fract_only VALUES (7, '0.00001');
684+
INSERT INTO fract_only VALUES (8, '0.00017');
685+
SELECT * FROM fract_only;
686+
id | val
687+
----+---------
688+
1 | 0.0000
689+
2 | 0.1000
690+
4 | -0.9999
691+
5 | 0.9999
692+
7 | 0.0000
693+
8 | 0.0002
694+
(6 rows)
695+
696+
DROP TABLE fract_only;

‎src/test/regress/sql/numeric.sql

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,3 +634,21 @@ SELECT t1.id1, t1.result, t2.expected
634634
WHEREt1.id1=t2.id
635635
ANDt1.result!=t2.expected;
636636

637+
-- ******************************
638+
-- * miscellaneous checks for things that have been broken in the past...
639+
-- ******************************
640+
-- numeric AVG used to fail on some platforms
641+
SELECTAVG(val)FROM num_data;
642+
643+
-- Check for appropriate rounding and overflow
644+
CREATETABLEfract_only (idint, valnumeric(4,4));
645+
INSERT INTO fract_onlyVALUES (1,'0.0');
646+
INSERT INTO fract_onlyVALUES (2,'0.1');
647+
INSERT INTO fract_onlyVALUES (3,'1.0');-- should fail
648+
INSERT INTO fract_onlyVALUES (4,'-0.9999');
649+
INSERT INTO fract_onlyVALUES (5,'0.99994');
650+
INSERT INTO fract_onlyVALUES (6,'0.99995');-- should fail
651+
INSERT INTO fract_onlyVALUES (7,'0.00001');
652+
INSERT INTO fract_onlyVALUES (8,'0.00017');
653+
SELECT*FROM fract_only;
654+
DROPTABLE fract_only;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp