*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
/*
* 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
* 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",
* 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 $
*
*-------------------------------------------------------------------------
*/
/* 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,