Re: Solve a problem of LC_TIME of windows.

From: ITAGAKI Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
To: Magnus Hagander <magnus(at)hagander(dot)net>
Cc: Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>, 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 02:54:36
Message-ID: 20090108113242.8B96.52131E4D@oss.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches


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.)

[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.20932
lc_ctype | Japanese_Japan.20932
lc_messages | Japanese_Japan.20932
lc_monetary | Japanese_Japan.20932
lc_numeric | Japanese_Japan.20932
lc_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 controlled by "client_encoding".

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message KaiGai Kohei 2009-01-08 02:55:08 Re: Updates of SE-PostgreSQL 8.4devel patches (r1389)
Previous Message Bruce Momjian 2009-01-08 02:49:51 Re: text search patch status update?

Browse pgsql-patches by date

  From Date Subject
Next Message Hiroshi Inoue 2009-01-08 21:31:48 Re: Solve a problem of LC_TIME of windows.
Previous Message Hiroshi Inoue 2009-01-07 21:47:38 Re: Solve a problem of LC_TIME of windows.