pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Sync behavior of var_samp and stddev_samp for single NaN inputs.
Date: Sat, 13 Jun 2020 18:01:53 +0000
Message-ID: <E1jkATZ-0002Y3-25@gemulon.postgresql.org> (raw)

Sync behavior of var_samp and stddev_samp for single NaN inputs.

var_samp(numeric) and stddev_samp(numeric) disagreed with their float
cousins about what to do for a single non-null input value that is NaN.
The float versions return NULL on the grounds that the calculation is
only defined for more than one non-null input, which seems like the
right answer.  But the numeric versions returned NaN, as a result of
dealing with edge cases in the wrong order.  Fix that.  The patch
also gets rid of an insignificant memory leak in such cases.

This inconsistency is of long standing, but on the whole it seems best
not to back-patch the change into stable branches; nobody's complained
and it's such an obscure point that nobody's likely to complain.
(Note that v13 and v12 now contain test cases that will notice if we
accidentally back-patch this behavior change in future.)

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/23cbeda50b94c817bed4f7d2127ee09c4e8c8b86

Modified Files
--------------
src/backend/utils/adt/numeric.c          | 35 ++++++++++++++++----------------
src/test/regress/expected/aggregates.out |  4 ++--
2 files changed, 19 insertions(+), 20 deletions(-)



Message-ID: <E1jkATZ-0002Y3-25@gemulon.postgresql.org>
Permalink:  ../E1jkATZ-0002Y3-25@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1jkATZ-0002Y3-25@gemulon.postgresql.org

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Sync behavior of var_samp and stddev_samp for single NaN inputs.
  In-Reply-To: <E1jkATZ-0002Y3-25@gemulon.postgresql.org>
  References: <E1jkATZ-0002Y3-25@gemulon.postgresql.org>

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

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