Skip to content

Commit

Permalink
Check for invalid down link while prefetching B-Tree leave pages for …
Browse files Browse the repository at this point in the history
…index-only scan
  • Loading branch information
Konstantin Knizhnik committed Dec 1, 2024
1 parent 373f9de commit 07fb9fb
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/backend/access/nbtree/nbtsearch.c
Original file line number Diff line number Diff line change
Expand Up @@ -884,9 +884,10 @@ _bt_read_parent_for_prefetch(IndexScanDesc scan, BlockNumber parent, ScanDirecti
{
ItemId itemid = PageGetItemId(page, offnum + i);
IndexTuple itup = (IndexTuple) PageGetItem(page, itemid);
if (i == next_parent_prefetch_index)
if (j == next_parent_prefetch_index)
so->prefetch_blocks[j++] = so->next_parent; /* time to prefetch next parent page */
so->prefetch_blocks[j++] = BTreeTupleGetDownLink(itup);
if (BlockNumberIsValid(BTreeTupleGetDownLink(itup)))
so->prefetch_blocks[j++] = BTreeTupleGetDownLink(itup);
}
}
else
Expand All @@ -898,9 +899,10 @@ _bt_read_parent_for_prefetch(IndexScanDesc scan, BlockNumber parent, ScanDirecti
{
ItemId itemid = PageGetItemId(page, offnum + n_child - i - 1);
IndexTuple itup = (IndexTuple) PageGetItem(page, itemid);
if (i == next_parent_prefetch_index)
if (j == next_parent_prefetch_index)
so->prefetch_blocks[j++] = so->next_parent; /* time to prefetch next parent page */
so->prefetch_blocks[j++] = BTreeTupleGetDownLink(itup);
if (BlockNumberIsValid(BTreeTupleGetDownLink(itup)))
so->prefetch_blocks[j++] = BTreeTupleGetDownLink(itup);
}
}
so->n_prefetch_blocks = j;
Expand Down

0 comments on commit 07fb9fb

Please sign in to comment.