diff options
| author | Heikki Linnakangas | 2008-09-23 10:58:03 +0000 |
|---|---|---|
| committer | Heikki Linnakangas | 2008-09-23 10:58:03 +0000 |
| commit | 4b0502baaa337b877c69ae2cfd051d684802450a (patch) | |
| tree | f1e2ec560b08b4eaf85c49fc58f9cea1a160bf25 /src/backend/commands/dbcommands.c | |
| parent | 34205f8024fc0b87c1f9f253a86b90963fd1ba8d (diff) | |
Tighten the check in initdb and CREATE DATABASE that the chosen encoding
matches the encoding of the locale. LC_COLLATE is now checked in addition
to LC_CTYPE.
Diffstat (limited to 'src/backend/commands/dbcommands.c')
| -rw-r--r-- | src/backend/commands/dbcommands.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c index c3b465367e..f31261db9e 100644 --- a/src/backend/commands/dbcommands.c +++ b/src/backend/commands/dbcommands.c @@ -118,6 +118,7 @@ createdb(const CreatedbStmt *stmt) int encoding = -1; int dbconnlimit = -1; int ctype_encoding; + int collate_encoding; int notherbackends; int npreparedxacts; createdb_failure_params fparms; @@ -334,6 +335,7 @@ createdb(const CreatedbStmt *stmt) * Note: if you change this policy, fix initdb to match. */ ctype_encoding = pg_get_encoding_from_locale(dbctype); + collate_encoding = pg_get_encoding_from_locale(dbcollate); if (!(ctype_encoding == encoding || ctype_encoding == PG_SQL_ASCII || @@ -345,9 +347,22 @@ createdb(const CreatedbStmt *stmt) (errmsg("encoding %s does not match locale %s", pg_encoding_to_char(encoding), dbctype), - errdetail("The chosen LC_CTYPE setting requires encoding %s.", + errdetail("The chosen CTYPE setting requires encoding %s.", pg_encoding_to_char(ctype_encoding)))); + if (!(collate_encoding == encoding || + collate_encoding == PG_SQL_ASCII || +#ifdef WIN32 + encoding == PG_UTF8 || +#endif + (encoding == PG_SQL_ASCII && superuser()))) + ereport(ERROR, + (errmsg("encoding %s does not match locale %s", + pg_encoding_to_char(encoding), + dbcollate), + errdetail("The chosen COLLATE setting requires encoding %s.", + pg_encoding_to_char(collate_encoding)))); + /* * Check that the new locale is compatible with the source database. * |
