diff --git a/src/gausskernel/storage/access/nbtree/nbtsearch.cpp b/src/gausskernel/storage/access/nbtree/nbtsearch.cpp index 24bdcf8b8..14a52d5dd 100644 --- a/src/gausskernel/storage/access/nbtree/nbtsearch.cpp +++ b/src/gausskernel/storage/access/nbtree/nbtsearch.cpp @@ -83,6 +83,7 @@ BTStack _bt_search(Relation rel, BTScanInsert key, Buffer *bufP, int access, boo ItemId itemid; IndexTuple itup; BlockNumber blkno; + BlockNumber par_blkno; BTStack new_stack = NULL; /* @@ -113,6 +114,7 @@ BTStack _bt_search(Relation rel, BTScanInsert key, Buffer *bufP, int access, boo itemid = PageGetItemId(page, offnum); itup = (IndexTuple)PageGetItem(page, itemid); blkno = BTreeInnerTupleGetDownLink(itup); + par_blkno = BufferGetBlockNumber(*bufP); /* * We need to save the location of the index entry we chose in the @@ -126,7 +128,7 @@ BTStack _bt_search(Relation rel, BTScanInsert key, Buffer *bufP, int access, boo */ if (needStack) { new_stack = (BTStack)palloc(sizeof(BTStackData)); - new_stack->bts_blkno = BufferGetBlockNumber(*bufP); + new_stack->bts_blkno = par_blkno; new_stack->bts_offset = offnum; new_stack->bts_btentry = blkno; new_stack->bts_parent = stack_in; diff --git a/src/gausskernel/storage/access/ubtree/ubtsearch.cpp b/src/gausskernel/storage/access/ubtree/ubtsearch.cpp index 65bc635db..22893d32f 100644 --- a/src/gausskernel/storage/access/ubtree/ubtsearch.cpp +++ b/src/gausskernel/storage/access/ubtree/ubtsearch.cpp @@ -81,6 +81,7 @@ BTStack UBTreeSearch(Relation rel, BTScanInsert key, Buffer *bufP, int access, b ItemId itemid; IndexTuple itup; BlockNumber blkno; + BlockNumber par_blkno; BTStack new_stack = NULL; /* @@ -111,6 +112,7 @@ BTStack UBTreeSearch(Relation rel, BTScanInsert key, Buffer *bufP, int access, b itup = (IndexTuple) PageGetItem(page, itemid); Assert(UBTreeTupleIsPivot(itup) || !key->heapkeyspace); blkno = UBTreeTupleGetDownLink(itup); + par_blkno = BufferGetBlockNumber(*bufP); /* * We need to save the location of the index entry we chose in the @@ -128,7 +130,7 @@ BTStack UBTreeSearch(Relation rel, BTScanInsert key, Buffer *bufP, int access, b */ if (needStack) { new_stack = (BTStack)palloc(sizeof(BTStackData)); - new_stack->bts_blkno = BufferGetBlockNumber(*bufP); + new_stack->bts_blkno = par_blkno; new_stack->bts_offset = offnum; new_stack->bts_btentry = blkno; new_stack->bts_parent = stack_in; @@ -1841,4 +1843,4 @@ bool UBTreeGetTupleInternal(IndexScanDesc scan, ScanDirection dir) } while (so->numArrayKeys && _bt_advance_array_keys(scan, dir)); return res; -} +} \ No newline at end of file