1
0
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:
Neil Conway
2004-03-12 00:25:43 +00:00
parent fe6e922136
commit bfd6f52b0e
7 changed files with 112 additions and 40 deletions

View File

@@ -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
------+-------------

View File

@@ -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
------+----------------------

View File

@@ -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.*;

View File

@@ -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.*;