Avoid overflow computing visibility map length

Computing the number of visibility map blocks used addition-based
ceiling division on a BlockNumber.  For heap lengths near MaxBlockNumber
on 32-bit builds, the addition could overflow and produce a much smaller
visibility map length, potentially zero.

Use quotient and remainder instead so the calculation cannot overflow.

Reported-by: Melanie Plageman <[email protected]>
Author: Melanie Plageman <[email protected]>
Reviewed-by: shihao zhong <[email protected]>
Backpatch-through: 17

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/a20d58b47f18f2085f5fadb553e56a8e9fa3160b

Modified Files
--------------
src/backend/access/heap/visibilitymap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

Reply via email to