pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: tejeswarm@hotmail.com
Subject: BUG #16376: ALTER SYSTEM incorrectly quotes empty list
Date: Fri, 17 Apr 2020 20:36:20 +0000
Message-ID: <16376-d2e5e5c8cbed7525@postgresql.org> (raw)

The following bug has been logged on the website:

Bug reference:      16376
Logged by:          Teja Mupparti
Email address:      tejeswarm@hotmail.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';
--



view thread (3+ messages)  latest in thread

Message-ID: <16376-d2e5e5c8cbed7525@postgresql.org>
Permalink:  ../16376-d2e5e5c8cbed7525@postgresql.org/
Also on:    postgresql.org/message-id/16376-d2e5e5c8cbed7525@postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, tejeswarm@hotmail.com
  Subject: Re: BUG #16376: ALTER SYSTEM incorrectly quotes empty list
  In-Reply-To: <16376-d2e5e5c8cbed7525@postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox