Tom Lane wrote:
> So the problem really occurs when database_encoding is set to an
> encoding that is incompatible with the one implied by the initdb-time
> LC_CTYPE ... which we have no good way to check. Ugh.
>
> I have some vague recollection that glibc offers an API extension
> that allows this to be checked. Is it worth having a solution that
> catches the problem on glibc only?
The problem is more likely to be that it will be hard to match up the
different encoding names. For example, if you set LC_CTYPE=C, then the
system encoding is report as
$ locale charmap
ANSI_X3.4-1968
whereas the closest thing in PostgreSQL would be SQL_ASCII.
It might already help if we allowed LC_CTYPE to be attached to a
database rather than the entire cluster, and make the user match them
up manually. The only drawback would be that indexes on global tables
involving upper() or lower() would no longer work reliably.