pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Josh Berkus <josh@agliodbs.com>
Cc: Charles Hauser <chauser@duke.edu>
Cc: pgsql-sql@postgresql.org
Subject: Re: problem fetching currval of sequence
Date: Tue, 06 Aug 2002 12:25:44 -0400
Message-ID: <20611.1028651144@sss.pgh.pa.us> (raw)
In-Reply-To: <web-1602018@davinci.ethosmedia.com>
References: <web-1602018@davinci.ethosmedia.com>

"Josh Berkus" <josh@agliodbs.com> writes:
> Sometime in the upgrade process for 7.1.0 --> 7.2.1, the CURRVAL
> function changed so that it was rigorously session-specific.

Huh?  AFAIR it's always worked the way it does now (and a quick review
of the CVS logs for sequence.c backs up my recollection).

> ... it has the unfortunate
> side effect that CURRVAL is virtually useless for querying the current
> value of the row you just inserted using a front-end that creates a new
> session for each command.   

Such a front end would be too broken to consider using anyway: if you
cannot wrap several related commands into a transaction, you cannot use
a database the way it's intended to be used.  The connection-pooling
front ends that I know about all give you dedicated use of a connection
for at least the length of a transaction block, so the secret to using
currval is "do it in the same transaction block as you call nextval in".

			regards, tom lane



view thread (12+ messages)  latest in thread

Message-ID: <20611.1028651144@sss.pgh.pa.us>
Permalink:  ../20611.1028651144@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/20611.1028651144@sss.pgh.pa.us

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, josh@agliodbs.com, chauser@duke.edu
  Subject: Re: problem fetching currval of sequence
  In-Reply-To: <20611.1028651144@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