public inbox for [email protected]  
help / color / mirror / Atom feed
From: Dean Rasheed <[email protected]>
To: [email protected]
Subject: pgsql: Improve overflow/underflow handling in regr_intercept().
Date: Wed, 03 Jun 2026 08:22:50 +0000
Message-ID: <[email protected]> (raw)

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 <[email protected]>
Author: Dean Rasheed <[email protected]>
Reviewed-by: Chengpeng Yan <[email protected]>
Discussion: https://postgr.es/m/[email protected]

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/eb8e76e130fd8bd42982d597f5a66f08b13380c0

Modified Files
--------------
src/backend/utils/adt/float.c            | 39 ++++++++++++++++++++++++++++++--
src/test/regress/expected/aggregates.out | 12 ++++++++++
src/test/regress/sql/aggregates.sql      |  2 ++
3 files changed, 51 insertions(+), 2 deletions(-)



view thread (2+ messages)

reply

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 using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: pgsql: Improve overflow/underflow handling in regr_intercept().
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox