17: lc_collate_is_c() when LC_CTYPE != LC_COLLATE

Started by Jeff Davisabout 2 years ago1 messagesbugs
Jump to latest
#1Jeff Davis
pgsql@j-davis.com

Due to a very unfortunate copy-and-paste error in 2d819a08a1, for the
libc provider, lc_collate_is_c() is checking the environment's LC_CTYPE
rather than LC_COLLATE :(

This sort of works if LC_COLLATE=C and LC_CTYPE=en_US.utf8 (or another
real locale), because lc_collate_is_c() returns false and it falls
through to strcoll(), which will observe LC_COLLATE.

But if LC_COLLATE=en_US.utf8 and LC_CTYPE=C, then it's wrong results. 

By good fortune, I believe that the latter combination is fairly rare,
which may explain why it evaded manual testing until now. But it's
still pretty bad.

Trivial patch attached, which I intend to commit shortly to 17 only.
The bug does not exist in master due to recent refactoring.

Regards,
Jeff Davis

Attachments:

v1-0001-Fix-lc_collate_is_c-when-LC_COLLATE-LC_CTYPE.patchtext/x-patch; charset=UTF-8; name=v1-0001-Fix-lc_collate_is_c-when-LC_COLLATE-LC_CTYPE.patchDownload+2-3