Re: Patch to make Turks happy.

From: Nicolai Tufar <ntufar(at)apb(dot)com(dot)tr>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: Patch to make Turks happy.
Date: 2002-12-05 21:01:22
Message-ID: 3DEFBEA2.6090404@apb.com.tr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Bruce Momjian wrote:
> I am not going to apply this patch because I think it will mess up the
> handling of other locales.

As far as I figured from the source code this function only deals with
cleaning up
locale names and nothing else. Since all the locale names are in plain
ASCII I think
it will be safe to use ASCII-only lower-case conversion.

By the way, I noticed only after sending the patch that compiler
complains about
ambiguous `else' so it can be rewritten as:


if (*p >= 'A' && *p <= 'Z'){

*np++ = *p + 'a' - 'A';

}else{

*np++ = *p;
}

Regards,
Nicolai

>
>
> ---------------------------------------------------------------------------
>
> Nicolai Tufar wrote:
>
>>Hi,
>>
>>Yet another problem with Turkish encoding. clean_encoding_name()
>>in src/backend/utils/mb/encnames.c uses tolower() to convert locale
>>names to lower-case. This causes errors if locale name contains
>>capital "I" and current olcale is Turkish. Some examples:
>>
>>aaa=# \l
>> List of databases
>> Name | Owner | Encoding
>>-----------+-------+----------
>> aaa | pgsql | LATIN5
>> bbb | pgsql | LATIN5
>> template0 | pgsql | LATIN5
>> template1 | pgsql | LATIN5
>>(4 rows)
>>aaa=# CREATE DATABASE ccc ENCODING='LATIN5';
>>ERROR: LATIN5 is not a valid encoding name
>>aaa=# \encoding
>>SQL_ASCII
>>aaa=# \encoding SQL_ASCII
>>SQL_ASCII: invalid encoding name or conversion procedure not found
>>aaa=# \encoding LATIN5
>>LATIN5: invalid encoding name or conversion procedure not found
>>
>>
>>Patch, is a simple change to use ASCII-only lower-case conversion
>>instead of locale-dependent tolower()
>>
>>Best regards,
>>Nic.
>>
>>
>>
>>
>>
>>
>>*** ./src/backend/utils/mb/encnames.c.orig Mon Dec 2 15:58:49 2002
>>--- ./src/backend/utils/mb/encnames.c Mon Dec 2 18:13:23 2002
>>***************
>>*** 407,413 ****
>> for (p = key, np = newkey; *p != '\0'; p++)
>> {
>> if (isalnum((unsigned char) *p))
>>! *np++ = tolower((unsigned char) *p);
>> }
>> *np = '\0';
>> return newkey;
>>--- 407,416 ----
>> for (p = key, np = newkey; *p != '\0'; p++)
>> {
>> if (isalnum((unsigned char) *p))
>>! if (*p >= 'A' && *p <= 'Z')
>>! *np++ = *p + 'a' - 'A';
>>! else
>>! *np++ = *p;
>> }
>> *np = '\0';
>> return newkey;
>>
>>
>>---------------------------(end of broadcast)---------------------------
>>TIP 4: Don't 'kill -9' the postmaster
>>
>
>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2002-12-05 21:04:19 Re: dbmirror
Previous Message Steven Singer 2002-12-05 20:54:10 Re: dbmirror

Browse pgsql-patches by date

  From Date Subject
Next Message Hannu Krosing 2002-12-05 21:27:46 Re: Hierarchical queries a la Oracle patch. for 7.3rc1.
Previous Message Fernando Nasser 2002-12-05 20:55:30 Re: Hierarchical queries a la Oracle patch. for 7.3rc1.