Use thread-safe strftime_l() instead of strftime().
Peter Eisentraut <peter@eisentraut.org>
Use thread-safe strftime_l() instead of strftime(). This removes some setlocale() calls and a lot of commentary about how dangerous that is. strftime_l() is from POSIX 2008, and on Windows we use _wcsftime_l(). While here, adjust error message for strftime_l() failure: it does not in practice set errno (even though POSIX says it could), so no %m. Author: Thomas Munro <thomas.munro@gmail.com> Reviewed-by: Heikki Linnakangas <hlinnaka@iki.fi> Reviewed-by: Peter Eisentraut <peter@eisentraut.org> Discussion: https://postgr.es/m/CA%2BhUKGJqVe0%2BPv9dvC9dSums_PXxGo9SWcxYAMBguWJUGbWz-A%40mail.gmail.com
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/main/main.c | modified | +1 −4 |
| src/backend/utils/adt/pg_locale.c | modified | +26 −84 |
| src/backend/utils/adt/pg_locale_libc.c | modified | +1 −2 |
| src/include/utils/pg_locale.h | modified | +1 −0 |
Discussion
- Thread-safe nl_langinfo() and localeconv() 21 messages · 2024-08-13 → 2025-04-04