v2_README_fix.md
text/markdown
Filename: v2_README_fix.md
Type: text/markdown
Part: 0
# ALTER SYSTEM Empty String Bug Fix - Version 2 ## Problem Description When using `ALTER SYSTEM SET` with an empty string for parameters that have the `GUC_LIST_QUOTE` flag (such as `shared_preload_libraries`), PostgreSQL was writing malformed configuration to `postgresql.auto.conf`. Specifically: ```sql ALTER SYSTEM SET "shared_preload_libraries" TO ''; ``` Would result in this malformed configuration: ``` shared_preload_libraries = '""' ``` This double-quoted empty string caused server crashes on restart due to invalid configuration syntax. ## Root Cause Analysis The issue was **NOT** in the `flatten_set_variable_args` function as initially suspected, but rather in the configuration file writing logic in `write_auto_conf_file()`. The problem occurred because: 1. Empty strings for `GUC_LIST_QUOTE` parameters were being processed correctly during the ALTER SYSTEM operation 2. However, when writing to the configuration file, the value was being double-quoted 3. This resulted in `'""'` being written instead of `''` 4. When the server tried to restart, it couldn't parse the malformed configuration ## Solution Implemented The fix targets the `write_auto_conf_file()` function in `src/backend/utils/misc/guc.c` and: 1. Identifies when a `GUC_LIST_QUOTE` parameter has an empty string value (`''` or `""`) 2. For such cases, writes the configuration as `parameter = ''` instead of the malformed double-quoted version 3. Maintains compatibility**: Only affects the specific bug case, leaving all other functionality intact ## Files Modified - `src/backend/utils/misc/guc.c` - Added special handling for empty strings in `GUC_LIST_QUOTE` parameters ## Why This Approach This solution is safer and more maintainable because it: - Addresses the symptom (malformed configuration output) directly - Doesn't change the underlying logic that other parts of the system depend on - Is targeted and specific to the problematic case - Maintains backward compatibility