From: Mark Lewis <mark.lewis@mir3.com>
To: Mike Clements <mclement@progress.com>
Cc: A.M. <agentm@themactionfaction.com>
Cc: PostgreSQL JDBC List <pgsql-jdbc@postgresql.org>
Subject: Re: Fetching generated keys
Date: Mon, 05 Mar 2007 14:28:36 -0800
Message-ID: <1173133716.16656.1017.camel@archimedes> (raw)
In-Reply-To: <626C0646ACE5D544BC9675C1FB81846B3388D1@MAIL03.bedford.progress.com>
References: <626C0646ACE5D544BC9675C1FB81846B3388D1@MAIL03.bedford.progress.com>
On Mon, 2007-03-05 at 17:19 -0500, Mike Clements wrote:
...
> The FAQ you posted suggests that "currval" uses a level of isolation
> that is more strict than the default "read committed". If so, setting
> isolation level to serializable would be unnecessary. Is that true? Or
> should I do it just to be safe? I'd hate to do it if unnecessary due to
> the performance and locking implications.
Yes, currval definitely returns the last value returned by the sequence
in the current transaction. Anything done in other transactions is
ignored.
Just for kicks, I did a simple test with two psql sessions to
demonstrate:
psql1: BEGIN TRANSACTION;
psql1: SELECT nextval('my_seq'); -- returns 4988
psql2: BEGIN TRANSACTION;
psql2: SELECT nextval('my_seq'); -- returns 4989
psql1: SELECT currval('my_seq'); -- returns 4988
(also tested with psql2 committing the transaction before psql1 reads
currval. Made no difference.)
-- Mark Lewis
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: mark.lewis@mir3.com, mclement@progress.com, agentm@themactionfaction.com
Subject: Re: Fetching generated keys
In-Reply-To: <1173133716.16656.1017.camel@archimedes>
References: <626C0646ACE5D544BC9675C1FB81846B3388D1@MAIL03.bedford.progress.com> <1173133716.16656.1017.camel@archimedes>
* 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