multibyte-character aware support for function "downcase_truncate_identifier()" - Mailing list pgsql-hackers

From Rajanikant Chirmade
Subject multibyte-character aware support for function "downcase_truncate_identifier()"
Date
Msg-id AANLkTinsNCP3NA7TqomnPKU2OgvS7TW1B1pf1JtY50fv@mail.gmail.com
Whole thread Raw
Responses Re: multibyte-character aware support for function "downcase_truncate_identifier()"
List pgsql-hackers
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.

Attachment

pgsql-hackers by date:

Previous
From: Takahiro Itagaki
Date:
Subject: Re: Does mbutils.c really need to use L'\0' ?
Next
From: "Joshua D. Drake"
Date:
Subject: Re: [COMMITTERS] pgsql: Add note that using PL/Python 2and 3 in the same session will