mirror of
https://github.com/postgres/postgres.git
synced 2025-08-31 17:02:12 +03:00
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
This commit is contained in:
@@ -79,13 +79,11 @@ itemptr_to_uint64(const ItemPointer iptr)
|
||||
uint64 val;
|
||||
|
||||
Assert(ItemPointerIsValid(iptr));
|
||||
Assert(iptr->ip_posid < (1 << MaxHeapTuplesPerPageBits));
|
||||
Assert(GinItemPointerGetOffsetNumber(iptr) < (1 << MaxHeapTuplesPerPageBits));
|
||||
|
||||
val = iptr->ip_blkid.bi_hi;
|
||||
val <<= 16;
|
||||
val |= iptr->ip_blkid.bi_lo;
|
||||
val = GinItemPointerGetBlockNumber(iptr);
|
||||
val <<= MaxHeapTuplesPerPageBits;
|
||||
val |= iptr->ip_posid;
|
||||
val |= GinItemPointerGetOffsetNumber(iptr);
|
||||
|
||||
return val;
|
||||
}
|
||||
@@ -93,11 +91,9 @@ itemptr_to_uint64(const ItemPointer iptr)
|
||||
static inline void
|
||||
uint64_to_itemptr(uint64 val, ItemPointer iptr)
|
||||
{
|
||||
iptr->ip_posid = val & ((1 << MaxHeapTuplesPerPageBits) - 1);
|
||||
GinItemPointerSetOffsetNumber(iptr, val & ((1 << MaxHeapTuplesPerPageBits) - 1));
|
||||
val = val >> MaxHeapTuplesPerPageBits;
|
||||
iptr->ip_blkid.bi_lo = val & 0xFFFF;
|
||||
val = val >> 16;
|
||||
iptr->ip_blkid.bi_hi = val & 0xFFFF;
|
||||
GinItemPointerSetBlockNumber(iptr, val);
|
||||
|
||||
Assert(ItemPointerIsValid(iptr));
|
||||
}
|
||||
|
Reference in New Issue
Block a user