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

From: Rajanikant Chirmade <rajanikant(dot)chirmade(at)enterprisedb(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: multibyte-character aware support for function "downcase_truncate_identifier()"
Date: 2010-07-07 04:35:29
Message-ID: AANLkTinsNCP3NA7TqomnPKU2OgvS7TW1B1pf1JtY50fv@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 Content-Type Size
fix.patch text/x-diff 1.3 KB
wide-charecter_aware_downcase.sql text/x-sql 312 bytes
wide-charecter_aware_downcase.out application/octet-stream 340 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Takahiro Itagaki 2010-07-07 06:14:50 Re: Partitioning syntax
Previous Message Takahiro Itagaki 2010-07-07 03:35:44 Re: Does mbutils.c really need to use L'\0' ?