]> git.ipfire.org Git - thirdparty/postgresql.git/commit
test_bitmapset: Simplify code of the module
authorMichael Paquier <michael@paquier.xyz>
Wed, 1 Oct 2025 05:17:54 +0000 (14:17 +0900)
committerMichael Paquier <michael@paquier.xyz>
Wed, 1 Oct 2025 05:17:54 +0000 (14:17 +0900)
commit9952f6c05a40976063c3e2a4482873ec710f01a2
treea52723f1637de7bf317193b59b3a1c87a1661cb2
parent8e2acda2b098bf53120721e16a7b1055c4e5b3a6
test_bitmapset: Simplify code of the module

Two macros are added in this module, to cut duplicated patterns:
- PG_ARG_GETBITMAPSET(), for input argument handling, with knowledge
about NULL.
- PG_RETURN_BITMAPSET_AS_TEXT(), that generates a text result from a
Bitmapset.

These changes limit the code so as the SQL functions are now mostly
wrappers of the equivalent C function.  Functions that use integer input
arguments still need some NULL handling, like bms_make_singleton().

A NULL input is translated to "<>", which is what nodeToString()
generates.  Some of the tests are able to generate this result.

Per discussion, the calls of bms_free() are removed.  These may be
justified if the functions are used in a rather long-lived memory
context, but let's keep the code minimal for now.  These calls used NULL
checks, which were also not necessary as NULL is an input authorized by
bms_free().

Some of the tests existed to cover behaviors related to the SQL
functions for NULL inputs.  Most of them are still relevant, as the
routines of bitmapset.c are able to handle such cases.

The coverage reports of bitmapset.c and test_bitmapset.c remain the
same after these changes, with 300 lines of C code removed.

Author: David Rowley <dgrowleyml@gmail.com>
Co-authored-by: Greg Burd <greg@burd.me>
Discussion: https://postgr.es/m/CAApHDvqghMnm_zgSNefto9oaEJ0S-3Cgb3gdsV7XvLC-hMS02Q@mail.gmail.com
src/test/modules/test_bitmapset/expected/test_bitmapset.out
src/test/modules/test_bitmapset/sql/test_bitmapset.sql
src/test/modules/test_bitmapset/test_bitmapset--1.0.sql
src/test/modules/test_bitmapset/test_bitmapset.c