diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c index ec0d02be6b..3090ae0af4 100644 --- a/src/backend/commands/dbcommands.c +++ b/src/backend/commands/dbcommands.c @@ -13,7 +13,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.201 2007/10/13 20:18:41 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/commands/dbcommands.c,v 1.202 2007/10/16 11:30:16 mha Exp $ * *------------------------------------------------------------------------- */ @@ -258,7 +258,7 @@ createdb(const CreatedbStmt *stmt) /* * Check whether encoding matches server locale settings. We allow - * mismatch in two cases: + * 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,12 +268,19 @@ createdb(const CreatedbStmt *stmt) * 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", diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c index 4da9fde1b5..410aa218f6 100644 --- a/src/bin/initdb/initdb.c +++ b/src/bin/initdb/initdb.c @@ -42,7 +42,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * Portions taken from FreeBSD. * - * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.146 2007/10/16 09:09:11 petere Exp $ + * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.147 2007/10/16 11:30:16 mha Exp $ * *------------------------------------------------------------------------- */ @@ -2840,7 +2840,17 @@ main(int argc, char *argv[]) /* 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)) + 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,