From: Andrey Lepikhov <a.lepikhov@postgrespro.ru>
To: Michael Paquier <michael@paquier.xyz>
To: Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>
Cc: hlinnaka@iki.fi
Cc: pgsql-hackers@postgresql.org
Subject: Re: [PATCH] XLogReadRecord returns pointer to currently read page
Date: Mon, 19 Nov 2018 10:48:06 +0500
Message-ID: <49518b48-2036-5e43-1818-0f594e375e76@postgrespro.ru> (raw)
In-Reply-To: <20181116062355.GE6613@paquier.xyz>
References: <2553f2b0-0e39-eb0e-d382-6c0ed08ca8ae@postgrespro.ru>
<20181026.143300.212568635.horiguchi.kyotaro@lab.ntt.co.jp>
<ea3dca6a-b898-e7a8-dcfa-b3ad227a6349@postgrespro.ru>
<20181115.181238.258013477.horiguchi.kyotaro@lab.ntt.co.jp>
<20181116062355.GE6613@paquier.xyz>
On 16.11.2018 11:23, Michael Paquier wrote:
> On Thu, Nov 15, 2018 at 06:12:38PM +0900, Kyotaro HORIGUCHI wrote:
>> This patch eliminates unnecessary copying that was done for
>> non-continued records. Now the return value of XLogReadRecord
>> directly points into page buffer holded in XLogReaderStats. It is
>> safe because no caller site uses the returned pointer beyond the
>> replacement of buffer content at the next call to the same
>> function.
>
> I was looking at this patch, and shouldn't we worry about compatibility
> with plugins or utilities which look directly at what's in readRecordBuf
> for the record contents? Let's not forget that the contents of
> XLogReaderState are public.
According to my experience, I clarify some comments to avoid this
mistakes in the future (see attachment).
--
Andrey Lepikhov
Postgres Professional
https://postgrespro.com
The Russian Postgres Company
Attachments:0001-Some-clarifications-on-readRecordBuf-comments.patch (text/x-patch, 1.7K) download
From 7de252405ef5d5979fe2711515c0c6402abc0e06 Mon Sep 17 00:00:00 2001
From: "Andrey V. Lepikhov" <a.lepikhov@postgrespro.ru>
Date: Mon, 19 Nov 2018 07:08:28 +0500
Subject: [PATCH] Some clarifications on readRecordBuf comments
---
src/backend/access/transam/xlogreader.c | 4 ++--
src/include/access/xlogreader.h | 6 +++++-
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.cindex c5e019bf77..88d0bcf48a 100644--- a/src/backend/access/transam/xlogreader.c+++ b/src/backend/access/transam/xlogreader.c@@ -209,8 +209,8 @@ allocate_recordbuf(XLogReaderState *state, uint32 reclength)
* If the reading fails for some other reason, NULL is also returned, and
* *errormsg is set to a string with details of the failure.
*
- * The returned pointer (or *errormsg) points to an internal buffer that's- * valid until the next call to XLogReadRecord.+ * The returned pointer (or *errormsg) points to an internal read-only buffer+ * that's valid until the next call to XLogReadRecord.
*/
XLogRecord *
XLogReadRecord(XLogReaderState *state, XLogRecPtr RecPtr, char **errormsg)
diff --git a/src/include/access/xlogreader.h b/src/include/access/xlogreader.hindex 40116f8ecb..0837625b95 100644--- a/src/include/access/xlogreader.h+++ b/src/include/access/xlogreader.h@@ -185,7 +185,11 @@ struct XLogReaderState
*/
TimeLineID nextTLI;
- /* Buffer for current ReadRecord result (expandable) */+ /*+ * Buffer for current ReadRecord result (expandable).+ * Used in the case, than current ReadRecord result don't fit on the+ * currently read WAL page.+ */
char *readRecordBuf;
uint32 readRecordBufSize;
--
2.17.1
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: a.lepikhov@postgrespro.ru, michael@paquier.xyz, horiguchi.kyotaro@lab.ntt.co.jp, hlinnaka@iki.fi
Subject: Re: [PATCH] XLogReadRecord returns pointer to currently read page
In-Reply-To: <49518b48-2036-5e43-1818-0f594e375e76@postgrespro.ru>
References: <2553f2b0-0e39-eb0e-d382-6c0ed08ca8ae@postgrespro.ru> <20181026.143300.212568635.horiguchi.kyotaro@lab.ntt.co.jp> <ea3dca6a-b898-e7a8-dcfa-b3ad227a6349@postgrespro.ru> <20181115.181238.258013477.horiguchi.kyotaro@lab.ntt.co.jp> <20181116062355.GE6613@paquier.xyz> <49518b48-2036-5e43-1818-0f594e375e76@postgrespro.ru>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox