Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id E1E6D2E0068 for ; Wed, 20 Feb 2008 09:42:02 -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 48484-01-2 for ; Wed, 20 Feb 2008 09:41:51 -0400 (AST) Received: from fk-out-0910.google.com (fk-out-0910.google.com [209.85.128.188]) by postgresql.org (Postfix) with ESMTP id 84B0D2E005E for ; Wed, 20 Feb 2008 09:41:58 -0400 (AST) Received: by fk-out-0910.google.com with SMTP id b27so2963324fka.3 for ; Wed, 20 Feb 2008 05:41:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=9ecVgn+WlpgERAvNN37qqbkDpmmOzKgsLVg4Csz9aJ8=; b=gZrmVp3FCaOKXVuWP7/evJ9Id0+Fg2pHNXuSgEwdbrjUXh0e18VWM/OBBtEJaRc3kv9Lmi9G2584GUUqCiHG2ejqKvUAcYw88pF1TQF96rZ5CLa3aCpTVy5d1Of0dhdkbuwmRjRg8IyUzBSEpgqigbqDvCJU8/eHms1djN9bePs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=l7MK7T1J6hLTYfHrHzJj4rHRoFjpr7o0VW9QLQ8Ibucdld/J2rk/s8fV6pTsTdEJNqilYI7McPnUlFjBTi/HDjsPRcLgZP5hwI/OAlsPq4N1BH+GC7AkRxa5onMsOCsOxwC0whrtfs/oXs+GeBTHUDD3Xf5ayCp0Db53aBWOM40= Received: by 10.82.184.2 with SMTP id h2mr14628282buf.32.1203514916884; Wed, 20 Feb 2008 05:41:56 -0800 (PST) Received: by 10.82.180.9 with HTTP; Wed, 20 Feb 2008 05:41:56 -0800 (PST) Message-ID: <8efd35820802200541p14e99d8bx60ad628302b24f14@mail.gmail.com> Date: Wed, 20 Feb 2008 08:41:56 -0500 From: "Paul Tomblin" To: pgsql-jdbc@postgresql.org Subject: Re: Retrieving last InsertedID : INSERT... RETURNING safe ? In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200802/166 X-Sequence-Number: 18373 On Feb 20, 2008 8:32 AM, Dave Cramer wrote: > As far as I can tall Paul has inherited an application which uses a > single connection for all database operations, and is a swing app > which has callbacks which do the following > > Callback code > > grab the global connection object > create a statement > do something > close statement > > in this scenario, since currval has connection scope if two callbacks > are called at the same time, only one will have the right answer . > > Paul am I correct in my assumptions above ? Pretty much, except with the added complication that there are a dozen or so daemons that are also updating the same tables, and up until now they've all had autocommit on. I thought the currval had transaction scope not connection scope, at least that's what my testing in pgsql seemed to indicate, which is why I stated that autocommit was a problem. Are you saying that if in one connection I do a nextval and commit, and somebody else in a different connection does a hundred nextvals and commits, then 20 minutes later I do the currval I'll get the one from my old transaction? -- For my assured failures and derelictions I ask pardon beforehand of my betters and my equals in my Calling here assembled, praying that in the hour of my temptations, weakness and weariness, the memory of this my Obligation and of the company before whom it was entered into, may return to me to aid, comfort and restrain.