Re: [PATCH] Fix ALTER SYSTEM empty string bug for GUC_LIST_QUOTE parameters

From: Andrei Klychkov <andrew(dot)a(dot)klychkov(at)gmail(dot)com>
To: Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: [PATCH] Fix ALTER SYSTEM empty string bug for GUC_LIST_QUOTE parameters
Date: 2025-09-03 09:59:26
Message-ID: CA+mfrmxtk+f3dE8zJ2=5cWrbSw6YzOXNOmbi1iC0Hb0HCa-G7w@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Jim,

Thanks a lot for reviewing! Nice catch, TIL!
Version 2 of the patch is attached, please check it out.
In a nutshell, the issue actually wasn't in the flatten_set_variable_args()
function as initially suspected, but rather in the configuration file
writing logic in the write_auto_conf_file(): more details in v2_README.md

Looking forward to your feedback, thanks!
Regards
Andrew

On Tue, Sep 2, 2025 at 2:16 PM Jim Jones <jim(dot)jones(at)uni-muenster(dot)de> wrote:

> Hi Andrew
>
> On 28.08.25 11:29, Andrei Klychkov wrote:
> > I'm submitting a patch to fix a bug where ALTER SYSTEM SET with empty
> > strings for
> > GUC_LIST_QUOTE parameters (like shared_preload_libraries) results in
> > malformed
> > configuration entries that cause server crashes on restart.
>
> I tested the patch and it does what you described
>
> $ psql postgres -c "ALTER SYSTEM SET shared_preload_libraries TO '';"
> ALTER SYSTEM
> $ cat /usr/local/postgres-dev/testdb/postgresql.auto.conf
> # Do not edit this file manually!
> # It will be overwritten by the ALTER SYSTEM command.
> shared_preload_libraries = ''
>
> However, it breaks one of the rules.sql regression tests
>
> @@ -3552,21 +3552,7 @@
> SET local_preload_libraries TO "Mixed/Case", 'c:/''a"/path', '',
>
> '0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'
> IMMUTABLE STRICT;
> SELECT pg_get_functiondef('func_with_set_params()'::regprocedure);
>
> -
>
> pg_get_functiondef
>
>
> ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
> - CREATE OR REPLACE FUNCTION
>
> public.func_with_set_params()
> +
> - RETURNS
>
> integer
> +
> - LANGUAGE
>
> sql
> +
> - IMMUTABLE
>
> STRICT
> +
> - SET search_path TO
>
> 'pg_catalog'
> +
> - SET extra_float_digits TO
>
> '2'
> +
> - SET work_mem TO
>
> '4MB'
> +
> - SET "DateStyle" TO 'iso,
>
> mdy'
> +
> - SET local_preload_libraries TO 'Mixed/Case', 'c:/''a"/path', '',
>
> '0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789'+
> - AS $function$select
>
> 1;$function$
> +
> -
> -(1 row)
> -
> +ERROR: invalid list syntax in proconfig item
>
> Best, Jim
>

Attachment Content-Type Size
v2_README_fix.md text/markdown 1.9 KB
v2_fix_alter_system_empty_string_bug.patch text/x-patch 2.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrei Lepikhov 2025-09-03 10:00:18 Re: Pathify RHS unique-ification for semijoin planning
Previous Message Steven Niu 2025-09-03 09:55:35 回复: 回复: Fix segfault while accessing half-initialized hash table in pgstat_shmem.c