Re: [PATCH] Fix overflow and underflow in regr_r2()

Chengpeng Yan <chengpeng_yan@outlook.com>

From: Chengpeng Yan <chengpeng_yan@outlook.com>
To: Dean Rasheed <dean.a.rasheed@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, PostgreSQL-development <pgsql-hackers@postgresql.org>
Date: 2026-05-23T02:42:37Z
Lists: pgsql-hackers
Hi,

> On May 17, 2026, at 17:16, Dean Rasheed <dean.a.rasheed@gmail.com> wrote:
> 
> OK, here's a more complete patch along those lines, intended to apply
> on top of the regr_r2() patch.


Thanks for the regr_intercept.patch. The approach looks good to me.

I only noticed a few small things:

1. The patch file seems to have a format issue and doesn't apply
directly. `git apply` reports:

```
error: git apply: bad git-diff - expected /dev/null on line 2
```

2. `dy` seems a bit hard to understand. Perhaps `offset`, as used in the
earlier sketch, would be clearer?

3. Do we need to add tests for the underflow path, and perhaps for the
Inf/NaN guard?

Other than that, this looks good to me.

--
Best regards,
Chengpeng Yan