From: Robert Haas <robertmhaas@gmail.com>
To: Brian S. Krug <bkrug@usatech.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #5996: CURRENT_TIMESTAMP uses often undesired TRANSACTION_TIMESTAMP, instead of STATEMENT_TIMESTAMP
Date: Wed, 11 May 2011 15:55:02 -0400
Message-ID: <BANLkTikAwB9G8ckQMKhgwuFeOJsw0bFX1Q@mail.gmail.com> (raw)
In-Reply-To: <201104281933.p3SJXD1V044515@wwwmaster.postgresql.org>
References: <201104281933.p3SJXD1V044515@wwwmaster.postgresql.org>
On Thu, Apr 28, 2011 at 3:33 PM, Brian S. Krug <bkrug@usatech.com> wrote:
>
> The following bug has been logged online:
>
> Bug reference: 5996
> Logged by: Brian S. Krug
> Email address: bkrug@usatech.com
> PostgreSQL version: 9.0.3
> Operating system: Solaris
> Description: CURRENT_TIMESTAMP uses often undesired
> TRANSACTION_TIMESTAMP, instead of STATEMENT_TIMESTAMP
> Details:
>
> CURRENT_TIMESTAMP (and CURRENT_DATE, CURRENT_TIME) return the time of the
> start of the transcaction - which seems to be right after the end of the
> last transaction. Thus, if you use pooled connections, CURRENT_TIMESTAMP
> will return the time of the last COMMIT. This is often unintended behavior.
> This tripped me up significant and I would anticipate that many have fallen
> into the same trap. I recommend that CURRENT_TIMESTAMP functions as
> STATEMENT_TIMESTAMP instead of as TRANSACTION_TIMESTAMP.
I've been bitten by this too, but I doubt we're likely to want to
change it at this point for reasons of backward compatibility. The
SQL standard may have something to say about it, too.
But as for pooled connections, it would seem unwise to multiplex a
server connection across different sessions while leaving a
transaction open. Presumably each client should commit after it
finishes its own work.
--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
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-bugs@postgresql.org
Cc: robertmhaas@gmail.com, bkrug@usatech.com
Subject: Re: BUG #5996: CURRENT_TIMESTAMP uses often undesired TRANSACTION_TIMESTAMP, instead of STATEMENT_TIMESTAMP
In-Reply-To: <BANLkTikAwB9G8ckQMKhgwuFeOJsw0bFX1Q@mail.gmail.com>
References: <201104281933.p3SJXD1V044515@wwwmaster.postgresql.org> <BANLkTikAwB9G8ckQMKhgwuFeOJsw0bFX1Q@mail.gmail.com>
* 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