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

get/setReadOnly broken if default_transaction_read_only on

From: J Chapman Flack <jflack(at)math(dot)purdue(dot)edu>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: get/setReadOnly broken if default_transaction_read_only on
Date: 2012-06-06 20:11:52
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-jdbc

I've found this in the git head so it applies to current versions.

AbstractJdbc2Connection initializes its readOnly member to a
hardcoded false instead of to 'show default_transaction_read_only'
from the backend.

That means two things: 1. getReadOnly() is wrong in case the
backend has default_transaction_read_only on, and

2. setReadOnly(false) doesn't work in that case, because the value
is compared to readOnly and looks the same, so no set session
characteristics command is sent to the backend.

An application can work around (2) by always calling
setReadOnly(true);setReadOnly(false); if it wants to write.
But that's a bit ugly.

The driver could do that too for a quick hack, but it would
be nice to query the correct value from the backend and use that.

Chapman Flack


pgsql-jdbc by date

Next:From: Kevin GrittnerDate: 2012-06-06 20:49:53
Subject: Re: get/setReadOnly broken if default_transaction_read_only on
Previous:From: Dave CramerDate: 2012-06-04 17:31:33
Subject: Re: REL9_2_DEVEL

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