diff --git a/engine.c b/engine.c index 89217a9..f656146 100644 --- a/engine.c +++ b/engine.c @@ -654,7 +654,7 @@ ptrack_mark_block(RelFileNodeBackend smgr_rnode, ForkNumber forknum, BlockNumber blocknum) { PtBlockId bid; - size_t hash; + uint64 hash; size_t slot1; size_t slot2; XLogRecPtr new_lsn; @@ -676,8 +676,8 @@ ptrack_mark_block(RelFileNodeBackend smgr_rnode, bid.blocknum = blocknum; hash = BID_HASH_FUNC(bid); - slot1 = hash % PtrackContentNblocks; - slot2 = ((hash << 32) | (hash >> 32)) % PtrackContentNblocks; + slot1 = (size_t)(hash % PtrackContentNblocks); + slot2 = (size_t)(((hash << 32) | (hash >> 32)) % PtrackContentNblocks); if (RecoveryInProgress()) new_lsn = GetXLogReplayRecPtr(NULL); diff --git a/engine.h b/engine.h index e46f803..3386cc2 100644 --- a/engine.h +++ b/engine.h @@ -86,7 +86,7 @@ typedef PtrackMapHdr * PtrackMap; /* Block address 'bid' to hash. To get slot position in map should be divided * with '% PtrackContentNblocks' */ #define BID_HASH_FUNC(bid) \ - (size_t)(DatumGetUInt64(hash_any_extended((unsigned char *)&bid, sizeof(bid), 0))) + (DatumGetUInt64(hash_any_extended((unsigned char *)&bid, sizeof(bid), 0))) /* * Per process pointer to shared ptrack_map diff --git a/ptrack.c b/ptrack.c index 40630e7..66f5676 100644 --- a/ptrack.c +++ b/ptrack.c @@ -487,7 +487,7 @@ ptrack_get_pagemapset(PG_FUNCTION_ARGS) while (true) { - size_t hash; + uint64 hash; size_t slot1; size_t slot2; XLogRecPtr update_lsn1; @@ -535,7 +535,7 @@ ptrack_get_pagemapset(PG_FUNCTION_ARGS) } hash = BID_HASH_FUNC(ctx->bid); - slot1 = hash % PtrackContentNblocks; + slot1 = (size_t)(hash % PtrackContentNblocks); update_lsn1 = pg_atomic_read_u64(&ptrack_map->entries[slot1]); @@ -547,7 +547,7 @@ ptrack_get_pagemapset(PG_FUNCTION_ARGS) /* Only probe the second slot if the first one is marked */ if (update_lsn1 >= ctx->lsn) { - slot2 = ((hash << 32) | (hash >> 32)) % PtrackContentNblocks; + slot2 = (size_t)(((hash << 32) | (hash >> 32)) % PtrackContentNblocks); update_lsn2 = pg_atomic_read_u64(&ptrack_map->entries[slot2]); if (update_lsn2 != InvalidXLogRecPtr)