On Thu, Feb 27, 2025 at 1:08 PM Tom Lane <t...@sss.pgh.pa.us> wrote: > > I wonder if it'd be a good idea to add something like > > Assert(stream->distance == 1); > Assert(stream->pending_read_nblocks == 0); > Assert(stream->per_buffer_data_size == 0); > + Assert(per_buffer_data == NULL); > > in read_stream_next_buffer. I doubt that this will shut Coverity > up, but it would help to catch caller coding errors, i.e. passing > a per_buffer_data pointer when there's no per-buffer data.
I think this is a good stopgap. I was discussing adding this assert off-list with Thomas and he wanted to detail his more ambitious plans for type safety improvements in the read stream API. Less on the order of a redesign and more like a separate read_stream_next_buffer()s for when there is per buffer data and when there isn't. And a by-value and by-reference version for the one where there is data. I'll plan to add this assert tomorrow if that discussion doesn't materialize. - Melanie