pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #5996: CURRENT_TIMESTAMP uses often undesired TRANSACTION_TIMESTAMP, instead of STATEMENT_TIMESTAMP
3+ messages / 3 participants
[nested] [flat]
* BUG #5996: CURRENT_TIMESTAMP uses often undesired TRANSACTION_TIMESTAMP, instead of STATEMENT_TIMESTAMP
@ 2011-04-28 19:33 Brian S. Krug <bkrug@usatech.com>
2011-04-29 05:34 ` Re: BUG #5996: CURRENT_TIMESTAMP uses often undesired TRANSACTION_TIMESTAMP, instead of STATEMENT_TIMESTAMP John R Pierce <pierce@hogranch.com>
2011-05-11 19:55 ` Re: BUG #5996: CURRENT_TIMESTAMP uses often undesired TRANSACTION_TIMESTAMP, instead of STATEMENT_TIMESTAMP Robert Haas <robertmhaas@gmail.com>
0 siblings, 2 replies; 3+ messages in thread
From: Brian S. Krug @ 2011-04-28 19:33 UTC (permalink / raw)
To: pgsql-bugs
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.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: BUG #5996: CURRENT_TIMESTAMP uses often undesired TRANSACTION_TIMESTAMP, instead of STATEMENT_TIMESTAMP
2011-04-28 19:33 BUG #5996: CURRENT_TIMESTAMP uses often undesired TRANSACTION_TIMESTAMP, instead of STATEMENT_TIMESTAMP Brian S. Krug <bkrug@usatech.com>
@ 2011-04-29 05:34 ` John R Pierce <pierce@hogranch.com>
1 sibling, 0 replies; 3+ messages in thread
From: John R Pierce @ 2011-04-29 05:34 UTC (permalink / raw)
To: pgsql-bugs; +Cc: bkrug@usatech.com
On 04/28/11 12:33 PM, Brian S. Krug 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.
>
Transactions start when you issue a BEGIN; command. If you don't issue
a BEGIN, then every statement is a self contained transaction. Are you
using a runtime abstraction thats doing this automagically behind your
back right after COMMIT; ? if so, thats your problem.
old JDBC's did exactly that, and it caused other ugly problems like long
running IDLE In Transaction processes.
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: BUG #5996: CURRENT_TIMESTAMP uses often undesired TRANSACTION_TIMESTAMP, instead of STATEMENT_TIMESTAMP
2011-04-28 19:33 BUG #5996: CURRENT_TIMESTAMP uses often undesired TRANSACTION_TIMESTAMP, instead of STATEMENT_TIMESTAMP Brian S. Krug <bkrug@usatech.com>
@ 2011-05-11 19:55 ` Robert Haas <robertmhaas@gmail.com>
1 sibling, 0 replies; 3+ messages in thread
From: Robert Haas @ 2011-05-11 19:55 UTC (permalink / raw)
To: Brian S. Krug <bkrug@usatech.com>; +Cc: pgsql-bugs
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
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2011-05-11 19:55 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-04-28 19:33 BUG #5996: CURRENT_TIMESTAMP uses often undesired TRANSACTION_TIMESTAMP, instead of STATEMENT_TIMESTAMP Brian S. Krug <bkrug@usatech.com>
2011-04-29 05:34 ` John R Pierce <pierce@hogranch.com>
2011-05-11 19:55 ` Robert Haas <robertmhaas@gmail.com>
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