Re: Add bms_offset_members() function for bitshifting Bitmapsets

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Cc: PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Add bms_offset_members() function for bitshifting Bitmapsets
Date: 2026-04-14 23:45:12
Message-ID: CAApHDvoALVPgVSCuGdAfNUbxx_NacnAd0nuj8Hi=_-61AEqzaQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Thanks for looking.

On Tue, 14 Apr 2026 at 20:46, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)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 increased by 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 Content-Type Size
v2-0001-Introduce-bms_offset_members-function.patch application/octet-stream 17.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2026-04-15 00:29:08 Re: Add bms_offset_members() function for bitshifting Bitmapsets
Previous Message surya poondla 2026-04-14 23:25:44 Re: Fix the race condition for updating slot minimum LSN