Skip to content

Commit

Permalink
Fix int anf float tests by v2.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mkgrgis committed Dec 11, 2024
1 parent 70649db commit 41a8165
Show file tree
Hide file tree
Showing 32 changed files with 834 additions and 11,612 deletions.
191 changes: 71 additions & 120 deletions expected/13.15/types/float4.out
Original file line number Diff line number Diff line change
Expand Up @@ -114,33 +114,6 @@ INSERT INTO FLOAT4_TBL(f1) VALUES ('123 5');
ERROR: invalid input syntax for type real: "123 5"
LINE 1: INSERT INTO FLOAT4_TBL(f1) VALUES ('123 5');
^
-- Also try it with non-error-throwing API
CREATE FOREIGN TABLE NON_ERROR_THROWING_API_FLOAT4(f1 text, id serial OPTIONS (key 'true')) SERVER sqlite_svr;
INSERT INTO NON_ERROR_THROWING_API_FLOAT4 VALUES ('34.5', 1), ('xyz', 2), ('1e400', 3);
SELECT pg_input_is_valid(f1, 'float4') FROM NON_ERROR_THROWING_API_FLOAT4 WHERE id = 1;
pg_input_is_valid
-------------------
t
(1 row)

SELECT pg_input_is_valid(f1, 'float4') FROM NON_ERROR_THROWING_API_FLOAT4 WHERE id = 2;
pg_input_is_valid
-------------------
f
(1 row)

SELECT pg_input_is_valid(f1, 'float4') FROM NON_ERROR_THROWING_API_FLOAT4 WHERE id = 3;
pg_input_is_valid
-------------------
f
(1 row)

SELECT * FROM pg_input_error_info((SELECT f1 FROM NON_ERROR_THROWING_API_FLOAT4 WHERE id = 3), 'float4');
message | detail | hint | sql_error_code
---------------------------------------+--------+------+----------------
"1e400" is out of range for type real | | | 22003
(1 row)

-- special inputs
--Testcase 18:
DELETE FROM FLOAT4_TMP;
Expand Down Expand Up @@ -259,17 +232,6 @@ SELECT f1 FROM FLOAT4_TMP;

(1 row)

--Testcase 185:
DELETE FROM FLOAT4_TMP;
--Testcase 186:
INSERT INTO FLOAT4_TMP VALUES ('42'::float4 / 'Infinity'::float4);
--Testcase 187:
SELECT f1 FROM FLOAT4_TMP;
f1
----
0
(1 row)

--Testcase 31:
DELETE FROM FLOAT4_TMP;
--Testcase 78:
Expand All @@ -281,17 +243,6 @@ SELECT f1 FROM FLOAT4_TMP;

(1 row)

--Testcase 188:
DELETE FROM FLOAT4_TMP;
--Testcase 189:
INSERT INTO FLOAT4_TMP VALUES ('nan'::float4 / '0'::float4);
--Testcase 190:
SELECT f1 FROM FLOAT4_TMP;
f1
----

(1 row)

--Testcase 32:
DELETE FROM FLOAT4_TMP;
--Testcase 80:
Expand All @@ -304,120 +255,120 @@ SELECT f1 FROM FLOAT4_TMP;
(1 row)

--Testcase 34:
SELECT * FROM FLOAT4_TBL;
f1
---------------
0
1004.3
-34.84
1.2345679e+20
1.2345679e-20
SELECT '' AS five, * FROM FLOAT4_TBL;
five | f1
------+---------------
| 0
| 1004.3
| -34.84
| 1.2345679e+20
| 1.2345679e-20
(5 rows)

--SELECT '' AS four, f.* FROM FLOAT4_TBL f WHERE f.f1 <> '1004.3';
--SELECT '' AS one, f.* FROM FLOAT4_TBL f WHERE f.f1 = '1004.3';
--SELECT '' AS three, f.* FROM FLOAT4_TBL f WHERE '1004.3' > f.f1;
--SELECT '' AS three, f.* FROM FLOAT4_TBL f WHERE f.f1 < '1004.3';
--Testcase 35:
SELECT f.* FROM FLOAT4_TBL f WHERE '1004.3' >= f.f1;
f1
---------------
0
1004.3
-34.84
1.2345679e-20
SELECT '' AS four, f.* FROM FLOAT4_TBL f WHERE '1004.3' >= f.f1;
four | f1
------+---------------
| 0
| 1004.3
| -34.84
| 1.2345679e-20
(4 rows)

--Testcase 36:
SELECT f.* FROM FLOAT4_TBL f WHERE f.f1 <= '1004.3';
f1
---------------
0
1004.3
-34.84
1.2345679e-20
SELECT '' AS four, f.* FROM FLOAT4_TBL f WHERE f.f1 <= '1004.3';
four | f1
------+---------------
| 0
| 1004.3
| -34.84
| 1.2345679e-20
(4 rows)

