Skip site navigation (1) Skip section navigation (2)

Re: Turkish locale bug

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Sezai YILMAZ <sezaiy(at)ata(dot)cs(dot)hun(dot)edu(dot)tr>
Cc: pgsql-bugs(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Turkish locale bug
Date: 2001-02-20 16:00:09
Message-ID: 12661.982684809@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-bugspgsql-hackers
Sezai YILMAZ <sezaiy(at)ata(dot)cs(dot)hun(dot)edu(dot)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

In response to

Responses

pgsql-hackers by date

Next:From: Tom LaneDate: 2001-02-20 16:19:04
Subject: Re: [HACKERS] Re: v7.1b4 bad performance
Previous:From: Tom LaneDate: 2001-02-20 15:50:57
Subject: Re: beta5 ...

pgsql-bugs by date

Next:From: Thomas LockhartDate: 2001-02-20 16:36:19
Subject: Re: Turkish locale bug
Previous:From: Tom LaneDate: 2001-02-20 15:36:26
Subject: Re:

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group