ltree: fix case-insensitive matching. master github/master
authorJeff Davis <[email protected]>
Tue, 16 Dec 2025 19:13:17 +0000 (11:13 -0800)
committerJeff Davis <[email protected]>
Tue, 16 Dec 2025 20:57:00 +0000 (12:57 -0800)
commit7f007e4a044a713df5320fca09621d6ba8e632ba
tree160672377262ef049e5454e35bd86f050aca6d68
parent24bf379cb15162514b01fc9fd05420a0203b82e9
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 <[email protected]>
Reviewed-by: Peter Eisentraut <[email protected]>
Backpatch-through: 18
Discussion: https://postgr.es/m/450ceb6260cad30d7afdf155d991a9caafee7c0d[email protected]
Discussion: https://postgr.es/m/01fc00fd66f641b9693d4f9f1af0ccf44cbdfbdf[email protected]
contrib/ltree/crc32.c
contrib/ltree/lquery_op.c