Skip to content

Commit 5be673a

Browse files
committed
fix bug in 2pc decoding
1 parent 3f3082c commit 5be673a

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

contrib/test_decoding/expected/prepared.out

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,26 +45,32 @@ SELECT data FROM pg_logical_slot_get_changes('regression_slot', NULL, NULL, 'inc
4545
BEGIN
4646
table public.test_prepared1: INSERT: id[integer]:1
4747
COMMIT
48+
COMMIT
4849
BEGIN
4950
table public.test_prepared1: INSERT: id[integer]:2
5051
COMMIT
5152
BEGIN
52-
table public.test_prepared1: INSERT: id[integer]:4
53+
table public.test_prepared1: INSERT: id[integer]:3
54+
COMMIT
5355
COMMIT
5456
BEGIN
55-
table public.test_prepared2: INSERT: id[integer]:7
57+
table public.test_prepared1: INSERT: id[integer]:4
5658
COMMIT
5759
BEGIN
5860
table public.test_prepared1: INSERT: id[integer]:5
5961
table public.test_prepared1: INSERT: id[integer]:6 data[text]:'frakbar'
6062
COMMIT
6163
BEGIN
64+
table public.test_prepared2: INSERT: id[integer]:7
65+
COMMIT
66+
COMMIT
67+
BEGIN
6268
table public.test_prepared1: INSERT: id[integer]:8 data[text]:null
6369
COMMIT
6470
BEGIN
6571
table public.test_prepared2: INSERT: id[integer]:9
6672
COMMIT
67-
(22 rows)
73+
(28 rows)
6874

6975
SELECT pg_drop_replication_slot('regression_slot');
7076
pg_drop_replication_slot

src/backend/replication/logical/decode.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -640,15 +640,16 @@ DecodeCommit(LogicalDecodingContext *ctx, XLogRecordBuffer *buf,
640640
* empty. So we can skip use shortcut for coomiting bare xact.
641641
*/
642642
strcpy(ctx->reorder->gid, parsed->twophase_gid);
643+
*ctx->reorder->state_3pc = '\0';
643644
ReorderBufferCommitBareXact(ctx->reorder, xid, buf->origptr, buf->endptr,
644645
commit_time, origin_id, origin_lsn);
645646
} else {
647+
*ctx->reorder->gid = '\0';
648+
*ctx->reorder->state_3pc = '\0';
646649
/* replay actions of all transaction + subtransactions in order */
647650
ReorderBufferCommit(ctx->reorder, xid, buf->origptr, buf->endptr,
648651
commit_time, origin_id, origin_lsn);
649-
*ctx->reorder->gid = '\0';
650652
}
651-
*ctx->reorder->state_3pc = '\0';
652653
}
653654

654655
static void

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy