From f684ba1a941912bfe57c256a080cb8f6e49e8871 Mon Sep 17 00:00:00 2001
From: Mats Kindahl <mats@timescale.com>
Date: Thu, 22 Aug 2024 09:25:30 +0200
Subject: Add accessors for ReadStream

Add accessors to be able to retrieve the buffer access strategy as well
as the callback with its private data.
---
 src/backend/storage/aio/read_stream.c | 19 +++++++++++++++++++
 src/include/storage/read_stream.h     |  4 ++++
 2 files changed, 23 insertions(+)

diff --git a/src/backend/storage/aio/read_stream.c b/src/backend/storage/aio/read_stream.c
index 684b6d6fc0..02c9ad229f 100644
--- a/src/backend/storage/aio/read_stream.c
+++ b/src/backend/storage/aio/read_stream.c
@@ -852,3 +852,22 @@ read_stream_end(ReadStream *stream)
 	read_stream_reset(stream);
 	pfree(stream);
 }
+
+BufferAccessStrategy
+read_stream_get_access_strategy(ReadStream *stream)
+{
+	/*
+	 * All the streams have the same strategy and there is at least one, so we
+	 * can safely get the first one.
+	 */
+	return stream->ios[0].op.strategy;
+}
+
+void
+read_stream_get_callback(ReadStream *stream,
+						 ReadStreamBlockNumberCB *callback,
+						 void **callback_private_data)
+{
+	*callback = stream->callback;
+	*callback_private_data = stream->callback_private_data;
+}
diff --git a/src/include/storage/read_stream.h b/src/include/storage/read_stream.h
index 4e599904f2..0da73719e5 100644
--- a/src/include/storage/read_stream.h
+++ b/src/include/storage/read_stream.h
@@ -69,5 +69,9 @@ extern ReadStream *read_stream_begin_smgr_relation(int flags,
 extern Buffer read_stream_next_buffer(ReadStream *stream, void **per_buffer_private);
 extern void read_stream_reset(ReadStream *stream);
 extern void read_stream_end(ReadStream *stream);
+extern BufferAccessStrategy read_stream_get_access_strategy(ReadStream *stream);
+extern void read_stream_get_callback(ReadStream *stream,
+									 ReadStreamBlockNumberCB *callback,
+									 void **callback_private_data);
 
 #endif							/* READ_STREAM_H */
-- 
2.34.1

