Re: [PATCH] Add tests for Bitmapset
От | David Rowley |
---|---|
Тема | Re: [PATCH] Add tests for Bitmapset |
Дата | |
Msg-id | CAApHDvrvixMmscGEfEyYz0=qbwzM7Y0Up-Uh_AKVmfn8K2sn_A@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: [PATCH] Add tests for Bitmapset (Greg Burd <greg@burd.me>) |
Ответы |
Re: [PATCH] Add tests for Bitmapset
|
Список | pgsql-hackers |
On Wed, 1 Oct 2025 at 01:38, Greg Burd <greg@burd.me> wrote: > v2 attached. Thanks. I looked at this and I think we can do a bit better to simplify the code and standardise what we do when faced with bogus inputs. Here's what I've done: 1. Added helper macros PG_ARG_GETBITMAPSET() and PG_RETURN_BITMAPSET_AS_TEXT(). These themselves save a few hundred lines of code and make the functions easier to read. 2. Standardised that the test function returns NULL when it receives invalid input. e.g if we aim to pass an "int" to the underlying Bitmapset function, if someone calls the test function with an SQL NULL, just return NULL rather than trying to come up with some logic on what we should do about that. 3. I couldn't quite understand the extra parameter to test_bms_get_singleton_member() so I ended up removing it and making the test function return -1 when the set isn't a singleton. I didn't search for discussion about that so I might have missed the specific reason it was done that way. 4. Wrote some comments to try to communicate the standards defined. This aims to offer guidance to callers of these functions and anyone hacking on the module itself in the future. git diff --stat looks like: 4 files changed, 233 insertions(+), 505 deletions(-) Things not done: 1. I didn't update the expected test results. 2. I didn't rationalise the tests. I feel that there's no point in the tests that purposefully pass invalid input to the module's test function. It appears that's aiming to increase coverage on the test module's C code, which I don't quite understand. In any case, due to the helper macros, I don't think removing these will lower the per-source-file line coverage of the module itself. I've not checked my work very thoroughly. I can do that, or you can if you and Michael are ok with the proposed ideas. I'm also not aiming to commandeer anything here. Writing the patch was just the easiest way to communicate the ideas I had. I also wonder how worthwhile it is to try to free the Bitmapsets. I'd have expected these allocations to be in a pretty short-lived memory context. I count 44 calls to bms_free(). David
Вложения
В списке pgsql-hackers по дате отправления: