Re: Add pg_strtoupper and pg_strtolower functions

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Add pg_strtoupper and pg_strtolower functions
Date: 2022-05-04 13:13:31
Message-ID: 202205041313.jieskov5k52h@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2022-May-02, Bharath Rupireddy wrote:

> Hi,
>
> I came across pg_toupper and pg_tolower functions, converting a single
> character, are being used in loops to convert an entire
> null-terminated string. The cost of calling these character-based
> conversion functions (even though small) can be avoided if we have two
> new functions pg_strtoupper and pg_strtolower.

Currently, pg_toupper/pg_tolower are used in very limited situations.
Are they really always safe enough to run in arbitrary situations,
enough to create this new layer on top of them? Reading the comment on
pg_tolower, "the whole thing is a bit bogus for multibyte charsets", I
worry that we might create security holes, either now or in future
callsites that use these new functions.

Consider that in the Turkish locale you lowercase an I (single-byte
ASCII character) with a dotless-i (two bytes). So overwriting the input
string is not a great solution.

--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/
"Nunca se desea ardientemente lo que solo se desea por razón" (F. Alexandre)

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2022-05-04 13:34:54 Re: Skipping schema changes in publication
Previous Message Petr Vejsada 2022-05-04 13:05:32 pg_upgrade (12->14) fails on aggregate