From: Oliver Jowett <oliver@opencloud.com>
To: roehm@it.usyd.edu.au
Cc: pgsql-jdbc@postgresql.org
Subject: Re: autocommit and stored procedures
Date: Thu, 16 Aug 2007 02:06:27 +1200
Message-ID: <46C30863.3080709@opencloud.com> (raw)
In-Reply-To: <D3A9FBB1-6304-4B25-878D-E0F1C06280BA@it.usyd.edu.au>
References: <D3A9FBB1-6304-4B25-878D-E0F1C06280BA@it.usyd.edu.au>
roehm@it.usyd.edu.au wrote:
> Which command granularity does the JDBC driver's autocommit have?
> Does it commit after each client-side JDBC statement, or does it commit
> each individual SQL statement on the server-side?
It effectively commits after each client-side JDBC statement execution,
even if you provide multiple semicolon-separated queries in a single
statement. At the protocol level the driver converts a single JDBC
statement into one or more groups of Parse/Bind/Execute messages,
followed by a single Sync. You can see this if you look at the debugging
produced with loglevel=2. Also see
http://www.postgresql.org/docs/8.2/static/protocol-flow.html#PROTOCOL-FLOW-EXT-QUERY
Regardless of that, there's no way I know of to get "autocommit" within
a stored procedure as you seem to be wanting, regardless of what client
driver you're using, because the server will always set up a transaction
(one way or another) before executing the top-level query that runs your
stored procedure so by the time your stored procedure is running it's
too late to think about transaction demarcation.
> Does anyone know what the specified behaviour is for JDBC AutoCommit?
See the javadoc for Connection.setAutoCommit():
> The commit occurs when the statement completes or the next execute occurs, whichever comes first. In the case of statements returning a ResultSet object, the statement completes when the last row of the ResultSet object has been retrieved or the ResultSet object has been closed. In advanced cases, a single statement may return multiple results as well as output parameter values. In these cases, the commit occurs when all results and output parameter values have been retrieved.
-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-jdbc@postgresql.org
Cc: oliver@opencloud.com, roehm@it.usyd.edu.au
Subject: Re: autocommit and stored procedures
In-Reply-To: <46C30863.3080709@opencloud.com>
References: <D3A9FBB1-6304-4B25-878D-E0F1C06280BA@it.usyd.edu.au> <46C30863.3080709@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