Skip to content

Commit 24d9f50

Browse files
akorotkovildus
authored andcommitted
Fix broken loop in pg_stat_wait_reset_profile.
1 parent 3947ef5 commit 24d9f50

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Diff for: contrib/pg_stat_wait/pg_stat_wait.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -511,23 +511,23 @@ PG_FUNCTION_INFO_V1(pg_stat_wait_reset_profile);
511511
Datum
512512
pg_stat_wait_reset_profile(PG_FUNCTION_ARGS)
513513
{
514-
int i;
514+
int i, j;
515515
BackendWaitCells *cells = (BackendWaitCells *)((char *)WaitShmem
516516
+ sizeof(int) + /* counter */
517517
+ MAXALIGN(sizeof(slock_t))); /* lock */
518518

519-
for(i=0; i < MaxBackends; i++)
519+
for(i = 0; i < MaxBackends; i++)
520520
{
521521
BackendWaitCells *item = cells + i;
522522
do
523523
{
524524
/* wait until backend is updating this block */
525525
} while (!pg_atomic_test_set_flag(&item->isBusy));
526526

527-
for (i=0; i < WAIT_EVENTS_COUNT; i++)
527+
for (j = 0; j < WAIT_EVENTS_COUNT; j++)
528528
{
529-
item->cells[i].interval = 0;
530-
item->cells[i].count = 0;
529+
item->cells[j].interval = 0;
530+
item->cells[j].count = 0;
531531
}
532532
pg_atomic_clear_flag(&item->isBusy);
533533
}

0 commit comments

Comments
 (0)