pgsql: Fix LIKE matching with nondeterministic collations and backslash

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix LIKE matching with nondeterministic collations and backslash
Date: 2026-07-06 18:48:15
Message-ID: E1wgoMZ-001d4S-1V@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix LIKE matching with nondeterministic collations and backslashes.

Commit 85b7efa1c added support for LIKE with nondeterministic
collations, but it included a bug in the de-escaping logic for
literal pattern substrings. That unconditionally skipped all
backslashes, but when it encounters '\\' it should emit the second
backslash as a de-escaped character. That led to acting as though
the escaped backslash was not there.

Bug: #19474
Reported-by: Bowen Shi <zxwsbg12138(at)gmail(dot)com>
Author: Nitin Motiani <nitinmotiani(at)google(dot)com>
Reviewed-by: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
Reviewed-by: Ewan Young <kdbase(dot)hack(at)gmail(dot)com>
Reviewed-by: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Discussion: https://postgr.es/m/19474-5b86a95f3d9a7ecb@postgresql.org
Discussion: https://postgr.es/m/CAH5HC94yU+K8Gcdy12M5BS8gwD_SXLSHzc9k5tNk7JDnpBiFMA@mail.gmail.com
Backpatch-through: 18

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/99775b3885b600277dea577db69e7469e59bcdbe

Modified Files
--------------
src/backend/utils/adt/like_match.c | 5 ++---
src/test/regress/expected/collate.icu.utf8.out | 31 ++++++++++++++++++++++++++
src/test/regress/sql/collate.icu.utf8.sql | 7 ++++++
3 files changed, 40 insertions(+), 3 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Robert Haas 2026-07-06 19:46:21 pgsql: Use PG_MODULE_MAGIC_EXT in newly introduced modules
Previous Message Tom Lane 2026-07-06 17:48:47 pgsql: Make PLy_elog() use pg_integer_constant_p().