Re: problem fetching currval of sequence - Mailing list pgsql-sql

From Josh Berkus
Subject Re: problem fetching currval of sequence
Date
Msg-id 200208061135.20799.josh@agliodbs.com
Whole thread Raw
In response to Re: problem fetching currval of sequence  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: problem fetching currval of sequence  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: problem fetching currval of sequence  (Charles Hauser <chauser@duke.edu>)
List pgsql-sql
Tom,

> 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).

No, back in 7.1.0 I was able to call CURRVAL without having previously called
NEXTVAL, and it would give me the "current" sequence value; that is, the same
result value as (NEXTVAL() - 1);   I wouldn't mind having a new function that
does this; I can understand making a distinction between the pre-session
CURRVAL, and the general current value.

> 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".

Me, I use functions.


--
-Josh BerkusAglio Database SolutionsSan Francisco



pgsql-sql by date:

Previous
From: Jean-Luc Lachance
Date:
Subject: Re: SQL syntax
Next
From: Tom Lane
Date:
Subject: Re: problem fetching currval of sequence