[bug fix] multibyte messages are displayed incorrectly on the client

From: "MauMau" <maumau307(at)gmail(dot)com>
To: <pgsql-hackers(at)postgresql(dot)org>
Subject: [bug fix] multibyte messages are displayed incorrectly on the client
Date: 2013-12-13 13:41:17
Message-ID: 60A7F9F5B25B4F1A9888F18E883E5581@maumau
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers


The attached patch fixes incorrect message output on the client side. I
guess this problem can happen with any major release. Could you review

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.

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.

Disable message localization during session startup. In other words,
messages are output in English until the database session is established.


Attachment Content-Type Size
no_localize_message_in_startup.patch application/octet-stream 4.8 KB


Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2013-12-13 13:44:30 Re: Time-Delayed Standbys
Previous Message Fabrízio de Royes Mello 2013-12-13 13:37:58 Re: patch: make_timestamp function