pgsql: Fix float8_regr_accum() for Inf/NaN with constant other input.

Started by Tom Lane3 months ago1 messagescommitters
Jump to latest
#1Tom Lane
tgl@sss.pgh.pa.us

Fix float8_regr_accum() for Inf/NaN with constant other input.

Commit 649828769 improved this code to keep Sxx, Syy, and Sxy
exactly zero so long as we see only a single value of the input(s).
However, if any values of the other input are Inf or NaN, we'd
better set Sxy to NaN instead. Otherwise we risk reporting zero
variance when the result is really undefined. The old coding handled
this implicitly, but in the short-circuit path we have to take care
of it explicitly.

Bug: #19615
Reported-by: Junwen An <feasiblechart@gmail.com>
Author: Andrey Rachitskiy <pl0h0yp1@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: /messages/by-id/19615-c7e390593416f6b6@postgresql.org
Backpatch-through: 19

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/94f94b245c6598f3a2b1d5ee3c463719ea83c869

Modified Files
--------------
src/backend/utils/adt/float.c | 11 ++++++++++
src/test/regress/expected/aggregates.out | 36 ++++++++++++++++++++++++++++++++
src/test/regress/sql/aggregates.sql | 12 +++++++++++
3 files changed, 59 insertions(+)