@@ -117,7 +117,8 @@ StartupDecodingContext(List *output_plugin_options,
117117 bool need_full_snapshot ,
118118 XLogPageReadCB read_page ,
119119 LogicalOutputPluginWriterPrepareWrite prepare_write ,
120- LogicalOutputPluginWriterWrite do_write )
120+ LogicalOutputPluginWriterWrite do_write ,
121+ LogicalOutputPluginWriterUpdateProgress update_progress )
121122{
122123 ReplicationSlot * slot ;
123124 MemoryContext context ,
@@ -186,6 +187,7 @@ StartupDecodingContext(List *output_plugin_options,
186187 ctx -> out = makeStringInfo ();
187188 ctx -> prepare_write = prepare_write ;
188189 ctx -> write = do_write ;
190+ ctx -> update_progress = update_progress ;
189191
190192 ctx -> output_plugin_options = output_plugin_options ;
191193
@@ -199,8 +201,9 @@ StartupDecodingContext(List *output_plugin_options,
199201 *
200202 * plugin contains the name of the output plugin
201203 * output_plugin_options contains options passed to the output plugin
202- * read_page, prepare_write, do_write are callbacks that have to be filled to
203- * perform the use-case dependent, actual, work.
204+ * read_page, prepare_write, do_write, update_progress
205+ * callbacks that have to be filled to perform the use-case dependent,
206+ * actual, work.
204207 *
205208 * Needs to be called while in a memory context that's at least as long lived
206209 * as the decoding context because further memory contexts will be created
@@ -215,7 +218,8 @@ CreateInitDecodingContext(char *plugin,
215218 bool need_full_snapshot ,
216219 XLogPageReadCB read_page ,
217220 LogicalOutputPluginWriterPrepareWrite prepare_write ,
218- LogicalOutputPluginWriterWrite do_write )
221+ LogicalOutputPluginWriterWrite do_write ,
222+ LogicalOutputPluginWriterUpdateProgress update_progress )
219223{
220224 TransactionId xmin_horizon = InvalidTransactionId ;
221225 ReplicationSlot * slot ;
@@ -300,7 +304,7 @@ CreateInitDecodingContext(char *plugin,
300304
301305 ctx = StartupDecodingContext (NIL , InvalidXLogRecPtr , xmin_horizon ,
302306 need_full_snapshot , read_page , prepare_write ,
303- do_write );
307+ do_write , update_progress );
304308
305309 /* call output plugin initialization callback */
306310 old_context = MemoryContextSwitchTo (ctx -> context );
@@ -324,7 +328,7 @@ CreateInitDecodingContext(char *plugin,
324328 * output_plugin_options
325329 * contains options passed to the output plugin.
326330 *
327- * read_page, prepare_write, do_write
331+ * read_page, prepare_write, do_write, update_progress
328332 * callbacks that have to be filled to perform the use-case dependent,
329333 * actual work.
330334 *
@@ -340,7 +344,8 @@ CreateDecodingContext(XLogRecPtr start_lsn,
340344 List * output_plugin_options ,
341345 XLogPageReadCB read_page ,
342346 LogicalOutputPluginWriterPrepareWrite prepare_write ,
343- LogicalOutputPluginWriterWrite do_write )
347+ LogicalOutputPluginWriterWrite do_write ,
348+ LogicalOutputPluginWriterUpdateProgress update_progress )
344349{
345350 LogicalDecodingContext * ctx ;
346351 ReplicationSlot * slot ;
@@ -390,7 +395,8 @@ CreateDecodingContext(XLogRecPtr start_lsn,
390395
391396 ctx = StartupDecodingContext (output_plugin_options ,
392397 start_lsn , InvalidTransactionId , false,
393- read_page , prepare_write , do_write );
398+ read_page , prepare_write , do_write ,
399+ update_progress );
394400
395401 /* call output plugin initialization callback */
396402 old_context = MemoryContextSwitchTo (ctx -> context );
@@ -503,6 +509,18 @@ OutputPluginWrite(struct LogicalDecodingContext *ctx, bool last_write)
503509 ctx -> prepared_write = false;
504510}
505511
512+ /*
513+ * Update progress tracking (if supported).
514+ */
515+ void
516+ OutputPluginUpdateProgress (struct LogicalDecodingContext * ctx )
517+ {
518+ if (!ctx -> update_progress )
519+ return ;
520+
521+ ctx -> update_progress (ctx , ctx -> write_location , ctx -> write_xid );
522+ }
523+
506524/*
507525 * Load the output plugin, lookup its output plugin init function, and check
508526 * that it provides the required callbacks.
0 commit comments