mirror of
https://github.com/postgres/postgres.git
synced 2025-05-01 01:04:50 +03:00
Remove no-longer-needed variant expected regression result files.
numerology_1.out and float8-small-is-zero_1.out differ from their base files only in showing plain zero rather than minus zero for some results. I believe that in the wake of commit 6eb3eb577, we will print minus zero as such on all IEEE-float platforms (and non-IEEE floats are going to cause many more regression diffs than this, anyway). Hence we should be able to remove these and eliminate a bit of maintenance pain. Let's see if the buildfarm agrees. Discussion: https://postgr.es/m/29037.1539021687@sss.pgh.pa.us
This commit is contained in:
parent
aed9fa0bd8
commit
6eb4378d53
@ -1,584 +0,0 @@
|
|||||||
--
|
|
||||||
-- FLOAT8
|
|
||||||
--
|
|
||||||
CREATE TABLE FLOAT8_TBL(f1 float8);
|
|
||||||
INSERT INTO FLOAT8_TBL(f1) VALUES (' 0.0 ');
|
|
||||||
INSERT INTO FLOAT8_TBL(f1) VALUES ('1004.30 ');
|
|
||||||
INSERT INTO FLOAT8_TBL(f1) VALUES (' -34.84');
|
|
||||||
INSERT INTO FLOAT8_TBL(f1) VALUES ('1.2345678901234e+200');
|
|
||||||
INSERT INTO FLOAT8_TBL(f1) VALUES ('1.2345678901234e-200');
|
|
||||||
-- test for underflow and overflow handling
|
|
||||||
SELECT '10e400'::float8;
|
|
||||||
ERROR: "10e400" is out of range for type double precision
|
|
||||||
LINE 1: SELECT '10e400'::float8;
|
|
||||||
^
|
|
||||||
SELECT '-10e400'::float8;
|
|
||||||
ERROR: "-10e400" is out of range for type double precision
|
|
||||||
LINE 1: SELECT '-10e400'::float8;
|
|
||||||
^
|
|
||||||
SELECT '10e-400'::float8;
|
|
||||||
float8
|
|
||||||
--------
|
|
||||||
0
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT '-10e-400'::float8;
|
|
||||||
float8
|
|
||||||
--------
|
|
||||||
0
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
-- bad input
|
|
||||||
INSERT INTO FLOAT8_TBL(f1) VALUES ('');
|
|
||||||
ERROR: invalid input syntax for type double precision: ""
|
|
||||||
LINE 1: INSERT INTO FLOAT8_TBL(f1) VALUES ('');
|
|
||||||
^
|
|
||||||
INSERT INTO FLOAT8_TBL(f1) VALUES (' ');
|
|
||||||
ERROR: invalid input syntax for type double precision: " "
|
|
||||||
LINE 1: INSERT INTO FLOAT8_TBL(f1) VALUES (' ');
|
|
||||||
^
|
|
||||||
INSERT INTO FLOAT8_TBL(f1) VALUES ('xyz');
|
|
||||||
ERROR: invalid input syntax for type double precision: "xyz"
|
|
||||||
LINE 1: INSERT INTO FLOAT8_TBL(f1) VALUES ('xyz');
|
|
||||||
^
|
|
||||||
INSERT INTO FLOAT8_TBL(f1) VALUES ('5.0.0');
|
|
||||||
ERROR: invalid input syntax for type double precision: "5.0.0"
|
|
||||||
LINE 1: INSERT INTO FLOAT8_TBL(f1) VALUES ('5.0.0');
|
|
||||||
^
|
|
||||||
INSERT INTO FLOAT8_TBL(f1) VALUES ('5 . 0');
|
|
||||||
ERROR: invalid input syntax for type double precision: "5 . 0"
|
|
||||||
LINE 1: INSERT INTO FLOAT8_TBL(f1) VALUES ('5 . 0');
|
|
||||||
^
|
|
||||||
INSERT INTO FLOAT8_TBL(f1) VALUES ('5. 0');
|
|
||||||
ERROR: invalid input syntax for type double precision: "5. 0"
|
|
||||||
LINE 1: INSERT INTO FLOAT8_TBL(f1) VALUES ('5. 0');
|
|
||||||
^
|
|
||||||
INSERT INTO FLOAT8_TBL(f1) VALUES (' - 3');
|
|
||||||
ERROR: invalid input syntax for type double precision: " - 3"
|
|
||||||
LINE 1: INSERT INTO FLOAT8_TBL(f1) VALUES (' - 3');
|
|
||||||
^
|
|
||||||
INSERT INTO FLOAT8_TBL(f1) VALUES ('123 5');
|
|
||||||
ERROR: invalid input syntax for type double precision: "123 5"
|
|
||||||
LINE 1: INSERT INTO FLOAT8_TBL(f1) VALUES ('123 5');
|
|
||||||
^
|
|
||||||
-- special inputs
|
|
||||||
SELECT 'NaN'::float8;
|
|
||||||
float8
|
|
||||||
--------
|
|
||||||
NaN
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT 'nan'::float8;
|
|
||||||
float8
|
|
||||||
--------
|
|
||||||
NaN
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT ' NAN '::float8;
|
|
||||||
float8
|
|
||||||
--------
|
|
||||||
NaN
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT 'infinity'::float8;
|
|
||||||
float8
|
|
||||||
----------
|
|
||||||
Infinity
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT ' -INFINiTY '::float8;
|
|
||||||
float8
|
|
||||||
-----------
|
|
||||||
-Infinity
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
-- bad special inputs
|
|
||||||
SELECT 'N A N'::float8;
|
|
||||||
ERROR: invalid input syntax for type double precision: "N A N"
|
|
||||||
LINE 1: SELECT 'N A N'::float8;
|
|
||||||
^
|
|
||||||
SELECT 'NaN x'::float8;
|
|
||||||
ERROR: invalid input syntax for type double precision: "NaN x"
|
|
||||||
LINE 1: SELECT 'NaN x'::float8;
|
|
||||||
^
|
|
||||||
SELECT ' INFINITY x'::float8;
|
|
||||||
ERROR: invalid input syntax for type double precision: " INFINITY x"
|
|
||||||
LINE 1: SELECT ' INFINITY x'::float8;
|
|
||||||
^
|
|
||||||
SELECT 'Infinity'::float8 + 100.0;
|
|
||||||
?column?
|
|
||||||
----------
|
|
||||||
Infinity
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT 'Infinity'::float8 / 'Infinity'::float8;
|
|
||||||
?column?
|
|
||||||
----------
|
|
||||||
NaN
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT 'nan'::float8 / 'nan'::float8;
|
|
||||||
?column?
|
|
||||||
----------
|
|
||||||
NaN
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT 'nan'::numeric::float8;
|
|
||||||
float8
|
|
||||||
--------
|
|
||||||
NaN
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT '' AS five, * FROM FLOAT8_TBL;
|
|
||||||
five | f1
|
|
||||||
------+----------------------
|
|
||||||
| 0
|
|
||||||
| 1004.3
|
|
||||||
| -34.84
|
|
||||||
| 1.2345678901234e+200
|
|
||||||
| 1.2345678901234e-200
|
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
SELECT '' AS four, f.* FROM FLOAT8_TBL f WHERE f.f1 <> '1004.3';
|
|
||||||
four | f1
|
|
||||||
------+----------------------
|
|
||||||
| 0
|
|
||||||
| -34.84
|
|
||||||
| 1.2345678901234e+200
|
|
||||||
| 1.2345678901234e-200
|
|
||||||
(4 rows)
|
|
||||||
|
|
||||||
SELECT '' AS one, f.* FROM FLOAT8_TBL f WHERE f.f1 = '1004.3';
|
|
||||||
one | f1
|
|
||||||
-----+--------
|
|
||||||
| 1004.3
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT '' AS three, f.* FROM FLOAT8_TBL f WHERE '1004.3' > f.f1;
|
|
||||||
three | f1
|
|
||||||
-------+----------------------
|
|
||||||
| 0
|
|
||||||
| -34.84
|
|
||||||
| 1.2345678901234e-200
|
|
||||||
(3 rows)
|
|
||||||
|
|
||||||
SELECT '' AS three, f.* FROM FLOAT8_TBL f WHERE f.f1 < '1004.3';
|
|
||||||
three | f1
|
|
||||||
-------+----------------------
|
|
||||||
| 0
|
|
||||||
| -34.84
|
|
||||||
| 1.2345678901234e-200
|
|
||||||
(3 rows)
|
|
||||||
|
|
||||||
SELECT '' AS four, f.* FROM FLOAT8_TBL f WHERE '1004.3' >= f.f1;
|
|
||||||
four | f1
|
|
||||||
------+----------------------
|
|
||||||
| 0
|
|
||||||
| 1004.3
|
|
||||||
| -34.84
|
|
||||||
| 1.2345678901234e-200
|
|
||||||
(4 rows)
|
|
||||||
|
|
||||||
SELECT '' AS four, f.* FROM FLOAT8_TBL f WHERE f.f1 <= '1004.3';
|
|
||||||
four | f1
|
|
||||||
------+----------------------
|
|
||||||
| 0
|
|
||||||
| 1004.3
|
|
||||||
| -34.84
|
|
||||||
| 1.2345678901234e-200
|
|
||||||
(4 rows)
|
|
||||||
|
|
||||||
SELECT '' AS three, f.f1, f.f1 * '-10' AS x
|
|
||||||
FROM FLOAT8_TBL f
|
|
||||||
WHERE f.f1 > '0.0';
|
|
||||||
three | f1 | x
|
|
||||||
-------+----------------------+-----------------------
|
|
||||||
| 1004.3 | -10043
|
|
||||||
| 1.2345678901234e+200 | -1.2345678901234e+201
|
|
||||||
| 1.2345678901234e-200 | -1.2345678901234e-199
|
|
||||||
(3 rows)
|
|
||||||
|
|
||||||
SELECT '' AS three, f.f1, f.f1 + '-10' AS x
|
|
||||||
FROM FLOAT8_TBL f
|
|
||||||
WHERE f.f1 > '0.0';
|
|
||||||
three | f1 | x
|
|
||||||
-------+----------------------+----------------------
|
|
||||||
| 1004.3 | 994.3
|
|
||||||
| 1.2345678901234e+200 | 1.2345678901234e+200
|
|
||||||
| 1.2345678901234e-200 | -10
|
|
||||||
(3 rows)
|
|
||||||
|
|
||||||
SELECT '' AS three, f.f1, f.f1 / '-10' AS x
|
|
||||||
FROM FLOAT8_TBL f
|
|
||||||
WHERE f.f1 > '0.0';
|
|
||||||
three | f1 | x
|
|
||||||
-------+----------------------+-----------------------
|
|
||||||
| 1004.3 | -100.43
|
|
||||||
| 1.2345678901234e+200 | -1.2345678901234e+199
|
|
||||||
| 1.2345678901234e-200 | -1.2345678901234e-201
|
|
||||||
(3 rows)
|
|
||||||
|
|
||||||
SELECT '' AS three, f.f1, f.f1 - '-10' AS x
|
|
||||||
FROM FLOAT8_TBL f
|
|
||||||
WHERE f.f1 > '0.0';
|
|
||||||
three | f1 | x
|
|
||||||
-------+----------------------+----------------------
|
|
||||||
| 1004.3 | 1014.3
|
|
||||||
| 1.2345678901234e+200 | 1.2345678901234e+200
|
|
||||||
| 1.2345678901234e-200 | 10
|
|
||||||
(3 rows)
|
|
||||||
|
|
||||||
SELECT '' AS one, f.f1 ^ '2.0' AS square_f1
|
|
||||||
FROM FLOAT8_TBL f where f.f1 = '1004.3';
|
|
||||||
one | square_f1
|
|
||||||
-----+------------
|
|
||||||
| 1008618.49
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
-- absolute value
|
|
||||||
SELECT '' AS five, f.f1, @f.f1 AS abs_f1
|
|
||||||
FROM FLOAT8_TBL f;
|
|
||||||
five | f1 | abs_f1
|
|
||||||
------+----------------------+----------------------
|
|
||||||
| 0 | 0
|
|
||||||
| 1004.3 | 1004.3
|
|
||||||
| -34.84 | 34.84
|
|
||||||
| 1.2345678901234e+200 | 1.2345678901234e+200
|
|
||||||
| 1.2345678901234e-200 | 1.2345678901234e-200
|
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
-- truncate
|
|
||||||
SELECT '' AS five, f.f1, trunc(f.f1) AS trunc_f1
|
|
||||||
FROM FLOAT8_TBL f;
|
|
||||||
five | f1 | trunc_f1
|
|
||||||
------+----------------------+----------------------
|
|
||||||
| 0 | 0
|
|
||||||
| 1004.3 | 1004
|
|
||||||
| -34.84 | -34
|
|
||||||
| 1.2345678901234e+200 | 1.2345678901234e+200
|
|
||||||
| 1.2345678901234e-200 | 0
|
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
-- round
|
|
||||||
SELECT '' AS five, f.f1, round(f.f1) AS round_f1
|
|
||||||
FROM FLOAT8_TBL f;
|
|
||||||
five | f1 | round_f1
|
|
||||||
------+----------------------+----------------------
|
|
||||||
| 0 | 0
|
|
||||||
| 1004.3 | 1004
|
|
||||||
| -34.84 | -35
|
|
||||||
| 1.2345678901234e+200 | 1.2345678901234e+200
|
|
||||||
| 1.2345678901234e-200 | 0
|
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
-- ceil / ceiling
|
|
||||||
select ceil(f1) as ceil_f1 from float8_tbl f;
|
|
||||||
ceil_f1
|
|
||||||
----------------------
|
|
||||||
0
|
|
||||||
1005
|
|
||||||
-34
|
|
||||||
1.2345678901234e+200
|
|
||||||
1
|
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
select ceiling(f1) as ceiling_f1 from float8_tbl f;
|
|
||||||
ceiling_f1
|
|
||||||
----------------------
|
|
||||||
0
|
|
||||||
1005
|
|
||||||
-34
|
|
||||||
1.2345678901234e+200
|
|
||||||
1
|
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
-- floor
|
|
||||||
select floor(f1) as floor_f1 from float8_tbl f;
|
|
||||||
floor_f1
|
|
||||||
----------------------
|
|
||||||
0
|
|
||||||
1004
|
|
||||||
-35
|
|
||||||
1.2345678901234e+200
|
|
||||||
0
|
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
-- sign
|
|
||||||
select sign(f1) as sign_f1 from float8_tbl f;
|
|
||||||
sign_f1
|
|
||||||
---------
|
|
||||||
0
|
|
||||||
1
|
|
||||||
-1
|
|
||||||
1
|
|
||||||
1
|
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
-- square root
|
|
||||||
SELECT sqrt(float8 '64') AS eight;
|
|
||||||
eight
|
|
||||||
-------
|
|
||||||
8
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT |/ float8 '64' AS eight;
|
|
||||||
eight
|
|
||||||
-------
|
|
||||||
8
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT '' AS three, f.f1, |/f.f1 AS sqrt_f1
|
|
||||||
FROM FLOAT8_TBL f
|
|
||||||
WHERE f.f1 > '0.0';
|
|
||||||
three | f1 | sqrt_f1
|
|
||||||
-------+----------------------+-----------------------
|
|
||||||
| 1004.3 | 31.6906926399535
|
|
||||||
| 1.2345678901234e+200 | 1.11111110611109e+100
|
|
||||||
| 1.2345678901234e-200 | 1.11111110611109e-100
|
|
||||||
(3 rows)
|
|
||||||
|
|
||||||
-- power
|
|
||||||
SELECT power(float8 '144', float8 '0.5');
|
|
||||||
power
|
|
||||||
-------
|
|
||||||
12
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT power(float8 'NaN', float8 '0.5');
|
|
||||||
power
|
|
||||||
-------
|
|
||||||
NaN
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT power(float8 '144', float8 'NaN');
|
|
||||||
power
|
|
||||||
-------
|
|
||||||
NaN
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT power(float8 'NaN', float8 'NaN');
|
|
||||||
power
|
|
||||||
-------
|
|
||||||
NaN
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT power(float8 '-1', float8 'NaN');
|
|
||||||
power
|
|
||||||
-------
|
|
||||||
NaN
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT power(float8 '1', float8 'NaN');
|
|
||||||
power
|
|
||||||
-------
|
|
||||||
1
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT power(float8 'NaN', float8 '0');
|
|
||||||
power
|
|
||||||
-------
|
|
||||||
1
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
-- take exp of ln(f.f1)
|
|
||||||
SELECT '' AS three, f.f1, exp(ln(f.f1)) AS exp_ln_f1
|
|
||||||
FROM FLOAT8_TBL f
|
|
||||||
WHERE f.f1 > '0.0';
|
|
||||||
three | f1 | exp_ln_f1
|
|
||||||
-------+----------------------+-----------------------
|
|
||||||
| 1004.3 | 1004.3
|
|
||||||
| 1.2345678901234e+200 | 1.23456789012338e+200
|
|
||||||
| 1.2345678901234e-200 | 1.23456789012339e-200
|
|
||||||
(3 rows)
|
|
||||||
|
|
||||||
-- cube root
|
|
||||||
SELECT ||/ float8 '27' AS three;
|
|
||||||
three
|
|
||||||
-------
|
|
||||||
3
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT '' AS five, f.f1, ||/f.f1 AS cbrt_f1 FROM FLOAT8_TBL f;
|
|
||||||
five | f1 | cbrt_f1
|
|
||||||
------+----------------------+----------------------
|
|
||||||
| 0 | 0
|
|
||||||
| 1004.3 | 10.014312837827
|
|
||||||
| -34.84 | -3.26607421344208
|
|
||||||
| 1.2345678901234e+200 | 4.97933859234765e+66
|
|
||||||
| 1.2345678901234e-200 | 2.3112042409018e-67
|
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
SELECT '' AS five, * FROM FLOAT8_TBL;
|
|
||||||
five | f1
|
|
||||||
------+----------------------
|
|
||||||
| 0
|
|
||||||
| 1004.3
|
|
||||||
| -34.84
|
|
||||||
| 1.2345678901234e+200
|
|
||||||
| 1.2345678901234e-200
|
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
UPDATE FLOAT8_TBL
|
|
||||||
SET f1 = FLOAT8_TBL.f1 * '-1'
|
|
||||||
WHERE FLOAT8_TBL.f1 > '0.0';
|
|
||||||
SELECT '' AS bad, f.f1 * '1e200' from FLOAT8_TBL f;
|
|
||||||
ERROR: value out of range: overflow
|
|
||||||
SELECT '' AS bad, f.f1 ^ '1e200' from FLOAT8_TBL f;
|
|
||||||
ERROR: value out of range: overflow
|
|
||||||
SELECT 0 ^ 0 + 0 ^ 1 + 0 ^ 0.0 + 0 ^ 0.5;
|
|
||||||
?column?
|
|
||||||
----------
|
|
||||||
2
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
SELECT '' AS bad, ln(f.f1) from FLOAT8_TBL f where f.f1 = '0.0' ;
|
|
||||||
ERROR: cannot take logarithm of zero
|
|
||||||
SELECT '' AS bad, ln(f.f1) from FLOAT8_TBL f where f.f1 < '0.0' ;
|
|
||||||
ERROR: cannot take logarithm of a negative number
|
|
||||||
SELECT '' AS bad, exp(f.f1) from FLOAT8_TBL f;
|
|
||||||
ERROR: value out of range: underflow
|
|
||||||
SELECT '' AS bad, f.f1 / '0.0' from FLOAT8_TBL f;
|
|
||||||
ERROR: division by zero
|
|
||||||
SELECT '' AS five, * FROM FLOAT8_TBL;
|
|
||||||
five | f1
|
|
||||||
------+-----------------------
|
|
||||||
| 0
|
|
||||||
| -34.84
|
|
||||||
| -1004.3
|
|
||||||
| -1.2345678901234e+200
|
|
||||||
| -1.2345678901234e-200
|
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
-- test for over- and underflow
|
|
||||||
INSERT INTO FLOAT8_TBL(f1) VALUES ('10e400');
|
|
||||||
ERROR: "10e400" is out of range for type double precision
|
|
||||||
LINE 1: INSERT INTO FLOAT8_TBL(f1) VALUES ('10e400');
|
|
||||||
^
|
|
||||||
INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e400');
|
|
||||||
ERROR: "-10e400" is out of range for type double precision
|
|
||||||
LINE 1: INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e400');
|
|
||||||
^
|
|
||||||
INSERT INTO FLOAT8_TBL(f1) VALUES ('10e-400');
|
|
||||||
INSERT INTO FLOAT8_TBL(f1) VALUES ('-10e-400');
|
|
||||||
-- maintain external table consistency across platforms
|
|
||||||
-- delete all values and reinsert well-behaved ones
|
|
||||||
DELETE FROM FLOAT8_TBL;
|
|
||||||
INSERT INTO FLOAT8_TBL(f1) VALUES ('0.0');
|
|
||||||
INSERT INTO FLOAT8_TBL(f1) VALUES ('-34.84');
|
|
||||||
INSERT INTO FLOAT8_TBL(f1) VALUES ('-1004.30');
|
|
||||||
INSERT INTO FLOAT8_TBL(f1) VALUES ('-1.2345678901234e+200');
|
|
||||||
INSERT INTO FLOAT8_TBL(f1) VALUES ('-1.2345678901234e-200');
|
|
||||||
SELECT '' AS five, * FROM FLOAT8_TBL;
|
|
||||||
five | f1
|
|
||||||
------+-----------------------
|
|
||||||
| 0
|
|
||||||
| -34.84
|
|
||||||
| -1004.3
|
|
||||||
| -1.2345678901234e+200
|
|
||||||
| -1.2345678901234e-200
|
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
-- test exact cases for trigonometric functions in degrees
|
|
||||||
SET extra_float_digits = 3;
|
|
||||||
SELECT x,
|
|
||||||
sind(x),
|
|
||||||
sind(x) IN (-1,-0.5,0,0.5,1) AS sind_exact
|
|
||||||
FROM (VALUES (0), (30), (90), (150), (180),
|
|
||||||
(210), (270), (330), (360)) AS t(x);
|
|
||||||
x | sind | sind_exact
|
|
||||||
-----+------+------------
|
|
||||||
0 | 0 | t
|
|
||||||
30 | 0.5 | t
|
|
||||||
90 | 1 | t
|
|
||||||
150 | 0.5 | t
|
|
||||||
180 | 0 | t
|
|
||||||
210 | -0.5 | t
|
|
||||||
270 | -1 | t
|
|
||||||
330 | -0.5 | t
|
|
||||||
360 | 0 | t
|
|
||||||
(9 rows)
|
|
||||||
|
|
||||||
SELECT x,
|
|
||||||
cosd(x),
|
|
||||||
cosd(x) IN (-1,-0.5,0,0.5,1) AS cosd_exact
|
|
||||||
FROM (VALUES (0), (60), (90), (120), (180),
|
|
||||||
(240), (270), (300), (360)) AS t(x);
|
|
||||||
x | cosd | cosd_exact
|
|
||||||
-----+------+------------
|
|
||||||
0 | 1 | t
|
|
||||||
60 | 0.5 | t
|
|
||||||
90 | 0 | t
|
|
||||||
120 | -0.5 | t
|
|
||||||
180 | -1 | t
|
|
||||||
240 | -0.5 | t
|
|
||||||
270 | 0 | t
|
|
||||||
300 | 0.5 | t
|
|
||||||
360 | 1 | t
|
|
||||||
(9 rows)
|
|
||||||
|
|
||||||
SELECT x,
|
|
||||||
tand(x),
|
|
||||||
tand(x) IN ('-Infinity'::float8,-1,0,
|
|
||||||
1,'Infinity'::float8) AS tand_exact,
|
|
||||||
cotd(x),
|
|
||||||
cotd(x) IN ('-Infinity'::float8,-1,0,
|
|
||||||
1,'Infinity'::float8) AS cotd_exact
|
|
||||||
FROM (VALUES (0), (45), (90), (135), (180),
|
|
||||||
(225), (270), (315), (360)) AS t(x);
|
|
||||||
x | tand | tand_exact | cotd | cotd_exact
|
|
||||||
-----+-----------+------------+-----------+------------
|
|
||||||
0 | 0 | t | Infinity | t
|
|
||||||
45 | 1 | t | 1 | t
|
|
||||||
90 | Infinity | t | 0 | t
|
|
||||||
135 | -1 | t | -1 | t
|
|
||||||
180 | 0 | t | -Infinity | t
|
|
||||||
225 | 1 | t | 1 | t
|
|
||||||
270 | -Infinity | t | 0 | t
|
|
||||||
315 | -1 | t | -1 | t
|
|
||||||
360 | 0 | t | Infinity | t
|
|
||||||
(9 rows)
|
|
||||||
|
|
||||||
SELECT x,
|
|
||||||
asind(x),
|
|
||||||
asind(x) IN (-90,-30,0,30,90) AS asind_exact,
|
|
||||||
acosd(x),
|
|
||||||
acosd(x) IN (0,60,90,120,180) AS acosd_exact
|
|
||||||
FROM (VALUES (-1), (-0.5), (0), (0.5), (1)) AS t(x);
|
|
||||||
x | asind | asind_exact | acosd | acosd_exact
|
|
||||||
------+-------+-------------+-------+-------------
|
|
||||||
-1 | -90 | t | 180 | t
|
|
||||||
-0.5 | -30 | t | 120 | t
|
|
||||||
0 | 0 | t | 90 | t
|
|
||||||
0.5 | 30 | t | 60 | t
|
|
||||||
1 | 90 | t | 0 | t
|
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
SELECT x,
|
|
||||||
atand(x),
|
|
||||||
atand(x) IN (-90,-45,0,45,90) AS atand_exact
|
|
||||||
FROM (VALUES ('-Infinity'::float8), (-1), (0), (1),
|
|
||||||
('Infinity'::float8)) AS t(x);
|
|
||||||
x | atand | atand_exact
|
|
||||||
-----------+-------+-------------
|
|
||||||
-Infinity | -90 | t
|
|
||||||
-1 | -45 | t
|
|
||||||
0 | 0 | t
|
|
||||||
1 | 45 | t
|
|
||||||
Infinity | 90 | t
|
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
SELECT x, y,
|
|
||||||
atan2d(y, x),
|
|
||||||
atan2d(y, x) IN (-90,0,90,180) AS atan2d_exact
|
|
||||||
FROM (SELECT 10*cosd(a), 10*sind(a)
|
|
||||||
FROM generate_series(0, 360, 90) AS t(a)) AS t(x,y);
|
|
||||||
x | y | atan2d | atan2d_exact
|
|
||||||
-----+-----+--------+--------------
|
|
||||||
10 | 0 | 0 | t
|
|
||||||
0 | 10 | 90 | t
|
|
||||||
-10 | 0 | 180 | t
|
|
||||||
0 | -10 | -90 | t
|
|
||||||
10 | 0 | 0 | t
|
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
RESET extra_float_digits;
|
|
@ -1,136 +0,0 @@
|
|||||||
--
|
|
||||||
-- NUMEROLOGY
|
|
||||||
-- Test various combinations of numeric types and functions.
|
|
||||||
--
|
|
||||||
--
|
|
||||||
-- Test implicit type conversions
|
|
||||||
-- This fails for Postgres v6.1 (and earlier?)
|
|
||||||
-- so let's try explicit conversions for now - tgl 97/05/07
|
|
||||||
--
|
|
||||||
CREATE TABLE TEMP_FLOAT (f1 FLOAT8);
|
|
||||||
INSERT INTO TEMP_FLOAT (f1)
|
|
||||||
SELECT float8(f1) FROM INT4_TBL;
|
|
||||||
INSERT INTO TEMP_FLOAT (f1)
|
|
||||||
SELECT float8(f1) FROM INT2_TBL;
|
|
||||||
SELECT '' AS ten, f1 FROM TEMP_FLOAT
|
|
||||||
ORDER BY f1;
|
|
||||||
ten | f1
|
|
||||||
-----+-------------
|
|
||||||
| -2147483647
|
|
||||||
| -123456
|
|
||||||
| -32767
|
|
||||||
| -1234
|
|
||||||
| 0
|
|
||||||
| 0
|
|
||||||
| 1234
|
|
||||||
| 32767
|
|
||||||
| 123456
|
|
||||||
| 2147483647
|
|
||||||
(10 rows)
|
|
||||||
|
|
||||||
-- int4
|
|
||||||
CREATE TABLE TEMP_INT4 (f1 INT4);
|
|
||||||
INSERT INTO TEMP_INT4 (f1)
|
|
||||||
SELECT int4(f1) FROM FLOAT8_TBL
|
|
||||||
WHERE (f1 > -2147483647) AND (f1 < 2147483647);
|
|
||||||
INSERT INTO TEMP_INT4 (f1)
|
|
||||||
SELECT int4(f1) FROM INT2_TBL;
|
|
||||||
SELECT '' AS nine, f1 FROM TEMP_INT4
|
|
||||||
ORDER BY f1;
|
|
||||||
nine | f1
|
|
||||||
------+--------
|
|
||||||
| -32767
|
|
||||||
| -1234
|
|
||||||
| -1004
|
|
||||||
| -35
|
|
||||||
| 0
|
|
||||||
| 0
|
|
||||||
| 0
|
|
||||||
| 1234
|
|
||||||
| 32767
|
|
||||||
(9 rows)
|
|
||||||
|
|
||||||
-- int2
|
|
||||||
CREATE TABLE TEMP_INT2 (f1 INT2);
|
|
||||||
INSERT INTO TEMP_INT2 (f1)
|
|
||||||
SELECT int2(f1) FROM FLOAT8_TBL
|
|
||||||
WHERE (f1 >= -32767) AND (f1 <= 32767);
|
|
||||||
INSERT INTO TEMP_INT2 (f1)
|
|
||||||
SELECT int2(f1) FROM INT4_TBL
|
|
||||||
WHERE (f1 >= -32767) AND (f1 <= 32767);
|
|
||||||
SELECT '' AS five, f1 FROM TEMP_INT2
|
|
||||||
ORDER BY f1;
|
|
||||||
five | f1
|
|
||||||
------+-------
|
|
||||||
| -1004
|
|
||||||
| -35
|
|
||||||
| 0
|
|
||||||
| 0
|
|
||||||
| 0
|
|
||||||
(5 rows)
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Group-by combinations
|
|
||||||
--
|
|
||||||
CREATE TABLE TEMP_GROUP (f1 INT4, f2 INT4, f3 FLOAT8);
|
|
||||||
INSERT INTO TEMP_GROUP
|
|
||||||
SELECT 1, (- i.f1), (- f.f1)
|
|
||||||
FROM INT4_TBL i, FLOAT8_TBL f;
|
|
||||||
INSERT INTO TEMP_GROUP
|
|
||||||
SELECT 2, i.f1, f.f1
|
|
||||||
FROM INT4_TBL i, FLOAT8_TBL f;
|
|
||||||
SELECT DISTINCT f1 AS two FROM TEMP_GROUP ORDER BY 1;
|
|
||||||
two
|
|
||||||
-----
|
|
||||||
1
|
|
||||||
2
|
|
||||||
(2 rows)
|
|
||||||
|
|
||||||
SELECT f1 AS two, max(f3) AS max_float, min(f3) as min_float
|
|
||||||
FROM TEMP_GROUP
|
|
||||||
GROUP BY f1
|
|
||||||
ORDER BY two, max_float, min_float;
|
|
||||||
two | max_float | min_float
|
|
||||||
-----+----------------------+-----------------------
|
|
||||||
1 | 1.2345678901234e+200 | 0
|
|
||||||
2 | 0 | -1.2345678901234e+200
|
|
||||||
(2 rows)
|
|
||||||
|
|
||||||
-- GROUP BY a result column name is not legal per SQL92, but we accept it
|
|
||||||
-- anyway (if the name is not the name of any column exposed by FROM).
|
|
||||||
SELECT f1 AS two, max(f3) AS max_float, min(f3) AS min_float
|
|
||||||
FROM TEMP_GROUP
|
|
||||||
GROUP BY two
|
|
||||||
ORDER BY two, max_float, min_float;
|
|
||||||
two | max_float | min_float
|
|
||||||
-----+----------------------+-----------------------
|
|
||||||
1 | 1.2345678901234e+200 | 0
|
|
||||||
2 | 0 | -1.2345678901234e+200
|
|
||||||
(2 rows)
|
|
||||||
|
|
||||||
SELECT f1 AS two, (max(f3) + 1) AS max_plus_1, (min(f3) - 1) AS min_minus_1
|
|
||||||
FROM TEMP_GROUP
|
|
||||||
GROUP BY f1
|
|
||||||
ORDER BY two, min_minus_1;
|
|
||||||
two | max_plus_1 | min_minus_1
|
|
||||||
-----+----------------------+-----------------------
|
|
||||||
1 | 1.2345678901234e+200 | -1
|
|
||||||
2 | 1 | -1.2345678901234e+200
|
|
||||||
(2 rows)
|
|
||||||
|
|
||||||
SELECT f1 AS two,
|
|
||||||
max(f2) + min(f2) AS max_plus_min,
|
|
||||||
min(f3) - 1 AS min_minus_1
|
|
||||||
FROM TEMP_GROUP
|
|
||||||
GROUP BY f1
|
|
||||||
ORDER BY two, min_minus_1;
|
|
||||||
two | max_plus_min | min_minus_1
|
|
||||||
-----+--------------+-----------------------
|
|
||||||
1 | 0 | -1
|
|
||||||
2 | 0 | -1.2345678901234e+200
|
|
||||||
(2 rows)
|
|
||||||
|
|
||||||
DROP TABLE TEMP_INT2;
|
|
||||||
DROP TABLE TEMP_INT4;
|
|
||||||
DROP TABLE TEMP_FLOAT;
|
|
||||||
DROP TABLE TEMP_GROUP;
|
|
Loading…
x
Reference in New Issue
Block a user