Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U5syX-0003Bn-Sx for pgsql-hackers@arkaria.postgresql.org; Thu, 14 Feb 2013 07:11:22 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1U5syX-0002PO-Bh for pgsql-hackers@arkaria.postgresql.org; Thu, 14 Feb 2013 07:11:21 +0000 Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U5syV-0002Of-LG for pgsql-hackers@postgresql.org; Thu, 14 Feb 2013 07:11:19 +0000 Received: from mail-lb0-f175.google.com ([209.85.217.175]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U5syT-0005Ha-P6 for pgsql-hackers@postgresql.org; Thu, 14 Feb 2013 07:11:19 +0000 Received: by mail-lb0-f175.google.com with SMTP id n3so1535848lbo.20 for ; Wed, 13 Feb 2013 23:11:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:cc :subject:references:in-reply-to:content-type; bh=2sYroDD22YnhLkX+L/YOC8FY/7VE3nNV/pIchpJJxko=; b=N0vWUzBSBaMlpsX1boJxtdJwrT4nQTwV9T77NlWoo2OVF5Nc2nq4HrdqWzi7MacqOt K7xWMuTNkRlylFSJL73pu0w86WxSet7TFBkl7x4Q/Z2AaivpjPo15d37IhXaR+hf5GE5 vPnICbqMGKa61QNqOXJDiGXqiAdhV3cuK+qiuGbQycvBjfMmtLWT67c1thadJosDIelg tH9hBjqSvIl95TYpbdoQ/DsZunLQo86juS9rXcArYv9p5f5nPaZv8yfQe77FGld7Goz0 ExXWZHf7zGNHuMF6O6rBBVAlxhUjHnpQ+q6URUhRIp5i1ZlUuimpssP0Hnx8vJFzVf1g Vwcw== X-Received: by 10.112.101.230 with SMTP id fj6mr139786lbb.115.1360825876059; Wed, 13 Feb 2013 23:11:16 -0800 (PST) Received: from [1.0.0.7] ([94.138.16.17]) by mx.google.com with ESMTPS id v7sm11649546lbg.13.2013.02.13.23.11.13 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 13 Feb 2013 23:11:14 -0800 (PST) Message-ID: <511C8E11.7090407@gmail.com> Date: Thu, 14 Feb 2013 11:11:13 +0400 From: Alexander Law User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2 MIME-Version: 1.0 To: Noah Misch CC: Tom Lane , pgsql-hackers , Magnus Hagander , Andrew Dunstan Subject: Re: BUG #7493: Postmaster messages unreadable in a Windows console References: <20121018154650.GA3763@alvh.no-ip.org> <51001879.3000207@gmail.com> <5100F3F6.3050107@2ndQuadrant.com> <51013C2C.5020703@dunslane.net> <20130124161954.GA2448@tornado.leadboat.com> <5101A1C4.3020407@dunslane.net> <5107656C.1050400@gmail.com> <28316.1359471244@sss.pgh.pa.us> <20130130015155.GD3524@tornado.leadboat.com> <5108B6E1.9070503@gmail.com> <20130210210259.GA7401@tornado.leadboat.com> In-Reply-To: <20130210210259.GA7401@tornado.leadboat.com> Content-Type: multipart/alternative; boundary="------------000107070807080905080507" X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-hackers Precedence: bulk Sender: pgsql-hackers-owner@postgresql.org This is a multi-part message in MIME format. --------------000107070807080905080507 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Hello, >>>> Alexander Law writes: >>>>> Please look at the following l10n bug: >>>>> http://www.postgresql.org/message-id/502A26F1.6010109@gmail.com >>>>> and the proposed patch. > With your proposed change, the problem will resurface in an actual SQL_ASCII > database. At the problem's root is write_console()'s assumption that messages > are in the database encoding. pg_bind_textdomain_codeset() tries to make that > so, but it only works for encodings with a pg_enc2gettext_tbl entry. That > excludes SQL_ASCII, MULE_INTERNAL, and others. write_console() needs to > behave differently in such cases. Thank you for the notice. So it seems that "DatabaseEncoding" variable alone can't present a database encoding (for communication with a client) and current process messages encoding (for logging messages) at once. There should be another variable, something like CurrentProcessEncoding, that will be set to OS encoding at start and can be changed to encoding of a connected database (if bind_textdomain_codeset succeeded). > On Tue, Feb 12, 2013 at 03:22:17AM +0000, Greg Stark wrote: >> >But that said I'm not sure saying the whole file is in an encoding is >> >the right approach. Paths are actually binary strings. any encoding is >> >purely for display purposes anyways. > For Unix, yes. On Windows, they're ultimately UTF16 strings; some system APIs > accept paths in the Windows ANSI code page and convert to UTF16 internally. > Nonetheless, good point. Yes, and if postresql.conf not going to be UTF16 encoded, it seems natural to use ANSI code page on Windows to write such paths in it. So the paths should be written in OS encoding, which is accepted by OS functions, such as fopen. (This is what we have now.) And it seems too complicated to have different encodings in one file. Or maybe path parameters should be separated from the others, for which OS encoding is undesirable. >> If we knew that postgresql.conf was stored in, say, UTF8, then it would >> probably be possible to perform encoding conversion to get string >> variables into the database encoding. Perhaps we should allow some >> magic syntax to tell us the encoding of a config file? >> >> file_encoding = 'utf8' # must precede any non-ASCII in the file > If we're going to do that we might as well use the Emacs standard > -*-coding: latin-1;-*- > > Explicit encoding specification such as these (or even ) can be useful but what encoding to assume without it? For XML (without BOM) it's UTF-8, for emacs it depends on it's language environment. If postgresql.conf doesn't have to be portable (as XML), then IMO OS encoding is the right choice for it. Best regards, Alexander --------------000107070807080905080507 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit
Hello,
Alexander Law <exclusion@gmail.com> writes:
Please look at the following l10n bug:
http://www.postgresql.org/message-id/502A26F1.6010109@gmail.com
and the proposed patch.
With your proposed change, the problem will resurface in an actual SQL_ASCII
database.  At the problem's root is write_console()'s assumption that messages
are in the database encoding.  pg_bind_textdomain_codeset() tries to make that
so, but it only works for encodings with a pg_enc2gettext_tbl entry.  That
excludes SQL_ASCII, MULE_INTERNAL, and others.  write_console() needs to
behave differently in such cases.
Thank you for the notice. So it seems that "DatabaseEncoding" variable alone can't present a database encoding (for communication with a client) and current process messages encoding (for logging messages) at once. There should be another variable, something like CurrentProcessEncoding, that will be set to OS encoding at start and can be changed to encoding of a connected database (if bind_textdomain_codeset succeeded).

On Tue, Feb 12, 2013 at 03:22:17AM +0000, Greg Stark wrote:
> But that said I'm not sure saying the whole file is in an encoding is
> the right approach. Paths are actually binary strings. any encoding is
> purely for display purposes anyways.
For Unix, yes.  On Windows, they're ultimately UTF16 strings; some system APIs
accept paths in the Windows ANSI code page and convert to UTF16 internally.
Nonetheless, good point.
Yes, and if postresql.conf not going to be UTF16 encoded, it seems natural to use ANSI code page on Windows to write such paths in it.
So the paths should be written in OS encoding, which is accepted by OS functions, such as fopen. (This is what we have now.)
And it seems too complicated to have different encodings in one file. Or maybe path parameters should be separated from the others, for which OS encoding is undesirable.
If we knew that postgresql.conf was stored in, say, UTF8, then it would
probably be possible to perform encoding conversion to get string
variables into the database encoding.  Perhaps we should allow some
magic syntax to tell us the encoding of a config file?

        file_encoding = 'utf8'  # must precede any non-ASCII in the file
If we're going to do that we might as well use the Emacs standard
-*-coding: latin-1;-*-


Explicit encoding specification such as these (or even <?xml version="1.0" encoding="utf-8"?>) can be useful but what encoding to assume without it? For XML (without BOM) it's UTF-8, for emacs it depends on it's language environment.
If postgresql.conf doesn't have to be portable (as XML), then IMO OS encoding is the right choice for it.


Best regards,
Alexander
--------------000107070807080905080507--