| From: | Heikki Linnakangas <hlinnaka(at)iki(dot)fi> |
|---|---|
| To: | Peter Eisentraut <peter(at)eisentraut(dot)org>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: several cases of float and integer mixup |
| Date: | 2026-12-03 14:49:14 |
| Message-ID: | ef6f4582-4046-4721-92dd-9934b7e6fafa@iki.fi |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On 03/12/2026 13:06, Peter Eisentraut wrote:
> I have found several cases where a variable or C function argument was
> declared as an integer but should be a floating-point type, or vice
> versa. See attached patches. I think most of these are harmless in
> practice.
All looks good to me.
> The one in gistbuild.c is technically a bug, but it's in
> quite rare circumstances and there is no correctness issue, so it's
> probably not worth bothering with backpatching.
So, that's this issue from the commit message:
> This could also lead to a miscalculation further below in
> gistInitBuffering(): If itupAvgSize is larger than half of
> pageFreeSpace, then avgIndexTuplesPerPage becomes exactly 1, and the
> subtreesize calculation below has a division by zero, which becomes a
> NaN, and then the effective_cache_size limit is not applied as
avgIndexTuplesPerPage can become exactly 1 anyway, if the tuples have
just the right sizes. It's rare, but can happen. avgIndexTuplesPerPage <
1.0 and maxIndexTuplesPerPage < 1.0 can happen too, but they're not very
sensible because every page must have at least one tuple.
AI devised the attached little SQL script to demonstrate that. It gets
stuck looping forever in the loop to determine levelStep, on master, and
with your 0002-gistbuild-Fix-variable-type.patch, too. How about the
attached (clamp-gistInitBuffering.patch), on top of your patch?
- Heikki
| Attachment | Content-Type | Size |
|---|---|---|
| repro-gist-bltone.sql | application/sql | 1.4 KB |
| clamp-gistInitBuffering.patch | text/x-patch | 1.8 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Andrew Dunstan | 2026-12-03 14:57:00 | Re: Table AM callback for logical decoding support (REPACK CONCURRENTLY) |
| Previous Message | Matthias van de Meent | 2026-12-03 14:43:57 | Re: Use local buffer for packed numerics |