Re: fixes for date_part micro/millisecond precision

Поиск
Список
Период
Сортировка
От Brent Verner
Тема Re: fixes for date_part micro/millisecond precision
Дата
Msg-id 20011126141102.GB7219@rcfile.org
обсуждение исходный текст
Ответ на Re: fixes for date_part micro/millisecond precision  (Karel Zak <zakkr@zf.jcu.cz>)
Список pgsql-patches
On 26 Nov 2001 at 13:38 (+0100), Karel Zak wrote:
| On Sat, Nov 24, 2001 at 02:24:09PM -0500, Tom Lane wrote:
| > Brent Verner <brent@rcfile.org> writes:
| > >   This patch fixes a problem where extract/date_part returns bad values
| > > for microsecond and millisecond parts.
| >
| > I'm not convinced the existing behavior is wrong.  Timestamps are floats
| > in PG, and therefore not infinitely precise.  Your patch seems to be
| > trying to cover this up, but I fear it will only succeed in introducing
| > other problems.
|
|  Tom is right. If you need non-float microsecond/millisecond you can
|  use to_char() -- it's news in 7.2:
|
| test=# select to_char('2001-11-24 13:49:12.826833-05'::timestamp, 'MS');
|  to_char
| ---------
|    827

Also, casting to float4 gives the 'expected' results.  The behavior
still seems wrong, since it gives me back something that I did not
put in.  Additionally, I can get back a value that I /can't/ put back
in the database.  I do agree with Tom that my solution was simply
a cover-up.  The SQL-99 spec says nothing of MILLI or MICROSECONDS,
so I'm curious if there is interest in really fixing the date_part
behavior WRT fractional seconds.  Comments Thomas?

The only way I can see to fix it is to make Timestamp a struct
something like...

typedef struct _pgTimestamp {
  unsigned long     ts_epoch;     /* seconds */
  unsigned int      ts_frac;      /* microseconds */
  signed   char     ts_tzo;       /* GMT offset in hours */
  unsigned char     ts_precision; /* (???) precision of fractional part */
} Timestamp;

  I'll probably try to implement this new Timestamp as a learning
exercise.  If my hacking goes well and there is a desire to fix
the current Timestamp limitations, I'll submit a patch.

cheers.
  brent

--
"Develop your talent, man, and leave the world something. Records are
really gifts from people. To think that an artist would love you enough
to share his music with anyone is a beautiful thing."  -- Duane Allman

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

Предыдущее
От: Weiping He
Дата:
Сообщение: the new patches for zh_CN NLS
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: Chinese NLS patch, the third try.