From 2fc38f7def122ac6cea63146ad93097cb0ec1071 Mon Sep 17 00:00:00 2001
From: Heikki Linnakangas <heikki.linnakangas@iki.fi>
Date: Tue, 30 Jul 2024 13:22:23 +0300
Subject: [PATCH v1 2/5] Replace static buf with palloc in str_time()

The function is only used once in startup process, so the leak into
current memory context is harmless.

This is tiny step in making the server thread-safe.
---
 src/backend/access/transam/xlog.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index f86f4b5c4b7..75463e153ec 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -5168,9 +5168,9 @@ BootStrapXLOG(uint32 data_checksum_version)
 static char *
 str_time(pg_time_t tnow)
 {
-	static char buf[128];
+	char	   *buf = palloc(128);
 
-	pg_strftime(buf, sizeof(buf),
+	pg_strftime(buf, 128,
 				"%Y-%m-%d %H:%M:%S %Z",
 				pg_localtime(&tnow, log_timezone));
 
-- 
2.39.2

