Skip to content

Commit 735cd61

Browse files
committed
Fix portability issues with stddev in pg_stat_statements
Stddev is calculated on the fly, and the code in commit 717f709 was using Float8GetDatumFast() inappropriately to convert the result to a Datum. Mea culpa. It now uses Float8GetDatum().
1 parent 717f709 commit 735cd61

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

contrib/pg_stat_statements/pg_stat_statements.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,12 +1577,15 @@ pg_stat_statements_internal(FunctionCallInfo fcinfo,
15771577
* sample variance, as we have data for the whole population,
15781578
* so Bessel's correction is not used, and we don't divide by
15791579
* tmp.calls - 1.
1580+
*
1581+
* We're calculating the stddev on the fly, so it's not in the tmp
1582+
* structure, so we can't use the Float8GetDatumFast macro here.
15801583
*/
15811584
if (tmp.calls > 1)
15821585
values[i++] =
1583-
Float8GetDatumFast(sqrtd(tmp.sum_var_time / tmp.calls));
1586+
Float8GetDatum(sqrtd(tmp.sum_var_time / tmp.calls));
15841587
else
1585-
values[i++] = Float8GetDatumFast(0.0);
1588+
values[i++] = Float8GetDatum(0.0);
15861589
}
15871590
values[i++] = Int64GetDatumFast(tmp.rows);
15881591
values[i++] = Int64GetDatumFast(tmp.shared_blks_hit);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy