]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix BRIN 32-bit counter wrap issue with huge tables
authorDavid Rowley <drowley@postgresql.org>
Tue, 21 Oct 2025 07:48:34 +0000 (20:48 +1300)
committerDavid Rowley <drowley@postgresql.org>
Tue, 21 Oct 2025 07:48:34 +0000 (20:48 +1300)
commiteea24eb0ac2f7fa0f3eb9611483653beb976b41e
treedf36b597be7596c4f23f71556d0d0044f8d80947
parent5274f11c17493a4011156a99e44cb1a8f5f9692e
Fix BRIN 32-bit counter wrap issue with huge tables

A BlockNumber (32-bit) might not be large enough to add bo_pagesPerRange
to when the table contains close to 2^32 pages.  At worst, this could
result in a cancellable infinite loop during the BRIN index scan with
power-of-2 pagesPerRange, and slow (inefficient) BRIN index scans and
scanning of unneeded heap blocks for non power-of-2 pagesPerRange.

Backpatch to all supported versions.

Author: sunil s <sunilfeb26@gmail.com>
Reviewed-by: David Rowley <dgrowleyml@gmail.com>
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/CAOG6S4-tGksTQhVzJM19NzLYAHusXsK2HmADPZzGQcfZABsvpA@mail.gmail.com
Backpatch-through: 13
src/backend/access/brin/brin.c