pgsql: ltree: fix case-insensitive matching.

From: Jeff Davis <jdavis(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: ltree: fix case-insensitive matching.
Date: 2025-12-16 21:00:41
Message-ID: E1vVc9w-0017wq-2N@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

ltree: fix case-insensitive matching.

Previously, ltree_prefix_eq_ci() used lowercasing with the default
collation; while ltree_crc32_sz() used tolower() directly. These were
equivalent only if the default collation provider was libc and the
encoding was single-byte.

Change both to use casefolding with the default collation.

Backpatch through 18, where the casefolding APIs were introduced. The
bug exists in earlier versions, but would require some adaptation.

A REINDEX is required for ltree indexes where the database default
collation is not libc.

Reviewed-by: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Reviewed-by: Peter Eisentraut <peter(at)eisentraut(dot)org>
Backpatch-through: 18
Discussion: https://postgr.es/m/450ceb6260cad30d7afdf155d991a9caafee7c0d.camel@j-davis.com
Discussion: https://postgr.es/m/01fc00fd66f641b9693d4f9f1af0ccf44cbdfbdf.camel@j-davis.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/7f007e4a044a713df5320fca09621d6ba8e632ba

Modified Files
--------------
contrib/ltree/crc32.c | 46 ++++++++++++++++++++++++++++++++++++++--------
contrib/ltree/lquery_op.c | 39 ++++++++++++++++++++++++++++++++++++---
2 files changed, 74 insertions(+), 11 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Jeff Davis 2025-12-16 21:00:47 pgsql: ltree: fix case-insensitive matching.
Previous Message Jeff Davis 2025-12-16 20:50:24 pgsql: Clarify a #define introduced in 8d299052fe.