Re: [HACKERS] Patch: Avoid precision error in to_timestamp().
| От | Tom Lane | 
|---|---|
| Тема | Re: [HACKERS] Patch: Avoid precision error in to_timestamp(). | 
| Дата | |
| Msg-id | 12772.1486587127@sss.pgh.pa.us обсуждение исходный текст | 
| Ответ на | Re: [HACKERS] Patch: Avoid precision error in to_timestamp(). (Tom Lane <tgl@sss.pgh.pa.us>) | 
| Ответы | Re: [HACKERS] Patch: Avoid precision error in to_timestamp(). | 
| Список | 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
		
	В списке pgsql-hackers по дате отправления: