Interval output bug in HAVE_INT64_TIMESTAMP

Поиск
Список
Период
Сортировка
От Ron Mayer
Тема Interval output bug in HAVE_INT64_TIMESTAMP
Дата
Msg-id 48E49A1E.8080309@cheapcomplexdevices.com
обсуждение исходный текст
Ответы Re: Interval output bug in HAVE_INT64_TIMESTAMP  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Seems to me there's a bug in HEAD (and probably old branches
as well) when compiled with HAVE_INT64_TIMESTAMP.  As shown below
It sometimes shows things like "-6.-70 secs" where 8.3
showed "-6.70 secs".

I think the attached one-liner patch fixes this, as well as
another roundoff regression between HEAD and 8.3.

   Ron Mayer

================================================================================
== ON HEAD
================================================================================
regression=#  set datestyle to sql;
SET
regression=#  select '-10 mons -3 days +03:55:06.70'::interval;
                       interval
----------------------------------------------------
  @ 10 mons 3 days -3 hours -55 mins -6.-70 secs ago
(1 row)

regression=# select '1 year 2 mons 3 days 04:05:06.699999'::interval;
                     interval
-------------------------------------------------
  @ 1 year 2 mons 3 days 4 hours 5 mins 6.69 secs
(1 row)

================================================================================
== ON 8.3
================================================================================
pg83=#  set datestyle to sql;
SET
pg83=# select '-10 mons -3 days +03:55:06.70'::interval;
                      interval
---------------------------------------------------
  @ 10 mons 3 days -3 hours -55 mins -6.70 secs ago
(1 row)


pg83=#  select '1 year 2 mons 3 days 04:05:06.699999'::interval;
                     interval
-------------------------------------------------
  @ 1 year 2 mons 3 days 4 hours 5 mins 6.70 secs
(1 row)
*** a/src/backend/utils/adt/datetime.c
--- b/src/backend/utils/adt/datetime.c
***************
*** 3791,3797 **** EncodeInterval(struct pg_tm * tm, fsec_t fsec, int style, char *str)
                      is_before = TRUE;
                  }
                  sprintf(cp, "%s%d.%02d secs", is_nonzero ? " " : "",
!                         tm->tm_sec, ((int) sec) / 10000);
                  cp += strlen(cp);
  #else
                  fsec += tm->tm_sec;
--- 3791,3797 ----
                      is_before = TRUE;
                  }
                  sprintf(cp, "%s%d.%02d secs", is_nonzero ? " " : "",
!                         tm->tm_sec, (int) abs(rint(sec / 10000.0)));
                  cp += strlen(cp);
  #else
                  fsec += tm->tm_sec;

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

Предыдущее
От: Greg Stark
Дата:
Сообщение: Re: Common Table Expressions (WITH RECURSIVE) patch
Следующее
От: Ron Mayer
Дата:
Сообщение: Re: Patch for SQL-Standard Interval output and decoupling DateStyle from IntervalStyle