| From: | Tình Trần <tranvantinhnbk(at)gmail(dot)com> |
|---|---|
| To: | Ishjaap Singh <ishjaap(dot)singh07(at)gmail(dot)com> |
| Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: [PATCH] Fix interval input at minimum signed field values (BUG #19746) |
| Date: | 2026-11-15 07:52:35 |
| Message-ID: | CAEPgAbFE+wLO2zfufAvjLYE1vSr-o3tgLMg1342wa3gXvM0uqg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Subject: Re: [PATCH] Fix interval input at minimum signed field values (BUG
#19746)
Hi Ishjaap, João,
Thanks for the reviews. Attached is v3, using wider temporary
accumulators to preserve cancellation and check storage limits
after applying AGO.
It includes tests for the original boundary round trips and
your counterexamples in both field orders.
Feedback on this approach would be welcome.
Regards,
Tinh
Vào Thứ 4, 4 thg 11, 2026 vào lúc 18:15 Ishjaap Singh <
ishjaap(dot)singh07(at)gmail(dot)com> đã viết:
> Hi Tinh,
>
> > This is my first PostgreSQL patch submission, so feedback would be
> greatly
> > appreciated.
>
> Thanks for working on this. I tested v2 on master (77705d1e5a6).
>
> The cases from the report are fixed: '-2562047788 <(256)%20204-7788>:00:54.775808'
> and
> '@ 2147483648 <(214)%20748-3648> days ago' (postgres_verbose) read back
> to the same value,
> and the pg_dump example now restores both rows instead of none. The new
> tests fail without the datetime.c change and pass with it, make check
> passes, and pgindent is clean.
>
> One problem: these are corner cases, but the commit message says
> cancellation between fields near the limits should be preserved, and
> with v2 that only holds for one field order. These return true on
> unpatched master and fail with "interval field value out of range"
> with v2:
>
> SELECT interval_send('1 millisecond -9223372036854775808 us ago'::interval)
> = interval_send('9223372036854774808 us'::interval);
> SELECT interval_send('1 hour -9223372036854775808 us ago'::interval)
> = interval_send('9223372033254775808 us'::interval);
> SELECT interval_send('1 week -2147483648 <(214)%20748-3648> days
> ago'::interval)
> = interval_send('2147483641 <(214)%20748-3641> days'::interval);
> SELECT interval_send('-2147483648 <(214)%20748-3648> months 0.5 years
> ago'::interval)
> = interval_send('2147483642 <(214)%20748-3642> months'::interval);
>
> DecodeInterval reads fields right to left, so here the minimum field is
> negated first and overflows before the other field can bring the total
> back into range. The patch's cancellation tests put the minimum first in
> the string, so they don't catch this. It would be good to test both
> orders.
>
> Smaller notes:
>
> - Some inputs that are invalid either way now get a different error,
> e.g. '2147483647 <(214)%20748-3647> days 1 days ago' says "invalid
> input syntax" instead
> of "field value out of range". That seems fine, since the real problem
> is the repeated unit.
> - v2 applies to master and REL_17-19, but not REL_15/16. REL_14 has
> older input code and didn't show the problem in my tests.
> - It isn't in a commitfest yet; registering it would get cfbot testing
> it.
>
> Regards,
> Ishjaap Singh
>
| Attachment | Content-Type | Size |
|---|---|---|
| 0001-Fix-interval-input-at-minimum-signed-field-values.patch | application/octet-stream | 24.2 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Joao Rito | 2026-11-15 08:26:41 | Re: XMLConcat() and XMLRoot() silently drop xml values with an invalid declaration |
| Previous Message | Zsolt Parragi | 2026-11-15 07:34:48 | Re: Prevent foreign key references to unlogged partitions |