Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 61A006324B9 for ; Thu, 8 Jan 2009 17:32:25 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 91524-06 for ; Thu, 8 Jan 2009 17:32:21 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sd.tpf.co.jp (sd.tpf.co.jp [210.161.239.34]) by mail.postgresql.org (Postfix) with SMTP id 824AD63245D for ; Thu, 8 Jan 2009 17:32:18 -0400 (AST) Received: (qmail 12572 invoked by uid 512); 8 Jan 2009 21:31:59 -0000 X-Authentication: inoue was authenticated by sd.tpf.co.jp at 8 Jan 2009 21:31:59 -0000 Received: from unknown (HELO ?192.168.11.3?) (219.61.40.6) by sd.tpf.co.jp with SMTP; 8 Jan 2009 21:31:59 -0000 Message-ID: <496670C4.7090209@tpf.co.jp> Date: Fri, 09 Jan 2009 06:31:48 +0900 From: Hiroshi Inoue User-Agent: Thunderbird 2.0.0.19 (Windows/20081209) MIME-Version: 1.0 To: ITAGAKI Takahiro , Magnus Hagander CC: Hiroshi Saito , pgsql-hackers Subject: Re: Solve a problem of LC_TIME of windows. References: <20090107140111.810A.52131E4D@oss.ntt.co.jp> <4964AD2D.7060009@hagander.net> <20090108113242.8B96.52131E4D@oss.ntt.co.jp> In-Reply-To: <20090108113242.8B96.52131E4D@oss.ntt.co.jp> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=2.125 tagged_above=0 required=5 tests=DNS_FROM_RFC_BOGUSMX=2.125 X-Spam-Level: ** X-Archive-Number: 200901/638 X-Sequence-Number: 131282 ITAGAKI Takahiro wrote: > Magnus Hagander wrote: > >> ITAGAKI Takahiro wrote: >>> Ok, wcsftime() requries both LC_TIME and LC_CTYPE are the same setting >>> (at least encoding) on Windows. >>> >> Hmm. Is this actually cleaner than using the original method as >> suggested? Because if I understand things right, that version did *not* >> require the setting of LC_CTYPE? (this is the version that uses strftime >> and does two conversions) > > No, we can't. I found strftime doesn't work if the database is > initialized with non-C locale. It works only when lc_ctype = C and > the encoding of lc_time is matched with Windows' one. > On the other hand, wcsftime seems to be more robust. > (The reason might come from mysterious msvcrt implementation.) The setting of LC_CTYPE acts like a catalyst for wcsftime() to work safely. I checked the code around the patch and found the central function cache_locale_time() is rarely called (at most once per LC_TIME change). The function cache_locale_time() calls strftime() only 38(=7*2+12*2) times. Now I fundamentally agree with Itagaki-san's patch. Though it may not be the most effective code, it looks like the clearest one. regards, Hiroshi Inoue