--Testcase 37:
SELECT f.f1, f.f1 * '-10' AS x FROM FLOAT4_TBL f
SELECT '' AS three, f.f1, f.f1 * '-10' AS x FROM FLOAT4_TBL f
WHERE f.f1 > '0.0';
f1 | x
---------------+----------------
1004.3 | -10043
1.2345679e+20 | -1.2345678e+21
1.2345679e-20 | -1.2345678e-19
three | f1 | x
-------+---------------+----------------
| 1004.3 | -10043
| 1.2345679e+20 | -1.2345678e+21
| 1.2345679e-20 | -1.2345678e-19
(3 rows)

--Testcase 38:
SELECT f.f1, f.f1 + '-10' AS x FROM FLOAT4_TBL f
SELECT '' AS three, f.f1, f.f1 + '-10' AS x FROM FLOAT4_TBL f
WHERE f.f1 > '0.0';
f1 | x
---------------+---------------
1004.3 | 994.3
1.2345679e+20 | 1.2345679e+20
1.2345679e-20 | -10
three | f1 | x
-------+---------------+---------------
| 1004.3 | 994.3
| 1.2345679e+20 | 1.2345679e+20
| 1.2345679e-20 | -10
(3 rows)

--Testcase 39:
SELECT f.f1, f.f1 / '-10' AS x FROM FLOAT4_TBL f
SELECT '' AS three, f.f1, f.f1 / '-10' AS x FROM FLOAT4_TBL f
WHERE f.f1 > '0.0';
f1 | x
---------------+----------------
1004.3 | -100.43
1.2345679e+20 | -1.2345679e+19
1.2345679e-20 | -1.2345679e-21
three | f1 | x
-------+---------------+----------------
| 1004.3 | -100.43
| 1.2345679e+20 | -1.2345679e+19
| 1.2345679e-20 | -1.2345679e-21
(3 rows)

--Testcase 40:
SELECT f.f1, f.f1 - '-10' AS x FROM FLOAT4_TBL f
SELECT '' AS three, f.f1, f.f1 - '-10' AS x FROM FLOAT4_TBL f
WHERE f.f1 > '0.0';
f1 | x
---------------+---------------
1004.3 | 1014.3
1.2345679e+20 | 1.2345679e+20
1.2345679e-20 | 10
three | f1 | x
-------+---------------+---------------
| 1004.3 | 1014.3
| 1.2345679e+20 | 1.2345679e+20
| 1.2345679e-20 | 10
(3 rows)

-- test divide by zero
--Testcase 41:
SELECT f.f1 / '0.0' from FLOAT4_TBL f;
SELECT '' AS bad, f.f1 / '0.0' from FLOAT4_TBL f;
ERROR: division by zero
--Testcase 42:
SELECT * FROM FLOAT4_TBL;
f1
---------------
0
1004.3
-34.84
1.2345679e+20
1.2345679e-20
SELECT '' AS five, * FROM FLOAT4_TBL;
five | f1
------+---------------
| 0
| 1004.3
| -34.84
| 1.2345679e+20
| 1.2345679e-20
(5 rows)

-- test the unary float4abs operator
--Testcase 43:
SELECT f.f1, @f.f1 AS abs_f1 FROM FLOAT4_TBL f;
f1 | abs_f1
---------------+---------------
0 | 0
1004.3 | 1004.3
-34.84 | 34.84
1.2345679e+20 | 1.2345679e+20
1.2345679e-20 | 1.2345679e-20
SELECT '' AS five, f.f1, @f.f1 AS abs_f1 FROM FLOAT4_TBL f;
five | f1 | abs_f1
------+---------------+---------------
| 0 | 0
| 1004.3 | 1004.3
| -34.84 | 34.84
| 1.2345679e+20 | 1.2345679e+20
| 1.2345679e-20 | 1.2345679e-20
(5 rows)

--Testcase 44:
UPDATE FLOAT4_TBL
SET f1 = FLOAT4_TBL.f1 * '-1'
WHERE FLOAT4_TBL.f1 > '0.0';
--Testcase 45:
SELECT * FROM FLOAT4_TBL;
f1
----------------
0
-1004.3
-34.84
-1.2345679e+20
-1.2345679e-20
SELECT '' AS five, * FROM FLOAT4_TBL;
five | f1
------+----------------
| 0
| -1004.3
| -34.84
| -1.2345679e+20
| -1.2345679e-20
(5 rows)

-- test edge-case coercions to integer
Expand Down
Loading

0 comments on commit 41a8165

Please sign in to comment.