Re: Re: SERIAL values - Mailing list pgsql-general

From Michael Fork
Subject Re: Re: SERIAL values
Date
Msg-id Pine.BSI.4.21.0103021057140.14787-100000@glass.toledolink.com
Whole thread Raw
In response to Re: SERIAL values  ("Gregory Wood" <gregw@com-stock.com>)
List pgsql-general
This is an incorrect statement (as pointed out in the FAQ)

4.16.3) Don't currval() and nextval() lead to a race condition with other
users?
No. This is handled by the backends.

More info:
http://www.postgresql.org/users-lounge/docs/7.0/user/sql-createsequence.htm

When calling currval, you recieve the last value used by *your backend*
(regardless of what others have done).

Michael Fork - CCNA - MCP - A+
Network Support - Toledo Internet Access - Toledo Ohio

On Fri, 2 Mar 2001, Gregory Wood wrote:

> SELECT currval('Table_SerialField_SEQ');
>
> Note: This selects the last value of the sequence defined by your SERIAL
> sequence, not necessarily the value in your INSERT. For example:
>
> 1. User A INSERTs.
> 2. User B INSERTs.
> 3. User A performs SELECT currval, which returns the value for User B's
> INSERT.
>
> If this could be a potential problem, I recommend peforming a:
>
> SELECT nextval('Table_SerialField_SEQ');
>
> *before* you perform the INSERT, and explicitly using that value.
>
> Greg
>
> ----- Original Message -----
> From: "Kostis Mentzelos" <mentzelos@ematic.com>
> To: <pgsql-general@postgresql.org>
> Sent: Thursday, March 01, 2001 5:53 PM
> Subject: SERIAL values
>
>
> > Hi all,
> >
> > how can I get the current values from SERIAL types after an INSERT using
> >
> > libpq?
> >
> >
> > Thanks,
> > kostis.
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
> >
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>


pgsql-general by date:

Previous
From: Raymond Chui
Date:
Subject: Re: store procedure in pl/pgsql
Next
From: Bruce Momjian
Date:
Subject: Re: Re: Want to learn the Postgresql database system