Re: [GENERAL] CURRENT_TIMESTAMP

From: "Josh Berkus" <josh(at)agliodbs(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Manfred Koizar <mkoi-pg(at)aon(dot)at>
Cc: josh(at)agliodbs(dot)com, Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, Aaron Held <aaron(at)MetroNY(dot)com>, Roberto Mello <rmello(at)cc(dot)usu(dot)edu>, Neil Conway <neilc(at)samurai(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: [GENERAL] CURRENT_TIMESTAMP
Date: 2002-09-24 15:05:59
Message-ID: web-1658838@davinci.ethosmedia.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers pgsql-sql

Tom,

> If we leave now() alone then there's no need to create another
> non-spec-compliant syntax like 'transaction_timestamp', either.
> (I really don't want to see us do that, because without parens
> it would mean making a new, not-in-the-spec fully-reserved word.)

So, if I've got this straight:

-- current_timestamp will return the timestamp for the beginning of the
SQL statement.

-- now() will return the timestamp for the beginning of the
transaction.

-- timeofday() will return the timestamp of the exact time the function
is called.

... thus changing only current_timestamp.

This looks fine to me, as a search-and-replace on current_timestamp is
easy. However, we need to do a better job of warning people about the
change than we did with interval() to "interval"().

Actually, can I make the proposal that *any* change that breaks
backward compatibility be mentioned in both the new version
announcement and on the download page? This would prevent a lot of
grief. If I'm kept informed of these changes, I'll be happy to write
up a user-friendly announcement/instructions on how to cope with the
change.

> BTW, as long as we are dorking with the current-time family, does
> anyone want to vote for changing timeofday() to return a timestamptz
> instead of a text string? There's no good argument except slavish
> backward compatibility for having it return text, and we seem to be
> quite willing to ignore backwards compatibility in this thread ...

No, I don't see any reason to do this. It's not like timeofday() is a
particularly logical name, anyway. Why not introduce a new function,
rightnow(), that returns timestamptz?

Better yet, how about we introduce a parameter to now()? Example:

now() or now('transaction') returns the transaction timestamp.
now('statement') returns the statement timestamp
now('immediate') returns the timestamp at the exact time the function
is called.

This would seem to me much more consistent than having 3 different
time-calls, whose names have nothing to do with the difference between
them. And it has the advantage of not breaking backward compatibility.

We could introduce the new version of now() in 7.4, encourage everyone
to use it instead of other timestamp calls, and then in 7.5 change the
behavior of current_timestamp for SQL92 compliance.

-Josh Berkus

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ross J. Reedstrom 2002-09-24 15:07:51 Re: [GENERAL] CURRENT_TIMESTAMP
Previous Message Yury Bokhoncovich 2002-09-24 15:05:06 Re: rotatelog / logrotate with PostgreSQL

Browse pgsql-hackers by date

  From Date Subject
Next Message Ross J. Reedstrom 2002-09-24 15:07:51 Re: [GENERAL] CURRENT_TIMESTAMP
Previous Message Roland Roberts 2002-09-24 14:55:41 Re: [SQL] CURRENT_TIMESTAMP

Browse pgsql-sql by date

  From Date Subject
Next Message Ross J. Reedstrom 2002-09-24 15:07:51 Re: [GENERAL] CURRENT_TIMESTAMP
Previous Message Roland Roberts 2002-09-24 14:55:41 Re: [SQL] CURRENT_TIMESTAMP