Re: Remaining dependency on setlocale()

Jeff Davis <pgsql@j-davis.com>

From: Jeff Davis <pgsql@j-davis.com>
To: Peter Eisentraut <peter@eisentraut.org>, Chao Li <li.evan.chao@gmail.com>
Cc: Thomas Munro <thomas.munro@gmail.com>, Tom Lane <tgl@sss.pgh.pa.us>, pgsql-hackers@postgresql.org
Date: 2026-01-27T19:44:36Z
Lists: pgsql-hackers
On Tue, 2026-01-06 at 14:20 -0800, Jeff Davis wrote:
> Looks good to me.

I closed the entry for this commitfest, though there are a few loose
ends:

  * Not sure what to do about strerror & gettext. One idea is to wrap
both in a uselocale() everywhere. For windows, we use the special
setlocale() mode. For NetBSD, I don't know if we can or should do
anything -- maybe just prevent changing lc_messages?

  * pg_strcasecmp() still used many places in the backend. We should
consider replacing with an ASCII variant or one that uses the database
collation.

  * A number of places still rely on isalpha(), etc., for simple
parsing (e.g. ltree).

Regards,
	Jeff Davis




Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Fix crash introduced by incorrect backport 806555e300.

  2. fuzzystrmatch: use pg_ascii_toupper().

  3. Make dmetaphone collation-aware

  4. Avoid global LC_CTYPE dependency in pg_locale_icu.c.

  5. downcase_identifier(): use method table from locale provider.

  6. ltree: fix case-insensitive matching.

  7. Fix multibyte issue in ltree_strncasecmp().

  8. Use multibyte-aware extraction of pattern prefixes.

  9. Add pg_iswcased().

  10. Remove char_tolower() API.

  11. Make regex "max_chr" depend on encoding, not provider.

  12. Change some callers to use pg_ascii_toupper().

  13. Allow pg_locale_t APIs to work when ctype_is_c.

  14. Add #define for UNICODE_CASEMAP_BUFSZ.

  15. Inline pg_ascii_tolower() and pg_ascii_toupper().

  16. Avoid global LC_CTYPE dependency in pg_locale_libc.c.

  17. Force LC_COLLATE to C in postmaster.

  18. Change wchar2char() and char2wchar() to accept a locale_t.

  19. Use pg_ascii_tolower()/pg_ascii_toupper() where appropriate.

  20. inet_net_pton.c: use pg_ascii_tolower() rather than tolower().

  21. isn.c: use pg_ascii_toupper() instead of toupper().

  22. contrib/spi/refint.c: use pg_ascii_tolower() instead.

  23. copyfromparse.c: use pg_ascii_tolower() rather than tolower().

  24. Revert "Tidy up locale thread safety in ECPG library."

  25. Tidy up locale thread safety in ECPG library.

  26. All supported systems have locale_t.