| From: | Amul Sul <sulamul(at)gmail(dot)com> |
|---|---|
| To: | Amit Langote <amitlangote09(at)gmail(dot)com> |
| Cc: | Michael Paquier <michael(at)paquier(dot)xyz>, 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-27 07:57:46 |
| Message-ID: | CAAJ_b94Gx+Qayq=Wx8A0dcsMAtwDQdqi0NzNgsFd=oBc4ekPhQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Thu, Nov 27, 2025 at 6:48 AM Amit Langote <amitlangote09(at)gmail(dot)com> wrote:
>
> On Thu, Nov 27, 2025 at 7:59 AM Michael Paquier <michael(at)paquier(dot)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(at)gmail(dot)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
| Attachment | Content-Type | Size |
|---|---|---|
| v2-0001-Switch-some-date-related-functions-to-use-soft-er.patch | application/octet-stream | 15.6 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Nazir Bilal Yavuz | 2025-11-27 07:59:47 | Re: Add pg_buffercache_mark_dirty[_all] functions to the pg_buffercache |
| Previous Message | Bryan Green | 2025-11-27 07:52:33 | Re: [Patch] Windows relation extension failure at 2GB and 4GB |