BUG: test_bloomfilter error message reports wrong variable and wrong format specifier

From: Jianghua Yang <yjhjstz(at)gmail(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: BUG: test_bloomfilter error message reports wrong variable and wrong format specifier
Date: 2026-03-24 12:31:55
Message-ID: CAAZLFmS2OMiwe65gdm-MKgO=LnKatGMSK6JWxhycGN3TWrhbnw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

I found a small bug in
src/test/modules/test_bloomfilter/test_bloomfilter.c, line 128.

The current code:

int64 nelements = PG_GETARG_INT64(1);
int tests = PG_GETARG_INT32(3);

if (tests <= 0)
elog(ERROR, "invalid number of tests: %d", tests);

if (nelements < 0)
elog(ERROR, "invalid number of elements: %d", tests);

The second elog has two issues:

1. It checks nelements but prints tests. For example, with
nelements = -1 and tests = 1, the error message would be
"invalid number of elements: 1" — which is misleading when debugging.
2. nelements is int64, so the format specifier should be
INT64_FORMAT rather than %d. Using %d for int64 is
undefined behavior on 32-bit platforms.

The fix:

if (nelements < 0)
elog(ERROR, "invalid number of elements: " INT64_FORMAT, nelements);

A patch is attached.

Regards,
Jianghua Yang

Attachment Content-Type Size
v1-0001-Fix-wrong-variable-and-format-specifier-in-test_b.patch application/octet-stream 1.2 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2026-03-24 13:13:21 Re: CAST(... ON DEFAULT) - WIP build on top of Error-Safe User Functions
Previous Message Daniel Gustafsson 2026-03-24 12:29:04 Re: Custom oauth validator options