Re: [PATCH] Add tests for Bitmapset
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Greg Burd <greg@burd.me>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>, Robert Haas <robertmhaas@gmail.com>, Nathan Bossart <nathandbossart@gmail.com>, Masahiko Sawada <sawada.mshk@gmail.com>
Date: 2025-09-22T07:57:05Z
Lists: pgsql-hackers
On Fri, Sep 19, 2025 at 02:48:43PM -0400, Greg Burd wrote: > I think I've incorporated your feedback which did indeed make the patch > more readable/crisp and maintainable, thank you. > > coverage: HEAD v7 v8 > lines......: 87.1 90.5 92.2 bitmap_match() had some duplicated tests. bms_replace_members() was not covered, and a function was added to the module. I get up to 93.4% for the lines, once added. +PG_FUNCTION_INFO_V1(test_bms_from_array); +PG_FUNCTION_INFO_V1(test_bms_to_array); These two were still declared, are not required. There were a couple of functions that acted as dead code in the module, covered in the tree. As we are trying to cover the gap I think that we should just do the whole thing. Here are the functions: - is_empty - subset_compare - get_singleton_member - nonempty_difference - member_index - join. The test C function had a mistake, because either input may be modified or updated by bms_join(). The code was freeing the right input, leading to errors in the node output function when tested. Mixing the CTEs and the UNION ALL would have been nice if the queries in the UNIONs relied on more than one input value, but none of them did that, so I have removed this part and made the tests leaner. That feels easier for the eye. Testing on equality for the hash functions should be OK, so I have kept these, including the NULL/0 cases. A few incorrect things related to the style, fixed on the way, like an incorrect copyright notice in meson.build, the top of test_bitmapset.c was largely incorrect. It seems like these were copy-pasted from elsewhere. Another thing was testing with -DREALLOCATE_BITMAPSETS, which I've done. A couple of code paths related to the test C functions don't test for NULL input, which is still OK as these don't impact the internal tests or the backend coverage, so I've left these out. The result I had was good enough, so applied. The CI was OK, the buildfarm may have a different opinion. -- Michael
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Minor fixes for test_bitmapset.c
- 5142f0093e64 19 (unreleased) landed
-
test_bitmapset: Improve random function
- 9d46b86529e8 19 (unreleased) landed
-
Add mem_exceeded_count column to pg_stat_replication_slots.
- d3b6183dd988 19 (unreleased) landed
-
Tidy-up unneeded NULL parameter checks from SQL function
- a69b55cd4727 19 (unreleased) landed
-
Remove check for NULL in STRICT function
- 381f5cffae00 19 (unreleased) landed
-
Fixes for comments in test_bitmapset
- a1b064e4b226 19 (unreleased) landed
-
Minor fixups of test_bitmapset.c
- 3a6615806859 19 (unreleased) landed
-
test_bitmapset: Simplify code of the module
- 9952f6c05a40 19 (unreleased) landed
-
test_bitmapset: Expand more the test coverage
- 5668fff3c512 19 (unreleased) landed
-
Fix compiler warnings in test_bitmapset
- f83fe65f3fc1 19 (unreleased) landed
-
Add a test module for Bitmapset
- 00c3d87a5cab 19 (unreleased) landed