pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Rowley <drowley@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix incorrect nmembers calculation in test_bitmapset
Date: Mon, 24 Aug 2026 10:44:40 +0000
Message-ID: <E1wySAR-00000001tL5-13Su@gemulon.postgresql.org> (raw)

Fix incorrect nmembers calculation in test_bitmapset

This calculation was failing to correctly account for the min_value when
calculating how many random members to add to the Bitmapset.  What the
code was meant to do was add a random number of members between the
minimum and maximum values.  The code failed to account for the minimum
value being non-zero, which could result in too many members being added
to the set, which could reduce the effectiveness of the test.  In reality,
the only caller to this function did pass 0 as the min_value, so there is
no live bug being fixed here.

Fix this so that the Bitmapset is more sparsely populated with members
between the minimum and maximum values.  In passing, swap the order of the
min_value and max_value parameters.  Having the minimum value appear
before the maximum value makes more sense.  Also align the names of both
parameters, and adjust the 'offset' calculation to widen the offset range
by 1 so that the possible range for that random value is -max_value to
max_value.

Author: David Rowley <dgrowleyml@gmail.com>
Reviewed-by: Greg Burd <greg@burd.me>
Discussion: https://postgr.es/m/CAApHDvpfZqdMRmR-6W9UXb+Tanex5wK6PsL=XzYCV4P3pD36Ng@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/53a981ed5bbaa8344da88dfa3550e6cfb6ecf3c9

Modified Files
--------------
.../test_bitmapset/expected/test_bitmapset.out     |  2 +-
.../modules/test_bitmapset/sql/test_bitmapset.sql  |  2 +-
src/test/modules/test_bitmapset/test_bitmapset.c   | 53 ++++++++++++++--------
3 files changed, 37 insertions(+), 20 deletions(-)



Message-ID: <E1wySAR-00000001tL5-13Su@gemulon.postgresql.org>
Permalink:  ../E1wySAR-00000001tL5-13Su@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1wySAR-00000001tL5-13Su@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: drowley@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix incorrect nmembers calculation in test_bitmapset
  In-Reply-To: <E1wySAR-00000001tL5-13Su@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox