Skip to content

Commit 48aae44

Browse files
author
Artur Zakirov
committed
Fix comparison of ItemPointer in the comparetup_rum()
1 parent 1469a92 commit 48aae44

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

rumsort.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3868,20 +3868,21 @@ comparetup_rum(const SortTuple *a, const SortTuple *b, Tuplesortstate *state)
38683868
/*
38693869
* If key values are equal, we sort on ItemPointer.
38703870
*/
3871-
{
3872-
BlockNumber blk1 = ItemPointerGetBlockNumber(&i1->iptr);
3873-
BlockNumber blk2 = ItemPointerGetBlockNumber(&i2->iptr);
3871+
if (i1->iptr.ip_blkid.bi_hi < i2->iptr.ip_blkid.bi_hi)
3872+
return -1;
3873+
else if (i1->iptr.ip_blkid.bi_hi > i2->iptr.ip_blkid.bi_hi)
3874+
return 1;
38743875

3875-
if (blk1 != blk2)
3876-
return (blk1 < blk2) ? -1 : 1;
3877-
}
3878-
{
3879-
OffsetNumber pos1 = ItemPointerGetOffsetNumber(&i1->iptr);
3880-
OffsetNumber pos2 = ItemPointerGetOffsetNumber(&i2->iptr);
3876+
if (i1->iptr.ip_blkid.bi_lo < i2->iptr.ip_blkid.bi_lo)
3877+
return -1;
3878+
else if (i1->iptr.ip_blkid.bi_lo > i2->iptr.ip_blkid.bi_lo)
3879+
return 1;
3880+
3881+
if (i1->iptr.ip_posid < i2->iptr.ip_posid)
3882+
return -1;
3883+
else if (i1->iptr.ip_posid > i2->iptr.ip_posid)
3884+
return 1;
38813885

3882-
if (pos1 != pos2)
3883-
return (pos1 < pos2) ? -1 : 1;
3884-
}
38853886
return 0;
38863887
}
38873888

0 commit comments

Comments
 (0)