Re: BUG #19341: REPLACE() fails to match final character when using nondeterministic ICU collation

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
Cc: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, adam(dot)warland(at)infor(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #19341: REPLACE() fails to match final character when using nondeterministic ICU collation
Date: 2025-12-06 01:12:12
Message-ID: 2074712.1764983532@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at> writes:
> On Wed, 2025-12-03 at 10:12 -0500, Tom Lane wrote:
>> We do require callers to eliminate the empty-needle case, and given
>> that I think we could assume that match substrings must be at least
>> 1 byte long. That assumption is what justifies the current API for
>> these functions, and perhaps we can also simplify this loop by
>> using it.

> The attached v5 patch simplifies the loop to a do-while loop, assuming
> that we cannot find a zero-length match.
> I have also updated the comments to no longer mention the possibility
> of an empty match, and for good measure I have added an Assert() that
> the needle cannot be empty.

LGTM. Pushed with tiny cosmetic fixes (mostly, more work on the
comments).

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2025-12-06 06:09:36 Re: BUG #19340: Wrong result from CORR() function
Previous Message Tom Lane 2025-12-05 22:17:33 Re: BUG #19340: Wrong result from CORR() function