Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit fded477

Browse files
committed
initdb: Remove obsolete locale handling
The method of passing LC_COLLATE and LC_CTYPE to the backend during initdb is obsolete as of 61d9674. This can all be removed. Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://www.postgresql.org/message-id/flat/eeaf2f99-a1a6-8aca-3f43-9ab0b2fb112a%402ndquadrant.com
1 parent 96e7e1b commit fded477

File tree

2 files changed

+10
-42
lines changed

2 files changed

+10
-42
lines changed

src/backend/main/main.c

+10-28
Original file line numberDiff line numberDiff line change
@@ -99,42 +99,24 @@ main(int argc, char *argv[])
9999
MemoryContextInit();
100100

101101
/*
102-
* Set up locale information from environment. Note that LC_CTYPE and
103-
* LC_COLLATE will be overridden later from pg_control if we are in an
104-
* already-initialized database. We set them here so that they will be
105-
* available to fill pg_control during initdb. LC_MESSAGES will get set
106-
* later during GUC option processing, but we set it here to allow startup
107-
* error messages to be localized.
102+
* Set up locale information
108103
*/
109-
110104
set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("postgres"));
111105

112-
#ifdef WIN32
113-
114106
/*
115-
* Windows uses codepages rather than the environment, so we work around
116-
* that by querying the environment explicitly first for LC_COLLATE and
117-
* LC_CTYPE. We have to do this because initdb passes those values in the
118-
* environment. If there is nothing there we fall back on the codepage.
107+
* In the postmaster, absorb the environment values for LC_COLLATE and
108+
* LC_CTYPE. Individual backends will change these later to settings
109+
* taken from pg_database, but the postmaster cannot do that. If we leave
110+
* these set to "C" then message localization might not work well in the
111+
* postmaster.
119112
*/
120-
{
121-
char *env_locale;
122-
123-
if ((env_locale = getenv("LC_COLLATE")) != NULL)
124-
init_locale("LC_COLLATE", LC_COLLATE, env_locale);
125-
else
126-
init_locale("LC_COLLATE", LC_COLLATE, "");
127-
128-
if ((env_locale = getenv("LC_CTYPE")) != NULL)
129-
init_locale("LC_CTYPE", LC_CTYPE, env_locale);
130-
else
131-
init_locale("LC_CTYPE", LC_CTYPE, "");
132-
}
133-
#else
134113
init_locale("LC_COLLATE", LC_COLLATE, "");
135114
init_locale("LC_CTYPE", LC_CTYPE, "");
136-
#endif
137115

116+
/*
117+
* LC_MESSAGES will get set later during GUC option processing, but we set
118+
* it here to allow startup error messages to be localized.
119+
*/
138120
#ifdef LC_MESSAGES
139121
init_locale("LC_MESSAGES", LC_MESSAGES, "");
140122
#endif

src/bin/initdb/initdb.c

-14
Original file line numberDiff line numberDiff line change
@@ -1417,20 +1417,6 @@ bootstrap_template1(void)
14171417
bki_lines = replace_token(bki_lines, "LC_CTYPE",
14181418
escape_quotes_bki(lc_ctype));
14191419

1420-
/*
1421-
* Pass correct LC_xxx environment to bootstrap.
1422-
*
1423-
* The shell script arranged to restore the LC settings afterwards, but
1424-
* there doesn't seem to be any compelling reason to do that.
1425-
*/
1426-
snprintf(cmd, sizeof(cmd), "LC_COLLATE=%s", lc_collate);
1427-
putenv(pg_strdup(cmd));
1428-
1429-
snprintf(cmd, sizeof(cmd), "LC_CTYPE=%s", lc_ctype);
1430-
putenv(pg_strdup(cmd));
1431-
1432-
unsetenv("LC_ALL");
1433-
14341420
/* Also ensure backend isn't confused by this environment var: */
14351421
unsetenv("PGCLIENTENCODING");
14361422

0 commit comments

Comments
 (0)