Re: Solve a problem of LC_TIME of windows. - Mailing list pgsql-hackers

From ITAGAKI Takahiro
Subject Re: Solve a problem of LC_TIME of windows.
Date
Msg-id 20090108113242.8B96.52131E4D@oss.ntt.co.jp
Whole thread Raw
In response to Re: Solve a problem of LC_TIME of windows.  (Magnus Hagander <magnus@hagander.net>)
Responses Re: Solve a problem of LC_TIME of windows.  (Hiroshi Inoue <inoue@tpf.co.jp>)
List pgsql-hackers
Magnus Hagander <magnus@hagander.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.)


[For reviewers and testers]
For the above reason, please test the patch with some combinations
of locales and encodings, some of that might be different from
Windows' native ones.


[error result of strftime version]
$ initdb --locale=Japanese_Japan.20932 --encoding=eucjp

postgres=# SELECT name, setting FROM pg_settings WHERE name LIKE 'lc%';   name     |       setting
-------------+----------------------lc_collate  | Japanese_Japan.20932lc_ctype    | Japanese_Japan.20932lc_messages |
Japanese_Japan.20932lc_monetary| Japanese_Japan.20932lc_numeric  | Japanese_Japan.20932lc_time     |
Japanese_Japan.20932
(6 rows)

postgres=# SELECT to_char(now(), 'TMday');
ERROR:  invalid byte sequence for encoding "UTF8": 0x00
HINT:  This error can also happen if the byte sequence does not match the encoding expected by the server, which is
controlledby "client_encoding".
 


Regards,
---
ITAGAKI Takahiro
NTT Open Source Software Center




pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: text search patch status update?
Next
From: KaiGai Kohei
Date:
Subject: Re: Updates of SE-PostgreSQL 8.4devel patches (r1389)