Обсуждение: pgsql: test_bitmapset: Simplify code of the module

Поиск
Список
Период
Сортировка

pgsql: test_bitmapset: Simplify code of the module

От
Michael Paquier
Дата:
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(-)