Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 3C45B9FB415 for ; Mon, 23 Oct 2006 19:32:47 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 45537-03 for ; Mon, 23 Oct 2006 19:32:33 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [131.203.101.226]) by postgresql.org (Postfix) with ESMTP id 5A0E79FB336 for ; Mon, 23 Oct 2006 19:32:32 -0300 (ADT) Received: from 222-152-242-244.jetstream.xtra.co.nz ([222.152.242.244] helo=[10.1.1.3]) by yass.opencloud.co.nz with asmtp (TLS-1.0:DHE_RSA_AES_128_CBC_SHA:16) (Exim 4.34) id 1Gc8LF-0004AJ-9S; Tue, 24 Oct 2006 11:32:21 +1300 Message-ID: <453D42E6.8020102@opencloud.com> Date: Mon, 23 Oct 2006 22:32:06 +0000 From: Oliver Jowett User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Tom Lane CC: Adriaan Joubert , pgsql-jdbc@postgresql.org Subject: Re: currval() race condition on server? References: <453CC859.8070306@albourne.com> <23634.1161613423@sss.pgh.pa.us> In-Reply-To: <23634.1161613423@sss.pgh.pa.us> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.908 tagged_above=0 required=5 tests=AWL, SPF_HELO_SOFTFAIL, SPF_SOFTFAIL X-Spam-Level: * X-Archive-Number: 200610/104 X-Sequence-Number: 15987 Tom Lane wrote: > Adriaan Joubert writes: > >>For some bookkeeping purposes I need the new audit number back from the >>update, so I submit a prepared statement through jdbc of the form >> >>UPDATE A SET ....; SELECT currval('ip_audit_seq'); > > > It's not possible to put two SQL commands into one prepared statement > --- at least not for the normal server-side meaning of "prepared statement". > I dunno what the JDBC driver is doing with this, but I wonder if it's > silently dropping the UPDATE part :-( The driver should split this query on the semicolons and send Parse/Bind/Execute for each part, followed by a Sync at the end. If it ends up using named statements due to JDBC statement reuse, it should use a different name for each part. Of course there might be unknown bugs in there, but it has been designed to handle this sort of compound statement.. To the OP: Is autocommit on or off? Can you reproduce the problem with a URL parameter of loglevel=2 and see what it looks like? (that'll generate a trace protocol-level messages) -O