> On Oct 18, 2026, at 11:52, shihao zhong <[email protected]> wrote:
>
> Hi,
>
> This is the first low item from my list in [1]. It has the same cause as
> the EUC_* report in [2], and 43a948b7b25 did not fix it.
>
> wc_iscased_libc_utf8() asks iswupper() and iswlower(), but ILIKE
> compares with towlower(). The macOS C library case-maps 117 code points
> that are neither upper nor lower, like U+2160 (Roman numeral one). So
> U+2160 stays in the index prefix:
>
> create table t (x text collate "en_US.UTF-8");
> insert into t values (U&'\2160q'), (U&'\2170q');
> insert into t select 'filler' || g from generate_series(1, 2000) g;
> create index on t (x text_pattern_ops);
> analyze t;
> select count(*) from t where x ilike U&'\2160q%';
>
> On the master and REL_19_STABLE heads the index scan returns 1. A seq
> scan returns 2. glibc on Linux classifies all of them, so it is fine.
>
> The attached patch also counts a character as cased when towupper() or
> towlower() changes it.
>
>
> [1]
> https://postgr.es/m/cagrkxqsfdjqzp_kwrz7dv6lhx-csrkdnynnxgntrscenqtk...@mail.gmail.com
> [2] https://postgr.es/m/[email protected]
>
> Thanks,
> Shihao
> <v1-0001-Fix-pg_iswcased-for-libc-UTF8-case-mappings.patch>
I can reproduce the issue on my MacBook too.
Given that this issue has only been confirmed on macOS so far, does it make
sense to add the extra checks only for macOS, like this:
```
return iswupper_l((wint_t) wc, locale->lt) ||
iswlower_l((wint_t) wc, locale->lt)
#if defined(__darwin__)
|| towupper_l((wint_t) wc, locale->lt) != (wint_t) wc
|| towlower_l((wint_t) wc, locale->lt) != (wint_t) wc
#endif
;
```
I see that #if defined(__darwin__) is already used in many places.
Then, I would suggest adding a regression test so that CI can help check
whether the problem exists on other platforms.
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/