pgsql: Detect more overflows in timestamp[tz]_pl_interval.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Detect more overflows in timestamp[tz]_pl_interval.
Date: 2024-04-28 17:42:28
Message-ID: E1s18Xj-000UbY-DV@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Detect more overflows in timestamp[tz]_pl_interval.

In commit 25cd2d640 I (tgl) opined that "The additions of the months
and microseconds fields could also overflow, of course. However,
I believe we need no additional checks there; the existing range
checks should catch such cases". This is demonstrably wrong however
for the microseconds field, and given that discovery it seems prudent
to be paranoid about the months addition as well.

Report and patch by Joseph Koshakow. As before, back-patch to all
supported branches. (However, the test case doesn't work before
v15 because we didn't allow wider-than-int32 numbers in interval
literals. A variant test could probably be built that fits within
that restriction, but it didn't seem worth the trouble.)

Discussion: https://postgr.es/m/CAAvxfHf77sRHKoEzUw9_cMYSpbpNS2C+J_+8Dq4+0oi8iKopeA@mail.gmail.com

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/cb0ccefa03d351d9c643362ac77fca7dadd9fc42

Modified Files
--------------
src/backend/utils/adt/timestamp.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2024-04-28 18:34:34 pgsql: Throw a more on-point error for functions depending on columns.
Previous Message David Rowley 2024-04-28 08:04:10 pgsql: Fix duplicated consecutive words in comments