diff --git a/src/backend/replication/logical/decode.c b/src/backend/replication/logical/decode.c index 6de54153f7..f3c561d8ed 100644 --- a/src/backend/replication/logical/decode.c +++ b/src/backend/replication/logical/decode.c @@ -631,7 +631,7 @@ logicalmsg_decode(LogicalDecodingContext *ctx, XLogRecordBuffer *buf) if (ctx->decoding_mode == DECODING_MODE_SILENT && !message->transactional) { - ctx->output_skipped = true; + ctx->processing_required = true; return; } @@ -1294,8 +1294,6 @@ DecodeXLogTuple(char *data, Size len, ReorderBufferTupleBuf *tuple) * 2) The transaction happened in another database. * 3) The output plugin is not interested in the origin. * 4) We are not in the normal decoding mode. - * - * Also, set output_skipped flag if we are in the slient mode. */ static bool DecodeTXNNeedSkip(LogicalDecodingContext *ctx, XLogRecordBuffer *buf, @@ -1308,9 +1306,15 @@ DecodeTXNNeedSkip(LogicalDecodingContext *ctx, XLogRecordBuffer *buf, ctx->decoding_mode != DECODING_MODE_NORMAL || FilterByOrigin(ctx, origin_id)); - /* Set a flag if we are in the slient mode */ + if (need_skip) + return true; + + /* + * We don't need to process the transaction in silent mode. Indicate the + * same via LogicalDecodingContext, so that the caller can skip processing. + */ if (ctx->decoding_mode == DECODING_MODE_SILENT) - ctx->output_skipped = true; + ctx->processing_required = true; - return need_skip; + return true; } diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c index 0f4b1c6323..e47f2ebd7c 100644 --- a/src/backend/replication/logical/logical.c +++ b/src/backend/replication/logical/logical.c @@ -2030,7 +2030,7 @@ DecodingContextHasdecodedItems(LogicalDecodingContext *ctx, InvalidateSystemCaches(); /* Loop until the end of WAL or some changes are processed */ - while (!ctx->output_skipped && ctx->reader->EndRecPtr < end_of_wal) + while (!ctx->processing_required && ctx->reader->EndRecPtr < end_of_wal) { XLogRecord *record; char *errm = NULL; @@ -2046,5 +2046,5 @@ DecodingContextHasdecodedItems(LogicalDecodingContext *ctx, CHECK_FOR_INTERRUPTS(); } - return ctx->output_skipped; + return ctx->processing_required; } diff --git a/src/include/replication/logical.h b/src/include/replication/logical.h index d0f9dda6c5..94cc631a5b 100644 --- a/src/include/replication/logical.h +++ b/src/include/replication/logical.h @@ -128,12 +128,8 @@ typedef struct LogicalDecodingContext /* Are we processing the end LSN of a transaction? */ bool end_xact; - /* - * Did the logical decoding context skip outputting any changes? - * - * This flag is used only when the context is in the silent mode. - */ - bool output_skipped; + /* Do we need to process any change in silent decoding mode? */ + bool processing_required; } LogicalDecodingContext;