BUG #16376: ALTER SYSTEM incorrectly quotes empty list

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: tejeswarm(at)hotmail(dot)com
Subject: BUG #16376: ALTER SYSTEM incorrectly quotes empty list
Date: 2020-04-17 20:36:20
Message-ID: 16376-d2e5e5c8cbed7525@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 16376
Logged by: Teja Mupparti
Email address: tejeswarm(at)hotmail(dot)com
PostgreSQL version: 11.0
Operating system: Linux
Description:

Some applications set Postgres parameters using GUI(s) Once a value is set
and deselected later, it issues a SQL
ALTER SYSTEM set shared_preload_libraries = '';
is translating into shared_preload_libraries = '""' in the
postgresql.auto.conf, which will prevent Postgres server from starting
(illegal value of "")
FATAL: could not access file "": No such file or directory.

The quick fix is in quote_identifier()
change
safe = ((ident[0] >= 'a' && ident[0] <= 'z') || ident[0] == '_');
to
safe = ((ident[0] >= 'a' && ident[0] <= 'z') || ident[0] == '_' || ident[0]
== '\0');

Which will avoid the unwnated double-quotes, but is opening a can of
worms.

Easy fix is in Alter system code path

+#define EMPTY_QUOTES "\"\""
+
/*
* Precision with which REAL type guc values are to be printed for GUC
* serialization.
@@ -7886,6 +7888,22 @@ AlterSystemSetConfigFile(AlterSystemStmt
*altersysstmt)
FreeFile(infile);
}

+ /*
+ * There is a special case where an empty list '' is
getting
+ * translated into '""' by the quoted_identifier() logic.
+ * For example, set shared_preload_libraries = '' is
written
+ * as shared_preload_libraries = '""' in the autoconfig
file
+ * and the subsequent restart fails with the below error.
+ *
+ * FATAL: could not access file "": No such file or
directory
+ *
+ * Fixing quoted_identifier() breaks other parts of the
code,
+ * where it depends on translating '' to "". If the list
is
+ * empty, set the value to NULL (this will remove the
entry
+ * from the auto-config file)
+ */
+ if (!strcmp(value, EMPTY_QUOTES))
+ value = '\0';
--

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David G. Johnston 2020-04-17 22:56:40 Re: BUG #16376: ALTER SYSTEM incorrectly quotes empty list
Previous Message David G. Johnston 2020-04-17 19:44:26 Re: BUG #16375: Error in pgAdmin 4.20 when trying to script a function to Query Tool