[BUG] Denormal float values break backup/restore - Mailing list pgsql-hackers

From Marti Raudsepp
Subject [BUG] Denormal float values break backup/restore
Date
Msg-id BANLkTi=Z6cT8c_j6YrXHcx=CkrxUMt6NBw@mail.gmail.com
Whole thread Raw
Responses Re: [BUG] Denormal float values break backup/restore
List pgsql-hackers
Hi list,

I was playing around with denormal float values in response to the
Itanium thread and noticed that Postgres' float conversion functions
behave inconsistently, at least on Linux with glibc 2.14

It can successfully convert denormal float values to strings:
marti=# select '0.25e-307'::float8/2 as val;   val
-----------1.25e-308

But trying to convert back to float fails:
marti=# select ('0.25e-307'::float8/2)::text::float8 as val;
ERROR:  "1.25e-308" is out of range for type double precision

The most significant impact of this is that anyone who has these
values in their tables can't restore them from backup. I'm surprised
nobody has reported this yet, but it seems like worthy of fixing in
9.2 at least.

Looking at utils/adt/float.c, seems that some platforms also have
other problems with the strtod() function. Maybe it's time to
implement our own, without bugs and with proper handling for denormal
float values?

Also applies to float4s:
marti=# select ('1.40129846432481707e-45'::float4/4)::text::float4;
ERROR:  value out of range: underflow

Another erratic behavior of float4in:
marti=# select ('1.40129846432481707e-45'::float4/2)::text;        text
----------------------7.00649232162409e-46

marti=# select ('1.40129846432481707e-45'::float4/2)::text::float4;  float4
------------1.4013e-45


Regards,
Marti


pgsql-hackers by date:

Previous
From: Florian Pflug
Date:
Subject: Re: TG_DEPTH patch v1
Next
From: Grzegorz Szpetkowski
Date:
Subject: Feature idea: standard_quoting_identifiers property