Re: Re: round - timestamp bug

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Re: round - timestamp bug
Дата
Msg-id 28480.981562253@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: round - timestamp bug  (Thomas Lockhart <lockhart@alumni.caltech.edu>)
Список pgsql-bugs
Thomas Lockhart <lockhart@alumni.caltech.edu> writes:
> The original report did not give complete platform details, but in
> my recollection the *only* recent cases of this display problem come
> from Mandrake systems which are built with overly aggressive compiler
> optimization options.

No, the behavior is not platform-specific.  I'm on HP-PA:

regression=# select 'Tue 23 Jan 21:38:59.997 2001'::timestamp;
         ?column?
---------------------------
 2001-01-23 21:38:60.00-05
(1 row)

The problem is that we round the fractional seconds part to two digits
only after we've separated seconds from the other fields.  (I imagine
the code is not even doing that explicitly, but leaving it to sprintf
to do so.)  It would work better if we rounded the entire floating
timestamp value to two fractional digits before we break it down,
eg with

    tstamp = rint(tstamp * 100.0) / 100.0;

            regards, tom lane

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Thomas Lockhart
Дата:
Сообщение: Re: round - timestamp bug
Следующее
От: Tom Lane
Дата:
Сообщение: Re: byteain() doesn't parse correctly