On 2022-Feb-13, Tomas Vondra wrote: > >> Fixing the tests however uncovered a bug in the code, because sequence > >> callbacks did not handle skip-empty-xacts properly. For trasactional > >> increments we need to check/update the xact_wrote_changes flag, and emit > >> the BEGIN if it's the first change in the transaction. > > > > Hmm. Perhaps there should be a separate test script that runs various > > things under skip-empty-xacts=0 and somehow protected against ancillary > > activities (maybe a TAP test using autovacuum=0), just so that this new > > code is covered ... > > I'm not sure what exactly would be the benefit?
Yeah, it's pointless. I propose the attached comment additions instead. -- Álvaro Herrera 39°49'30"S 73°17'W — https://www.EnterpriseDB.com/
diff --git a/contrib/test_decoding/test_decoding.c b/contrib/test_decoding/test_decoding.c index ea22649e41..c7a87f5fe5 100644 --- a/contrib/test_decoding/test_decoding.c +++ b/contrib/test_decoding/test_decoding.c @@ -322,6 +322,10 @@ pg_decode_begin_txn(LogicalDecodingContext *ctx, ReorderBufferTXN *txn) txndata->xact_wrote_changes = false; txn->output_plugin_private = txndata; + /* + * If asked to skip empty transactions, we'll emit BEGIN at the point where + * the first operation is received for this transaction. + */ if (data->skip_empty_xacts) return; @@ -378,6 +382,10 @@ pg_decode_begin_prepare_txn(LogicalDecodingContext *ctx, ReorderBufferTXN *txn) txndata->xact_wrote_changes = false; txn->output_plugin_private = txndata; + /* + * If asked to skip empty transactions, we'll emit BEGIN at the point where + * the first operation is received for this transaction. + */ if (data->skip_empty_xacts) return; @@ -392,6 +400,10 @@ pg_decode_prepare_txn(LogicalDecodingContext *ctx, ReorderBufferTXN *txn, TestDecodingData *data = ctx->output_plugin_private; TestDecodingTxnData *txndata = txn->output_plugin_private; + /* + * If asked to skip empty transactions, we'll emit PREPARE at the point + * where the first operation is received for this transaction. + */ if (data->skip_empty_xacts && !txndata->xact_wrote_changes) return;