Fix incorrect nmembers calculation in test_bitmapset This calculation was failing to correctly account for the min_value when calculating how many random members to add to the Bitmapset. What the code was meant to do was add a random number of members between the minimum and maximum values. The code failed to account for the minimum value being non-zero, which could result in too many members being added to the set, which could reduce the effectiveness of the test. In reality, the only caller to this function did pass 0 as the min_value, so there is no live bug being fixed here.
Fix this so that the Bitmapset is more sparsely populated with members between the minimum and maximum values. In passing, swap the order of the min_value and max_value parameters. Having the minimum value appear before the maximum value makes more sense. Also align the names of both parameters, and adjust the 'offset' calculation to widen the offset range by 1 so that the possible range for that random value is -max_value to max_value. Author: David Rowley <[email protected]> Reviewed-by: Greg Burd <[email protected]> Discussion: https://postgr.es/m/CAApHDvpfZqdMRmR-6W9UXb+Tanex5wK6PsL=xzycv4p3pd3...@mail.gmail.com Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/53a981ed5bbaa8344da88dfa3550e6cfb6ecf3c9 Modified Files -------------- .../test_bitmapset/expected/test_bitmapset.out | 2 +- .../modules/test_bitmapset/sql/test_bitmapset.sql | 2 +- src/test/modules/test_bitmapset/test_bitmapset.c | 53 ++++++++++++++-------- 3 files changed, 37 insertions(+), 20 deletions(-)
