Re: 'value' has special behaviour in alter system

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Jonathan S(dot) Katz" <jkatz(at)postgresql(dot)org>, "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, splarv(at)ya(dot)ru, pgsql-docs(at)lists(dot)postgresql(dot)org
Subject: Re: 'value' has special behaviour in alter system
Date: 2023-10-24 17:07:28
Message-ID: ZTf50EnaCrfbyWaV@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

On Thu, Dec 15, 2022 at 12:10:27PM -0500, Tom Lane wrote:
> "Jonathan S. Katz" <jkatz(at)postgresql(dot)org> writes:
> > On 12/15/22 10:50 AM, David G. Johnston wrote:
> >> I suggest changing it to:
> >> SET configuration_parameter { TO | = } { value [, ...] | DEFAULT }
>
> > +1 in general. I would also suggest we add an example in the Examples
> > section to show what the output is when you add single-quotes.
>
> I think the core problem here is that the syntax diagram and discussion
> don't clearly discuss the behavior for list values. David's version of
> the syntax diagram looks fine, but not sure about the text. There likely
> needs to be some explicit acknowledgement of the fact that some GUCs
> act differently than others (cf GUC_LIST_INPUT and GUC_LIST_QUOTE flags).
>
> +1 for examples, for sure.

Finally getting back to this, there is a lot going on and Tom is right
that the inconsistent use of GUC_LIST_QUOTE adds a lot of confusion.
Here are the list settings, and which ones add double-quotes to
non-alphanumeric quoted values:

GUC_LIST_QUOTE (adds quotes)
temp_tablespaces
session_preload_libraries
shared_preload_libraries
local_preload_libraries
search_path
unix_socket_directories

NO GUC_LIST_QUOTE (does not add quotes)
DateStyle
createrole_self_grant
log_destination
listen_addresses
synchronous_standby_names
wal_consistency_checking
debug_io_direct

and this leads to different quoting behaviors depending on which
category of list you are using. First, let's look at alphanumeric
values, which are treated the same by list types with different
GUC_LIST_QUOTE statuses:

ALTER SYSTEM SET shared_preload_libraries TO a, b, c;
.conf shared_preload_libraries = 'a, b, c'

ALTER SYSTEM SET listen_addresses TO a, b, c;
.conf listen_addresses = 'a, b, c'

Even with quotes, the output is the same:

ALTER SYSTEM SET shared_preload_libraries TO a, 'b', c;
.conf shared_preload_libraries = 'a, b, c'

ALTER SYSTEM SET shared_preload_libraries TO a, "b", c;
.conf shared_preload_libraries = 'a, b, c'

ALTER SYSTEM SET listen_addresses TO a, 'b', c;
.conf listen_addresses = 'a, b, c'

ALTER SYSTEM SET listen_addresses TO a, "b", c;
.conf listen_addresses = 'a, b, c'

With non-alphanumeric (spaces), there is a difference:

ALTER SYSTEM SET shared_preload_libraries TO a, 'b x', c;
.conf shared_preload_libraries = 'a, "b x", c'

ALTER SYSTEM SET listen_addresses TO a, 'b x', c;
.conf listen_addresses = 'a, b x, c'

For listen_addresses to get the quoting behavior of
shared_preload_libraries, I have to use double-quotes inside single
quotes:

ALTER SYSTEM SET listen_addresses TO 'a, "b x", c';
.conf listen_addresses = 'a, "b x", c'

Do we want to retain this difference in list processing?

I have developed the attached patch to document this.

--
Bruce Momjian <bruce(at)momjian(dot)us> https://momjian.us
EDB https://enterprisedb.com

Only you can decide what is important to you.

Attachment Content-Type Size
alter_system.diff text/x-diff 1.6 KB

In response to

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Tom Lane 2023-10-24 18:05:53 Re: 'value' has special behaviour in alter system
Previous Message Maxim Yablokov 2023-10-24 14:24:24 Wrong link in the documentation for versions 11, 12