Hi,

I noticed a bug in src/test/modules/test_bloomfilter/test_bloomfilter.c
where the false positive rate is displayed incorrectly in
create_and_test_bloom().

The issue is in the ereport() call:

    errmsg_internal("seed: " UINT64_FORMAT " false positives: "
INT64_FORMAT " (%.6f%%) bitset %.2f%% set",
                     seed, nfalsepos, (double) nfalsepos / nelements,
                     100.0 * bloom_prop_bits_set(filter))

The format specifier %.6f%% expects a value already scaled to a percentage,
but (double) nfalsepos / nelements produces a raw fraction. This means a
true false positive rate of 0.5% is displayed as 0.005000% — 100x smaller
than the actual value.

This is inconsistent with the very next argument, bloom_prop_bits_set(),
which is correctly multiplied by 100.0 before being passed to its %.2f%%
format specifier.

The fix is straightforward — multiply the ratio by 100.0:

    - seed, nfalsepos, (double) nfalsepos / nelements,
    + seed, nfalsepos, 100.0 * (double) nfalsepos / nelements,

Patch is attached.

Thanks & Regards,

*Jhon k*

Postgres Specialist

Project & IT Department

Cybrosys Technologies

Mail

Mobile

WhatsApp


[email protected]

+91 8606827707

+91 8606827707
From f4ca602e7c902ec34028d0a3a7fded39a9d8669e Mon Sep 17 00:00:00 2001
From: postgress cybrosys <[email protected]>
Date: Wed, 25 Mar 2026 12:17:16 +0530
Subject: [PATCH] Fix incorrect false positive rate formatting in
 create_and_test_bloom()

The false positive rate was reported as a raw fraction (e.g., 0.005000%) instead of a percentage (0.500000%). The "%.6f%%" format specifier expects a value already scaled to percentage, but the computed ratio was not multiplied by 100.0.

This is inconsistent with bloom_prop_bits_set(), which correctly scales its value by 100.0 before passing it to a "%.2f%%" format specifier.

Fix by multiplying (nfalsepos / nelements) by 100.0 to ensure correct percentage output.
---
 src/test/modules/test_bloomfilter/test_bloomfilter.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/test/modules/test_bloomfilter/test_bloomfilter.c b/src/test/modules/test_bloomfilter/test_bloomfilter.c
index df41066138c..268e1938cad 100644
--- a/src/test/modules/test_bloomfilter/test_bloomfilter.c
+++ b/src/test/modules/test_bloomfilter/test_bloomfilter.c
@@ -94,7 +94,7 @@ create_and_test_bloom(int power, int64 nelements, int callerseed)
 
 	ereport((nfalsepos > nelements * FPOSITIVE_THRESHOLD) ? WARNING : DEBUG1,
 			(errmsg_internal("seed: " UINT64_FORMAT " false positives: " INT64_FORMAT " (%.6f%%) bitset %.2f%% set",
-							 seed, nfalsepos, (double) nfalsepos / nelements,
+							 seed, nfalsepos, 100.0 * (double) nfalsepos / nelements,
 							 100.0 * bloom_prop_bits_set(filter))));
 
 	bloom_free(filter);
-- 
2.34.1

Reply via email to