Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 696559F9FAC for ; Wed, 15 Aug 2007 11:06:18 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 92971-02-4 for ; Wed, 15 Aug 2007 11:06:08 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from tremor.opencloud.co.nz (tremor.opencloud.co.nz [131.203.101.230]) by postgresql.org (Postfix) with ESMTP id 75C829F9FDD for ; Wed, 15 Aug 2007 11:06:14 -0300 (ADT) Received: from 222-154-153-196.jetstream.xtra.co.nz ([222.154.153.196] helo=[10.1.1.3]) by tremor.opencloud.co.nz with esmtpsa (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1ILJVj-0003jD-57; Thu, 16 Aug 2007 02:06:11 +1200 Message-ID: <46C30863.3080709@opencloud.com> Date: Thu, 16 Aug 2007 02:06:27 +1200 From: Oliver Jowett User-Agent: Thunderbird 1.5.0.12 (Windows/20070509) MIME-Version: 1.0 To: roehm@it.usyd.edu.au CC: pgsql-jdbc@postgresql.org Subject: Re: autocommit and stored procedures References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200708/67 X-Sequence-Number: 17380 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