Re: [PATCH] Handle out-of-range timestamps in timestamptz_to_str()

From: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
To: Алена Васильева <gorcom2012(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [PATCH] Handle out-of-range timestamps in timestamptz_to_str()
Date: 2025-10-15 09:12:53
Message-ID: 103342A9-CF97-4BE0-8D68-1A55CA357F35@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On Oct 15, 2025, at 16:54, Алена Васильева <gorcom2012(at)gmail(dot)com> wrote:
>
> Hello,
>
> The function timestamptz_to_str() in src/bin/pg_waldump/compat.c does not
> handle the case when localtime() returns NULL, which can happen for timestamps
> that are out of the supported time_t range on some platforms.
>
> This patch adds a simple check for a NULL return value and ensures that the
> function returns a clear error string "(timestamp out of range)" instead of
> causing undefined behavior or a crash.
>
>
I think we can just return a static const string, without copying the string into “buf" as the function returns a “const char *”.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Gustafsson 2025-10-15 09:17:14 Re: [PATCH] Handle out-of-range timestamps in timestamptz_to_str()
Previous Message Michael Paquier 2025-10-15 08:58:37 Re: [BUG] temporary file usage report with extended protocol and unnamed portals