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/[email protected] Discussion: https://postgr.es/m/[email protected] Branch ------ REL_18_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/806555e3000d0b0e0c536c1dc65548128d457d86 Modified Files -------------- contrib/ltree/crc32.c | 47 +++++++++++++++++++++++++++++++++++-------- contrib/ltree/lquery_op.c | 39 ++++++++++++++++++++++++++++++++--- src/include/utils/pg_locale.h | 14 +++++++++++++ 3 files changed, 89 insertions(+), 11 deletions(-)
