Re: How do I make a timestamp column default to current time

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "John D(dot) Burger" <john(at)mitre(dot)org>, PostgreSQL-general general <pgsql-general(at)postgresql(dot)org>
Subject: Re: How do I make a timestamp column default to current time
Date: 2006-03-17 03:32:59
Message-ID: 200603170332.k2H3Wxr12165@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tom Lane wrote:
> "John D. Burger" <john(at)mitre(dot)org> writes:
> >> mycol timestamp default now()
> >> or
> >> mycol timestamp default current_timestamp
>
> > And both of these return start time of the current transaction, yes?
> > Is it the case that there is no SQL-standard way to get the current
> > time?
>
> AFAIK the spec doesn't really define the meaning of current_timestamp
> all that closely. I believe there's a patch in the queue to add some
> additional nonstandard functions for current time and start of current
> interactive command, though.

I am working on a patch for 8.2 for this:

* Add transaction_timestamp(), statement_timestamp(), clock_timestamp()
functionality

Current CURRENT_TIMESTAMP returns the start time of the current
transaction, and gettimeofday() returns the wallclock time. This will
make time reporting more consistent and will allow reporting of
the statement start time.

--
Bruce Momjian http://candle.pha.pa.us
SRA OSS, Inc. http://www.sraoss.com

+ If your life is a hard drive, Christ can be your backup. +

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Oleg Bartunov 2006-03-17 05:10:35 Re: full text indexing
Previous Message Christopher Browne 2006-03-17 03:12:44 Re: Replication & web apps