diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c
index 0cdb6af052d0777a634dc7dc493c5e072c933606..419736da3103ddc65aaf09ed614a90a7ed1fd307 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);