Commit 735cd612 authored by Andrew Dunstan's avatar Andrew Dunstan

Fix portability issues with stddev in pg_stat_statements

Stddev is calculated on the fly, and the code in commit 717f7095 was
using Float8GetDatumFast() inappropriately to convert the result to a
Datum. Mea culpa. It now uses Float8GetDatum().
parent 717f7095
...@@ -1577,12 +1577,15 @@ pg_stat_statements_internal(FunctionCallInfo fcinfo, ...@@ -1577,12 +1577,15 @@ pg_stat_statements_internal(FunctionCallInfo fcinfo,
* sample variance, as we have data for the whole population, * sample variance, as we have data for the whole population,
* so Bessel's correction is not used, and we don't divide by * so Bessel's correction is not used, and we don't divide by
* tmp.calls - 1. * tmp.calls - 1.
*
* We're calculating the stddev on the fly, so it's not in the tmp
* structure, so we can't use the Float8GetDatumFast macro here.
*/ */
if (tmp.calls > 1) if (tmp.calls > 1)
values[i++] = values[i++] =
Float8GetDatumFast(sqrtd(tmp.sum_var_time / tmp.calls)); Float8GetDatum(sqrtd(tmp.sum_var_time / tmp.calls));
else else
values[i++] = Float8GetDatumFast(0.0); values[i++] = Float8GetDatum(0.0);
} }
values[i++] = Int64GetDatumFast(tmp.rows); values[i++] = Int64GetDatumFast(tmp.rows);
values[i++] = Int64GetDatumFast(tmp.shared_blks_hit); values[i++] = Int64GetDatumFast(tmp.shared_blks_hit);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment