Re: Add bms_offset_members() function for bitshifting Bitmapsets - Mailing list pgsql-hackers

From David Rowley
Subject Re: Add bms_offset_members() function for bitshifting Bitmapsets
Date
Msg-id CAApHDvoALVPgVSCuGdAfNUbxx_NacnAd0nuj8Hi=_-61AEqzaQ@mail.gmail.com
Whole thread
In response to Re: Add bms_offset_members() function for bitshifting Bitmapsets  (Chao Li <li.evan.chao@gmail.com>)
Responses Re: Add bms_offset_members() function for bitshifting Bitmapsets
List pgsql-hackers
Thanks for looking.

On Tue, 14 Apr 2026 at 20:46, Chao Li <li.evan.chao@gmail.com> wrote:
> +               if (((uint64) new_nwords - 1) * BITS_PER_BITMAPWORD + high_bit + offset_bits > PG_INT32_MAX)
> +                       elog(ERROR, "bitmapset overflow");

> This overflow check seems wrong. Because when high_bit + offset_bits > BITS_PER_BITMAPWORD, new_nwords has been
increasedby 1, so there high_bit + offset_bits are double counted.
 

Your idea of checking the old highest member plus the offset seems a
more robust method, so I've adjusted the patch to use that.

David

Attachment

pgsql-hackers by date:

Previous
From: surya poondla
Date:
Subject: Re: Fix the race condition for updating slot minimum LSN
Next
From: Tom Lane
Date:
Subject: Re: Add bms_offset_members() function for bitshifting Bitmapsets