diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c index 9cc2470de87..0e4a8ac800a 100644 --- a/src/backend/storage/buffer/bufmgr.c +++ b/src/backend/storage/buffer/bufmgr.c @@ -4020,8 +4020,8 @@ local_buffer_write_error_callback(void *arg) static int rnode_comparator(const void *p1, const void *p2) { - RelFileNode n1 = *(RelFileNode *) p1; - RelFileNode n2 = *(RelFileNode *) p2; + RelFileNode n1 = *(const RelFileNode *) p1; + RelFileNode n2 = *(const RelFileNode *) p2; if (n1.relNode < n2.relNode) return -1; @@ -4130,8 +4130,8 @@ buffertag_comparator(const void *a, const void *b) static int ckpt_buforder_comparator(const void *pa, const void *pb) { - const CkptSortItem *a = (CkptSortItem *) pa; - const CkptSortItem *b = (CkptSortItem *) pb; + const CkptSortItem *a = (const CkptSortItem *) pa; + const CkptSortItem *b = (const CkptSortItem *) pb; /* compare tablespace */ if (a->tsId < b->tsId) @@ -4151,8 +4151,10 @@ ckpt_buforder_comparator(const void *pa, const void *pb) /* compare block number */ else if (a->blockNum < b->blockNum) return -1; - else /* should not be the same block ... */ + else if (a->blockNum > b->blockNum) return 1; + /* equal page IDs are unlikely, but not impossible */ + return 0; } /*