diff options
author | Amit Kapila | 2023-07-11 03:01:11 +0000 |
---|---|---|
committer | Amit Kapila | 2023-07-11 03:01:11 +0000 |
commit | 26dd0284b98f6bf730dc1f7f7e1f917525d71eda (patch) | |
tree | a6ecae28f2f1e4dc406c81102a93df8075cb9b27 /contrib/test_decoding/test_decoding.c | |
parent | 4e9fa6d56b3e4e1b6238fb24200e6baece229401 (diff) |
Add BEGIN/COMMIT for transactional messages during decoding.
In test_decoding module, when skip_empty_xacts option was specified, add
BEGIN/COMMIT for transactional messages. This makes the handling of
transactional messages consistent irrespective of whether skip_empty_xacts
option was specified.
We decided not to backpatch this change because skip_empty_xacts is
primarily used to have consistent test results across different runs and
this change won't help with that.
Author: Vignesh C
Reviewed-by: Ashutosh Bapat, Hou Zhijie
Discussion: https://postgr.es/m/CAExHW5ujRhbOz6_aTq_jQA8NjeFqq9d_8G9viShWvXx8gdSXiQ@mail.gmail.com
Diffstat (limited to 'contrib/test_decoding/test_decoding.c')
-rw-r--r-- | contrib/test_decoding/test_decoding.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/contrib/test_decoding/test_decoding.c b/contrib/test_decoding/test_decoding.c index 12d1d0505d7..ab870d9e4dc 100644 --- a/contrib/test_decoding/test_decoding.c +++ b/contrib/test_decoding/test_decoding.c @@ -743,6 +743,18 @@ pg_decode_message(LogicalDecodingContext *ctx, ReorderBufferTXN *txn, XLogRecPtr lsn, bool transactional, const char *prefix, Size sz, const char *message) { + TestDecodingData *data = ctx->output_plugin_private; + TestDecodingTxnData *txndata; + + txndata = transactional ? txn->output_plugin_private : NULL; + + /* output BEGIN if we haven't yet for transactional messages */ + if (transactional && data->skip_empty_xacts && !txndata->xact_wrote_changes) + pg_output_begin(ctx, data, txn, false); + + if (transactional) + txndata->xact_wrote_changes = true; + OutputPluginPrepareWrite(ctx, true); appendStringInfo(ctx->out, "message: transactional: %d prefix: %s, sz: %zu content:", transactional, prefix, sz); |