Index: backend/commands/dbcommands.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/backend/commands/dbcommands.c,v retrieving revision 1.201 diff -c -r1.201 dbcommands.c *** backend/commands/dbcommands.c 13 Oct 2007 20:18:41 -0000 1.201 --- backend/commands/dbcommands.c 15 Oct 2007 10:55:20 -0000 *************** *** 258,264 **** /* * Check whether encoding matches server locale settings. We allow ! * mismatch in two cases: * * 1. ctype_encoding = SQL_ASCII, which means either that the locale * is C/POSIX which works with any encoding, or that we couldn't determine --- 258,264 ---- /* * Check whether encoding matches server locale settings. We allow ! * mismatch in three cases: * * 1. ctype_encoding = SQL_ASCII, which means either that the locale * is C/POSIX which works with any encoding, or that we couldn't determine *************** *** 268,279 **** --- 268,286 ---- * This is risky but we have historically allowed it --- notably, the * regression tests require it. * + * 3. selected encoding is UTF8 and platform is win32. This is because + * UTF8 is a pseudo codepage that is supported in all locales since + * it's converted to UTF16 before being used. + * * Note: if you change this policy, fix initdb to match. */ ctype_encoding = pg_get_encoding_from_locale(NULL); if (!(ctype_encoding == encoding || ctype_encoding == PG_SQL_ASCII || + #ifdef WIN32 + encoding == PG_UTF8 || + #endif (encoding == PG_SQL_ASCII && superuser()))) ereport(ERROR, (errmsg("encoding %s does not match server's locale %s", Index: bin/initdb/initdb.c =================================================================== RCS file: /projects/cvsroot/pgsql/src/bin/initdb/initdb.c,v retrieving revision 1.145 diff -c -r1.145 initdb.c *** bin/initdb/initdb.c 13 Oct 2007 20:18:41 -0000 1.145 --- bin/initdb/initdb.c 15 Oct 2007 10:50:27 -0000 *************** *** 2840,2846 **** /* We allow selection of SQL_ASCII --- see notes in createdb() */ if (!(ctype_enc == user_enc || ctype_enc == PG_SQL_ASCII || ! user_enc == PG_SQL_ASCII)) { fprintf(stderr, _("%s: encoding mismatch\n"), progname); fprintf(stderr, --- 2840,2856 ---- /* We allow selection of SQL_ASCII --- see notes in createdb() */ if (!(ctype_enc == user_enc || ctype_enc == PG_SQL_ASCII || ! user_enc == PG_SQL_ASCII ! #ifdef WIN32 ! /* ! * On win32, if the encoding chosen is UTF8, all locales are OK ! * (assuming the actual locale name passed the checks above). This ! * is because UTF8 is a pseudo-codepage, that we convert to UTF16 ! * before doing any operations on, and UTF16 supports all locales. ! */ ! || user_enc == PG_UTF8 ! #endif ! )) { fprintf(stderr, _("%s: encoding mismatch\n"), progname); fprintf(stderr,