ReadRecord wrongly assumes randAccess after 38a957316d. - Mailing list pgsql-hackers

From Kyotaro Horiguchi
Subject ReadRecord wrongly assumes randAccess after 38a957316d.
Date
Msg-id 20200128.194408.2260703306774646445.horikyota.ntt@gmail.com
Whole thread Raw
Responses Re: ReadRecord wrongly assumes randAccess after 38a957316d.  (Heikki Linnakangas <hlinnaka@iki.fi>)
List pgsql-hackers
Hello.

While rebasing a patch, I found that after the commit 38a957316d
(Sorry for overlooking that.), ReadRecord sets randAccess reverse
way. That is, it sets randAccess to false just after a XLogBeginRead()
call. The attached fixes that.

regards.

-- 
Kyotaro Horiguchi
NTT Open Source Software Center
From 504600f918376f36d8d4d3ccb34e5d004ef8b4df Mon Sep 17 00:00:00 2001
From: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Date: Tue, 28 Jan 2020 18:58:05 +0900
Subject: [PATCH] Fix randAccess setting in ReadRecrod

Before the commit 38a957316d, the function assumes random access at
the initial state, on which a valid LSN is given as RecPtr. After the
commit XLogBeginRead initializes reader state by setting ReadRecPtr to
invalid. However ReadRecord was wrongly changed so that a valid
ReadRecPtr is assumed as the initial state. Fix it.
---
 src/backend/access/transam/xlog.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 882d5e8a73..6e09ded597 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -4265,7 +4265,7 @@ ReadRecord(XLogReaderState *xlogreader, int emode,
     /* Pass through parameters to XLogPageRead */
     private->fetching_ckpt = fetching_ckpt;
     private->emode = emode;
-    private->randAccess = (xlogreader->ReadRecPtr != InvalidXLogRecPtr);
+    private->randAccess = (xlogreader->ReadRecPtr == InvalidXLogRecPtr);
 
     /* This is the first attempt to read this page. */
     lastSourceFailed = false;
-- 
2.18.2


pgsql-hackers by date:

Previous
From: Daniel Gustafsson
Date:
Subject: Re: Setting min/max TLS protocol in clientside libpq
Next
From: Daniel Gustafsson
Date:
Subject: Re: Some incorrect option sizes for PQconninfoOption in libpq