From: Andreas Karlsson <andreas@proxel.se>
To: Jeff Davis <pgsql@j-davis.com>
To: Alexander Lakhin <exclusion@gmail.com>
To: zengman <zengman@halodbtech.com>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: Speed up ICU case conversion by using ucasemap_utf8To*()
Date: Tue, 14 Apr 2026 02:20:25 +0200
Message-ID: <118ca69e-47eb-42e1-83e9-72ccf40dd6fd@proxel.se> (raw)
In-Reply-To: <84006e443ef2dcfcbff8dcb3814c0c402b8ff7fd.camel@j-davis.com>
References: <167986ff-afcf-4542-94c6-61ee8474e138@proxel.se>
<72c7c2b5848da44caddfe0f20f6c7ebc7c0c6e60.camel@j-davis.com>
<c380cf11-dd23-4a75-af3e-3da8ec88bf6c@proxel.se>
<tencent_32015AAF279D4D696813121C@qq.com>
<4cfde442-25dd-495f-8d76-a23502ce17b8@proxel.se>
<744b9998-4463-4be5-b60e-a960eeb43202@proxel.se>
<tencent_3C4ABC775EDA640F219A5E69@qq.com>
<5a010b27-8ed9-4739-86fe-1562b07ba564@proxel.se>
<cca5b4a19d68e4488ffab1f41b222a7b4c60468f.camel@j-davis.com>
<96d80a47-f17f-42fa-82b1-2908efbd6541@gmail.com>
<dcea4840-18d0-4b5f-af16-1baefc563a3d@proxel.se>
<84006e443ef2dcfcbff8dcb3814c0c402b8ff7fd.camel@j-davis.com>
On 4/13/26 20:40, Jeff Davis wrote:
> Thank you both!
Thanks!
> Committed with minor revisions:
>
> * also check the status code, just to be sure
If we do that shouldn't we also do the same in the other callsites in
initdb.c uloc_getLanguage()? Maybe something like the attached. Also I
wonder if maybe other ICU functions have the same risk.
Andreas
Attachments:v1-0001-Always-check-for-untermianted-strings-when-callin.patch (text/x-patch, 1.2K) download
From 86703cae627f2d1a12fecb3a6ab7fbc0f0511330 Mon Sep 17 00:00:00 2001
From: Andreas Karlsson <andreas.karlsson@percona.com>
Date: Tue, 14 Apr 2026 02:12:15 +0200
Subject: [PATCH v1] Always check for untermianted strings when calling
uloc_getLanguage()
---
src/bin/initdb/initdb.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.cindex 509f1114ef6..21f25915ab2 100644--- a/src/bin/initdb/initdb.c+++ b/src/bin/initdb/initdb.c@@ -2403,7 +2403,7 @@ icu_validate_locale(const char *loc_str)
/* validate that we can extract the language */
status = U_ZERO_ERROR;
uloc_getLanguage(loc_str, lang, ULOC_LANG_CAPACITY, &status);
- if (U_FAILURE(status))+ if (U_FAILURE(status) || status == U_STRING_NOT_TERMINATED_WARNING)
{
pg_fatal("could not get language from locale \"%s\": %s",
loc_str, u_errorName(status));
@@ -2423,7 +2423,7 @@ icu_validate_locale(const char *loc_str)
status = U_ZERO_ERROR;
uloc_getLanguage(otherloc, otherlang, ULOC_LANG_CAPACITY, &status);
- if (U_FAILURE(status))+ if (U_FAILURE(status) || status === U_STRING_NOT_TERMINATED_WARNING)
continue;
if (strcmp(lang, otherlang) == 0)
--
2.43.0
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-hackers@postgresql.org
Cc: andreas@proxel.se, pgsql@j-davis.com, exclusion@gmail.com, zengman@halodbtech.com
Subject: Re: Speed up ICU case conversion by using ucasemap_utf8To*()
In-Reply-To: <118ca69e-47eb-42e1-83e9-72ccf40dd6fd@proxel.se>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox