Re: [PATCH] Fix for bug #19474: LIKE fails to match literal backslashes with nondeterministic collations

From: Nitin Motiani <nitinmotiani(at)google(dot)com>
To: Ewan Young <kdbase(dot)hack(at)gmail(dot)com>
Cc: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: [PATCH] Fix for bug #19474: LIKE fails to match literal backslashes with nondeterministic collations
Date: 2026-06-06 12:25:20
Message-ID: CAH5HC94r6aRJAVOqUiO=eAt3hvBA3r=H77y8qd3cV2pzOskQUA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> I reviewed the v2 patch.
>

Thanks for the feedback.

>
> 1. The commit message describes the symptom as "an incorrect match
> failure", but the bug also causes incorrect matches in the other
> direction. Since the unescaping logic dropped the literal backslash
> from the pattern, a text *without* a backslash could wrongly match a
> pattern that requires one:
>
> SELECT 'backslash' COLLATE ignore_accents LIKE 'back\\slash%';
> -- unpatched: t (wrong), patched: f (correct)
>
> I think it's worth mentioning this false-positive side of the bug in
> the commit message, since silently-too-permissive LIKE filters are
> arguably the more dangerous symptom for applications.
>

I have updated the commit message. I also added another test for this
scenario in v3.

> 2. A small typo in the new comment in like_match.c:
> "occurences" should be "occurrences".
>

Fixed the typo.

Thanks,
Nitin Motiani
Google

Attachment Content-Type Size
v3-0001-Fix-LIKE-matching-with-nondeterministic-collation.patch application/x-patch 5.1 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Erik Rijkers 2026-06-06 12:36:24 Re: pgsql: doc: Clarify OAuth validator authn_id logging
Previous Message Bertrand Drouvot 2026-06-06 11:07:11 Re: t/035_standby_logical_decoding.pl might fail on attempt to read wrong timeline