Re: Refactoring: Use soft error reporting for *_opt_overflow functions of date/timestamp
amul sul <sulamul@gmail.com>
From: Amul Sul <sulamul@gmail.com>
To: Amit Langote <amitlangote09@gmail.com>
Cc: Michael Paquier <michael@paquier.xyz>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-11-27T07:57:46Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Update some timestamp[tz] functions to use soft-error reporting
- 713d9a847e64 19 (unreleased) landed
-
Switch some date/timestamp functions to use the soft error reporting
- d03668ea0566 19 (unreleased) landed
-
Switch some numeric-related functions to use soft error reporting
- 4246a977bad6 19 (unreleased) cited
Attachments
- v2-0001-Switch-some-date-related-functions-to-use-soft-er.patch (application/octet-stream) patch v2-0001
On Thu, Nov 27, 2025 at 6:48 AM Amit Langote <amitlangote09@gmail.com> wrote: > > On Thu, Nov 27, 2025 at 7:59 AM Michael Paquier <michael@paquier.xyz> wrote: > > On Wed, Nov 26, 2025 at 06:40:38PM +0530, Amul Sul wrote: > > > On Wed, Nov 26, 2025 at 5:41 PM Amit Langote <amitlangote09@gmail.com> wrote: > > >> [....] > > > > It seems to me that it is important to keep documented the overflow > > check in some way rather than removing it as the patch is doing, > > particularly regarding the finite vs infinite value behaviors. We do > > not need anymore the documentation about how "overflow" is set in this > > routines, of course, but keeping these expectations documented would > > be better. > > Yeah, I meant we should expand "including soft error reporting > capabilities" somehow, something like this: > > - * On successful conversion, *overflow is set to zero if it's not NULL. > - * > - * If the date is finite but out of the valid range for timestamp, then: > - * if overflow is NULL, we throw an out-of-range error. > - * if overflow is not NULL, we store +1 or -1 there to indicate the sign > - * of the overflow, and return the appropriate timestamp infinity. > + * If the date is finite but out of the valid range for timestamp, an > + * out-of-range error is reported. When escontext is NULL this is a > + * normal ERROR; when escontext points to an ErrorSaveContext, the error > + * is reported softly and TIMESTAMP_NOEND is returned. > Okay, I have attached an updated version -- added the necessary comments and renamed the function, replacing "opt_overflow" with the "_safe". One question: Regarding date2timestamp_no_overflow(), should we rename it to date2double? We can't use date2timestamp_safe because we already have that function. The renaming is relevant because this function converts a date to the double data type, which allows us to remove the "_no_overflow" extension. Regards, Amul