postgres.git / summary / log / commit / refs
commit 8474bae2ba4cf8c6e91db800a441daffe22098ee
Author: Jeff Davis <jdavis@postgresql.org>
Date: Mon Oct 26 22:11:21 2026 +0000
First released in: 19.0
Fix pg_iswcased() for some libc case mappings.
Some C libraries, such as macOS libc, case-map characters that they do
not classify as upper or lower. ILIKE index scans could then miss
rows, because those characters stayed in the fixed prefix.
Introduced in 630706ced0. 43a948b7b25 fixed similar issues, but missed
this one.
Author: shihao zhong <zhong950419@gmail.com>
Reviewed-by: Fujii Masao <masao.fujii@gmail.com>
Reviewed-by: Chao Li <li.evan.chao@gmail.com>
Discussion: https://postgr.es/m/CAGRkXqS6pr-hG-g=K6RTdRw53SnMZWz3iXvh_wi8rqLSf972sA@mail.gmail.com
Backpatch-through: 19
src/backend/utils/adt/pg_locale_libc.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/backend/utils/adt/pg_locale_libc.c b/src/backend/utils/adt/pg_locale_libc.c
index 02c419aa62a..801f3dcafe0 100644
--- a/src/backend/utils/adt/pg_locale_libc.c
+++ b/src/backend/utils/adt/pg_locale_libc.c
@@ -328,10 +328,14 @@ wc_iscased_libc_utf8(pg_wchar wc, pg_locale_t locale)
/*
* For UTF8, pg_wchar is a codepoint and we assume we can pass it directly
- * to iswupper_l()/iswlower_l().
+ * to iswupper_l()/iswlower_l(). Some C libraries case-map characters
+ * that they do not classify as upper or lower, so also check the mapping,
+ * which is what ILIKE uses.
*/
return iswupper_l((wint_t) wc, locale->lt) ||
- iswlower_l((wint_t) wc, locale->lt);
+ iswlower_l((wint_t) wc, locale->lt) ||
+ towupper_l((wint_t) wc, locale->lt) != (wint_t) wc ||
+ towlower_l((wint_t) wc, locale->lt) != (wint_t) wc;
}
static pg_wchar
[parent: 1dc45adefa07]