Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id DB5F32E006C for ; Wed, 20 Feb 2008 10:00:01 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 76840-09 for ; Wed, 20 Feb 2008 09:59:49 -0400 (AST) Received: from beaver.fastcrypt.com (beaver.fastcrypt.com [64.7.141.17]) by postgresql.org (Postfix) with ESMTP id 84ECA2E0070 for ; Wed, 20 Feb 2008 09:59:57 -0400 (AST) Received: from [192.168.1.14] (dcdsl.ebox.com [64.7.143.116]) by beaver.fastcrypt.com (Postfix) with ESMTP id F3BAA158036C; Wed, 20 Feb 2008 09:03:16 -0500 (EST) Cc: "Paul Tomblin" , Message-Id: From: Dave Cramer To: Heikki Linnakangas In-Reply-To: <47BC300E.1030507@enterprisedb.com> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v919.2) Subject: Re: Retrieving last InsertedID : INSERT... RETURNING safe ? Date: Wed, 20 Feb 2008 08:59:55 -0500 References: <38245.1203500677@motionsponsor.com> <47BC0AF6.2060500@enterprisedb.com> <87prurrh87.fsf@mnc.ch> <55C92F71-0317-4E91-A092-C22A7A2F1FD8@fastcrypt.com> <47BC1AC4.5010809@gmail.com> <9096E930-A528-4AF7-92B9-6EB1A5A52F84@fastcrypt.com> <47BC2798.9010300@enterprisedb.com> <8efd35820802200536n22c75f92u97474ab4d3a9cdee@mail.gmail.com> <47BC300E.1030507@enterprisedb.com> X-Mailer: Apple Mail (2.919.2) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200802/168 X-Sequence-Number: 18375 On 20-Feb-08, at 8:50 AM, Heikki Linnakangas wrote: > Paul Tomblin wrote: >> On Feb 20, 2008 8:14 AM, Heikki Linnakangas >> wrote: >>> Dave Cramer wrote: >>>> I was going to say there are absolutely no situations where this >>>> is not >>>> true, however in your case autocommit or not it doesn't matter. >>>> You have a single connection for the entire application and >>>> asynchronous >>>> events using that connection. Autocommit or not it will not work >>>> with >>>> currval. >>>> >>>> In your case you must use nextval before doing the insert. >>> Now you lost me. By asynchronous events, do you mean NOTIFY/ >>> LISTEN? What >>> exactly is the scenario you're talking about? >> In my case, we're talking about a system that has dozens of Java >> processes, many of which access the database. Because the system >> used >> to have autocommit on, one process could do the "insert nextval" and >> commit, and then another process could do an "insert nextval" and >> commit, and then the first process would do the "select currval" and >> would probably get the wrong value. > > From Dave's comment, I gather that those processes return the > connection to the pool and grab a new one between the "insert > nextval" and "select currval" steps? Yeah, I can see the problem in > that case. > No, there is no pool, only one connection. > -- > Heikki Linnakangas > EnterpriseDB http://www.enterprisedb.com > > ---------------------------(end of > broadcast)--------------------------- > TIP 1: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly