Hi list,

Back in June we had a discussion about parsing denormal floating-point
values. A float8->text conversion could result in a number that can't
be converted back to float8 anymore for some values. Among other
things, this could break backups (though my searches didn't turn up
any reports of this ever happening).

The reason is that Linux strtod() sets errno=ERANGE for denormal
numbers. This behavior is also explicitly allowed
(implementation-defined) by the C99 standard.

Further analysis was done by Jeroen Vermeulen here:
http://archives.postgresql.org/pgsql-hackers/2011-06/msg01773.php

I think the least invasive fix, as proposed by Jeroen, is to fail only
when ERANGE is set *and* the return value is 0.0 or +/-HUGE_VAL.
Reading relevant specifications, this seems to be a fairly safe
assumption. That's what the attached patch does.

(I also updated the float4in function, but that's not strictly
necessary -- it would fail later in CHECKFLOATVAL() anyway)

What I don't know is how many platforms are actually capable of
parsing denormal double values. I added some regression tests, it
would be interesting to see results from pgbuildfarm and potentially
revert these tests later.

Regards,
Marti

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to