public inbox for [email protected]
help / color / mirror / Atom feedFrom: Greg Burd <[email protected]>
To: Michael Paquier <[email protected]>
To: Masahiko Sawada <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Cc: Nathan Bossart <[email protected]>
Cc: Robert Haas <[email protected]>
Subject: Re: [PATCH] Add tests for Bitmapset
Date: Wed, 17 Sep 2025 07:59:15 -0400
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
On Sep 16 2025, at 8:35 pm, Michael Paquier <[email protected]> wrote:
> On Tue, Sep 16, 2025 at 03:00:40PM -0700, Masahiko Sawada wrote:
>> Thank you for updating the patch. It seems cfbot caught a regression
>> test error[1] in a 32-bit build.
>
> - bitmap_hash [1,3,5] | 49870778
> + bitmap_hash [1,3,5] | 1509752520
>
> This one is able the hash value computation being not portable across
> architectures. I would just change these to be non-NULL, I guess.
> --
> Michael
Thanks Michael, Sawada-san, yep hashing is arch dependent (go figure!),
but thankfully it is deterministic. Rather that test for non-NULL I've
come up with this approach:
-- Architecture-aware hash testing
WITH arch_info AS (
SELECT
CASE
WHEN pg_column_size(1::bigint) = 8 THEN '64bit'
ELSE '32bit'
END as architecture
),
expected_values AS (
SELECT
architecture,
CASE architecture
WHEN '64bit' THEN 0
WHEN '32bit' THEN 0
END as hash_null,
CASE architecture
WHEN '64bit' THEN 49870778
WHEN '32bit' THEN 1509752520
END as hash_135,
CASE architecture
WHEN '64bit' THEN -303921606
WHEN '32bit' THEN 0 -- TBD
END as hash_246
FROM arch_info
)
SELECT 'expected hash NULL' as test,
test_bitmap_hash(NULL) = hash_null as result
FROM expected_values
UNION ALL
SELECT 'expected hash [1,3,5]' as test,
test_bitmap_hash(test_bms_from_array(ARRAY[1,3,5])) = hash_135 as result
FROM expected_values
UNION ALL
SELECT 'expected hash [2,4,6]' as test,
test_bitmap_hash(test_bms_from_array(ARRAY[2,4,6])) = hash_246 as result
FROM expected_values;
However I'm not sure what the value is for testing hash functions except
for coverage and I'm fairly certain that function is well exercised.
That said, I think that will work. I'll let cfbot tell me the 32bit
hash value on the next run.
thanks again for the helpful insights,
-greg
view thread (81+ messages) latest in thread
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: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: Re: [PATCH] Add tests for Bitmapset
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox