| From: | Tomas Vondra <tomas(dot)vondra(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Handle numeric overflow when handling range values |
| Date: | 2026-11-05 14:51:07 |
| Message-ID: | E1xOynz-00000000KJL-3rfp@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
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(at)gmail(dot)com>
Reviewed-by: shihao zhong <zhong950419(at)gmail(dot)com>
Backpatch-through: 14
Discussion: https://postgr.es/m/CALdSSPgBvXz-VSF0p-5k%3D_uFfN38cWrERmm_AC4K67N6MWQhmg%40mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/d06ac896faa7ff14e6eca5c9bc27a34818adf634
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(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tomas Vondra | 2026-11-05 14:51:17 | pgsql: Handle numeric overflow when handling range values |
| Previous Message | Daniel Gustafsson | 2026-11-05 13:16:59 | pgsql: oauth: Recheck oauth_validator_libraries during authentication |