Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id C89D36333FE for ; Wed, 21 Oct 2009 11:41:40 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 18934-10 for ; Wed, 21 Oct 2009 14:41:21 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from gw.wicourts.gov (gwmta.wicourts.gov [165.219.244.99]) by mail.postgresql.org (Postfix) with ESMTP id E2E3163321A for ; Wed, 21 Oct 2009 11:41:29 -0300 (ADT) Received: from Courts-MTA by gw.wicourts.gov with Novell_GroupWise; Wed, 21 Oct 2009 09:41:25 -0500 Message-Id: <4ADED72A020000250002BC40@gw.wicourts.gov> X-Mailer: Novell GroupWise Internet Agent 8.0.0 Date: Wed, 21 Oct 2009 09:40:58 -0500 From: "Kevin Grittner" To: "Oliver Jowett" Cc: , Subject: Re: commit and rollback don't throw exceptions when they should References: <4ADDCCE1020000250002BBEA@gw.wicourts.gov> <4ADF0210.4010100@opencloud.com> In-Reply-To: <4ADF0210.4010100@opencloud.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.589 tagged_above=-10 required=5 tests=AWL=0.010, BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200910/24 X-Sequence-Number: 20026 Oliver Jowett wrote: > Kevin Grittner wrote: > >> I could take a shot at a patch if nobody disagrees with making this >> change. > > What exactly is the change you're suggesting? I need to go back and see if any earlier versions conflict with this, but recent version of the Java API specify that commit and rollback should throw a SQLException if autoCommit is true. The driver currently returns without any warning or exception, and without doing anything. There is a similar requirement for these methods when a distributed transaction is active, which is only mentioned in Java 6 javadocs, but seems as though it makes sense whenever distributed transactions are used. Java 6 also explicitly mentions that an exception should be thrown for attempts to use these methods on a closed connection, although that could arguably fall under the earlier language requiring an exception when "a database access error occurs" -- since you can't access a database across a closed connection. This surfaced because a popular connection pooler is reportedly failing to behave correctly when the connection is lost (for example, if PostgreSQL is restarted). It works with other databases the user has tested. The user believes it to be because the rollback method is not throwing an exception on the closed connection. I haven't independently confirmed this yet. (Takiguchi, if you have a self-contained test case, that would save me some time on that point.) I'm suggesting that we throw exceptions for all of the above. It worries me that some existing applications may be relying on the silent success of a commit or rollback when autoCommit is active, though. That's contrary to the javadocs for the API, but there's still the backwards compatibility issue for current PostgreSQL users.... -Kevin