Re: [PHP] Re: Getting last record ID created from DB



Richard Lynch wrote:

On Mon, March 19, 2007 10:58 pm, markw@xxxxxxxxxxxxxx wrote:
markw@xxxxxxxxxxxxxx wrote:
markw@xxxxxxxxxxxxxx wrote:
On Sat, 2007-03-17 at 12:19 -0400, Mark wrote:
Check the documentation - currval returns the last one *for that
session* - it does not return the last global change.

http://www.postgresql.org/docs/current/static/functions-sequence.html

It is perfectly safe to use this.

In theory that may be true, but can the application developer make any
assumption about the underlying architecture? Might you be familiar
with
connection pooling? Where multiple threads or processes share a
database
connection or "session?"

If the pool breaks the documentation about current session, the pool
is broken.

Fix it.

:-)

I don't think the "pool" will give you somebody else's ID, for the
record. It's smart enough to not do that, I *believe*, mostly on
faith.

I've seen some pretty disturbing behavior in some Oracle connection pooling
software. The problem is that you don't know it is the connection pool
causing the problem until you chase it down.
.