Re: Refactoring: Use soft error reporting for *_opt_overflow functions of date/timestamp

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Amul Sul <sulamul(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Refactoring: Use soft error reporting for *_opt_overflow functions of date/timestamp
Date: 2025-11-26 11:42:55
Message-ID: aSbnv83Rw9a0wOX4@paquier.xyz
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Nov 26, 2025 at 03:09:25PM +0530, Amul Sul wrote:
> This continues the previous refactoring commit [1] where we adopted
> soft error reporting for some numeric functions. This patch applies
> the same pattern to the date/timestamp function. The change ensures
> consistency by utilizing the existing soft error reporting
> infrastructure.

Thanks for continuing this work.

> Note that in the patch, I renamed the function by replacing the
> "no_overflow" extension in the function name with "overflow_safe".
> Alternatively, we could just use "safe" alone. Suggestions are
> welcome.

Hmm. Following the previous example you have quoted, I am wondering
if we'd tweak the names a bit differently. Rather than the
popo_overflow_safe() pattern from your patch, I would choose a simpler
popo_safe() as naming convention. That would be also more consistent
with the names applied to the refactored routines of 4246a977bad6.

- result = date2timestamp_opt_overflow(val, &overflow);
+ result = date2timestamp_overflow_safe(val, (Node *) &escontext);
/* We can ignore the overflow result, since result is useful as-is */

In these cases, why don't you just pass NULL to the routines for the
error context? (Sorry, I don't have my eyes on the code now, but I
recall that NULL should work as well, meaning the same as "ignore
me".)
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2025-11-26 11:46:51 Re: POC: enable logical decoding when wal_level = 'replica' without a server restart
Previous Message Marcos Pegoraro 2025-11-26 11:24:57 Re: Additional info for CREATE ROLE with REPLICATION