Improve overflow/underflow handling in regr_intercept().
Dean Rasheed <dean.a.rasheed@gmail.com>
Author:
Dean Rasheed <dean.a.rasheed@gmail.com>
Date: 2026-06-03T08:20:21Z
Releases:
19 (unreleased)
Improve overflow/underflow handling in regr_intercept(). As with corr() and regr_r2(), improve regr_intercept()'s final function to cope with overflow/underflow in the final calculation. Here, instead of using sqrt(), we use frexp() and ldexp() to recover, if an overflow or underflow is detected, so that the multiplication and division steps operate on normalised mantissas, and cannot overflow or underflow. As with 6498287696d, and the previous commit improving regr_r2(), this is arguably a bug fix, but given the lack of prior complaints, refrain from back-patching. Reported-by: Tom Lane <tgl@sss.pgh.pa.us> Author: Dean Rasheed <dean.a.rasheed@gmail.com> Reviewed-by: Chengpeng Yan <chengpeng_yan@outlook.com> Discussion: https://postgr.es/m/33E01656-BB3B-46E9-A41F-24A01A7C35F4@outlook.com
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/utils/adt/float.c | modified | +37 −2 |
| src/test/regress/expected/aggregates.out | modified | +12 −0 |
| src/test/regress/sql/aggregates.sql | modified | +2 −0 |
Discussion
- [PATCH] Fix overflow and underflow in regr_r2() 15 messages · 2026-04-27 → 2026-06-03