Fix multibyte issue in ltree_strncasecmp(). REL_15_STABLE github/REL_15_STABLE
authorJeff Davis <[email protected]>
Tue, 16 Dec 2025 18:35:40 +0000 (10:35 -0800)
committerJeff Davis <[email protected]>
Tue, 16 Dec 2025 18:37:22 +0000 (10:37 -0800)
commit335b2f30b468c133f86891ec3d82a2fd0d50e221
treee6fdfaed387101a57f61f9233ec8485ca452425d
parentbd2726d3e15fdf8245f63bdbaddf4e3700f86577
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 <[email protected]>
Reviewed-by: Peter Eisentraut <[email protected]>
Discussion: https://postgr.es/m/5f65b85740197ba6249ea507cddf609f84a6188b.camel%40j-davis.com
Backpatch-through: 14
contrib/ltree/lquery_op.c
contrib/ltree/ltree.h
contrib/ltree/ltxtquery_op.c