Re: [BUGS] Turkish locale bug - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [BUGS] Turkish locale bug
Date
Msg-id 12661.982684809@sss.pgh.pa.us
Whole thread Raw
In response to Re: [BUGS] Turkish locale bug  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Sezai YILMAZ <sezaiy@ata.cs.hun.edu.tr> writes:
> You are right. What about this one?

>             setlocale(LC_ALL, "C");  

>                     for(i = 0; yytext[i]; i++)
>                           if (isascii((unsigned char)yytext[i]) &&
>                                 isupper(yytext[i]))
>                                 yytext[i] = tolower(yytext[i]);

>                     /* This sets locale to default locale which 
>                        user prefer to use */

>             setlocale(LC_ALL, "");  

This isn't really better than "if (isupper(ch)) ch = ch + ('a' - 'A')".
It still breaks the existing locale-aware handling of identifier case,
which I believe is considered a good thing in all locales except C
and Turkish.  Another small problem is that setlocale() is moderately
expensive in most implementations, and we don't want to call it twice
for every identifier scanned.

I am starting to think that the only real solution is a special case
for Turkish users.  Perhaps use tolower() normally but have a compile-
time option to use a non-locale-aware method:

#ifdef LOCALE_AWARE_IDENTIFIER_FOLDING                 if (isupper(yytext[i]))                    yytext[i] =
tolower(yytext[i]);
#else                 /* this assumes ASCII encoding... */                 if (yytext[i] >= 'A' && yytext[i] <= 'Z')
               yytext[i] += 'a' - 'A';
 
#endif

and then document that you have to disable
LOCALE_AWARE_IDENTIFIER_FOLDING to use Turkish locale.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: enable-debug considered pointless
Next
From: Tom Lane
Date:
Subject: Re: beta5 ...