mirror of
https://github.com/postgres/postgres.git
synced 2025-12-10 14:22:35 +03:00
Allow 'Infinity' and '-Infinity' as input to the float4 and float8
types. Update the regression tests and the documentation to reflect this. Remove the UNSAFE_FLOATS #ifdef. This is only half the story: we still unconditionally reject floating point operations that result in +/- infinity. See recent thread on -hackers for more information.
This commit is contained in:
@@ -50,9 +50,39 @@ SELECT ' NAN '::float4;
|
||||
NaN
|
||||
(1 row)
|
||||
|
||||
SELECT 'infinity'::float4;
|
||||
float4
|
||||
----------
|
||||
Infinity
|
||||
(1 row)
|
||||
|
||||
SELECT ' -INFINiTY '::float4;
|
||||
float4
|
||||
-----------
|
||||
-Infinity
|
||||
(1 row)
|
||||
|
||||
-- bad special inputs
|
||||
SELECT 'N A N'::float4;
|
||||
ERROR: invalid input syntax for type real: "N A N"
|
||||
SELECT 'NaN x'::float4;
|
||||
ERROR: invalid input syntax for type real: "NaN x"
|
||||
SELECT ' INFINITY x'::float4;
|
||||
ERROR: invalid input syntax for type real: " INFINITY x"
|
||||
SELECT 'Infinity'::float4 + 100.0;
|
||||
ERROR: type "double precision" value out of range: overflow
|
||||
SELECT 'Infinity'::float4 / 'Infinity'::float4;
|
||||
?column?
|
||||
----------
|
||||
NaN
|
||||
(1 row)
|
||||
|
||||
SELECT 'nan'::float4 / 'nan'::float4;
|
||||
?column?
|
||||
----------
|
||||
NaN
|
||||
(1 row)
|
||||
|
||||
SELECT '' AS five, FLOAT4_TBL.*;
|
||||
five | f1
|
||||
------+-------------
|
||||
|
||||
@@ -50,9 +50,39 @@ SELECT ' NAN '::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"
|
||||
SELECT 'NaN x'::float8;
|
||||
ERROR: invalid input syntax for type double precision: "NaN x"
|
||||
SELECT ' INFINITY x'::float8;
|
||||
ERROR: invalid input syntax for type double precision: " INFINITY x"
|
||||
SELECT 'Infinity'::float8 + 100.0;
|
||||
ERROR: type "double precision" value out of range: overflow
|
||||
SELECT 'Infinity'::float8 / 'Infinity'::float8;
|
||||
?column?
|
||||
----------
|
||||
NaN
|
||||
(1 row)
|
||||
|
||||
SELECT 'nan'::float8 / 'nan'::float8;
|
||||
?column?
|
||||
----------
|
||||
NaN
|
||||
(1 row)
|
||||
|
||||
SELECT '' AS five, FLOAT8_TBL.*;
|
||||
five | f1
|
||||
------+----------------------
|
||||
|
||||
@@ -29,8 +29,17 @@ INSERT INTO FLOAT4_TBL(f1) VALUES ('123 5');
|
||||
SELECT 'NaN'::float4;
|
||||
SELECT 'nan'::float4;
|
||||
SELECT ' NAN '::float4;
|
||||
SELECT 'infinity'::float4;
|
||||
SELECT ' -INFINiTY '::float4;
|
||||
-- bad special inputs
|
||||
SELECT 'N A N'::float4;
|
||||
SELECT 'NaN x'::float4;
|
||||
SELECT ' INFINITY x'::float4;
|
||||
|
||||
SELECT 'Infinity'::float4 + 100.0;
|
||||
SELECT 'Infinity'::float4 / 'Infinity'::float4;
|
||||
SELECT 'nan'::float4 / 'nan'::float4;
|
||||
|
||||
|
||||
SELECT '' AS five, FLOAT4_TBL.*;
|
||||
|
||||
|
||||
@@ -29,8 +29,16 @@ INSERT INTO FLOAT8_TBL(f1) VALUES ('123 5');
|
||||
SELECT 'NaN'::float8;
|
||||
SELECT 'nan'::float8;
|
||||
SELECT ' NAN '::float8;
|
||||
SELECT 'infinity'::float8;
|
||||
SELECT ' -INFINiTY '::float8;
|
||||
-- bad special inputs
|
||||
SELECT 'N A N'::float8;
|
||||
SELECT 'NaN x'::float8;
|
||||
SELECT ' INFINITY x'::float8;
|
||||
|
||||
SELECT 'Infinity'::float8 + 100.0;
|
||||
SELECT 'Infinity'::float8 / 'Infinity'::float8;
|
||||
SELECT 'nan'::float8 / 'nan'::float8;
|
||||
|
||||
SELECT '' AS five, FLOAT8_TBL.*;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user