Re: Add bms_offset_members() function for bitshifting Bitmapsets
David Rowley <dgrowleyml@gmail.com>
From: David Rowley <dgrowleyml@gmail.com>
To: Chao Li <li.evan.chao@gmail.com>
Cc: PostgreSQL Developers <pgsql-hackers@lists.postgresql.org>
Date: 2026-04-14T23:45:12Z
Lists: pgsql-hackers
Attachments
- v2-0001-Introduce-bms_offset_members-function.patch (application/octet-stream) patch v2-0001
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 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