public inbox for [email protected]
help / color / mirror / Atom feedFrom: Amit Kapila <[email protected]>
To: vignesh C <[email protected]>
Cc: Zhijie Hou (Fujitsu) <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Cc: Ashutosh Bapat <[email protected]>
Subject: Re: pg_decode_message vs skip_empty_xacts and xact_wrote_changes
Date: Wed, 5 Jul 2023 14:28:56 +0530
Message-ID: <CAA4eK1KPvbtpCJUuU6ZaZ=6BuBEvAzLCHNniNG98g0tOo3CkNA@mail.gmail.com> (raw)
In-Reply-To: <CAA4eK1LA=gb0xyg+-93WJOX1EEJE8qroPQnNw==DreuW2VDm7g@mail.gmail.com>
References: <CAExHW5ujRhbOz6_aTq_jQA8NjeFqq9d_8G9viShWvXx8gdSXiQ@mail.gmail.com>
<CAA4eK1JLRiW_Mkps+oGu_a1DZHJqhoXV9Ru33B4hV5UYUtLPJg@mail.gmail.com>
<CALDaNm1bfwt=hmZD7V17t-giJLw3kndLBxLzSD+oSXNfMmGVsw@mail.gmail.com>
<CAExHW5sqY8AS5WqyTD1v=V+pAZvtHXcZ5++2z1fn7NcpBmhj_g@mail.gmail.com>
<CALDaNm0fWoS7eX9o3iVq8NwynpvAKKFK0YPEXWDTgBEOOjvFkw@mail.gmail.com>
<OS0PR01MB57161E8D61ACCF34D505FBDA9425A@OS0PR01MB5716.jpnprd01.prod.outlook.com>
<CALDaNm14bBNi60JaveK-WDgjYsDxa5ArRWzj2JrjQgc9CBzYiw@mail.gmail.com>
<CAA4eK1J-_g8ruuOKTXA7sGjRASBG7XsXpHzpz324ygEd+HmsvA@mail.gmail.com>
<CALDaNm3Hj72XtEcn_nRm4t4c59gaYCJk=-aeaJT47ktoAmBUNQ@mail.gmail.com>
<CAA4eK1LA=gb0xyg+-93WJOX1EEJE8qroPQnNw==DreuW2VDm7g@mail.gmail.com>
On Wed, Jul 5, 2023 at 2:28 PM Amit Kapila <[email protected]> wrote:
>
> On Mon, Jul 3, 2023 at 4:49 PM vignesh C <[email protected]> wrote:
> >
> > +1 for the first version patch, I also felt the first version is
> > easily understandable.
> >
>
> Okay, please find the slightly updated version (changed a comment and
> commit message). Unless there are more comments, I'll push this in a
> day or two.
>
oops, forgot to attach the patch.
--
With Regards,
Amit Kapila.
Attachments:
[application/octet-stream] v3-0001-Add-BEGIN-COMMIT-for-transactional-messages-durin.patch (3.9K, ../CAA4eK1KPvbtpCJUuU6ZaZ=6BuBEvAzLCHNniNG98g0tOo3CkNA@mail.gmail.com/2-v3-0001-Add-BEGIN-COMMIT-for-transactional-messages-durin.patch)
download | inline diff:
From 28573cb6932ead7f3f399faac25bdea08fdd48c8 Mon Sep 17 00:00:00 2001
From: Vignesh C <[email protected]>
Date: Wed, 28 Jun 2023 14:01:22 +0530
Subject: [PATCH v3] 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
---
contrib/test_decoding/expected/messages.out | 10 ++++++++--
contrib/test_decoding/sql/messages.sql | 2 +-
contrib/test_decoding/test_decoding.c | 12 ++++++++++++
3 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/contrib/test_decoding/expected/messages.out b/contrib/test_decoding/expected/messages.out
index c75d40190b..0fd70036bd 100644
--- a/contrib/test_decoding/expected/messages.out
+++ b/contrib/test_decoding/expected/messages.out
@@ -58,17 +58,23 @@ SELECT 'ignorethis' FROM pg_logical_emit_message(true, 'test', 'czechtastic');
ignorethis
(1 row)
-SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'force-binary', '0', 'skip-empty-xacts', '1');
+SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'force-binary', '0', 'skip-empty-xacts', '1', 'include-xids', '0');
data
--------------------------------------------------------------------
+ BEGIN
message: transactional: 1 prefix: test, sz: 4 content:msg1
+ COMMIT
message: transactional: 0 prefix: test, sz: 4 content:msg2
message: transactional: 0 prefix: test, sz: 4 content:msg4
message: transactional: 0 prefix: test, sz: 4 content:msg6
+ BEGIN
message: transactional: 1 prefix: test, sz: 4 content:msg5
message: transactional: 1 prefix: test, sz: 4 content:msg7
+ COMMIT
+ BEGIN
message: transactional: 1 prefix: test, sz: 11 content:czechtastic
-(7 rows)
+ COMMIT
+(13 rows)
-- test db filtering
\set prevdb :DBNAME
diff --git a/contrib/test_decoding/sql/messages.sql b/contrib/test_decoding/sql/messages.sql
index cf3f7738e5..3d8500f99c 100644
--- a/contrib/test_decoding/sql/messages.sql
+++ b/contrib/test_decoding/sql/messages.sql
@@ -19,7 +19,7 @@ COMMIT;
SELECT 'ignorethis' FROM pg_logical_emit_message(true, 'test', 'czechtastic');
-SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'force-binary', '0', 'skip-empty-xacts', '1');
+SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'force-binary', '0', 'skip-empty-xacts', '1', 'include-xids', '0');
-- test db filtering
\set prevdb :DBNAME
diff --git a/contrib/test_decoding/test_decoding.c b/contrib/test_decoding/test_decoding.c
index 12d1d0505d..ab870d9e4d 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);
--
2.28.0.windows.1
view thread (7+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected], [email protected]
Subject: Re: pg_decode_message vs skip_empty_xacts and xact_wrote_changes
In-Reply-To: <CAA4eK1KPvbtpCJUuU6ZaZ=6BuBEvAzLCHNniNG98g0tOo3CkNA@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox