Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id 8C7B69FB2BC for ; Fri, 13 Oct 2006 11:14:36 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 46041-09 for ; Fri, 13 Oct 2006 14:14:27 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 06A9F9FB272 for ; Fri, 13 Oct 2006 11:14:26 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k9DEENNn029409; Fri, 13 Oct 2006 10:14:23 -0400 (EDT) To: Guillaume Cottenceau cc: pgsql-jdbc@postgresql.org Subject: Re: 'now' is sometimes not now - but current_timestamp is In-reply-to: <87pscwk65j.fsf@meuh.mnc.lan> References: <87pscwk65j.fsf@meuh.mnc.lan> Comments: In-reply-to Guillaume Cottenceau message dated "13 Oct 2006 09:48:40 +0200" Date: Fri, 13 Oct 2006 10:14:23 -0400 Message-ID: <29408.1160748863@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200610/88 X-Sequence-Number: 15971 Guillaume Cottenceau writes: > I update a row's TIMESTAMP WITH TIME ZONE column value with: > ... SET = '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