pgsql: Allow "SET list_guc TO NULL" to specify setting the GUC to empty - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Allow "SET list_guc TO NULL" to specify setting the GUC to empty
Date
Msg-id E1vGKyb-0051TF-0t@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Allow "SET list_guc TO NULL" to specify setting the GUC to empty.

We have never had a SET syntax that allows setting a GUC_LIST_INPUT
parameter to be an empty list.  A locution such as
        SET search_path = '';
doesn't mean that; it means setting the GUC to contain a single item
that is an empty string.  (For search_path the net effect is much the
same, because search_path ignores invalid schema names and '' must be
invalid.)  This is confusing, not least because configuration-file
entries and the set_config() function can easily produce empty-list
values.

We considered making the empty-string syntax do this, but that would
foreclose ever allowing empty-string items to be valid in list GUCs.
While there isn't any obvious use-case for that today, it feels like
the kind of restriction that might hurt someday.  Instead, let's
accept the forbidden-up-to-now value NULL and treat that as meaning an
empty list.  (An objection to this could be "what if we someday want
to allow NULL as a GUC value?".  That seems unlikely though, and even
if we did allow it for scalar GUCs, we could continue to treat it as
meaning an empty list for list GUCs.)

Author: Tom Lane <tgl@sss.pgh.pa.us>
Reviewed-by: Andrei Klychkov <andrew.a.klychkov@gmail.com>
Reviewed-by: Jim Jones <jim.jones@uni-muenster.de>
Discussion: https://postgr.es/m/CA+mfrmwsBmYsJayWjc8bJmicxc3phZcHHY=yW5aYe=P-1d_4bg@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/ff4597acd4c3d957373335034e1ac16b6584c3e6

Modified Files
--------------
doc/src/sgml/ref/alter_system.sgml  | 12 +++++++++++-
doc/src/sgml/ref/set.sgml           | 24 +++++++++++++++++++----
src/backend/parser/gram.y           | 20 +++++++++++++++++++
src/backend/utils/adt/ruleutils.c   |  6 +++++-
src/backend/utils/adt/varlena.c     |  6 +++---
src/backend/utils/misc/guc_funcs.c  | 38 +++++++++++++++++++++++++++++++------
src/bin/pg_dump/dumputils.c         |  6 +++++-
src/bin/pg_dump/pg_dump.c           |  6 +++++-
src/test/regress/expected/guc.out   | 22 +++++++++++++++++++++
src/test/regress/expected/rules.out |  2 ++
src/test/regress/sql/guc.sql        |  9 +++++++++
src/test/regress/sql/rules.sql      |  1 +
12 files changed, 135 insertions(+), 17 deletions(-)


pgsql-committers by date:

Previous
From: Álvaro Herrera
Date:
Subject: pgsql: Have psql's "\? variables" show csv_fieldsep
Next
From: Jeff Davis
Date:
Subject: pgsql: Remove redundant memset() introduced by a0942f4.