From 094d4a0cb69525f478f1452bded176fd2d3d2904 Mon Sep 17 00:00:00 2001
From: Daniel Gustafsson <daniel@yesql.se>
Date: Mon, 8 Jul 2019 16:25:35 +0200
Subject: [PATCH] Fix assertion in decoding multi-insert

The assertion in the code for logical decoding of a multi-insert
didn't take multi-inserts into the catalog into consideration, but
the actual decoding did.  This assertion hasn't tripped since we
don't logically decode catalog inserts and until now there are no
multi inserts into the catalog. If that happens thoug, this assert
will trip so better fix it now.
---
 src/backend/replication/logical/decode.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/backend/replication/logical/decode.c b/src/backend/replication/logical/decode.c
index 151c3ef882..36d43eee2a 100644
--- a/src/backend/replication/logical/decode.c
+++ b/src/backend/replication/logical/decode.c
@@ -974,7 +974,8 @@ DecodeMultiInsert(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
 		ReorderBufferQueueChange(ctx->reorder, XLogRecGetXid(r),
 								 buf->origptr, change);
 	}
-	Assert(data == tupledata + tuplelen);
+	Assert(data == tupledata + tuplelen ||
+		   ~(xlrec->flags & XLH_INSERT_CONTAINS_NEW_TUPLE));
 }
 
 /*
-- 
2.14.1.145.gb3622a4ee

