Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id D51979066D0 for ; Thu, 7 Jun 2012 11:07:44 -0300 (ADT) Received: from mailhub130.itcs.purdue.edu ([128.210.5.130]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1ScdNH-0004ao-Rc for pgsql-jdbc@postgresql.org; Thu, 07 Jun 2012 14:07:44 +0000 Received: from math.purdue.edu (gauss.math.purdue.edu [128.210.3.205]) by mailhub130.itcs.purdue.edu (8.14.4/8.14.4/mta.smtp.purdue.edu) with ESMTP id q57E7UmK007462 for ; Thu, 7 Jun 2012 10:07:30 -0400 Received: from mailrelay.math.purdue.edu (mailrelay.math.purdue.edu [128.210.3.183]) by math.purdue.edu (8.14.4+Sun/8.14.4/RPM-20111028-1) with ESMTP id q57E7U7o022232 for ; Thu, 7 Jun 2012 10:07:30 -0400 (EDT) Received: from hardy.math.purdue.edu [128.210.3.54] by mailrelay.math.purdue.edu (Alligate(TM) SMTP Gateway v3.11.5.9) with ESMPT id for ; Thu, 07 Jun 2012 10:07:14 -0400 Message-ID: <4FD0B592.5040602@math.purdue.edu> Date: Thu, 07 Jun 2012 10:07:14 -0400 From: J Chapman Flack User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.3) Gecko/20120307 Thunderbird/10.0.3 MIME-Version: 1.0 To: pgsql-jdbc@postgresql.org Subject: Re: get/setReadOnly broken if default_transaction_read_only on References: <4FCFB988.2080408@math.purdue.edu> <4FD08767.6000302@ringerc.id.au> In-Reply-To: <4FD08767.6000302@ringerc.id.au> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Alligate-SMTP: Whitelisted X-Alligate-ReceivingIP: [128.210.3.183] X-Originating-IP: 128.210.3.54 X-Destination-IP: X-Alligate-ID: 29045 X-Alligate-RcptTo: X-Alligate-Out: IGNORED - WhiteListed From: (@*purdue.edu) X-PMX-Version: 5.5.9.388399 X-PerlMx-Virus-Scanned: Yes X-Pg-Spam-Score: -2.6 (--) X-Archive-Number: 201206/43 X-Sequence-Number: 23037 On 06/07/2012 06:50 AM, Craig Ringer wrote: > > This may be an opportunity to improve how PgJDBC finds out important > details about the backend in general. > > Right now, lots of things require individual queries of GUCs via SHOW > commands or other misc queries. A typical JDBC session may do several > round trips before running its first real query, and it's only going to > get worse. > ... > (Why extensibility? Because various layers - ORMs, query builders, etc > etc etc - tend to ask for more GUCs, and having the JDBC driver able to > immediately return them without more round trips would be great). I certainly like that idea, but I hope someone won't mind doing the quick, current-practice fix for setReadOnly() meanwhile. There may be a large and growing set of new layers that all want more GUCs, but by contrast the set { x | x is defined by jdbc2 and doesn't currently work } is smaller and bounded, and getReadOnly/setReadOnly are in it. I'd submit a patch myself but this is really my first time looking at the code, I haven't set up a development workspace, and I'm hoping there's someone who could commit in 5 minutes what I'd be tinkering with much of the day while I learn. -Chap > On 06/07/2012 04:11 AM, J Chapman Flack wrote: >> >> Hi, >> >> 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.