Received: from makus.postgresql.org (makus.postgresql.org [98.129.198.125]) by mail.postgresql.org (Postfix) with ESMTP id 1C664D84656 for ; Fri, 8 Jun 2012 10:13:57 -0300 (ADT) Received: from mail-pb0-f46.google.com ([209.85.160.46]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Scz0l-0008FC-Hz for pgsql-jdbc@postgresql.org; Fri, 08 Jun 2012 13:13:56 +0000 Received: by pbbrp8 with SMTP id rp8so2532798pbb.19 for ; Fri, 08 Jun 2012 06:13:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=xcVpDjAh0DY4VcWkOaEvolCApsF0siYVc0g7CrxaGbY=; b=HY6YFReAwiLnJE6/isleOVZlrUHrnJHpSKx/qdq8eGvG9P53zBjccm4w1BMn68yAnk dgLg5+IEzABqyCwV3rucP1PR7Fxxy//02YATw/ui4kzB//osPJn0nGf9j6XscmRrk/jm tBfPgtEJ6nXW1NDRAH7GwODqNDX6jk+n72zhEJIAwgJFhqSfujihSRXz2r19JoRvyqVQ lMvJAGVQvbXwqhwlR4i0jyPjBZxdfrJEPCeZvRh91XeAwQHIS8rOYwfqDA8/UblnZfYR WEQ5C+JW7yrlN5cXhWJHdyJjey709phn4Ki7OecJxr/z3gi5C0Nlt4th+SmoS0uGr/Jk gU2Q== Received: by 10.68.218.103 with SMTP id pf7mr19982338pbc.67.1339161222022; Fri, 08 Jun 2012 06:13:42 -0700 (PDT) Received: from ayaki.localdomain (124-169-197-239.dyn.iinet.net.au. [124.169.197.239]) by mx.google.com with ESMTPS id sy3sm7824559pbc.18.2012.06.08.06.13.38 (version=SSLv3 cipher=OTHER); Fri, 08 Jun 2012 06:13:40 -0700 (PDT) Message-ID: <4FD1FA7F.4050400@ringerc.id.au> Date: Fri, 08 Jun 2012 21:13:35 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 MIME-Version: 1.0 To: Johann 'Myrkraverk' Oskarsson CC: PostgreSQL JDBC 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: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQnUoaYUp9abp/ZJaLP9hcUUUC/OK7TdQKksk2XbA4o4eDG/1EkLD55LewgTwtAPNFEDZmEA X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201206/27 X-Sequence-Number: 23021 On 06/08/2012 04:19 PM, Johann 'Myrkraverk' Oskarsson wrote: > Craig Ringer writes: > >> The JDBC driver really needs a way to grab everything it needs to know >> efficiently during initial connection setup, with some extensibility >> so connection parameters can specify other things to request and cache >> when the connection is first established. > > Something like > > SELECT current_setting( 'shared_buffers' ) > UNION > SELECT current_setting( 'data_directory' ); > > for some randomly chosen settings? Of course the query will need to be > structured with key/values to be useful. I was thinking more of running something like: regress=# SELECT name, setting FROM pg_settings WHERE name IN ('client_encoding','server_encoding','bytea_output','standard_conforming_strings', 'xmlbinary','DateStyle','TimeZone','array_nulls','backslash_quote','IntervalStyle', 'quote_all_identifiers', 'default_transaction_read_only'); name | setting -------------------------------+---------------- array_nulls | on backslash_quote | safe_encoding bytea_output | hex client_encoding | UTF8 default_transaction_read_only | off DateStyle | ISO, MDY IntervalStyle | postgres quote_all_identifiers | off server_encoding | UTF8 standard_conforming_strings | on TimeZone | Australia/West xmlbinary | base64 (11 rows) ... preferably combined with a mechanism for the server to notify (or NOTIFY) the JDBC client when a pg_ctl reload or a SET causes settings to change. While the JDBC driver could try to track SET commands sent by its own client, that would be trivially foiled by a SET wrapped in a function, so really the server needs to tell the JDBC driver. The main hurdles with using LISTEN/NOTIFY for that are: - No triggers allowed on system tables so server code changes are required; and - If using LISTEN/NOTIFY, a way would be needed to make sure the application never saw NOTIFY messages destined for PgJDBC (not hard with payload notifies) and that a PgJDBC driver LISTEN name never clashed with an application one. - The JDBC driver won't find out about a settings change until the end of a long-running query. Dunno of that matters, really. The reason I'm interested in this is to allow the JDBC driver to do the right thing for situations where server settings change how it should interpret or send data. It'd also allow the JDBC driver to entirely cut out server round trips and log spew on the backend when query generators, ORMs, etc query settings. For example, one tool I use will issue a `SHOW TRANSACTION ISOLATION;` painfully frequently; being able to have PgJDBC answer that without a round trip by examining its cached `transaction_isolation` would be great. -- Craig Ringer