Re: Definitional issue: stddev_pop (and related) for 1 input

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Dean Rasheed <dean.a.rasheed@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2020-06-13T15:56:00Z
Lists: pgsql-hackers
Dean Rasheed <dean.a.rasheed@gmail.com> writes:
> The patch looks reasonable, except I wonder if all compilers are smart
> enough to realise that totCount is always initialised.

I think they should be, since that if-block ends with a return;
the only way to get to the use of totCount is for both parts of the
first if-condition to be executed.

In any case, we do have an effective policy of ignoring
uninitialized-variable warnings from very old/stupid compilers.
locust and prairiedog, which I think use the same ancient gcc
version, emit a couple dozen such warnings.  If they are the only
ones that complain about this new code, I'll not worry.

Thanks for looking at the patch!

			regards, tom lane



Commits

  1. Sync behavior of var_samp and stddev_samp for single NaN inputs.

  2. Fix behavior of float aggregates for single Inf or NaN inputs.