From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Erik Nordström <erik(dot)nordstrom(at)gmail(dot)com> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Patch: Avoid precision error in to_timestamp(). |
Date: | 2017-02-08 20:52:07 |
Message-ID: | 12772.1486587127@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
I wrote:
> I wonder if we could make things better just by using rint() rather than
> a naive cast-to-integer. The cast will truncate not round, and I think
> that might be what's mostly biting you. Does this help for you?
> #ifdef HAVE_INT64_TIMESTAMP
> - result = seconds * USECS_PER_SEC;
> + result = rint(seconds * USECS_PER_SEC);
> #else
I poked around looking for possible similar issues elsewhere, and found
that a substantial majority of the datetime-related code already uses
rint() when trying to go from float to int representations. As far as
I can find, this function and make_interval() are the only ones that
fail to do so. So I'm now thinking that this is a clear oversight,
and both those places need to be patched to use rint().
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2017-02-08 20:56:00 | Re: WAL consistency check facility |
Previous Message | Alvaro Herrera | 2017-02-08 20:51:10 | Re: Press Release Draft - 2016-02-09 Cumulative Update |