From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Handle integer overflow in interval justification functions.
Date: Mon, 28 Feb 2022 20:37:02 +0000
Message-ID: <E1nOmlR-000Kpi-Km@gemulon.postgresql.org> (raw)
Handle integer overflow in interval justification functions.
justify_interval, justify_hours, and justify_days didn't check for
overflow when promoting hours to days or days to months; but that's
possible when the upper field's value is already large. Detect and
report any such overflow.
Also, we can avoid unnecessary overflow in some cases in justify_interval
by pre-justifying the days field. (Thanks to Nathan Bossart for this
idea.)
Joe Koshakow
Discussion: https://postgr.es/m/CAAvxfHeNqsJ2xYFbPUf_8nNQUiJqkag04NW6aBQQ0dbZsxfWHA@mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/54bd1e43ca56e323aef309dc2dc0e1391825ce68
Modified Files
--------------
src/backend/utils/adt/timestamp.c | 35 +++++++++++++++++++++++++++++----
src/test/regress/expected/interval.out | 36 ++++++++++++++++++++++++++++++++++
src/test/regress/sql/interval.sql | 12 ++++++++++++
3 files changed, 79 insertions(+), 4 deletions(-)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: tgl@sss.pgh.pa.us
Subject: Re: pgsql: Handle integer overflow in interval justification functions.
In-Reply-To: <E1nOmlR-000Kpi-Km@gemulon.postgresql.org>
References: <E1nOmlR-000Kpi-Km@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox