Re: BUG: Incorrect working with POSIX locale if database in UTF-8 encoding

From: Олег Самойлов <splarv(at)ya(dot)ru>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org, Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Subject: Re: BUG: Incorrect working with POSIX locale if database in UTF-8 encoding
Date: 2018-10-22 05:33:47
Message-ID: 8840458F-CD2F-4838-BB5F-7C41496C3FA8@ya.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I think correct behavior will be get the whole locale from postgresql.conf (like the backend processes do) or from environment. It’s a question, may be, from what place do take locale, but obviously from only one. But do not take LC_TYPE from the one place (postgresql.conf), while LC_MESSAGES from other (environment). Te bug is here.

> 18 окт. 2018 г., в 19:29, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> написал(а):
>
> =?utf-8?B?0J7Qu9C10LMg0KHQsNC80L7QudC70L7Qsg==?= <splarv(at)ya(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message aman gupta 2018-10-22 05:56:44 Optimizing Postgresql ILIKE while query
Previous Message Dinko Papak 2018-10-22 04:44:13 RE: Help with list partitioning on expression