pgsql: Use thread-safe strftime_l() instead of strftime().

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Use thread-safe strftime_l() instead of strftime().
Date: 2025-03-28 06:19:20
Message-ID: E1ty33o-001NdU-2V@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(dot)munro(at)gmail(dot)com>
Reviewed-by: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Reviewed-by: Peter Eisentraut <peter(at)eisentraut(dot)org>
Discussion: https://postgr.es/m/CA%2BhUKGJqVe0%2BPv9dvC9dSums_PXxGo9SWcxYAMBguWJUGbWz-A%40mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/890fc826c91f153ae8c084d3a008f91798495b13

Modified Files
--------------
src/backend/main/main.c | 5 +-
src/backend/utils/adt/pg_locale.c | 110 ++++++++-------------------------
src/backend/utils/adt/pg_locale_libc.c | 3 +-
src/include/utils/pg_locale.h | 1 +
4 files changed, 29 insertions(+), 90 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Amit Kapila 2025-03-28 07:06:19 pgsql: pg_createsubscriber: Add '--all' option.
Previous Message Amit Kapila 2025-03-28 05:48:18 pgsql: Stablize tests added in 3abe9dc188.