Re: Solve a problem of LC_TIME of windows.

From: Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>
To: ITAGAKI Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>, Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Hiroshi Saito <z-saito(at)guitar(dot)ocn(dot)ne(dot)jp>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Solve a problem of LC_TIME of windows.
Date: 2009-01-08 21:31:48
Message-ID: 496670C4.7090209@tpf.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

ITAGAKI Takahiro wrote:
> Magnus Hagander <magnus(at)hagander(dot)net> 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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message D'Arcy J.M. Cain 2009-01-08 21:37:54 Re: Proposal: new border setting in psql
Previous Message Bruce Momjian 2009-01-08 21:16:11 Re: Enabling archive_mode without restart

Browse pgsql-patches by date

  From Date Subject
Next Message Magnus Hagander 2009-01-09 13:05:03 Re: Solve a problem of LC_TIME of windows.
Previous Message ITAGAKI Takahiro 2009-01-08 02:54:36 Re: Solve a problem of LC_TIME of windows.