[PATCH] Reject nonpositive Bloom filter element estimates

From: CharSyam <charsyam(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: [PATCH] Reject nonpositive Bloom filter element estimates
Date: 2026-09-18 10:31:04
Message-ID: CAMrLSE671yN2u4zeo2pnUY2rm=arYfb0rVSr5v+9m9t9vL802w@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi, Hackers.

bloom_create() currently accepts a zero total_elems estimate. This
causes optimal_k() to divide by zero and then convert infinity to int,
which is undefined behavior.

The attached patch rejects nonpositive estimates before the calculation.
It also performs the bitset size multiplication as unsigned arithmetic
to avoid signed overflow for very large positive estimates, and adds a
regression test for the zero case.

The affected source and test module compile successfully, and
git diff --check passes.

Regards,
DaeMyung Kang

Attachment Content-Type Size
v1-0001-Reject-nonpositive-Bloom-filter-element-estimates.patch application/octet-stream 2.3 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Virender Singla 2026-09-18 10:37:48 Re: Do we reduce autovacuum_naptime max values
Previous Message Nazir Bilal Yavuz 2026-09-18 10:26:54 Stabilize and shorten test_checksums/013_rewind test