]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix LIKE/regex optimization for indexscan with exact-match pattern.
authorTom Lane <tgl@sss.pgh.pa.us>
Mon, 6 Jul 2026 17:06:21 +0000 (13:06 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Mon, 6 Jul 2026 17:06:25 +0000 (13:06 -0400)
commit67cf73ddbe3334ee1fecc29ffb6d4cd2e10ab9ac
treee4164a891226e591dea5ec6b14b4b5f7c66663e0
parent2ddc4566214d8eff3c4013a9e241b5e9b47abbaf
Fix LIKE/regex optimization for indexscan with exact-match pattern.

Commit 85b7efa1c introduced support for LIKE with non-deterministic
collations.  By moving some conditionals around, it accidentally broke
the optimization for converting a LIKE or regex exact-match pattern
to an equality indexqual when the index collation doesn't match the
expression collation.  That should be allowed if the expression
collation is deterministic.  This patch re-introduces the optimization
for that common case.

One important beneficiary of this optimization is the "\d tablename"
command in psql.  Without this fix that will do a seqscan on pg_class
instead of an index point lookup.

Reported-by: Andres Freund <andres@anarazel.de>
Author: Jelte Fennema-Nio <postgres@jeltef.nl>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/DHBQIZX8SZVI.ZX614ZMFL645@jeltef.nl
Backpatch-through: 18
src/backend/utils/adt/like_support.c
src/test/regress/expected/collate.icu.utf8.out
src/test/regress/expected/collate.out
src/test/regress/sql/collate.icu.utf8.sql
src/test/regress/sql/collate.sql