diff options
author | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2017-03-28 12:52:55 -0300 |
---|---|---|
committer | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2017-03-28 19:02:23 -0300 |
commit | ce96ce60ca2293f75f36c3661e4657a3c79ffd61 (patch) | |
tree | 45247e9dd84a19acd6a2d024ddcc95007e12a577 /src/backend/storage/page/itemptr.c | |
parent | a99f77021f0c8c1c221af4e36b64ca43abd04389 (diff) | |
download | postgresql-ce96ce60ca2293f75f36c3661e4657a3c79ffd61.tar.gz |
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
Diffstat (limited to 'src/backend/storage/page/itemptr.c')
-rw-r--r-- | src/backend/storage/page/itemptr.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/backend/storage/page/itemptr.c b/src/backend/storage/page/itemptr.c index 703cbb9c39..b872928f2f 100644 --- a/src/backend/storage/page/itemptr.c +++ b/src/backend/storage/page/itemptr.c @@ -52,20 +52,21 @@ int32 ItemPointerCompare(ItemPointer arg1, ItemPointer arg2) { /* - * Don't use ItemPointerGetBlockNumber or ItemPointerGetOffsetNumber here, - * because they assert ip_posid != 0 which might not be true for a - * user-supplied TID. + * Use ItemPointerGet{Offset,Block}NumberNoCheck to avoid asserting + * ip_posid != 0, which may not be true for a user-supplied TID. */ - BlockNumber b1 = BlockIdGetBlockNumber(&(arg1->ip_blkid)); - BlockNumber b2 = BlockIdGetBlockNumber(&(arg2->ip_blkid)); + BlockNumber b1 = ItemPointerGetBlockNumberNoCheck(arg1); + BlockNumber b2 = ItemPointerGetBlockNumberNoCheck(arg2); if (b1 < b2) return -1; else if (b1 > b2) return 1; - else if (arg1->ip_posid < arg2->ip_posid) + else if (ItemPointerGetOffsetNumberNoCheck(arg1) < + ItemPointerGetOffsetNumberNoCheck(arg2)) return -1; - else if (arg1->ip_posid > arg2->ip_posid) + else if (ItemPointerGetOffsetNumberNoCheck(arg1) > + ItemPointerGetOffsetNumberNoCheck(arg2)) return 1; else return 0; |