Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit26dd028

Browse files
author
Amit Kapila
committed
Add BEGIN/COMMIT for transactional messages during decoding.
In test_decoding module, when skip_empty_xacts option was specified, addBEGIN/COMMIT for transactional messages. This makes the handling oftransactional messages consistent irrespective of whether skip_empty_xactsoption was specified.We decided not to backpatch this change because skip_empty_xacts isprimarily used to have consistent test results across different runs andthis change won't help with that.Author: Vignesh CReviewed-by: Ashutosh Bapat, Hou ZhijieDiscussion:https://postgr.es/m/CAExHW5ujRhbOz6_aTq_jQA8NjeFqq9d_8G9viShWvXx8gdSXiQ@mail.gmail.com
1 parent4e9fa6d commit26dd028

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

‎contrib/test_decoding/expected/messages.out

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,17 +58,23 @@ SELECT 'ignorethis' FROM pg_logical_emit_message(true, 'test', 'czechtastic');
5858
ignorethis
5959
(1 row)
6060

61-
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'force-binary', '0', 'skip-empty-xacts', '1');
61+
SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'force-binary', '0', 'skip-empty-xacts', '1', 'include-xids', '0');
6262
data
6363
--------------------------------------------------------------------
64+
BEGIN
6465
message: transactional: 1 prefix: test, sz: 4 content:msg1
66+
COMMIT
6567
message: transactional: 0 prefix: test, sz: 4 content:msg2
6668
message: transactional: 0 prefix: test, sz: 4 content:msg4
6769
message: transactional: 0 prefix: test, sz: 4 content:msg6
70+
BEGIN
6871
message: transactional: 1 prefix: test, sz: 4 content:msg5
6972
message: transactional: 1 prefix: test, sz: 4 content:msg7
73+
COMMIT
74+
BEGIN
7075
message: transactional: 1 prefix: test, sz: 11 content:czechtastic
71-
(7 rows)
76+
COMMIT
77+
(13 rows)
7278

7379
-- test db filtering
7480
\set prevdb :DBNAME

‎contrib/test_decoding/sql/messages.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ COMMIT;
1919

2020
SELECT'ignorethis'FROM pg_logical_emit_message(true,'test','czechtastic');
2121

22-
SELECT dataFROM pg_logical_slot_get_changes('regression_slot',NULL,NULL,'force-binary','0','skip-empty-xacts','1');
22+
SELECT dataFROM pg_logical_slot_get_changes('regression_slot',NULL,NULL,'force-binary','0','skip-empty-xacts','1','include-xids','0');
2323

2424
-- test db filtering
2525
\set prevdb :DBNAME

‎contrib/test_decoding/test_decoding.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,6 +743,18 @@ pg_decode_message(LogicalDecodingContext *ctx,
743743
ReorderBufferTXN*txn,XLogRecPtrlsn,booltransactional,
744744
constchar*prefix,Sizesz,constchar*message)
745745
{
746+
TestDecodingData*data=ctx->output_plugin_private;
747+
TestDecodingTxnData*txndata;
748+
749+
txndata=transactional ?txn->output_plugin_private :NULL;
750+
751+
/* output BEGIN if we haven't yet for transactional messages */
752+
if (transactional&&data->skip_empty_xacts&& !txndata->xact_wrote_changes)
753+
pg_output_begin(ctx,data,txn, false);
754+
755+
if (transactional)
756+
txndata->xact_wrote_changes= true;
757+
746758
OutputPluginPrepareWrite(ctx, true);
747759
appendStringInfo(ctx->out,"message: transactional: %d prefix: %s, sz: %zu content:",
748760
transactional,prefix,sz);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp