Re: timestamp resolution?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Thomas Lockhart <lockhart(at)fourpalms(dot)org>
Cc: thomas(at)pgsql(dot)com, Tatsuo Ishii <t-ishii(at)sra(dot)co(dot)jp>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: timestamp resolution?
Date: 2001-10-04 18:13:29
Message-ID: 29540.1002219209@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Thomas Lockhart <lockhart(at)fourpalms(dot)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 the time 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2001-10-04 18:17:40 Re: Beta time
Previous Message Tom Lane 2001-10-04 18:06:38 Re: pgsql/src/backend parser/parse_coerce.c utils/ ...