fix_alter_system_empty_string_bug.patch
text/x-patch
Filename: fix_alter_system_empty_string_bug.patch
Type: text/x-patch
Part: 1
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Subject: Fix ALTER SYSTEM empty string bug for GUC_LIST_QUOTE parameters
| File | + | − |
|---|---|---|
| src/backend/utils/misc/guc_funcs.c | 3 | 1 |
From 3a6a7db602036309fbc6a7f5c7c731a71038967b Mon Sep 17 00:00:00 2001 From: Andrew Klychkov <andrew.a.klychkov@gmail.com> Date: Thu, 28 Aug 2025 10:33:42 +0200 Subject: [PATCH] Fix ALTER SYSTEM empty string bug for GUC_LIST_QUOTE parameters When ALTER SYSTEM SET is used with an empty string for parameters with GUC_LIST_QUOTE flag (like shared_preload_libraries), the empty string was being quoted by quote_identifier(), resulting in '' being written to postgresql.auto.conf. This caused server crashes on restart. The fix prevents empty strings from being quoted when GUC_LIST_QUOTE is set, treating them as 'no value' rather than literal empty strings. Fixes bug where 'ALTER SYSTEM SET "shared_preload_libraries" TO ''' would write 'shared_preload_libraries = '""'' to postgresql.auto.conf. --- src/backend/utils/misc/guc_funcs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/backend/utils/misc/guc_funcs.c b/src/backend/utils/misc/guc_funcs.c index b9e26982ab..389841a4ec 100644 --- a/src/backend/utils/misc/guc_funcs.c +++ b/src/backend/utils/misc/guc_funcs.c @@ -288,8 +288,10 @@ flatten_set_variable_args(const char *name, List *args) /* * Plain string literal or identifier. For quote mode, * quote it if it's not a vanilla identifier. + * However, empty strings should not be quoted as they + * represent "no value" rather than a literal empty string. */ - if (flags & GUC_LIST_QUOTE) + if ((flags & GUC_LIST_QUOTE) && val[0] != '\0') appendStringInfoString(&buf, quote_identifier(val)); else appendStringInfoString(&buf, val); -- 2.47.0