Hello,
The attached patch fixes incorrect message output on the client side. I
guess this problem can happen with any major release. Could you review
this?
[Problem]
When the client's locale differs from the server's message locale, the
messages generated on the server are converted appropriately and sent to the
client. For example, if the server runs on Linux with lc_messages =
'ja_JP.UTF-8' in postgresql.conf, and you run psql on Windows where the
system locale is SJIS, Japanese messages are converted from UTF-8 to SJIS on
the server and sent to psql. psql can display those SJIS messages
correctly. This is no problem.
However, this desirable behavior holds true only after the database session
is established. The error messages during session establishment are
displayed incorrectly, and you cannot recognize the message contents. For
example, run psql -d postgres -U non-existent-username. The displayed
message is unrecognizable.
[Cause]
While the session is being established, the server cannot use the client
encoding for message conversion yet, because it cannot access system
catalogs to retrieve conversion functions. So, the server sends messages to
the client without conversion. In the above example, the server sends
Japanese UTF-8 messages to psql, which expects those messages in SJIS.
[Fix]
Disable message localization during session startup. In other words,
messages are output in English until the database session is established.
Regards
MauMau