Skip site navigation (1) Skip section navigation (2)

Re: [JDBC] Problem with Serializable transactions

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Oliver Jowett <oliver(at)opencloud(dot)com>
Cc: Robert Green <Robert(dot)Green(at)marconi(dot)com>,pgsql-bugs(at)postgresql(dot)org, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: [JDBC] Problem with Serializable transactions
Date: 2004-03-26 02:18:31
Message-ID: 17707.1080267511@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-bugspgsql-jdbc
Oliver Jowett <oliver(at)opencloud(dot)com> writes:
> What do we do if setTransactionIsolation() is called halfway through a 
> transaction?

You can't change the isolation status of an already-started transaction
(both Postgres and the SQL spec agree on this).  So to the extent that
the user expects this to affect the current xact and not just subsequent
xacts, that's user error that might be best addressed through
documentation.  However, it sounds like the JDBC driver is contributing
to the problem by delaying the effectiveness of the SET more than a user
would reasonably expect.

> Perhaps we should just always throw an exception if 
> setTransactionIsolation() is called with autocommit off, since we know 
> that doesn't work at all currently?

Might be a good quick-hack answer.  In the long run I think what you
ought to do is save the requested change and apply it during the next
transaction boundary --- that is,
	commit;begin
becomes
	commit; SET SESSION ... ; begin
I also wonder if you could force this to happen immediately if the
current transaction hasn't actually done anything yet.

Given your comment about the JDBC spec, Robert's test program is simply
wrong as written, so his answer is to change the order of calls.

			regards, tom lane

In response to

pgsql-bugs by date

Next:From: PostgreSQL Bugs ListDate: 2004-03-26 16:45:29
Subject: BUG #1116: "insert into" from "select" crashes backends
Previous:From: Oliver JowettDate: 2004-03-26 01:37:17
Subject: Re: [JDBC] Problem with Serializable transactions

pgsql-jdbc by date

Next:From: Barry LindDate: 2004-03-26 20:06:49
Subject: Re: [HACKERS] Bad timestamp external representation
Previous:From: Mikhail TsDate: 2004-03-26 02:15:50
Subject: Invalid message format

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group