Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id AA57F9F9765 for ; Thu, 16 Aug 2007 07:20:10 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 52137-01 for ; Thu, 16 Aug 2007 07:19:55 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from beaver.fastcrypt.com (beaver.fastcrypt.com [64.7.141.17]) by postgresql.org (Postfix) with ESMTP id 32CCE9F9776 for ; Thu, 16 Aug 2007 07:19:49 -0300 (ADT) Received: from [192.168.1.14] (dcdsl.ebox.com [64.7.143.116]) by beaver.fastcrypt.com (Postfix) with ESMTP id DC53D1580699; Thu, 16 Aug 2007 06:19:52 -0400 (EDT) In-Reply-To: References: Mime-Version: 1.0 (Apple Message framework v752.3) Content-Type: text/plain; charset=UTF-8; delsp=yes; format=flowed Message-Id: <77ED2597-BCE7-4BD1-9BD2-14EC2E178099@fastcrypt.com> Cc: , Content-Transfer-Encoding: quoted-printable From: Dave Cramer Subject: Re: autocommit and stored procedures Date: Thu, 16 Aug 2007 06:19:56 -0400 To: Albe Laurenz X-Mailer: Apple Mail (2.752.3) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200708/74 X-Sequence-Number: 17387 On 16-Aug-07, at 5:46 AM, Albe Laurenz wrote: > roehm@it.usyd.edu.au wrote: >> In particular, does an JDBC autocommit around the call to a stored >> procedure commit each statement within that stored procedure, or does >> it commit the procedure as a whole? > > A function in PostgreSQL is always executed within one single > transaction, so you cannot commit only part of the SQL-statements > within a function. > > The JDBC 4.0 specification says: > > The Connection attribute auto-commit specifies when to end =20 > transactions. Enabling > auto-commit causes a transaction commit after each individual SQL =20 > statement as > soon as that statement is complete. The point at which a statement =20= > is considered to > be "complete" depends on the type of SQL statement as well as what =20= > the application > does after executing it: > > =E2=96=A0 For Data Manipulation Language (DML) statements such as = Insert, =20 > Update, > Delete, and DDL statements, the statement is complete as soon as =20 > it has finished > executing. > =E2=96=A0 For Select statements, the statement is complete when the =20= > associated result set > is closed. > =E2=96=A0 For CallableStatement objects or for statements that return = =20 > multiple results, > the statement is complete when all of the associated result sets =20 > have been closed, > and all update counts and output parameters have been retrieved. Isn't that interesting I wonder who's database has the above select =20 and CallableStatement semantics. Dave > > To me that seems to mean that if I do > > executeUpdate("SELECT myfunction()") > > the autocommit should occur after the select statement is finished, =20= > i.e. > after the complete function has been executed. > > But I'll admit that this is disputable... > > Yours, > Laurenz Albe > > ---------------------------(end of =20 > broadcast)--------------------------- > TIP 9: In versions below 8.0, the planner will ignore your desire to > choose an index scan if your joining column's datatypes do not > match