Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gESrn-00026N-DB for pgsql-general@arkaria.postgresql.org; Mon, 22 Oct 2018 05:35:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gESrj-0006sn-1Q for pgsql-general@arkaria.postgresql.org; Mon, 22 Oct 2018 05:34:59 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gESri-0006sg-NX for pgsql-general@lists.postgresql.org; Mon, 22 Oct 2018 05:34:58 +0000 Received: from forward104p.mail.yandex.net ([2a02:6b8:0:1472:2741:0:8b7:107]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1gESrb-00080x-NQ for pgsql-general@lists.postgresql.org; Mon, 22 Oct 2018 05:34:58 +0000 Received: from mxback9o.mail.yandex.net (mxback9o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::23]) by forward104p.mail.yandex.net (Yandex) with ESMTP id AA2C11849CB; Mon, 22 Oct 2018 08:34:48 +0300 (MSK) Received: from smtp4j.mail.yandex.net (smtp4j.mail.yandex.net [2a02:6b8:0:1619::15:6]) by mxback9o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id oSqQjpdAU3-YmJKN1d7; Mon, 22 Oct 2018 08:34:48 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ya.ru; s=mail; t=1540186488; bh=OykrAZ8PoSgnFwENBoinP0FdfodJM4tRzsvcdxaC7kA=; h=Subject:From:In-Reply-To:Date:Cc:Message-Id:References:To; b=dk0/mQ3BOrS5pmKolnLMULQJGRkt1fy0bIu3pDQj1sxejZae/Eel/VReDnGV0coWm PEoEVkyvT+wqrKo+Cl4r2qtt+5nbjZd1OZ6swKnzdvk0+AKhN7TxAWqaQLE+5I2zwa GLjgX8O6B6y6PgmRsYdEViIPOAuMiP7AaXh8b2hc= Received: by smtp4j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id wuxqEwfjHK-YlFSQMBm; Mon, 22 Oct 2018 08:34:47 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ya.ru; s=mail; t=1540186487; bh=OykrAZ8PoSgnFwENBoinP0FdfodJM4tRzsvcdxaC7kA=; h=Subject:From:In-Reply-To:Date:Cc:Message-Id:References:To; b=Rf0y3KxOQge+0DAPqr/vXMoCkJsmPXRT3qqavGwwKv0wy6othFiT7IuS7hHQL9xnD ze4z3BJSnk9s7ths/lrOaCkGJRWHr6nGEgrSn9X5TJYtwVypPK/7XAMAGs81J1irrK Zifn0qLmbLBdO4jAHRyKSMquF1f5QK/h/qBbPWlE= Authentication-Results: smtp4j.mail.yandex.net; dkim=pass header.i=@ya.ru Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 11.5 \(3445.9.1\)) Subject: Re: BUG: Incorrect working with POSIX locale if database in UTF-8 encoding From: =?utf-8?B?0J7Qu9C10LMg0KHQsNC80L7QudC70L7Qsg==?= In-Reply-To: <29517.1539880173@sss.pgh.pa.us> Date: Mon, 22 Oct 2018 08:33:47 +0300 Cc: pgsql-general@lists.postgresql.org, Peter Eisentraut Content-Transfer-Encoding: quoted-printable Message-Id: <8840458F-CD2F-4838-BB5F-7C41496C3FA8@ya.ru> References: <13FE0F7C-5140-499C-8C2E-0BE64BC3A48B@ya.ru> <29517.1539880173@sss.pgh.pa.us> To: Tom Lane X-Mailer: Apple Mail (2.3445.9.1) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk I think correct behavior will be get the whole locale from = postgresql.conf (like the backend processes do) or from environment. = It=E2=80=99s 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 =D0=BE=D0=BA=D1=82. 2018 =D0=B3., =D0=B2 19:29, Tom Lane = =D0=BD=D0=B0=D0=BF=D0=B8=D1=81=D0=B0=D0=BB(=D0=B0): >=20 > =3D?utf-8?B?0J7Qu9C10LMg0KHQsNC80L7QudC70L7Qsg=3D=3D?=3D = writes: >> [ postmaster's localized messages are printed as garbage if LANG is C = or unset ] >=20 > 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. >=20 > 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=3Dru_RU.koi8r and = messages > should get printed in the encoding the terminal is expecting. >=20 > 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. >=20 > 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. >=20 > Peter, any thoughts? >=20 > regards, tom lane