pgsql: Guard against overflow in make_interval().

From: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Guard against overflow in make_interval().
Date: 2023-10-29 15:54:14
Message-ID: E1qx87C-002yRD-CA@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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

Branch
------
master

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

Modified Files
--------------
src/backend/utils/adt/timestamp.c | 39 ++++++++++++++++++++++++----------
src/include/datatype/timestamp.h | 1 +
src/test/regress/expected/interval.out | 27 +++++++++++++++++++++++
src/test/regress/sql/interval.sql | 15 +++++++++++++
4 files changed, 71 insertions(+), 11 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2023-10-29 16:56:52 pgsql: Teach pg_dump about the new pg_subscription.subrunasowner option
Previous Message Dean Rasheed 2023-10-29 11:23:35 pgsql: btree_gin: Fix calculation of leftmost interval value.