X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 455E0D1B182 for ; Sat, 17 Jul 2004 19:58:51 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 04405-07 for ; Sat, 17 Jul 2004 22:58:51 +0000 (GMT) Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [203.79.85.162]) by svr1.postgresql.org (Postfix) with ESMTP id 81293D1B17B for ; Sat, 17 Jul 2004 19:58:47 -0300 (ADT) Received: from 203-79-104-60.cable.paradise.net.nz ([203.79.104.60] helo=opencloud.com) by yass.opencloud.co.nz with asmtp (Exim 3.35 #1 (Debian)) id 1Bly8l-000180-00; Sun, 18 Jul 2004 10:58:47 +1200 Message-ID: <40F9AF24.9090601@opencloud.com> Date: Sun, 18 Jul 2004 10:58:44 +1200 From: Oliver Jowett User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Kris Jurka Cc: "pgsql-jdbc@postgresql.org" Subject: Re: revisiting transaction isolation References: <40F8A692.8000105@opencloud.com> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200407/220 X-Sequence-Number: 10604 Kris Jurka wrote: > > On Sat, 17 Jul 2004, Oliver Jowett wrote: > > >>Currently, this type of code will fail: >> >> >>> conn.setAutoCommit(false); >>> if (conn.getTransactionIsolation() != Connection.TRANSACTION_SERIALIZABLE) >>> conn.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE); >> >>The problem is that getTransactionIsolation() issues a query and thus >>starts a new transaction, and then setTransactionIsolation() complains >>you can't change isolation level mid-transaction. >> >>I'm not sure this is reasonable behaviour. One option is to make >>getTransactionIsolation (and what other methods too?) not cause a BEGIN >>to occur if there is no transaction in progress and autocommit is off. > > > I see no reason for getTransactionIsolation or any driver call to start a > transaction, these are only SELECTs and won't be rolled back anyway. It's ok for getTransactionIsolation(), but what about, say, metadata queries -- we do want transaction isolation to apply there even if it's just a SELECT, right? A quick skim of AbstractJdbc2Connection turns up these methods as candidates for ignoring autocommit: - getTransactionIsolation() - getPGType (both versions) on a cache miss It seems reasonable to suppress BEGINs for both of those cases. I can put together a patch to do that. I'll leave the metadata queries alone for the moment. >>>The return value of the method getTransactionIsolation should reflect >>>the change in isolation level when it actually occurs. [...] > > This seems confusing and error prone. Ok -- I'll leave that alone too. -O