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

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

+/* Negate an accumulator value; the parser's input bounds exclude
INT128_MIN. */
+static INT128
+NegateIntervalValue(INT128 value)
+{
+#if USE_NATIVE_INT128
+ return -value;
+#else
+ value.hi = ~value.hi;
+ value.lo = ~value.lo;
+ int128_add_int64(&value, 1);
+ return value;
+#endif
+}
+

Looking at USE_NATIVE_INT128, it has no uses outside int128.h/c, and
it most likely should remain so. Maybe it should go into int128.h as
int128_negate, following the functions of the other functions there?

+ if (!AdjustFractMicroseconds(fval, 1, &fraction))
return DTERR_FIELD_OVERFLOW;

Another mostly nitpick question, can these AdjustFract* overflow
actually happen?

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

I think keeping it together is fine, they are closely related and
basically in the same code.

You should also create an entry for your patch at the commitfest, so
it doesn't get lost: https://commitfest.postgresql.org/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Adesh Thakare 2026-11-25 22:57:50 Re: Postmaster PANIC on a standby with slot synchronization enabled
Previous Message Tomas Vondra 2026-11-25 22:31:36 Re: Unify parallel worker handling for index builds and instrumentation