diff --git a/src/backend/storage/aio/read_stream.c b/src/backend/storage/aio/read_stream.c index 7f0e07d958..b8ea1180e2 100644 --- a/src/backend/storage/aio/read_stream.c +++ b/src/backend/storage/aio/read_stream.c @@ -797,6 +797,20 @@ read_stream_next_buffer(ReadStream *stream, void **per_buffer_data) return buffer; } +/* + * Transitional support for code that would like to perform or skip reads + * itself, without using the stream. Returns, and consumes, the next block + * number that would be read by the stream's look-ahead algorithm, or + * InvalidBlockNumber if the end of the stream is reached. Also reports the + * strategy that would be used to read it. + */ +BlockNumber +read_stream_next_block(ReadStream *stream, BufferAccessStrategy *strategy) +{ + *strategy = stream->ios[0].op.strategy; + return read_stream_get_block(stream, NULL); +} + /* * Reset a read stream by releasing any queued up buffers, allowing the stream * to be used again for different blocks. This can be used to clear an diff --git a/src/include/storage/read_stream.h b/src/include/storage/read_stream.h index 2f94ee744b..2f98b600f7 100644 --- a/src/include/storage/read_stream.h +++ b/src/include/storage/read_stream.h @@ -68,6 +68,8 @@ extern ReadStream *read_stream_begin_relation(int flags, void *callback_private_data, size_t per_buffer_data_size); extern Buffer read_stream_next_buffer(ReadStream *stream, void **per_buffer_data); +extern BlockNumber read_stream_next_block(ReadStream *stream, + BufferAccessStrategy *strategy); extern ReadStream *read_stream_begin_smgr_relation(int flags, BufferAccessStrategy strategy, SMgrRelation smgr,