@@ -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 ,
@@ -1260,6 +1261,7 @@ StartLogicalReplication(StartReplicationCmd *cmd)
1260
1261
{
1261
1262
StringInfoData buf ;
1262
1263
QueryCompletion qc ;
1264
+ XLogReaderRoutine xlr ;
1263
1265
1264
1266
/* make sure that our requirements are still fulfilled */
1265
1267
CheckLogicalDecodingRequirements ();
@@ -1280,6 +1282,12 @@ StartLogicalReplication(StartReplicationCmd *cmd)
1280
1282
got_STOPPING = true;
1281
1283
}
1282
1284
1285
+ xlr .page_read = logical_read_xlog_page ;
1286
+ xlr .segment_open = WalSndSegmentOpen ;
1287
+ xlr .segment_close = wal_segment_close ;
1288
+ if (WalSender_Custom_XLogReaderRoutines != NULL )
1289
+ WalSender_Custom_XLogReaderRoutines (& xlr );
1290
+
1283
1291
/*
1284
1292
* Create our decoding context, making it start at the previously ack'ed
1285
1293
* position.
@@ -1288,10 +1296,7 @@ StartLogicalReplication(StartReplicationCmd *cmd)
1288
1296
* are reported early.
1289
1297
*/
1290
1298
logical_decoding_ctx =
1291
- CreateDecodingContext (cmd -> startpoint , cmd -> options , false,
1292
- XL_ROUTINE (.page_read = logical_read_xlog_page ,
1293
- .segment_open = WalSndSegmentOpen ,
1294
- .segment_close = wal_segment_close ),
1299
+ CreateDecodingContext (cmd -> startpoint , cmd -> options , false, & xlr ,
1295
1300
WalSndPrepareWrite , WalSndWriteData ,
1296
1301
WalSndUpdateProgress );
1297
1302
xlogreader = logical_decoding_ctx -> reader ;
@@ -1539,7 +1544,7 @@ WalSndUpdateProgress(LogicalDecodingContext *ctx, XLogRecPtr lsn, TransactionId
1539
1544
* if we detect a shutdown request (either from postmaster or client)
1540
1545
* we will return early, so caller must always check.
1541
1546
*/
1542
- static XLogRecPtr
1547
+ XLogRecPtr
1543
1548
WalSndWaitForWal (XLogRecPtr loc )
1544
1549
{
1545
1550
int wakeEvents ;
0 commit comments