@@ -384,30 +384,31 @@ pg_decode_begin_txn(LogicalDecodingContext *ctx, ReorderBufferTXN *txn)
384
384
send_replication_origin &= txn -> origin_id != InvalidRepOriginId ;
385
385
386
386
OutputPluginPrepareWrite (ctx , !send_replication_origin );
387
- data -> api -> write_begin (ctx -> out , data , txn );
387
+ if (data -> api ) {
388
+ data -> api -> write_begin (ctx -> out , data , txn );
388
389
389
- if (send_replication_origin )
390
- {
391
- char * origin ;
392
-
393
- /* Message boundary */
394
- OutputPluginWrite (ctx , false);
395
- OutputPluginPrepareWrite (ctx , true);
396
-
397
- /*
398
- * XXX: which behaviour we want here?
399
- *
400
- * Alternatives:
401
- * - don't send origin message if origin name not found
402
- * (that's what we do now)
403
- * - throw error - that will break replication, not good
404
- * - send some special "unknown" origin
405
- */
406
- if (data -> api -> write_origin &&
407
- replorigin_by_oid (txn -> origin_id , true, & origin ))
390
+ if (send_replication_origin )
391
+ {
392
+ char * origin ;
393
+
394
+ /* Message boundary */
395
+ OutputPluginWrite (ctx , false);
396
+ OutputPluginPrepareWrite (ctx , true);
397
+
398
+ /*
399
+ * XXX: which behaviour we want here?
400
+ *
401
+ * Alternatives:
402
+ * - don't send origin message if origin name not found
403
+ * (that's what we do now)
404
+ * - throw error - that will break replication, not good
405
+ * - send some special "unknown" origin
406
+ */
407
+ if (data -> api -> write_origin &&
408
+ replorigin_by_oid (txn -> origin_id , true, & origin ))
408
409
data -> api -> write_origin (ctx -> out , origin , txn -> origin_lsn );
410
+ }
409
411
}
410
-
411
412
OutputPluginWrite (ctx , true);
412
413
}
413
414
@@ -421,7 +422,9 @@ pg_decode_commit_txn(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,
421
422
PGLogicalOutputData * data = (PGLogicalOutputData * )ctx -> output_plugin_private ;
422
423
423
424
OutputPluginPrepareWrite (ctx , true);
424
- data -> api -> write_commit (ctx -> out , data , txn , commit_lsn );
425
+ if (data -> api ) {
426
+ data -> api -> write_commit (ctx -> out , data , txn , commit_lsn );
427
+ }
425
428
OutputPluginWrite (ctx , true);
426
429
}
427
430
@@ -433,7 +436,7 @@ pg_decode_change(LogicalDecodingContext *ctx, ReorderBufferTXN *txn,
433
436
MemoryContext old ;
434
437
435
438
/* First check the table filter */
436
- if (!call_row_filter_hook (data , txn , relation , change ))
439
+ if (!call_row_filter_hook (data , txn , relation , change ) || data -> api == NULL )
437
440
return ;
438
441
439
442
/* Avoid leaking memory by using and resetting our own context */
@@ -539,7 +542,9 @@ send_startup_message(LogicalDecodingContext *ctx,
539
542
*/
540
543
541
544
OutputPluginPrepareWrite (ctx , last_message );
542
- data -> api -> write_startup_message (ctx -> out , msg );
545
+ if (data -> api ) {
546
+ data -> api -> write_startup_message (ctx -> out , msg );
547
+ }
543
548
OutputPluginWrite (ctx , last_message );
544
549
545
550
pfree (msg );
0 commit comments