From: Tomas Vondra <tomas.vondra@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Handle numeric overflow when handling range values
Date: Thu, 05 Nov 2026 14:51:17 +0000
Message-ID: <E1xOyo9-00000000KJz-2o7W@gemulon.postgresql.org> (raw)
Handle numeric overflow when handling range values
The numrange_subdiff() function was calculating the difference simply by
calling numeric_sub and numeric_float8, but those functions are not
overflow-safe. It's possible to insert valid numeric ranges for which
the difference overflows either numeric or float8.
The overflow may affect various operations on numrange columns. It may
cause failures during ANALYZE on the table, inserts into GiST indexes,
selectivity estimation, and possibly other operations.
Fixed by handling overflows in numrange_subdiff() - extreme differences
are treated as infinity.
Author: Kirill Reshke <reshkekirill@gmail.com>
Reviewed-by: shihao zhong <zhong950419@gmail.com>
Backpatch-through: 14
Discussion: https://postgr.es/m/CALdSSPgBvXz-VSF0p-5k%3D_uFfN38cWrERmm_AC4K67N6MWQhmg%40mail.gmail.com
Branch
------
REL_19_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/1137ebf22b0d1feb0c61182b81f4aa4779c01195
Modified Files
--------------
src/backend/utils/adt/rangetypes.c | 37 ++++++++++++++++++++++-----
src/test/regress/expected/multirangetypes.out | 7 +++++
src/test/regress/sql/multirangetypes.sql | 9 +++++++
3 files changed, 46 insertions(+), 7 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: tomas.vondra@postgresql.org
Subject: Re: pgsql: Handle numeric overflow when handling range values
In-Reply-To: <E1xOyo9-00000000KJz-2o7W@gemulon.postgresql.org>
References: <E1xOyo9-00000000KJz-2o7W@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