Durumdara <durumdara@gmail.com> writes:
> Today we found strange database collation names in a server (V11).
> "hu_HU.UTF-8"
> "hu_HU.UTF8"
> "hu_HU.utf8"
Yeah, these are all the same so far as the operating system is
concerned. I believe most if not all variants of Unix are
permissive about the spelling of the encoding part.
> What I don't understand, that if I query for collations, I got only this:
> hu_HU.utf8
pg_collation generally contains only "canonical" spellings of the locale
names, because initdb builds it from what "locale -a" prints. However,
different OS releases may have different ideas about which encoding name
is canonical.
> The whole problem appeared when we wanted to copy a database to a new (with
> defining the old as template).
> *Error: new collation (hu_HU.utf8) is incompatible with the collation of
> the template database (hu_HU.UTF-8)*
The code that checks that isn't as permissive as libc. You can spell
it exactly the same, or if you wanted to live dangerously you could
manually update the template database's pg_database entry to use the
currently-canonical spelling. (I'd try that in a scratch installation
first ...)
There was some discussion not long ago about relaxing the check
for "same collation name" [1], but no one has written a patch.
regards, tom lane
[1] https://www.postgresql.org/message-id/flat/fedc0205-c15b-e400-aa3f-e1d2a1285ddb%40sourcepole.ch