pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: test_bitmapset: Simplify code of the module
Date: Wed, 01 Oct 2025 05:18:59 +0000
Message-ID: <E1v3pEw-000swn-2Q@gemulon.postgresql.org> (raw)

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/9952f6c05a40976063c3e2a4482873ec710f01a2

Modified Files
--------------
.../test_bitmapset/expected/test_bitmapset.out     | 271 +++------
.../modules/test_bitmapset/sql/test_bitmapset.sql  |  84 +--
.../modules/test_bitmapset/test_bitmapset--1.0.sql |   2 +-
src/test/modules/test_bitmapset/test_bitmapset.c   | 615 +++++----------------
4 files changed, 254 insertions(+), 718 deletions(-)



Message-ID: <E1v3pEw-000swn-2Q@gemulon.postgresql.org>
Permalink:  ../E1v3pEw-000swn-2Q@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1v3pEw-000swn-2Q@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: michael@paquier.xyz, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: test_bitmapset: Simplify code of the module
  In-Reply-To: <E1v3pEw-000swn-2Q@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