Hi Zsolt Parragi,

Thanks for the review! Attached is v4.  it nice catch with the old bug i
have the
change draft base on your suggestions
The bellowing attachment is current my update approach for your review

I changed the clock-time assignment to addition, added tests for fractional
days/weeks in both orders, and fixed the comments. Negation now avoids the
newer int128 helpers to ease backpatching.


Once we agree on the approach, I think i can  prepare and test backpatches
for the
affected maintained branches, back to PG15 upward ?

Could you take another look would you also prefer the fractional day/week
fix
as a separate patch?

Regards,

Vào Thứ 3, 17 thg 11, 2026 vào lúc 05:23 Zsolt Parragi <
[email protected]> đã viết:

> Hello
>
> Thanks for working on this!
>
> +       itm_in->tm_usec = int64_to_int128(itm.tm_usec);
> +       int128_add_int64_mul_int64(&itm_in->tm_usec, itm.tm_hour,
> USECS_PER_HOUR);
> +       int128_add_int64_mul_int64(&itm_in->tm_usec, itm.tm_min,
> USECS_PER_MINUTE);
>
> There's also a related preexisting bug: time field overwrites the
> fractional part of a day/week unit
>
> SELECT '01:00:00 1.5 days'::interval AS a, '1.5 days 01:00:00'::interval
> AS b;
> a | b
> ----------------+----------------
> 1 day 01:00:00 | 1 day 13:00:00
>
> SELECT '01:00 0.5 weeks'::interval, '0.5 weeks 01:00'::interval;
> 3 days 01:00:00 | 3 days 13:00:00
>
> int128_add_int64(&itm_in->tm_usec, itm.tm_usec) would also fix this
>
>
> There are also some stale comments now:
>
>  * dtype and itm_in are output parameters.
>  ...
>  * itm_in remains undefined for infinite interval values for which dtype
> alone
>  * suffices.
>
>
> +/* Private wide arithmetic for the general interval parser. */
> +static INT128
> +NegateIntervalValue(INT128 value)
> +{
> +       INT128          result = make_int128(~PG_INT128_HI_INT64(value),
> +
> ~PG_INT128_LO_UINT64(value));
> +
> +       int128_add_int64(&result, 1);
> +       return result;
> +}
> +
>
> The bug exists on 15+, and this function uses PG19 functions - that is
> fine, but this part will need a different solution on older branches.
>
>
> +/*
> + * Keep general interval input wider than its stored representation until
> AGO
> + * has been applied.  There are at most MAXDATEFIELDS int64 input values,
> and
> + * even the largest unit scale fits comfortably in this accumulator.
> + */
>
> I am not sure how good this comment is outside this patch, as it
> mostly seems to explain implementation details, not the type.
>

Attachment: v4-0001-Fix-interval-input-at-minimum-signed-field-values.patch
Description: Binary data

Reply via email to