Restore initdb's old behavior of always setting the lc_xxx GUCs.
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 10 Jan 2024 23:09:29 +0000 (18:09 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 10 Jan 2024 23:09:29 +0000 (18:09 -0500)
In commit 3e51b278d I (tgl) caused initdb to leave lc_messages and
other lc_xxx GUCs commented-out in the installed postgresql.conf file
if they were going to be set to 'C'.  This was a hack for cosmetic
purposes, and it was buggy because lc_messages' wired-in default is
not 'C' but '' (empty string).  That led to --no-locale not having
the expected effect, since the postmaster would then obtain
lc_messages from its startup environment.

Let's just revert to the prior behavior of always de-commenting the
lc_xxx entries; the argument for changing that longstanding behavior
was weak in the first place.

Also, fix postgresql.conf.sample's erroneous claim that the default
value of lc_messages is 'C'.  I suspect that was what misled me into
making this mistake in the first place.

Report and patch by Kyotaro Horiguchi.  Back-patch to v16 where
the problem was introduced.

Discussion: https://postgr.es/m/20231122.162700.1995154567625541112.horikyota.ntt@gmail.com

src/backend/utils/misc/postgresql.conf.sample
src/bin/initdb/initdb.c

index b2809c711a18b7b91e2b5d3c9c4cc6d1405c2fe3..835b0e9ba89fda93db5fb98a1bbc5bcec28c4965 100644 (file)
                                        # encoding
 
 # These settings are initialized by initdb, but they can be changed.
-#lc_messages = 'C'                     # locale for system error message
+#lc_messages = '                     # locale for system error message
                                        # strings
 #lc_monetary = 'C'                     # locale for monetary formatting
 #lc_numeric = 'C'                      # locale for number formatting
index 791817119098600bd58fcd08027c0c12fb0ecc68..ac409b00064f4307482790fd397671428efcd8df 100644 (file)
@@ -1227,25 +1227,17 @@ setup_config(void)
        conflines = replace_guc_value(conflines, "shared_buffers",
                                                                  repltok, false);
 
-       /*
-        * Hack: don't replace the LC_XXX GUCs when their value is 'C', because
-        * replace_guc_value will decide not to quote that, which looks strange.
-        */
-       if (strcmp(lc_messages, "C") != 0)
-               conflines = replace_guc_value(conflines, "lc_messages",
-                                                                         lc_messages, false);
+       conflines = replace_guc_value(conflines, "lc_messages",
+                                                                 lc_messages, false);
 
-       if (strcmp(lc_monetary, "C") != 0)
-               conflines = replace_guc_value(conflines, "lc_monetary",
-                                                                         lc_monetary, false);
+       conflines = replace_guc_value(conflines, "lc_monetary",
+                                                                 lc_monetary, false);
 
-       if (strcmp(lc_numeric, "C") != 0)
-               conflines = replace_guc_value(conflines, "lc_numeric",
-                                                                         lc_numeric, false);
+       conflines = replace_guc_value(conflines, "lc_numeric",
+                                                                 lc_numeric, false);
 
-       if (strcmp(lc_time, "C") != 0)
-               conflines = replace_guc_value(conflines, "lc_time",
-                                                                         lc_time, false);
+       conflines = replace_guc_value(conflines, "lc_time",
+                                                                 lc_time, false);
 
        switch (locale_date_order(lc_time))
        {