pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Олег Самойлов <splarv@ya.ru>
Cc: pgsql-general@lists.postgresql.org
Cc: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Subject: Re: BUG: Incorrect working with POSIX locale if database in UTF-8 encoding
Date: Thu, 18 Oct 2018 12:29:33 -0400
Message-ID: <29517.1539880173@sss.pgh.pa.us> (raw)
In-Reply-To: <13FE0F7C-5140-499C-8C2E-0BE64BC3A48B@ya.ru>
References: <13FE0F7C-5140-499C-8C2E-0BE64BC3A48B@ya.ru>

=?utf-8?B?0J7Qu9C10LMg0KHQsNC80L7QudC70L7Qsg==?= <splarv@ya.ru> writes:
> [ postmaster's localized messages are printed as garbage if LANG is C or unset ]

I'm not quite convinced that this is a bug.  The reason it's misbehaving
is that in the postmaster process (and, probably, non-backend children)
LC_MESSAGES gets set to whatever you said in postgresql.conf, but LC_CTYPE
is never changed away from what it was in the postmaster's environment.
So if the prevailing environment setting is C/POSIX, gettext() throws up
its hands and substitutes "?" for non-ASCII characters, because it has
no idea which encoding to render them in.

This is sort of intentional, in that the environment LC_CTYPE ought to
reflect the "console encoding" that you're operating in; if you run your
terminal in say KOI8R, then you set LC_CTYPE=ru_RU.koi8r and messages
should get printed in the encoding the terminal is expecting.

We could maybe make a case for forcing gettext to use the encoding
implied by LC_MESSAGES if LC_CTYPE is C/POSIX, but I'm not really
convinced that there's anything principled about that.

On the other hand, the current behavior in this situation surely
isn't useful to anybody.  Arguably, gettext() is being pretty
unhelpful here, but I doubt we could get them to change.

Peter, any thoughts?

			regards, tom lane




view thread (6+ messages)  latest in thread

Message-ID: <29517.1539880173@sss.pgh.pa.us>
Permalink:  ../29517.1539880173@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/29517.1539880173@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, splarv@ya.ru, peter.eisentraut@2ndquadrant.com
  Subject: Re: BUG: Incorrect working with POSIX locale if database in UTF-8 encoding
  In-Reply-To: <29517.1539880173@sss.pgh.pa.us>
  References: <13FE0F7C-5140-499C-8C2E-0BE64BC3A48B@ya.ru> <29517.1539880173@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox