From ec3d976bce7e322c29f1007d19b63b7a3a1a6ee4 Mon Sep 17 00:00:00 2001
From: Heikki Linnakangas <heikki.linnakangas@iki.fi>
Date: Mon, 4 May 2015 20:58:42 +0300
Subject: [PATCH] Fix the same-rel optimization when creating WAL records.

prev_regbuf was never set, and therefore the same-rel flag was never set on
WAL records.

Report and fix by Zhanq Zq
---
 src/backend/access/transam/xloginsert.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c
index 0cdb6af052d..419736da310 100644
--- a/src/backend/access/transam/xloginsert.c
+++ b/src/backend/access/transam/xloginsert.c
@@ -667,10 +667,10 @@ XLogRecordAssemble(RmgrId rmid, uint8 info,
 		{
 			samerel = true;
 			bkpb.fork_flags |= BKPBLOCK_SAME_REL;
-			prev_regbuf = regbuf;
 		}
 		else
 			samerel = false;
+		prev_regbuf = regbuf;
 
 		/* Ok, copy the header to the scratch buffer */
 		memcpy(scratch, &bkpb, SizeOfXLogRecordBlockHeader);
-- 
GitLab