From: Oliver Jowett <oliver@opencloud.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Adriaan Joubert <a.joubert@albourne.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: currval() race condition on server?
Date: Mon, 23 Oct 2006 22:32:06 +0000
Message-ID: <453D42E6.8020102@opencloud.com> (raw)
In-Reply-To: <23634.1161613423@sss.pgh.pa.us>
References: <453CC859.8070306@albourne.com>
<23634.1161613423@sss.pgh.pa.us>
Tom Lane wrote:
> Adriaan Joubert <a.joubert@albourne.com> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: oliver@opencloud.com, tgl@sss.pgh.pa.us, a.joubert@albourne.com, pgsql-jdbc@postgresql.org
Subject: Re: currval() race condition on server?
In-Reply-To: <453D42E6.8020102@opencloud.com>
References: <453CC859.8070306@albourne.com> <23634.1161613423@sss.pgh.pa.us> <453D42E6.8020102@opencloud.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox