pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Fix behavior of float aggregates for single Inf or NaN inputs. 3+ messages / 1 participants [nested] [flat]
* pgsql: Fix behavior of float aggregates for single Inf or NaN inputs. @ 2020-06-13 17:43 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 3+ messages in thread From: Tom Lane @ 2020-06-13 17:43 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix behavior of float aggregates for single Inf or NaN inputs. When there is just one non-null input value, and it is infinity or NaN, aggregates such as stddev_pop and covar_pop should produce a NaN result, because the calculation is not well-defined. They used to do so, but since we adopted Youngs-Cramer aggregation in commit e954a727f, they produced zero instead. That's an oversight, so fix it. Add tests exercising these edge cases. Affected aggregates are var_pop(double precision) stddev_pop(double precision) var_pop(real) stddev_pop(real) regr_sxx(double precision,double precision) regr_syy(double precision,double precision) regr_sxy(double precision,double precision) regr_r2(double precision,double precision) regr_slope(double precision,double precision) regr_intercept(double precision,double precision) covar_pop(double precision,double precision) corr(double precision,double precision) Back-patch to v12 where the behavior change was accidentally introduced. Report and patch by me; thanks to Dean Rasheed for review. Discussion: https://postgr.es/m/353062.1591898766@sss.pgh.pa.us Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/03109a53020e4663df3a8d822cdc665a7d712a93 Modified Files -------------- src/backend/utils/adt/float.c | 35 +++++++++++ src/test/regress/expected/aggregates.out | 105 ++++++++++++++++++++++++++++++- src/test/regress/sql/aggregates.sql | 21 ++++++- 3 files changed, 159 insertions(+), 2 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: Fix behavior of float aggregates for single Inf or NaN inputs. @ 2020-06-13 17:43 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 3+ messages in thread From: Tom Lane @ 2020-06-13 17:43 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix behavior of float aggregates for single Inf or NaN inputs. When there is just one non-null input value, and it is infinity or NaN, aggregates such as stddev_pop and covar_pop should produce a NaN result, because the calculation is not well-defined. They used to do so, but since we adopted Youngs-Cramer aggregation in commit e954a727f, they produced zero instead. That's an oversight, so fix it. Add tests exercising these edge cases. Affected aggregates are var_pop(double precision) stddev_pop(double precision) var_pop(real) stddev_pop(real) regr_sxx(double precision,double precision) regr_syy(double precision,double precision) regr_sxy(double precision,double precision) regr_r2(double precision,double precision) regr_slope(double precision,double precision) regr_intercept(double precision,double precision) covar_pop(double precision,double precision) corr(double precision,double precision) Back-patch to v12 where the behavior change was accidentally introduced. Report and patch by me; thanks to Dean Rasheed for review. Discussion: https://postgr.es/m/353062.1591898766@sss.pgh.pa.us Branch ------ REL_13_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/33dd9bb3b0a88981f18a10d89720b4e40d8876ba Modified Files -------------- src/backend/utils/adt/float.c | 35 +++++++++++ src/test/regress/expected/aggregates.out | 105 ++++++++++++++++++++++++++++++- src/test/regress/sql/aggregates.sql | 21 ++++++- 3 files changed, 159 insertions(+), 2 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: Fix behavior of float aggregates for single Inf or NaN inputs. @ 2020-06-13 17:43 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 3+ messages in thread From: Tom Lane @ 2020-06-13 17:43 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Fix behavior of float aggregates for single Inf or NaN inputs. When there is just one non-null input value, and it is infinity or NaN, aggregates such as stddev_pop and covar_pop should produce a NaN result, because the calculation is not well-defined. They used to do so, but since we adopted Youngs-Cramer aggregation in commit e954a727f, they produced zero instead. That's an oversight, so fix it. Add tests exercising these edge cases. Affected aggregates are var_pop(double precision) stddev_pop(double precision) var_pop(real) stddev_pop(real) regr_sxx(double precision,double precision) regr_syy(double precision,double precision) regr_sxy(double precision,double precision) regr_r2(double precision,double precision) regr_slope(double precision,double precision) regr_intercept(double precision,double precision) covar_pop(double precision,double precision) corr(double precision,double precision) Back-patch to v12 where the behavior change was accidentally introduced. Report and patch by me; thanks to Dean Rasheed for review. Discussion: https://postgr.es/m/353062.1591898766@sss.pgh.pa.us Branch ------ REL_12_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/874372a941a6ee31ba4034db0367e0929e5f49bc Modified Files -------------- src/backend/utils/adt/float.c | 35 +++++++++++ src/test/regress/expected/aggregates.out | 105 ++++++++++++++++++++++++++++++- src/test/regress/sql/aggregates.sql | 21 ++++++- 3 files changed, 159 insertions(+), 2 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2020-06-13 17:43 UTC | newest] Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2020-06-13 17:43 pgsql: Fix behavior of float aggregates for single Inf or NaN inputs. Tom Lane <tgl@sss.pgh.pa.us> 2020-06-13 17:43 pgsql: Fix behavior of float aggregates for single Inf or NaN inputs. Tom Lane <tgl@sss.pgh.pa.us> 2020-06-13 17:43 pgsql: Fix behavior of float aggregates for single Inf or NaN inputs. Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox