Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2c33e0f

Browse files
committed
Better fix for misuse of Float8GetDatumFast().
We can use that macro as long as we put the value into a local variable.Commit735cd61 was not wrong on its own terms, but I think this waylooks nicer, and it should save a few cycles on 32-bit machines.
1 parent7655f4c commit2c33e0f

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

‎contrib/pg_stat_statements/pg_stat_statements.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1246,7 +1246,6 @@ pgss_store(const char *query, uint32 queryId,
12461246
e->counters.min_time=total_time;
12471247
if (e->counters.max_time<total_time)
12481248
e->counters.max_time=total_time;
1249-
12501249
}
12511250
e->counters.rows+=rows;
12521251
e->counters.shared_blks_hit+=bufusage->shared_blks_hit;
@@ -1491,6 +1490,7 @@ pg_stat_statements_internal(FunctionCallInfo fcinfo,
14911490
boolnulls[PG_STAT_STATEMENTS_COLS];
14921491
inti=0;
14931492
Counterstmp;
1493+
doublestddev;
14941494
int64queryid=entry->key.queryid;
14951495

14961496
memset(values,0,sizeof(values));
@@ -1577,15 +1577,12 @@ 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.
15831580
*/
15841581
if (tmp.calls>1)
1585-
values[i++]=
1586-
Float8GetDatum(sqrt(tmp.sum_var_time /tmp.calls));
1582+
stddev=sqrt(tmp.sum_var_time /tmp.calls);
15871583
else
1588-
values[i++]=Float8GetDatum(0.0);
1584+
stddev=0.0;
1585+
values[i++]=Float8GetDatumFast(stddev);
15891586
}
15901587
values[i++]=Int64GetDatumFast(tmp.rows);
15911588
values[i++]=Int64GetDatumFast(tmp.shared_blks_hit);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp