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

Commit699a0ef

Browse files
committed
Re-allow UTF8 encodings on win32. Since UTF8 is converted to
UTF16 before being used, all (valid) locales will work for this.
1 parent2d5b16b commit699a0ef

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

‎src/backend/commands/dbcommands.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
*
1515
* IDENTIFICATION
16-
* $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.201 2007/10/13 20:18:41 tgl Exp $
16+
* $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.202 2007/10/16 11:30:16 mha Exp $
1717
*
1818
*-------------------------------------------------------------------------
1919
*/
@@ -258,7 +258,7 @@ createdb(const CreatedbStmt *stmt)
258258

259259
/*
260260
* Check whether encoding matches server locale settings. We allow
261-
* mismatch intwo cases:
261+
* mismatch inthree cases:
262262
*
263263
* 1. ctype_encoding = SQL_ASCII, which means either that the locale
264264
* is C/POSIX which works with any encoding, or that we couldn't determine
@@ -268,12 +268,19 @@ createdb(const CreatedbStmt *stmt)
268268
* This is risky but we have historically allowed it --- notably, the
269269
* regression tests require it.
270270
*
271+
* 3. selected encoding is UTF8 and platform is win32. This is because
272+
* UTF8 is a pseudo codepage that is supported in all locales since
273+
* it's converted to UTF16 before being used.
274+
*
271275
* Note: if you change this policy, fix initdb to match.
272276
*/
273277
ctype_encoding=pg_get_encoding_from_locale(NULL);
274278

275279
if (!(ctype_encoding==encoding||
276280
ctype_encoding==PG_SQL_ASCII||
281+
#ifdefWIN32
282+
encoding==PG_UTF8||
283+
#endif
277284
(encoding==PG_SQL_ASCII&&superuser())))
278285
ereport(ERROR,
279286
(errmsg("encoding %s does not match server's locale %s",

‎src/bin/initdb/initdb.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
* Portions Copyright (c) 1994, Regents of the University of California
4343
* Portions taken from FreeBSD.
4444
*
45-
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.146 2007/10/1609:09:11 petere Exp $
45+
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.147 2007/10/1611:30:16 mha Exp $
4646
*
4747
*-------------------------------------------------------------------------
4848
*/
@@ -2840,7 +2840,17 @@ main(int argc, char *argv[])
28402840
/* We allow selection of SQL_ASCII --- see notes in createdb() */
28412841
if (!(ctype_enc==user_enc||
28422842
ctype_enc==PG_SQL_ASCII||
2843-
user_enc==PG_SQL_ASCII))
2843+
user_enc==PG_SQL_ASCII
2844+
#ifdefWIN32
2845+
/*
2846+
* On win32, if the encoding chosen is UTF8, all locales are OK
2847+
* (assuming the actual locale name passed the checks above). This
2848+
* is because UTF8 is a pseudo-codepage, that we convert to UTF16
2849+
* before doing any operations on, and UTF16 supports all locales.
2850+
*/
2851+
||user_enc==PG_UTF8
2852+
#endif
2853+
))
28442854
{
28452855
fprintf(stderr,_("%s: encoding mismatch\n"),progname);
28462856
fprintf(stderr,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp