Improve overflow/underflow handling in regr_r2().
Dean Rasheed <dean.a.rasheed@gmail.com>
Author:
Dean Rasheed <dean.a.rasheed@gmail.com>
Date: 2026-06-03T08:01:13Z
Releases:
19 (unreleased)
Improve overflow/underflow handling in regr_r2(). Commit 6498287696d improved corr()'s final function to cope with overflow/underflow in the final calculation, and clamped its result to [-1, 1] in case of roundoff error. Improve regr_r2() in a similar way, clamping its result to [0, 1]. Arguably this is a bug fix, but given the lack of prior complaints, refrain from back-patching, as we did with 6498287696d. Reported-by: Chengpeng Yan <chengpeng_yan@outlook.com> Author: Chengpeng Yan <chengpeng_yan@outlook.com> Reviewed-by: Dean Rasheed <dean.a.rasheed@gmail.com> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/33E01656-BB3B-46E9-A41F-24A01A7C35F4@outlook.com
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/utils/adt/float.c | modified | +35 −2 |
| src/test/regress/expected/aggregates.out | modified | +38 −20 |
| src/test/regress/sql/aggregates.sql | modified | +14 −5 |
Discussion
- [PATCH] Fix overflow and underflow in regr_r2() 15 messages · 2026-04-27 → 2026-06-03