Re: OID's - Mailing list pgsql-general

From Doug McNaught
Subject Re: OID's
Date
Msg-id 87k6tho3k5.fsf@asmodeus.mcnaught.org
Whole thread Raw
In response to Re: OID's  (Eddy Macnaghten <eddy@edlsystems.com>)
List pgsql-general
Eddy Macnaghten <eddy@edlsystems.com> writes:

> The other thing to be aware of is if a large number of people are
> writing to the database concurrently it can go wrong (any method).  That
> is if you insert a record (using nextval for the sequence), then someone
> else quickly inserts a row too before you have a chance to get the
> sequence number at the next statement then the sequence number you get
> will be wrong (it would be of the new one, not yours).  This would be
> the case regardless of how the records are committed.

Not the case.  If you use currval(), it will always be the last value
the sequence took *in your session*, so it's immune to other sessions
inserting at the same time.  See the docs.

-Doug

pgsql-general by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: Bug or stupidity
Next
From: "Leen Besselink"
Date:
Subject: Re: OID's