Detect more overflows in timestamp[tz]_pl_interval.
commit4019285c064028fbf613f0e43766416a63b826db
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 28 Apr 2024 17:42:13 +0000 (28 13:42 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 28 Apr 2024 17:42:13 +0000 (28 13:42 -0400)
treeddd0308657117c3a6f9a7038c9ace406bbfc1d5a
parent310cd8ab386ca44213b62b1c36162110d46bfc7a
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
src/backend/utils/adt/timestamp.c
src/test/regress/expected/horology.out
src/test/regress/sql/horology.sql