Added SetIndexTuple function

This commit is contained in:
Andrew Kane
2023-09-03 17:10:09 -07:00
parent ed9e450571
commit 46e1db1f15

View File

@@ -238,6 +238,34 @@ MarkPriorTupleDead(IndexScanDesc scan)
LockBuffer(buf, BUFFER_LOCK_UNLOCK);
}
/*
* Set tuple for index-only scan
*/
static void
SetIndexTuple(IndexScanDesc scan, ItemPointer indextid)
{
IvfflatScanOpaque so = (IvfflatScanOpaque) scan->opaque;
Buffer buf = so->buf;
Page page;
OffsetNumber offno = ItemPointerGetOffsetNumber(indextid);
IndexTuple itup;
Size itupSize;
LockBuffer(buf, BUFFER_LOCK_SHARE);
page = BufferGetPage(buf);
itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, offno));
itupSize = IndexTupleSize(itup);
if (so->itup == NULL)
so->itup = palloc(BLCKSZ);
memcpy(so->itup, itup, itupSize);
scan->xs_itup = so->itup;
LockBuffer(buf, BUFFER_LOCK_UNLOCK);
}
/*
* Prepare for an index scan
*/
@@ -409,27 +437,7 @@ ivfflatgettuple(IndexScanDesc scan, ScanDirection dir)
so->buf = ReadBuffer(scan->indexRelation, ItemPointerGetBlockNumber(indextid));
if (scan->xs_want_itup)
{
Page page;
OffsetNumber offno;
IndexTuple itup;
Size itupSize;
LockBuffer(so->buf, BUFFER_LOCK_SHARE);
page = BufferGetPage(so->buf);
offno = ItemPointerGetOffsetNumber(indextid);
itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, offno));
itupSize = IndexTupleSize(itup);
if (so->itup == NULL)
so->itup = palloc(BLCKSZ);
memcpy(so->itup, itup, itupSize);
scan->xs_itup = so->itup;
LockBuffer(so->buf, BUFFER_LOCK_UNLOCK);
}
SetIndexTuple(scan, indextid);
scan->xs_recheckorderby = false;
return true;