| From: | PG Bug reporting form <noreply(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
| Cc: | feasiblechart(at)gmail(dot)com |
| Subject: | BUG #19615: COVAR_POP / COVAR_SAMP / REGR_SXY return 0.0 instead of NaN |
| Date: | 2026-08-11 02:34:38 |
| Message-ID: | 19615-c7e390593416f6b6@postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
The following bug has been logged on the website:
Bug reference: 19615
Logged by: Junwen An
Email address: feasiblechart(at)gmail(dot)com
PostgreSQL version: 19beta2
Operating system: Linux Ubuntu
Description:
I found `COVAR_POP`/`REGR_SXY` returns 0.0 instead of NaN when one arg is
constant and the other has Inf (not first), which might be unexpected. I
could reproduce it on 19beta1, 19beta2, and 20devel, but not on 18.4.
Minimal repro:
CREATE TABLE t (y double precision);
INSERT INTO t VALUES (3), ('Infinity'), (4);
SELECT COVAR_POP(0::float8, y) FROM t;
-- Expected 1 row: NaN
-- Actual: 0.0
SELECT COVAR_POP(y, 0::float8) FROM t;
-- Expected 1 row: NaN
-- Actual: 0.0
SELECT COVAR_SAMP(0::float8, y) FROM t;
-- Expected 1 row: NaN
-- Actual: 0.0
SELECT REGR_SXY(0::float8, y) FROM t;
-- Expected 1 row: NaN
-- Actual: 0.0
Did some further experiments, and it seems this behavior also depends on the
position of 'Inf'
WITH t(ord, y) AS (
VALUES
(1, 'Infinity'::float8),
(2, 3::float8),
(3, 4::float8)
)
SELECT
covar_pop(0::float8, y ORDER BY ord) AS inf_first,
covar_pop(0::float8, y ORDER BY ord DESC) AS inf_last
FROM t;
inf_first | inf_last
-----------+----------
NaN | 0
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Andrey Rachitskiy | 2026-08-11 06:30:03 | Re: BUG #19612: SEGV in ParseConfigFp() in guc-file.l |
| Previous Message | Zexin Li | 2026-08-11 00:40:55 | Re: BUG #19598: pg_waldump: -s/-e accept out-of-range WAL locations and silently use the low 32 bits |