PostgreSQL Bugs

Collected from the PG bugs email list.

Bug ID16376
PG Version11.0
OSLinux
Opened2020-04-17 20:36:20+00
Reported byTeja Mupparti
StatusNew

Body of first available message related to this bug follows.

The following bug has been logged on the website:

Bug reference:      16376
Logged by:          Teja Mupparti
Email address:      (redacted)
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';
--

Messages

DateAuthorSubject
2020-04-17 20:36:20+00PG Bug reporting formBUG #16376: ALTER SYSTEM incorrectly quotes empty list
2020-04-17 22:56:40+00"David G(dot) Johnston"Re: BUG #16376: ALTER SYSTEM incorrectly quotes empty list
2020-04-18 01:35:51+00Tom LaneRe: BUG #16376: ALTER SYSTEM incorrectly quotes empty list