0001-Fix-timestamptz_to_str-for-out-of-range-timestamps.patch

text/x-patch

Filename: 0001-Fix-timestamptz_to_str-for-out-of-range-timestamps.patch
Type: text/x-patch
Part: 0
Message: [PATCH] Handle out-of-range timestamps in timestamptz_to_str()

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: format-patch
Series: patch 0001
Subject: Fix timestamptz_to_str() for out-of-range timestamps
File+
src/bin/pg_waldump/compat.c 6 0
From b443fb1a5b3b0f0ffb419c2eb7a7375c9d5b990e Mon Sep 17 00:00:00 2001
From: Eugeny Goryachev <gorcom2012@gmail.com>
Date: Wed, 15 Oct 2025 12:41:10 +0400
Subject: [PATCH] Fix timestamptz_to_str() for out-of-range timestamps

---
 src/bin/pg_waldump/compat.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/bin/pg_waldump/compat.c b/src/bin/pg_waldump/compat.c
index 2aca73f2e93..825311b1bd4 100644
--- a/src/bin/pg_waldump/compat.c
+++ b/src/bin/pg_waldump/compat.c
@@ -54,6 +54,12 @@ timestamptz_to_str(TimestampTz t)
 	time_t		result = (time_t) timestamptz_to_time_t(t);
 	struct tm  *ltime = localtime(&result);
 
+	if (!ltime)
+	{
+		strlcpy(buf, "(timestamp out of range)", sizeof(buf));
+		return buf;
+	}
+
 	strftime(ts, sizeof(ts), "%Y-%m-%d %H:%M:%S", ltime);
 	strftime(zone, sizeof(zone), "%Z", ltime);
 
-- 
2.43.0