pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Greg Burd <greg@burd.me>
To: David Rowley <dgrowleyml@gmail.com>
To: Peter Eisentraut <peter@eisentraut.org>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Chao Li <li.evan.chao@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: Add bms_offset_members() function for bitshifting Bitmapsets
Date: Mon, 24 Aug 2026 02:25:08 -0400
Message-ID: <66d041b4-32f4-4097-bb2c-0e7147337a5e@app.fastmail.com> (raw)
In-Reply-To: <CAApHDvpfZqdMRmR-6W9UXb+Tanex5wK6PsL=XzYCV4P3pD36Ng@mail.gmail.com>
References: <CAApHDvq=eEdw2Qp+aSzSOtTSe+h0fnVQ55CcTNqBkLDYiRZmxw@mail.gmail.com>
	<278B9FE3-F349-4494-99C5-483105C1C999@gmail.com>
	<CAApHDvoALVPgVSCuGdAfNUbxx_NacnAd0nuj8Hi=_-61AEqzaQ@mail.gmail.com>
	<1900289.1776212948@sss.pgh.pa.us>
	<CAApHDvq4_WDfTaWX6nHU8TV+no+aD1zjLphza685Ek7=xgGzew@mail.gmail.com>
	<1913188.1776220247@sss.pgh.pa.us>
	<CAApHDvp=fhr8ksuGyXkwYPXQpYvJ38YMhHvx6JmdD39cAvNRhw@mail.gmail.com>
	<CAApHDvrp6JwOVH3VwMB=YL3p97F5_0hKJc7J8zHRKuyhKru1dA@mail.gmail.com>
	<77f5109f-6d39-4cf1-8d0d-f826435d6cb6@app.fastmail.com>
	<CAApHDvqOgtX2MqaPmPmPET7=ySszzuoP3MLSUbWZit_V30VBLg@mail.gmail.com>
	<08fa9f01-373e-4cb4-9650-ad20517e2de3@eisentraut.org>
	<CAApHDvrxVejtenPtju9RUt8A8zb-vdr1wu_R7_pQTcmCj6f9VQ@mail.gmail.com>
	<CAApHDvpfZqdMRmR-6W9UXb+Tanex5wK6PsL=XzYCV4P3pD36Ng@mail.gmail.com>


On Sat, Aug 22, 2026, at 9:38 PM, David Rowley wrote:
> On Thu, 9 Jul 2026 at 11:55, David Rowley <dgrowleyml@gmail.com> wrote:
>> I pushed a change to make seed int64 instead. It's still possible to
>> specify the full range of possible values that GetCurrentTimestamp()
>> can (or could ever) return with the int64 type. This way, there's no
>> longer a mismatch in the format specifier for elog and the type we're
>> formatting. That's an improvement, so thanks.

Hey David,

> I was just in this area again and noticed that the nmembers
> calculation does not take into account the min_value parameter. The
> bad code is:
>
> nmembers = pg_prng_uint32(&state) % max_range + min_value;

Indeed, good catch.

> That should really be subtracting the min_value, as I had intended
> nmembers to do was populate a random set of members in the range
> specified by the function. While there, I noticed that the parameter
> names are not very consistently named and having the max_value before
> the min_value seems weird too.

I agree that is an implicit convention and is more intuitive.

> I understand test_random_operations()
> has it that way. I didn't adjust that function. Maybe that could be
> done separately since it's also in v19, whereas
> test_random_offset_operations() is new to v20.

I think this is a good idea, simply to be consistent/tidy and re-enforce the pattern for future work.

> I've attached a patch which fixes this plus a few more things that
> Claude code pointed out to me when I asked it to review my changes.
> Those are primarily around overflow risk if max_value was given as
> INT32_MAX.

I applied, reviewed, and tested the v1 patch.  I think it is good and necessary for the reasons you've outlined.  I'd happily help or implement the additional test_random_operations() for v20/v19 when I get a second (currently traveling) if you're not going to do so.

Thanks for continuing to improve this testing module.

best.

-greg

> David
>
> Attachments:
> * v1-0001-Fix-incorrect-nmembers-calculation-in-test_bitmap.patch





view thread (23+ messages)  latest in thread

Message-ID: <66d041b4-32f4-4097-bb2c-0e7147337a5e@app.fastmail.com>
Permalink:  ../66d041b4-32f4-4097-bb2c-0e7147337a5e@app.fastmail.com/
Also on:    postgresql.org/message-id/66d041b4-32f4-4097-bb2c-0e7147337a5e@app.fastmail.com

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: greg@burd.me, dgrowleyml@gmail.com, peter@eisentraut.org, tgl@sss.pgh.pa.us, li.evan.chao@gmail.com
  Subject: Re: Add bms_offset_members() function for bitshifting Bitmapsets
  In-Reply-To: <66d041b4-32f4-4097-bb2c-0e7147337a5e@app.fastmail.com>
  References: <CAApHDvq=eEdw2Qp+aSzSOtTSe+h0fnVQ55CcTNqBkLDYiRZmxw@mail.gmail.com> <278B9FE3-F349-4494-99C5-483105C1C999@gmail.com> <CAApHDvoALVPgVSCuGdAfNUbxx_NacnAd0nuj8Hi=_-61AEqzaQ@mail.gmail.com> <1900289.1776212948@sss.pgh.pa.us> <CAApHDvq4_WDfTaWX6nHU8TV+no+aD1zjLphza685Ek7=xgGzew@mail.gmail.com> <1913188.1776220247@sss.pgh.pa.us> <CAApHDvp=fhr8ksuGyXkwYPXQpYvJ38YMhHvx6JmdD39cAvNRhw@mail.gmail.com> <CAApHDvrp6JwOVH3VwMB=YL3p97F5_0hKJc7J8zHRKuyhKru1dA@mail.gmail.com> <77f5109f-6d39-4cf1-8d0d-f826435d6cb6@app.fastmail.com> <CAApHDvqOgtX2MqaPmPmPET7=ySszzuoP3MLSUbWZit_V30VBLg@mail.gmail.com> <08fa9f01-373e-4cb4-9650-ad20517e2de3@eisentraut.org> <CAApHDvrxVejtenPtju9RUt8A8zb-vdr1wu_R7_pQTcmCj6f9VQ@mail.gmail.com> <CAApHDvpfZqdMRmR-6W9UXb+Tanex5wK6PsL=XzYCV4P3pD36Ng@mail.gmail.com> <66d041b4-32f4-4097-bb2c-0e7147337a5e@app.fastmail.com>

* 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