From d3be106cb320fbbcf2056929460497b005d33969 Mon Sep 17 00:00:00 2001 From: Sasha Krassovsky Date: Tue, 4 Jun 2024 09:31:27 -0700 Subject: [PATCH] Add on-demand WAL download to logicalfuncs --- src/backend/replication/logical/logicalfuncs.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/backend/replication/logical/logicalfuncs.c b/src/backend/replication/logical/logicalfuncs.c index dc29b6c6740..987542b1d61 100644 --- a/src/backend/replication/logical/logicalfuncs.c +++ b/src/backend/replication/logical/logicalfuncs.c @@ -40,6 +40,8 @@ #include "utils/regproc.h" #include "utils/resowner.h" +void (*LogicalFuncs_Custom_XLogReaderRoutines)(XLogReaderRoutine *xlr); + /* Private data for writing out data */ typedef struct DecodingOutputState { @@ -205,13 +207,19 @@ pg_logical_slot_get_changes_guts(FunctionCallInfo fcinfo, bool confirm, bool bin PG_TRY(); { + XLogReaderRoutine xlr; + xlr.page_read = read_local_xlog_page; + xlr.segment_open = wal_segment_open; + xlr.segment_close = wal_segment_close; + + if (LogicalFuncs_Custom_XLogReaderRoutines != NULL) + LogicalFuncs_Custom_XLogReaderRoutines(&xlr); + /* restart at slot's confirmed_flush */ ctx = CreateDecodingContext(InvalidXLogRecPtr, options, false, - XL_ROUTINE(.page_read = read_local_xlog_page, - .segment_open = wal_segment_open, - .segment_close = wal_segment_close), + &xlr, LogicalOutputPrepareWrite, LogicalOutputWrite, NULL);