From: Laurenz Albe <laurenz.albe@cybertec.at>
To: adam.warland@infor.com
To: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #19341: REPLACE() fails to match final character when using nondeterministic ICU collation
Date: Tue, 02 Dec 2025 17:24:54 +0100
Message-ID: <60b467ac47d5c6bbb9c21c3bdfecce8e5de60cda.camel@cybertec.at> (raw)
In-Reply-To: <19341-1d9a22915edfec58@postgresql.org>
References: <19341-1d9a22915edfec58@postgresql.org>
On Tue, 2025-12-02 at 10:03 +0000, PG Bug reporting form wrote:
> PostgreSQL version: 18.1
>
> When using a nondeterministic ICU collation, the replace() function fails to
> replace a substring when that substring appears at the end of the input
> string.
>
> Occurrences of the same substring earlier in the string are replaced
> normally.
>
> Specific collation used:
> create collation test_nondeterministic (
> provider = icu,
> locale = 'und-u-ks-level2',
> deterministic = false
> )
>
> -- Replace final character under nondeterministic collation
> SELECT replace(
> 'testx' COLLATE "test_nondeterministic",
> 'x' COLLATE "test_nondeterministic",
> 'y') AS res1;
I can reproduce the problem, and the attached patch fixes it for me.
I am not certain if it is safe to apply pg_mblen() to "haystack_end", though.
Yours,
Laurenz Albe
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-bugs@postgresql.org
Cc: laurenz.albe@cybertec.at, adam.warland@infor.com, pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #19341: REPLACE() fails to match final character when using nondeterministic ICU collation
In-Reply-To: <60b467ac47d5c6bbb9c21c3bdfecce8e5de60cda.camel@cybertec.at>
* 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