pgsql: Fix multibyte issue in ltree_strncasecmp().

From: Jeff Davis <jdavis(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix multibyte issue in ltree_strncasecmp().
Date: 2025-12-16 18:49:36
Message-ID: E1vVa75-0016ww-1Y@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix multibyte issue in ltree_strncasecmp().

Previously, the API for ltree_strncasecmp() took two inputs but only
one length (that of the smaller input). It truncated the larger input
to that length, but that could break a multibyte sequence.

Change the API to be a check for prefix equality (possibly
case-insensitive) instead, which is all that's needed by the
callers. Also, provide the lengths of both inputs.

Reviewed-by: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Reviewed-by: Peter Eisentraut <peter(at)eisentraut(dot)org>
Discussion: https://postgr.es/m/5f65b85740197ba6249ea507cddf609f84a6188b.camel%40j-davis.com
Backpatch-through: 14

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/b80227c0a54ccc6c358a24f2a8772667d0a4f0d4

Modified Files
--------------
contrib/ltree/lquery_op.c | 40 ++++++++++++++++++++++++++++------------
contrib/ltree/ltree.h | 7 +++++--
contrib/ltree/ltxtquery_op.c | 8 ++++----
3 files changed, 37 insertions(+), 18 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Jeff Davis 2025-12-16 18:49:40 pgsql: Fix multibyte issue in ltree_strncasecmp().
Previous Message Jeff Davis 2025-12-16 18:49:32 pgsql: Fix multibyte issue in ltree_strncasecmp().