BUG in XLogRecordAssemble

Started by Zhang Zqover 10 years ago3 messages
#1Zhang Zq
zqzhangmail@163.com
1 attachment(s)

hi,
I found the code in 'backend/access/transam/xloginsert.c' as that:
XLogRecordAssemble:
if (prev_regbuf && RelFileNodeEquals(regbuf->rnode, prev_regbuf->rnode))
{
samerel = true;
bkpb.fork_flags |= BKPBLOCK_SAME_REL;
prev_regbuf = regbuf;
}
else
samerel = false;

There is the only place that prev_regbuf is assigned, so prev_regbuf will never be assigned.
The patch will fix it, Thanks.
Zhang Zq

Attachments:

XLogRecordAssemble.patchapplication/octet-stream; name=XLogRecordAssemble.patchDownload
*** a/src/backend/access/transam/xloginsert.c
--- b/src/backend/access/transam/xloginsert.c
***************
*** 667,676 **** XLogRecordAssemble(RmgrId rmid, uint8 info,
  		{
  			samerel = true;
  			bkpb.fork_flags |= BKPBLOCK_SAME_REL;
- 			prev_regbuf = regbuf;
  		}
  		else
  			samerel = false;
  
  		/* Ok, copy the header to the scratch buffer */
  		memcpy(scratch, &bkpb, SizeOfXLogRecordBlockHeader);
--- 667,676 ----
  		{
  			samerel = true;
  			bkpb.fork_flags |= BKPBLOCK_SAME_REL;
  		}
  		else
  			samerel = false;
+ 		prev_regbuf = regbuf;
  
  		/* Ok, copy the header to the scratch buffer */
  		memcpy(scratch, &bkpb, SizeOfXLogRecordBlockHeader);
#2Michael Paquier
michael.paquier@gmail.com
In reply to: Zhang Zq (#1)
Re: BUG in XLogRecordAssemble

On Tue, May 5, 2015 at 1:04 AM, Zhang Zq <zqzhangmail@163.com> wrote:

There is the only place that prev_regbuf is assigned, so prev_regbuf will
never be assigned.
The patch will fix it, Thanks.

Indeed. I think you are right. We never set prev_regbuf with the current code.
--
Michael

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3Heikki Linnakangas
hlinnaka@iki.fi
In reply to: Zhang Zq (#1)
Re: BUG in XLogRecordAssemble

On 05/04/2015 07:04 PM, Zhang Zq wrote:

hi,
I found the code in 'backend/access/transam/xloginsert.c' as that:
XLogRecordAssemble:
if (prev_regbuf && RelFileNodeEquals(regbuf->rnode, prev_regbuf->rnode))
{
samerel = true;
bkpb.fork_flags |= BKPBLOCK_SAME_REL;
prev_regbuf = regbuf;
}
else
samerel = false;

There is the only place that prev_regbuf is assigned, so prev_regbuf will never be assigned.
The patch will fix it, Thanks.

Thanks, good catch! Committed.

- Heikki

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers