Received: from sss.sss.pgh.pa.us (sss.pgh.pa.us [209.114.166.2]) by hub.org (8.9.3/8.9.3) with ESMTP id NAA74322 for ; Tue, 7 Dec 1999 13:00:14 -0500 (EST) (envelope-from tgl@sss.pgh.pa.us) Received: from sss.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.sss.pgh.pa.us (8.9.1/8.9.1) with ESMTP id MAA23998; Tue, 7 Dec 1999 12:59:33 -0500 (EST) To: "Ross J. Reedstrom" cc: Gary Stainburn , "'Pgsql Interfaces'" Subject: Re: [INTERFACES] locking on database updates In-reply-to: Your message of Tue, 7 Dec 1999 11:12:34 -0600 <19991207111234.A6021@rice.edu> Date: Tue, 07 Dec 1999 12:59:33 -0500 Message-ID: <23996.944589573@sss.pgh.pa.us> From: Tom Lane "Ross J. Reedstrom" 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