Hi,
On 2026-04-04 01:21:53 -0400, Andres Freund wrote:
> > +StaticAssertDecl(INDEX_SCAN_MAX_BATCHES <= PG_UINT8_MAX + 1,
> > + "INDEX_SCAN_MAX_BATCHES must fit in uint8 ring buffer indexes");
>
> I'd just use a < without the + 1 on the other side :)
Actually, I think there are actual issues around this. Once you set
INDEX_SCAN_MAX_BATCHES to 256, there are a lot of, justified looking,
warnings.
[1/1 1 100%] Compiling C object src/backend/postgres_lib.a.p/access_heap_heapam_handler.c.o
In file included from ../../../../../home/andres/src/postgresql/src/include/access/heapam.h:19,
from ../../../../../home/andres/src/postgresql/src/backend/access/heap/heapam_handler.c:23:
../../../../../home/andres/src/postgresql/src/include/access/relscan.h: In function 'index_scan_batch_full':
../../../../../home/andres/src/postgresql/src/include/access/relscan.h:488:45: warning: comparison is always false due
tolimited range of data type [-Wtype-limits]
488 | return index_scan_batch_count(scan) == INDEX_SCAN_MAX_BATCHES;
| ^~
I'm also not sure this is actually quite right
/*
* Do we already have a batch loaded at 'idx' offset in scan's ring buffer?
*
* NOTE: a stale batch idx can alias a currently-loaded range after uint8
* overflow, producing a false positive. False negatives are not possible.
*/
static inline bool
index_scan_batch_loaded(IndexScanDescData *scan, uint8 idx)
{
return (int8) (idx - scan->batchringbuf.headBatch) >= 0 &&
(int8) (idx - scan->batchringbuf.nextBatch) < 0;
}
once the differences between the values don't fit into an int8 anymore. But
I'm tired.
Greetings,
Andres Freund