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 77647D1B2A6 for ; Sat, 17 Jul 2004 04:37:21 -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 41972-03 for ; Sat, 17 Jul 2004 07:37:23 +0000 (GMT) Received: from mail63.csoft.net (leary3.csoft.net [63.111.22.74]) by svr1.postgresql.org (Postfix) with SMTP id BF135D1B27A for ; Sat, 17 Jul 2004 04:37:16 -0300 (ADT) Received: (qmail 24698 invoked by uid 1112); 17 Jul 2004 07:37:23 -0000 Date: Sat, 17 Jul 2004 02:37:23 -0500 (EST) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: Oliver Jowett Cc: "pgsql-jdbc@postgresql.org" Subject: Re: revisiting transaction isolation In-Reply-To: <40F8A692.8000105@opencloud.com> Message-ID: References: <40F8A692.8000105@opencloud.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/216 X-Sequence-Number: 10600 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. > On a related topic I just took a look at the JDBC3 spec and it says: > > > The return value of the method getTransactionIsolation should reflect > > the change in isolation level when it actually occurs. It is recommended > > that drivers implement the setTransactionIsolation method to change the > > isolation level starting with the next transaction. Committing the > > current transaction to make the effect immediate is also a valid > > implementation. This seems confusing and error prone. I would expect a command I issue to take effect immediately or throw an Exception, not do nothing now, but alter later behavior. Kris Jurka