From: Tom Lane <tgl@sss.pgh.pa.us>
To: Guillaume Cottenceau <gc@mnc.ch>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: 'now' is sometimes not now - but current_timestamp is
Date: Fri, 13 Oct 2006 10:14:23 -0400
Message-ID: <29408.1160748863@sss.pgh.pa.us> (raw)
In-Reply-To: <87pscwk65j.fsf@meuh.mnc.lan>
References: <87pscwk65j.fsf@meuh.mnc.lan>
Guillaume Cottenceau <gc@mnc.ch> writes:
> I update a row's TIMESTAMP WITH TIME ZONE column value with:
> ... SET <colname> = 'now'::TIMESTAMP WITH TIME ZONE ...
What you will have there is a timestamp-type constant with the value
that now() had at the time the statement was parsed. If you re-use a
prepared statement then the value will be out of date.
> Initially, I was hesitating with CURRENT_TIMESTAMP, but in a
> table description, a column with a default value of 'now' or
> CURRENT_TIMESTAMP will both be printed "not null default
> ('now'::text)::timestamp(6) with time zone" so I assumed the
> correct way of writing it was 'now' and then to cast to a
> timestamp with/without time zone.
If you are going to copy the implementation of CURRENT_TIMESTAMP,
you should at least copy it accurately. (Hint: the cast from
text to timestamp is not immutable.) But why are you not just
using CURRENT_TIMESTAMP, rather than trying to outsmart the system?
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: tgl@sss.pgh.pa.us, gc@mnc.ch
Subject: Re: 'now' is sometimes not now - but current_timestamp is
In-Reply-To: <29408.1160748863@sss.pgh.pa.us>
References: <87pscwk65j.fsf@meuh.mnc.lan> <29408.1160748863@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox