BUG #19538: ALTER SYSTEM adds extra quotes

Started by PG Bug reporting form27 days ago2 messagesbugs
Jump to latest
#1PG Bug reporting form
noreply@postgresql.org

The following bug has been logged on the website:

Bug reference: 19538
Logged by: Gábor Szabó
Email address: fotonszekta@gmail.com
PostgreSQL version: 14.23
Operating system: Ubuntu 24.04.4
Description:

The following command adds extra quotes to postgresql.auto.conf:
ALTER SYSTEM SET shared_preload_libraries = 'pg_stat_statements, auth_delay,
auto_explain, pg_prewarm';
The result entry in postgresql.auto.conf is:
shared_preload_libraries = '"pg_stat_statements, auth_delay, auto_explain,
pg_prewarm"'
As a result, PostgreSQL tries to load the entire string as a single library
name and reports the following error in /var/log/postgresql:
FATAL: could not access file "pg_stat_statements, auth_delay, auto_explain,
pg_prewarm": Nincs ilyen fájl vagy könyvtár

("Nincs ilyen fájl vagy könyvtár" is the Hungarian translation of "No such
file or directory", because the server is running with the hu_HU.UTF-8
locale)

When I run ALTER SYSTEM SET shared_preload_libraries = 'pg_stat_statements';
It works correctly and the resulting entry is:
shared_preload_libraries = 'pg_stat_statements'

However, when the value contains commas, the extra double quotes appear
around the entire string.
I also tried using double quotes in the ALTER SYSTEM command, but the result
was the same.

I reproduced the same behavior on my development system running PostgreSQL
18.4 on Windows.

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: PG Bug reporting form (#1)
Re: BUG #19538: ALTER SYSTEM adds extra quotes

PG Bug reporting form <noreply@postgresql.org> writes:

The following command adds extra quotes to postgresql.auto.conf:
ALTER SYSTEM SET shared_preload_libraries = 'pg_stat_statements, auth_delay,
auto_explain, pg_prewarm';
The result entry in postgresql.auto.conf is:
shared_preload_libraries = '"pg_stat_statements, auth_delay, auto_explain,
pg_prewarm"'
As a result, PostgreSQL tries to load the entire string as a single library
name and reports the following error in /var/log/postgresql:
FATAL: could not access file "pg_stat_statements, auth_delay, auto_explain,
pg_prewarm": Nincs ilyen fájl vagy könyvtár

This behavior is correct; what's wrong is the SQL syntax you used.
You should have written

ALTER SYSTEM SET shared_preload_libraries = pg_stat_statements, auth_delay,
auto_explain, pg_prewarm;

since what you are providing is a list, not a single value that
happens to contain some commas. (It wouldn't matter in this case
whether you quote the individual values; though if any of them match
a SQL reserved word, it'd need quotes.)

I know this is confusing, because the rules are different when you
are writing a list directly in postgresql.conf. But, well, SQL is
not postgresql.conf.

regards, tom lane