Re: OID's

From: Doug McNaught <doug(at)mcnaught(dot)org>
To: eddy(at)edlsystems(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: OID's
Date: 2004-10-23 15:30:02
Message-ID: 87k6tho3k5.fsf@asmodeus.mcnaught.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Eddy Macnaghten <eddy(at)edlsystems(dot)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

In response to

  • Re: OID's at 2004-10-23 14:42:20 from Eddy Macnaghten

Browse pgsql-general by date

  From Date Subject
Next Message Leen Besselink 2004-10-23 15:46:51 Re: OID's
Previous Message Stephan Szabo 2004-10-23 15:20:51 Re: Bug or stupidity