Thread: pgsql: Change the way encoding and locale checks are done in pg_upgrade

pgsql: Change the way encoding and locale checks are done in pg_upgrade

From
Heikki Linnakangas
Date:
Change the way encoding and locale checks are done in pg_upgrade.

Lc_collate and lc_ctype have been per-database settings since server version
8.4, but pg_upgrade was still treating them as cluster-wide options. It
fetched the values for the template0 databases in old and new cluster, and
compared them. That's backwards; the encoding and locale of the template0
database doesn't matter, as template0 is guaranteed to contain only ASCII
characters. But if there are any other databases that exist on both clusters
(in particular template1 and postgres databases), their encodings and
locales must be compatible.

Also, make the locale comparison more lenient. If the locale names are not
equal, try to canonicalize both of them by passing them to setlocale(). We
used to do that only when upgrading from 9.1 or below, but it seems like a
good idea even with newer versions. If we change the canonical form of a
locale, this allows pg_upgrade to still work. I'm about to do just that to
fix bug #11431, by mapping a locale name that contains non-ASCII characters
to a pure-ASCII alias of the same locale.

No backpatching, because earlier versions of pg_upgrade still support
upgrading from 8.3 servers. That would be more complicated, so it doesn't
seem worth it, given that we haven't received any complaints about this
from users.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/33755e8edf149dabfc0ed9b697a84f70b0cca0de

Modified Files
--------------
contrib/pg_upgrade/check.c       |  206 +++++++++++++-------------------------
contrib/pg_upgrade/controldata.c |   34 -------
contrib/pg_upgrade/info.c        |   14 ++-
contrib/pg_upgrade/pg_upgrade.h  |    6 +-
4 files changed, 87 insertions(+), 173 deletions(-)