diff --git a/src/backend/replication/slotfuncs.c b/src/backend/replication/slotfuncs.c index 31e74d38322..4a0819566bc 100644 --- a/src/backend/replication/slotfuncs.c +++ b/src/backend/replication/slotfuncs.c @@ -34,6 +34,8 @@ check_permissions(void) errmsg("must be superuser or replication role to use replication slots"))); } +void (*SlotFuncs_Custom_XLogReaderRoutines)(XLogReaderRoutine *xlr); + /* * Helper function for creating a new physical replication slot with * given arguments. Note that this function doesn't release the created @@ -504,6 +506,14 @@ pg_logical_replication_slot_advance(XLogRecPtr moveto) PG_TRY(); { + XLogReaderRoutine xlr; + xlr.page_read = read_local_xlog_page; + xlr.segment_open = wal_segment_open; + xlr.segment_close = wal_segment_close; + + if (SlotFuncs_Custom_XLogReaderRoutines != NULL) + SlotFuncs_Custom_XLogReaderRoutines(&xlr); + /* * Create our decoding context in fast_forward mode, passing start_lsn * as InvalidXLogRecPtr, so that we start processing from my slot's @@ -512,9 +522,7 @@ pg_logical_replication_slot_advance(XLogRecPtr moveto) ctx = CreateDecodingContext(InvalidXLogRecPtr, NIL, true, /* fast_forward */ - XL_ROUTINE(.page_read = read_local_xlog_page, - .segment_open = wal_segment_open, - .segment_close = wal_segment_close), + &xlr, NULL, NULL, NULL); /* diff --git a/src/include/replication/slot.h b/src/include/replication/slot.h index c0fca56bee5..c4badf6b866 100644 --- a/src/include/replication/slot.h +++ b/src/include/replication/slot.h @@ -169,6 +169,8 @@ typedef struct ReplicationSlot #define SlotIsPhysical(slot) ((slot)->data.database == InvalidOid) #define SlotIsLogical(slot) ((slot)->data.database != InvalidOid) +extern void (*SlotFuncs_Custom_XLogReaderRoutines)(XLogReaderRoutine *xlr); + /* * Shared memory control area for all of replication slots. */