Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc7007d1

Browse files
committed
Use a more portable technique for unsetting environment variables,
and unset PGCLIENTENCODING to prevent backend from dying if it's setto something incompatible with the -E option.
1 parente845adf commitc7007d1

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

‎src/bin/initdb/initdb.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
* Portions Copyright (c) 1994, Regents of the University of California
4444
* Portions taken from FreeBSD.
4545
*
46-
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.23 2004/03/09 04:49:02 momjian Exp $
46+
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.24 2004/05/05 16:09:31 tgl Exp $
4747
*
4848
*-------------------------------------------------------------------------
4949
*/
@@ -263,6 +263,24 @@ xstrdup(const char *s)
263263
returnresult;
264264
}
265265

266+
/*
267+
* unsetenv() doesn't exist everywhere, so emulate it with this ugly
268+
* but well-tested technique (borrowed from backend's variable.c).
269+
*/
270+
staticvoid
271+
pg_unsetenv(constchar*varname)
272+
{
273+
char*envstr=xmalloc(strlen(varname)+2);
274+
275+
/* First, override any existing setting by forcibly defining the var */
276+
sprintf(envstr,"%s=",varname);
277+
putenv(envstr);
278+
279+
/* Now we can clobber the variable definition this way: */
280+
strcpy(envstr,"=");
281+
putenv(envstr);
282+
}
283+
266284
/*
267285
* delete a directory tree recursively
268286
* assumes path points to a valid directory
@@ -1242,7 +1260,10 @@ bootstrap_template1(char *short_version)
12421260
snprintf(cmd,sizeof(cmd),"LC_CTYPE=%s",lc_ctype);
12431261
putenv(xstrdup(cmd));
12441262

1245-
putenv("LC_ALL");
1263+
pg_unsetenv("LC_ALL");
1264+
1265+
/* Also ensure backend isn't confused by this environment var: */
1266+
pg_unsetenv("PGCLIENTENCODING");
12461267

12471268
snprintf(cmd,sizeof(cmd),
12481269
"\"%s/postgres\" -boot -x1 %s %s template1",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp