Re: Last ID Problem

From: Mitch Pirtle <mitch(dot)pirtle(at)gmail(dot)com>
To: Michael Fuhr <mike(at)fuhr(dot)org>
Cc: operationsengineer1(at)yahoo(dot)com, pgsql-novice(at)postgresql(dot)org
Subject: Re: Last ID Problem
Date: 2005-02-01 01:55:22
Message-ID: 330532b605013117551658dd1d@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-novice

On Mon, 31 Jan 2005 18:38:55 -0700, Michael Fuhr <mike(at)fuhr(dot)org> wrote:
>
> Contrary to what another message in this thread says, it is indeed
> common practice to do the insert first and call currval() afterwards
> to find out what value you got from the sequence. And no, this
> doesn't introduce a race condition -- currval() returns the last
> value obtained from the sequence in the current session.

Tell that to the maintainers of PEAR's DB, which is installed by
default with all recent versions of PHP (that would be all of them). I
felt the exact same way as you did, and spent an afternoon
rediscovering the joys of sequence values until one of the maintainers
pointed out that behavior. I even tried to convince them that this was
a bug ('inappropriate behavior' was the term IIRC)...

'Common', unfortunately, is relative; and in this matter might only
apply to ADOdb ;-)

-- Mitch, getting his PHP database classes all mixed up *gasp*

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2005-02-01 03:45:08 Re: [Feed-back] Installing PostgreSQL 8.0.0 on SPARC/Solaris. Configure and install issues.
Previous Message Michael Fuhr 2005-02-01 01:45:55 Re: Last ID Problem

Browse pgsql-novice by date

  From Date Subject
Next Message Alexander Borkowski 2005-02-01 02:09:11 Re: pgAdminIII and User Grants
Previous Message Mike G. 2005-02-01 01:53:55 Re: pgAdminIII and User Grants