| From: | Rahul Yadav <rahul(at)rhyadav(dot)com> |
|---|---|
| To: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
| Cc: | 1950233439(at)qq(dot)com |
| Subject: | Re: BUG #19670: Silent Integer Overflow in time_pl_interval() Returns Wrong Time Value |
| Date: | 2026-09-26 15:25:21 |
| Message-ID: | CAJJjRRe0fUFsh4ocp4bBui=Jd+_t4cwYAs53kYzteRGmMm_SBw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
Hi,
I can reproduce this on master. time_pl_interval() adds the
interval's time field to the time value before reducing the result
modulo one day, so a large enough interval overflows int64.
time_mi_interval() and the two timetz variants have the same problem.
Since the result wraps around at midnight anyway, only the interval's
time field modulo one day matters. The attached patch reduces it
first, so the intermediate result always fits in an int64; results
for intervals that didn't overflow are unchanged. It also adds
regression tests for the largest and smallest interval time values,
which fail without the fix.
The same arithmetic exists in all supported branches, so I think this
should be back-patched.
Regards,
Rahul Yadav
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-Fix-integer-overflow-in-time-and-timetz-interval-.patch | application/x-patch | 5.4 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | jian he | 2026-09-26 16:28:59 | Re: BUG #19621: Unexpected results of JSON_VALUE with DEFAULT ON EMPTY |
| Previous Message | Tom Lane | 2026-09-26 14:39:35 | Re: BUG #19722: Window PARTITION BY numeric treats equal values with different scales as separate partitions |