pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Gary Stainburn <gary.stainburn@ringways.co.uk>
To: 'Tom Lane' <tgl@sss.pgh.pa.us>
Cc: 'Pgsql Interfaces' <pgsql-interfaces@postgresql.org>
Subject: RE: [INTERFACES] locking on database updates
Date: Tue, 7 Dec 1999 19:36:41 -0000
Message-ID: <01BF40EA.63E2DC00@garys.ringways.co.uk> (raw)


-----Original Message-----
From:	Tom Lane [SMTP:tgl@sss.pgh.pa.us]
Sent:	Tuesday, December 07, 1999 6:00 PM
To:	Ross J. Reedstrom
Cc:	Gary Stainburn; 'Pgsql Interfaces'
Subject:	Re: [INTERFACES] locking on database updates 

|"Ross J. Reedstrom" <reedstrm@wallace.ece.rice.edu> writes:
|> create table foo (bar serial, baz text);
|> insert into foo (baz) values ('wooble');
|> select currval('foo_bar_seq');
|
|I don't think this is safe in a multi-client environment;
|what if someone else inserts at about the same time?
|
|Better to do
|	select nextval('foo_bar_seq');
|	insert into foo values (just-retrieved-value, 'wooble');
|which is safer and probably marginally faster (since the
|sequence object is touched only once, not twice).
|
|			regards, tom lane

Perfect - exactly what I need. Another fine day at the office.
-----------------------------------------
Gary Stainburn.
Work: http://www.ringways.co.uk gary.stainburn@ringways.co.uk
REVCOM: http://www.revcom.dhs.org http://www.revcom.org.uk gary.stainburn@revcom.org.uk
-----------------------------------------
The nice ones are always taken - anon
-----------------------------------------




view thread (21+ messages)  latest in thread

Message-ID: <01BF40EA.63E2DC00@garys.ringways.co.uk>
Permalink:  ../01BF40EA.63E2DC00@garys.ringways.co.uk/
Also on:    postgresql.org/message-id/01BF40EA.63E2DC00@garys.ringways.co.uk

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: gary.stainburn@ringways.co.uk, tgl@sss.pgh.pa.us
  Subject: RE: [INTERFACES] locking on database updates
  In-Reply-To: <01BF40EA.63E2DC00@garys.ringways.co.uk>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox