Re: Re: [COMMITTERS] pgsql: setlocale() on Windows doesn't work correctly if the locale name

From: Hiroshi Inoue <inoue(at)tpf(dot)co(dot)jp>
To: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Cc: Andrew Dunstan <andrew(at)dunslane(dot)net>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Re: [COMMITTERS] pgsql: setlocale() on Windows doesn't work correctly if the locale name
Date: 2011-04-20 13:16:38
Message-ID: 4DAEDCB6.4010000@tpf.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers pgsql-hackers

(2011/04/20 15:30), Heikki Linnakangas wrote:
> On 20.04.2011 06:48, Hiroshi Inoue wrote:
>> I can find no concrete reference to problems about locale
>> names containing dots. Is the following an example?
>
> Yes.
>
>> In my environment (Windows Vista using VC8)
>>
>> setlocale(LC_XXXX, "Chinese (Traditional)_MCO.950");
>> works and
>> setlocale(LC_XXXX, NULL);
>> returns
>> Chinese (Traditional)_Macao S.A.R..950

but
setlocale(LC_XXXX, "Chinese (Traditional)_Macao S.A.R..950");
fails.

I see another issue for the behavior.

For example, the following code in src/backend/utis/adt/pg_locale.c
won't work as expected in case the current locale is Hong Kong, Macao or
UAE because the last setlocale() in the code would fail. I can
find such save & restore operations of locales in several places.

bool
check_locale(int category, const char *value)
{
char *save;
bool ret;

save = setlocale(category, NULL);
if (!save)
return false; /* won't happen, we hope */

/* save may be pointing at a modifiable scratch variable, see above */
save = pstrdup(save);

/* set the locale with setlocale, to see if it accepts it. */
ret = (setlocale(category, value) != NULL);

setlocale(category, save); /* assume this won't fail */
pfree(save);

return ret;
}

regards,
Hiroshi Inoue

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2011-04-20 13:38:27 Re: Re: [COMMITTERS] pgsql: setlocale() on Windows doesn't work correctly if the locale name
Previous Message Tom Lane 2011-04-20 13:08:59 Re: Re: [COMMITTERS] pgsql: setlocale() on Windows doesn't work correctly if the locale name

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2011-04-20 13:19:50 Re: time-delayed standbys
Previous Message Tom Lane 2011-04-20 13:08:59 Re: Re: [COMMITTERS] pgsql: setlocale() on Windows doesn't work correctly if the locale name