Re: GetLastInsertID ?

From: Doug McNaught <doug(at)mcnaught(dot)org>
To: Mike Nolan <nolan(at)gw(dot)tssi(dot)com>
Cc: tgl(at)sss(dot)pgh(dot)pa(dot)us (Tom Lane), kleptog(at)svana(dot)org, db(at)zigo(dot)dhs(dot)org (Dennis Bjorklund), spinel(at)noos(dot)fr (Stephane Pinel), pgsql-general(at)postgresql(dot)org
Subject: Re: GetLastInsertID ?
Date: 2004-01-04 23:04:30
Message-ID: 87smiv8ge9.fsf@asmodeus.mcnaught.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Mike Nolan <nolan(at)gw(dot)tssi(dot)com> writes:

> It sound to me like there's the potential for a second web program sharing
> the persistent connection to do something in between the nextval and
> the currval.

"Don't do that then."

Your code should hang on to the same connection for as long as it
needs to rely on the correct value of currval().

> Is currval for each process maintained at the front end (e.g., the PHP or
> psql connection) or at the back end? If the latter, isn't there always
> the potential for memory overflows or other high-demand situations causing
> the pairing of nextval/currval to get corrupted or lost, in which case
> RELYING upon it for the last key value could be a source of problems.

How, exactly, would this happen? Is this worry based on an analysis
of the source code, or just speculation?

-Doug

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Mike Nolan 2004-01-04 23:41:37 Re: GetLastInsertID ?
Previous Message Mike Nolan 2004-01-04 22:14:59 Re: GetLastInsertID ?