From ce96ce60ca2293f75f36c3661e4657a3c79ffd61 Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Tue, 28 Mar 2017 12:52:55 -0300 Subject: Remove direct uses of ItemPointer.{ip_blkid,ip_posid} There are no functional changes here; this simply encapsulates knowledge of the ItemPointerData struct so that a future patch can change things without more breakage. All direct users of ip_blkid and ip_posid are changed to use existing macros ItemPointerGetBlockNumber and ItemPointerGetOffsetNumber respectively. For callers where that's inappropriate (because they Assert that the itempointer is is valid-looking), add ItemPointerGetBlockNumberNoCheck and ItemPointerGetOffsetNumberNoCheck, which lack the assertion but are otherwise identical. Author: Pavan Deolasee Discussion: https://postgr.es/m/CABOikdNnFon4cJiL=h1mZH3bgUeU+sWHuU4Yr8AB=j3A2p1GiA@mail.gmail.com --- src/backend/access/gin/ginget.c | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'src/backend/access/gin/ginget.c') diff --git a/src/backend/access/gin/ginget.c b/src/backend/access/gin/ginget.c index 87cd9eaa9f5..610d386ff8a 100644 --- a/src/backend/access/gin/ginget.c +++ b/src/backend/access/gin/ginget.c @@ -626,8 +626,9 @@ entryLoadMoreItems(GinState *ginstate, GinScanEntry entry, } else { - entry->btree.itemptr = advancePast; - entry->btree.itemptr.ip_posid++; + ItemPointerSet(&entry->btree.itemptr, + GinItemPointerGetBlockNumber(&advancePast), + OffsetNumberNext(GinItemPointerGetOffsetNumber(&advancePast))); } entry->btree.fullScan = false; stack = ginFindLeafPage(&entry->btree, true, snapshot); @@ -979,15 +980,17 @@ keyGetItem(GinState *ginstate, MemoryContext tempCtx, GinScanKey key, if (GinItemPointerGetBlockNumber(&advancePast) < GinItemPointerGetBlockNumber(&minItem)) { - advancePast.ip_blkid = minItem.ip_blkid; - advancePast.ip_posid = 0; + ItemPointerSet(&advancePast, + GinItemPointerGetBlockNumber(&minItem), + InvalidOffsetNumber); } } else { - Assert(minItem.ip_posid > 0); - advancePast = minItem; - advancePast.ip_posid--; + Assert(GinItemPointerGetOffsetNumber(&minItem) > 0); + ItemPointerSet(&advancePast, + GinItemPointerGetBlockNumber(&minItem), + OffsetNumberPrev(GinItemPointerGetOffsetNumber(&minItem))); } /* @@ -1245,15 +1248,17 @@ scanGetItem(IndexScanDesc scan, ItemPointerData advancePast, if (GinItemPointerGetBlockNumber(&advancePast) < GinItemPointerGetBlockNumber(&key->curItem)) { - advancePast.ip_blkid = key->curItem.ip_blkid; - advancePast.ip_posid = 0; + ItemPointerSet(&advancePast, + GinItemPointerGetBlockNumber(&key->curItem), + InvalidOffsetNumber); } } else { - Assert(key->curItem.ip_posid > 0); - advancePast = key->curItem; - advancePast.ip_posid--; + Assert(GinItemPointerGetOffsetNumber(&key->curItem) > 0); + ItemPointerSet(&advancePast, + GinItemPointerGetBlockNumber(&key->curItem), + OffsetNumberPrev(GinItemPointerGetOffsetNumber(&key->curItem))); } /* -- cgit v1.2.3