Re: [PATCH] Fix interval input at minimum signed field values (BUG #19746)

From: Ishjaap Singh <ishjaap(dot)singh07(at)gmail(dot)com>
To: Tình Trần <tranvantinhnbk(at)gmail(dot)com>
Cc: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: [PATCH] Fix interval input at minimum signed field values (BUG #19746)
Date: 2026-11-25 19:39:06
Message-ID: CA+Y2BmcN-ysBbCCML9Y+rxCOvnj8QsiR1GFRqMkMo9FDCOEtOA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Tinh,

Thanks for v4. I tested it on master (4255812efdb).

The cancellation cases from my earlier mail now work in both field
orders, and the cases from the report still read back unchanged.
Zsolt's example is fixed too: '01:00:00 1.5 days' and
'1.5 days 01:00:00' both give 1 day 13:00:00, and the same for weeks.

make check passes, also with datetime.c built with -DUSE_NATIVE_INT128=0
so NegateIntervalValue takes the struct path. The new tests fail without
the datetime.c change, and pgindent is clean.

I compared about 2000 generated inputs on master and v4 (IntervalStyle
postgres and sql_standard). Nothing master accepts is rejected or read
differently. One case outside that set does change, because of the
fractional-day fix: master accepts '2562047788:00:54.775807 0.5 days'
because the clock time overwrites the half day. v4 adds it and rejects
the sum, as master already does for '0.5 days 2562047788:00:54.775807'.
I think that's correct.

Smaller notes:

- Out-of-range signed time fields now get the same error as unsigned
ones: '-1:60' says "interval field value out of range" (22015)
instead of "invalid input syntax" (22007), like '1:60'. Repeated units
go the other way, as in v2. Maybe worth a line in the commit message.
- v4 applies to master and REL_19, not REL_15-18. The int128.h functions
it uses exist back to 15.

From my side v4 looks good. I'll leave your question about splitting
out the fractional fix to Zsolt.

Regards,
Ishjaap Singh

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2026-11-25 19:43:37 Re: [PATCH] pg_input_is_valid() reuses the first type name inside a PL/pgSQL loop
Previous Message Tom Lane 2026-11-25 19:34:25 Re: Fix OOM when rendering large geometry arrays