Guard against overflow in make_interval().
authorDean Rasheed <dean.a.rasheed@gmail.com>
Sun, 29 Oct 2023 15:46:04 +0000 (15:46 +0000)
committerDean Rasheed <dean.a.rasheed@gmail.com>
Sun, 29 Oct 2023 15:51:53 +0000 (15:51 +0000)
commitb2d55447a563036579d6777f64a7483dceeab6ea
tree4bb29b19a118c7fac9a02d57ec080b3e87e066b6
parent849172ff4883d44168f96f39d3fde96d0aa34c99
Guard against overflow in make_interval().

The original code did very little to guard against integer or floating
point overflow when computing the interval's fields.  Detect any such
overflows and error out, rather than silently returning bogus results.

Joseph Koshakow, reviewed by Ashutosh Bapat and me.

Discussion: https://postgr.es/m/CAAvxfHcm1TPwH_zaGWuFoL8pZBestbRZTU6Z%3D-RvAdSXTPbKfg%40mail.gmail.com
src/backend/utils/adt/timestamp.c
src/include/datatype/timestamp.h
src/test/regress/expected/interval.out
src/test/regress/sql/interval.sql