Re: GetLastInsertID ? - Mailing list pgsql-general

From Mike Nolan
Subject Re: GetLastInsertID ?
Date
Msg-id 200401042215.i04MF0Xo000964@gw.tssi.com
Whole thread Raw
In response to Re: GetLastInsertID ?  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: GetLastInsertID ?
List pgsql-general
> If you are using persistent connections in PHP you have to be very
> careful, because independent bits of PHP script may re-use the same
> database connection, and thereby will see a common currval value.
> After doing a nextval, you have to be sure to fetch currval before
> releasing the connection back to the pool.

I don't think I was using persistent connections at the time, as I have
security concerns about them.

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.

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.
--
Mike Nolan

pgsql-general by date:

Previous
From: Paul Ganainm
Date:
Subject: Re: Is my MySQL Gaining ?
Next
From: Doug McNaught
Date:
Subject: Re: GetLastInsertID ?