datetime questions and fix to dt.c - Mailing list pgsql-hackers

From t-ishii@sra.co.jp (Tatsuo Ishii)
Subject datetime questions and fix to dt.c
Date
Msg-id 199809230756.QAA16775@meshsv26.tk.mesh.ad.jp
Whole thread Raw
In response to Re: [HACKERS] current- crash  (Bruce Momjian <maillist@candle.pha.pa.us>)
Responses Re: [HACKERS] datetime questions and fix to dt.c  (Bruce Momjian <maillist@candle.pha.pa.us>)
List pgsql-hackers
Hi,

Documents stat that datetime type allows "far into future."
So I did some testing.

test=> select datetime '3276900-12-01';
?column?
--------------------------
Tue Aug 27 00:00:00 337095
(1 row)

test=> select '32769000-12-01'::datetime;
?column?
--------------------------
Thu Jan 07 00:00:00 431143
(1 row)

test=> select '327690000-12-01'::datetime;
?column?
---------------------------
Sat Aug 27 00:00:00 1371616
(1 row)

I suspect this is due to the limitation of the timezone database
in my system. Is that correct? If so, how can I know how far we
can go into the future using the datetime type?

BTW, dt.c seems to have problem with date_part() function.

test=> select date_part('microsecond','1998/9/23 12:04:05.1234'::datetime);
date_part
---------
    123.4
(1 row)

test=> select date_part('millisecond','1998/9/23 12:04:05.1234'::datetime);
date_part
---------
    123.4

Included patches should fix this.

*** dt.c.orig    Wed Sep 23 16:03:44 1998
--- dt.c    Wed Sep 23 16:06:10 1998
***************
*** 2199,2205 ****
      {INVALID, RESERV, DTK_INVALID},        /* "invalid" reserved for invalid
                                           * time */
      {"m", UNITS, DTK_MINUTE},    /* "minute" relative time units */
!     {"microsecon", UNITS, DTK_MILLISEC},        /* "microsecond" relative
                                                   * time units */
      {"mil", UNITS, DTK_MILLENIUM},        /* "millenium" relative time units */
      {"mils", UNITS, DTK_MILLENIUM},        /* "millenia" relative time units */
--- 2199,2205 ----
      {INVALID, RESERV, DTK_INVALID},        /* "invalid" reserved for invalid
                                           * time */
      {"m", UNITS, DTK_MINUTE},    /* "minute" relative time units */
!     {"microsecon", UNITS, DTK_MICROSEC},        /* "microsecond" relative
                                                   * time units */
      {"mil", UNITS, DTK_MILLENIUM},        /* "millenium" relative time units */
      {"mils", UNITS, DTK_MILLENIUM},        /* "millenia" relative time units */
--
Tatsuo Ishii
t-ishii@sra.co.jp


pgsql-hackers by date:

Previous
From: The Hermit Hacker
Date:
Subject: Re: [HACKERS] Re: Results of port of Sept 18 port of PostgreSQL
Next
From: Keith Parks
Date:
Subject: pg_dump, problem with user defined types?