Re: timestamp resolution? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: timestamp resolution?
Date
Msg-id 29540.1002219209@sss.pgh.pa.us
Whole thread Raw
In response to Re: timestamp resolution?  (Thomas Lockhart <lockhart@fourpalms.org>)
List pgsql-hackers
Thomas Lockhart <lockhart@fourpalms.org> writes:
> I'm going through gram.y and fixing up the implementations of
> CURRENT_TIMESTAMP et al. One point folks will run into is that
> CURRENT_TIMESTAMP *should* return time to the second, not fractions
> thereof, and CURRENT_TIMESTAMP(p) should be used to get something more
> precise. Another issue I just noticed is that the result of

> create table t1 (d timestamp(2) default current_timestamp);

> gives me two decimal points of fractional seconds (after fixups for
> Tatsuo's reported troubles) but I would think that it should round to
> the second. Looks like we are "type folding" past the typmod attributes.

No, it's just that CURRENT_TIMESTAMP doesn't presently reduce its
precision, as you assert it should do.  However, I see nothing in SQL99
6.19 that asserts anything about the precision of CURRENT_TIMESTAMP
without a precision indicator.  It just says
        2) If specified, <time precision> and <timestamp precision>           respectively determine the precision of
thetime or timestamp           value returned.
 

which seems to leave it up to us to choose the behavior when no
precision is specified.  I'd prefer to see CURRENT_TIMESTAMP return as
much precision as possible (see also previous message).

BTW, CURRENT_TIME and CURRENT_TIMESTAMP should return TIMETZ and
TIMESTAMPTZ respectively, but currently do not --- are you fixing that?
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Beta time
Next
From: Bruce Momjian
Date:
Subject: Re: Beta time