Received: from neodymium.btinternet.com (neodymium.btinternet.com [194.73.73.83]) by hub.org (8.9.3/8.9.3) with ESMTP id OAA41728 for ; Tue, 7 Dec 1999 14:39:02 -0500 (EST) (envelope-from gary.stainburn@ringways.co.uk) Received: from [212.140.1.5] (helo=linux.ringways.co.uk) by neodymium.btinternet.com with esmtp (Exim 2.05 #1) id 11vQRy-0000DU-00; Tue, 7 Dec 1999 19:39:03 +0000 Received: from garys.ringways.co.uk (garys.ringways.co.uk [10.1.1.2]) by linux.ringways.co.uk (8.7.6/8.7.3) with SMTP id TAA13779; Tue, 7 Dec 1999 19:39:37 GMT Received: by garys.ringways.co.uk with Microsoft Mail id <01BF40EA.63E2DC00@garys.ringways.co.uk>; Tue, 7 Dec 1999 19:36:43 -0000 Message-ID: <01BF40EA.63E2DC00@garys.ringways.co.uk> From: Gary Stainburn To: "'Tom Lane'" Cc: "'Pgsql Interfaces'" Subject: RE: [INTERFACES] locking on database updates Date: Tue, 7 Dec 1999 19:36:41 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit -----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" 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 -----------------------------------------