Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U0QiS-0006J7-Uq for pgsql-hackers@arkaria.postgresql.org; Wed, 30 Jan 2013 06:00:13 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1U0QiR-0005wW-Ol for pgsql-hackers@arkaria.postgresql.org; Wed, 30 Jan 2013 06:00:11 +0000 Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U0QiP-0005vn-8l for pgsql-hackers@postgresql.org; Wed, 30 Jan 2013 06:00:09 +0000 Received: from mail-lb0-f177.google.com ([209.85.217.177]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1U0QiJ-0000E7-GS for pgsql-hackers@postgresql.org; Wed, 30 Jan 2013 06:00:08 +0000 Received: by mail-lb0-f177.google.com with SMTP id go11so1676911lbb.8 for ; Tue, 29 Jan 2013 22:00:02 -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 :content-transfer-encoding; bh=hKikvHiP9zJcw/+8Lkn8y9dUAEoULLwe1VLAHRLLSQ8=; b=C7CcdMYNV+IwsIb2dThczbiqZ0+GEp8sNpGDfzj2S9A6DrqhIiKIeG0jDJafo1hO9n WwK67Ulkw/MhiAeZ00enTOOXbpHdEkOj+ZmEk7dQwFNR9mRoe8XDhSNT3kIOH/dvXFWc wmaCxiiZLTTXO0l+ToNB1ARnEk2OabGCp5IzthCqaFEPSBKi/V2DqP4fiBgy1XE+JAdd I2hGcsTcdH+6dXS4GxnfqxWgL3P11ahbVPig9a9CeYVOabuzajk3hy64kUj3FWbDGuxn IsoEuNXWKA58uI6JRuf0++hTpnowkW2bOhThI71lcLMbuz5kYgydLIJ1IV5UMvr/XHY3 vH9g== X-Received: by 10.112.42.5 with SMTP id j5mr1435823lbl.37.1359525602512; Tue, 29 Jan 2013 22:00:02 -0800 (PST) Received: from [1.0.0.7] ([94.138.26.200]) by mx.google.com with ESMTPS id ns7sm176523lab.5.2013.01.29.22.00.00 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 29 Jan 2013 22:00:01 -0800 (PST) Message-ID: <5108B6E1.9070503@gmail.com> Date: Wed, 30 Jan 2013 10:00:01 +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 , Tom Lane CC: pgsql-hackers , Magnus Hagander , Andrew Dunstan Subject: Re: BUG #7493: Postmaster messages unreadable in a Windows console References: <20121015094136.GA4627@tornado.leadboat.com> <20121015233817.GC13670@tornado.leadboat.com> <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> In-Reply-To: <20130130015155.GD3524@tornado.leadboat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.7 (--) 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 30.01.2013 05:51, Noah Misch wrote: > On Tue, Jan 29, 2013 at 09:54:04AM -0500, Tom Lane wrote: >> Alexander Law writes: >>> Please look at the following l10n bug: >>> http://www.postgresql.org/message-id/502A26F1.6010109@gmail.com >>> and the proposed patch. >> That patch looks entirely unsafe to me. Neither of those functions >> should be expected to be able to run when none of our standard >> infrastructure (palloc, elog) is up yet. >> >> Possibly it would be safe to do this somewhere around where we do >> GUC initialization. Looking at elog.c:write_console, and boostrap.c:AuxiliaryProcessMain, mcxt.c:MemoryContextInit I would place this call (SetDatabaseEncoding(GetPlatformEncoding())) at MemoryContextInit. (The branch of conversion pgwin32_toUTF16 is not executed until CurrentMemoryContext is not null) But I see some calls to ereport before MemoryContextInit. Is it ok or MemoryContext initialization should be done before? For example, main.c:main -> pgwin32_signal_initialize -> ereport And there is another issue with elog.c:write_stderr if (pgwin32_is_service) then the process writes message to the windows eventlog (write_eventlog), trying to convert in to UTF16. But it doesn't check MemoryContext before the call to pgwin32_toUTF16 (as write_console does) and we can get a crash in the following way: main.c:check_root -> if (pgwin32_is_admin()) write_stderr -> if (pgwin32_is_service()) write_eventlog -> if (if (GetDatabaseEncoding() != GetPlatformEncoding() ) pgwin32_toUTF16 -> crash So placing SetDatabaseEncoding(GetPlatformEncoding()) before the check_root can be a solution for the issue. > Even then, I wouldn't be surprised to find problematic consequences beyond > error display. What if all the databases are EUC_JP, the platform encoding is > KOI8, and some postgresql.conf settings contain EUC_JP characters? Does the > postmaster not rely on its use of SQL_ASCII to allow those values? > > I would look at fixing this by making the error output machinery smarter in > this area before changing the postmaster's notion of server_encoding. Maybe I still miss something but I thought that postinit.c/CheckMyDatabase will switch encoding of a messages by pg_bind_textdomain_codeset to EUC_JP so there will be no issues with it. But until then KOI8 should be used. Regarding postgresql.conf, as it has no explicit encoding specification, it should be interpreted as having the platform encoding. So in your example it should contain KOI8, not EUC_JP characters. Thanks, Alexander -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers