multibyte-character aware support for function "downcase_truncate_identifier()"

Rajanikant Chirmade <rajanikant.chirmade@enterprisedb.com>

From: Rajanikant Chirmade <rajanikant.chirmade@enterprisedb.com>
To: pgsql-hackers@postgresql.org
Date: 2010-07-07T04:35:29Z
Lists: pgsql-hackers

Attachments

Hi All,

Every identifier is downcase & truncated by function
"downcase_truncate_identifier()"
before using it.

But since the function "downcase_truncate_identifier()" is not
multibyte-charecter aware,
it is not able to downcase some of special charecters in identifier like
"my_SchemÄ".

If schema is created of name "my_SchemÄ", pg_namespace shows entries as
"my_schemÄ" .

Example is as below :

postgres=# create schema my_SchemÄ;
CREATE SCHEMA
postgres=# select nspname from pg_namespace;
      nspname
--------------------
 pg_toast
 pg_temp_1
 pg_toast_temp_1
 pg_catalog
 public
 information_schema
 my_schemÄ
(7 rows)

postgres=#

Achually it should downcase as "my_schemä" as per multibyte-character aware
as lower()
works :

postgres=# select lower('my_SchemÄ');
   lower
-----------
 my_schemä
(1 row)

There is function str_tolower()  which work as multibyte-character aware.
Need to use same function where ever downcase required. So, it will create
uniform down-casing at all places.

two places identified where need to add wide-character aware downcase :

1. downcase_truncate_identifier();
   -  Attaching patch for changes and small test case.

Following functions should also synchronise with
"downcase_truncate_identifier()" :

2. pg_strcasecmp();
3. pg_strncasecmp();

    - to add fix at these functions (2,3) need to move str_tolower() from
formatting.c  from backend to some common location (may be in src/port) from
where these can be used with client as well as server.

Thanks & Regards,
Rajanikant Chirmade.

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Implement a solution to the 'Turkish locale downcases I incorrectly'