@@ -126,6 +126,7 @@ int wal_sender_timeout = 60 * 1000; /* maximum time to send one WAL
126
126
* data message */
127
127
bool log_replication_commands = false;
128
128
129
+ void (* WalSender_Custom_XLogReaderRoutines )(XLogReaderRoutine * xlr );
129
130
/*
130
131
* State for WalSndWakeupRequest
131
132
*/
@@ -258,7 +259,7 @@ static void WalSndPrepareWrite(LogicalDecodingContext *ctx, XLogRecPtr lsn, Tran
258
259
static void WalSndWriteData (LogicalDecodingContext * ctx , XLogRecPtr lsn , TransactionId xid , bool last_write );
259
260
static void WalSndUpdateProgress (LogicalDecodingContext * ctx , XLogRecPtr lsn , TransactionId xid ,
260
261
bool skipped_xact );
261
- static XLogRecPtr WalSndWaitForWal (XLogRecPtr loc );
262
+ XLogRecPtr WalSndWaitForWal (XLogRecPtr loc );
262
263
static bool TransactionIdInRecentPast (TransactionId xid , uint32 epoch );
263
264
264
265
static void WalSndSegmentOpen (XLogReaderState * state , XLogSegNo nextSegNo ,
@@ -1261,6 +1262,7 @@ StartLogicalReplication(StartReplicationCmd *cmd)
1261
1262
{
1262
1263
StringInfoData buf ;
1263
1264
QueryCompletion qc ;
1265
+ XLogReaderRoutine xlr ;
1264
1266
1265
1267
/* make sure that our requirements are still fulfilled */
1266
1268
CheckLogicalDecodingRequirements ();
@@ -1288,6 +1290,12 @@ StartLogicalReplication(StartReplicationCmd *cmd)
1288
1290
got_STOPPING = true;
1289
1291
}
1290
1292
1293
+ xlr .page_read = logical_read_xlog_page ;
1294
+ xlr .segment_open = WalSndSegmentOpen ;
1295
+ xlr .segment_close = wal_segment_close ;
1296
+ if (WalSender_Custom_XLogReaderRoutines != NULL )
1297
+ WalSender_Custom_XLogReaderRoutines (& xlr );
1298
+
1291
1299
/*
1292
1300
* Create our decoding context, making it start at the previously ack'ed
1293
1301
* position.
@@ -1296,10 +1304,7 @@ StartLogicalReplication(StartReplicationCmd *cmd)
1296
1304
* are reported early.
1297
1305
*/
1298
1306
logical_decoding_ctx =
1299
- CreateDecodingContext (cmd -> startpoint , cmd -> options , false,
1300
- XL_ROUTINE (.page_read = logical_read_xlog_page ,
1301
- .segment_open = WalSndSegmentOpen ,
1302
- .segment_close = wal_segment_close ),
1307
+ CreateDecodingContext (cmd -> startpoint , cmd -> options , false, & xlr ,
1303
1308
WalSndPrepareWrite , WalSndWriteData ,
1304
1309
WalSndUpdateProgress );
1305
1310
xlogreader = logical_decoding_ctx -> reader ;
@@ -1547,7 +1552,7 @@ WalSndUpdateProgress(LogicalDecodingContext *ctx, XLogRecPtr lsn, TransactionId
1547
1552
* if we detect a shutdown request (either from postmaster or client)
1548
1553
* we will return early, so caller must always check.
1549
1554
*/
1550
- static XLogRecPtr
1555
+ XLogRecPtr
1551
1556
WalSndWaitForWal (XLogRecPtr loc )
1552
1557
{
1553
1558
int wakeEvents ;
0 commit comments