@@ -124,6 +124,7 @@ int wal_sender_timeout = 60 * 1000; /* maximum time to send one WAL
124
124
* data message */
125
125
bool log_replication_commands = false;
126
126
127
+ void (* WalSender_Custom_XLogReaderRoutines )(XLogReaderRoutine * xlr );
127
128
/*
128
129
* State for WalSndWakeupRequest
129
130
*/
@@ -255,7 +256,7 @@ static void WalSndWait(uint32 socket_events, long timeout, uint32 wait_event);
255
256
static void WalSndPrepareWrite (LogicalDecodingContext * ctx , XLogRecPtr lsn , TransactionId xid , bool last_write );
256
257
static void WalSndWriteData (LogicalDecodingContext * ctx , XLogRecPtr lsn , TransactionId xid , bool last_write );
257
258
static void WalSndUpdateProgress (LogicalDecodingContext * ctx , XLogRecPtr lsn , TransactionId xid );
258
- static XLogRecPtr WalSndWaitForWal (XLogRecPtr loc );
259
+ XLogRecPtr WalSndWaitForWal (XLogRecPtr loc );
259
260
static bool TransactionIdInRecentPast (TransactionId xid , uint32 epoch );
260
261
261
262
static void WalSndSegmentOpen (XLogReaderState * state , XLogSegNo nextSegNo ,
@@ -1136,6 +1137,7 @@ StartLogicalReplication(StartReplicationCmd *cmd)
1136
1137
{
1137
1138
StringInfoData buf ;
1138
1139
QueryCompletion qc ;
1140
+ XLogReaderRoutine xlr ;
1139
1141
1140
1142
/* make sure that our requirements are still fulfilled */
1141
1143
CheckLogicalDecodingRequirements ();
@@ -1163,6 +1165,12 @@ StartLogicalReplication(StartReplicationCmd *cmd)
1163
1165
got_STOPPING = true;
1164
1166
}
1165
1167
1168
+ xlr .page_read = logical_read_xlog_page ;
1169
+ xlr .segment_open = WalSndSegmentOpen ;
1170
+ xlr .segment_close = wal_segment_close ;
1171
+ if (WalSender_Custom_XLogReaderRoutines != NULL )
1172
+ WalSender_Custom_XLogReaderRoutines (& xlr );
1173
+
1166
1174
/*
1167
1175
* Create our decoding context, making it start at the previously ack'ed
1168
1176
* position.
@@ -1171,10 +1179,7 @@ StartLogicalReplication(StartReplicationCmd *cmd)
1171
1179
* are reported early.
1172
1180
*/
1173
1181
logical_decoding_ctx =
1174
- CreateDecodingContext (cmd -> startpoint , cmd -> options , false,
1175
- XL_ROUTINE (.page_read = logical_read_xlog_page ,
1176
- .segment_open = WalSndSegmentOpen ,
1177
- .segment_close = wal_segment_close ),
1182
+ CreateDecodingContext (cmd -> startpoint , cmd -> options , false, & xlr ,
1178
1183
WalSndPrepareWrite , WalSndWriteData ,
1179
1184
WalSndUpdateProgress );
1180
1185
xlogreader = logical_decoding_ctx -> reader ;
@@ -1395,7 +1400,7 @@ WalSndUpdateProgress(LogicalDecodingContext *ctx, XLogRecPtr lsn, TransactionId
1395
1400
* if we detect a shutdown request (either from postmaster or client)
1396
1401
* we will return early, so caller must always check.
1397
1402
*/
1398
- static XLogRecPtr
1403
+ XLogRecPtr
1399
1404
WalSndWaitForWal (XLogRecPtr loc )
1400
1405
{
1401
1406
int wakeEvents ;
0 commit comments