agora inbox for pgsql-committers@postgresql.org
help / color / mirror / Atom feedFrom: Heikki Linnakangas <heikki.linnakangas@iki.fi>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix pg_strupper/lower/title/fold() functions to work with C loca
Date: Tue, 11 Aug 2026 18:25:42 +0000
Message-ID: <E1wtrAT-0000000093Z-1QC1@gemulon.postgresql.org> (raw)
Fix pg_strupper/lower/title/fold() functions to work with C locale
Starting with commit 011384ba45, calling to_date() or to_timestamp()
with "TMMonth" or other TM-prefixed format keyword, with the C locale,
would crash.
In REL_19_STABLE and above, pg_strupper(), pg_strlower(),
pg_strtitle(), and pg_strfold() functions have a special case for the
C locale, but that was missing in REL_18_STABLE. On REL_18_STABLE,
the functions call the libc function even in C locale, even though the
native locale object is NULL. On Linux, the underlying libc functions
will crash when called with NULL locale. (On macOS, they reportedly
do not, but even then it's not clear if they will do what you'd
expect.)
This went unnoticed because until commit 011384ba45, we never called
these functions in C locale, all the callers had a special codepath
for C locale. We could add a special path in the new callers too, but
it's an accident waiting to happen, so let's backport the C
locale-specific handling from REL_19_STABLE to REL_18_STABLE. Older
versions did not have these functions at all, hence no problem.
This applies to REL_18_STABLE only.
Reported-by: Masashi Kamura <kamura.masashi@fujitsu.com>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Discussion: https://www.postgresql.org/message-id/OS9PR01MB1317436E07D06281AD1A0452F94DD2%40OS9PR01MB13174.jpnpr...
Branch
------
REL_18_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/5f003855e7f05bd03c5531a58838540f62b8b19e
Modified Files
--------------
src/backend/utils/adt/pg_locale.c | 68 ++++++++++++++++++++++++++++++++++++---
1 file changed, 64 insertions(+), 4 deletions(-)
Message-ID: <E1wtrAT-0000000093Z-1QC1@gemulon.postgresql.org>
Permalink: ../E1wtrAT-0000000093Z-1QC1@gemulon.postgresql.org/
Also on: postgresql.org/message-id/E1wtrAT-0000000093Z-1QC1@gemulon.postgresql.org
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-committers@postgresql.org
Cc: heikki.linnakangas@iki.fi, pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Fix pg_strupper/lower/title/fold() functions to work with C loca
In-Reply-To: <E1wtrAT-0000000093Z-1QC1@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox