Fix incorrect false positive rate formatting in create_and_test_bloom()

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

Fix incorrect false positive rate formatting in create_and_test_bloom()

От:
Postgress Cybrosys <postgress@cybrosys.com>
Дата:
Вложения:
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


postgress@cybrosys.com

+91 8606827707

+91 8606827707


FAQ