Fixup the variable name to indicate the WAL record reservation status.
Hi All,
Please find a small patch to improve code readability by fixing up the
variable name to indicate the WAL record reservation status. The
insertion is done later in the code based on the reservation status.
--
Thanks and Regards,
Krishnakumar (KK).
[Microsoft]
Attachments:
v1-0001-Fixup-the-variable-name-to-indicate-the-wal-recor.patchapplication/octet-stream; name=v1-0001-Fixup-the-variable-name-to-indicate-the-wal-recor.patchDownload
From 2ff3eb8f1ffc6cedfe3f426957d16fb9fa3ef5fd Mon Sep 17 00:00:00 2001
From: "Krishnakumar R (KK)" <kksrcv001@gmail.com>
Date: Wed, 13 Sep 2023 23:37:05 -0700
Subject: [PATCH v1] Fixup the variable name to indicate the wal record
reservation status.
---
src/backend/access/transam/xlog.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 9987184231..b42c90483d 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -736,7 +736,7 @@ XLogInsertRecord(XLogRecData *rdata,
{
XLogCtlInsert *Insert = &XLogCtl->Insert;
pg_crc32c rdata_crc;
- bool inserted;
+ bool reserved;
XLogRecord *rechdr = (XLogRecord *) rdata->data;
uint8 info = rechdr->xl_info & ~XLR_INFO_MASK;
bool isLogSwitch = (rechdr->xl_rmid == RM_XLOG_ID &&
@@ -838,15 +838,15 @@ XLogInsertRecord(XLogRecData *rdata,
* pointer.
*/
if (isLogSwitch)
- inserted = ReserveXLogSwitch(&StartPos, &EndPos, &rechdr->xl_prev);
+ reserved = ReserveXLogSwitch(&StartPos, &EndPos, &rechdr->xl_prev);
else
{
ReserveXLogInsertLocation(rechdr->xl_tot_len, &StartPos, &EndPos,
&rechdr->xl_prev);
- inserted = true;
+ reserved = true;
}
- if (inserted)
+ if (reserved)
{
/*
* Now that xl_prev has been filled in, calculate CRC of the record
@@ -930,7 +930,7 @@ XLogInsertRecord(XLogRecData *rdata,
* reflected in EndPos, we return a pointer to just the end of the
* xlog-switch record.
*/
- if (inserted)
+ if (reserved)
{
EndPos = StartPos + SizeOfXLogRecord;
if (StartPos / XLOG_BLCKSZ != EndPos / XLOG_BLCKSZ)
@@ -1016,7 +1016,7 @@ XLogInsertRecord(XLogRecData *rdata,
XactLastRecEnd = EndPos;
/* Report WAL traffic to the instrumentation. */
- if (inserted)
+ if (reserved)
{
pgWalUsage.wal_bytes += rechdr->xl_tot_len;
pgWalUsage.wal_records++;
--
2.34.1
At Wed, 13 Sep 2023 23:48:30 -0700, Krishnakumar R <kksrcv001@gmail.com> wrote in
Please find a small patch to improve code readability by fixing up the
variable name to indicate the WAL record reservation status. The
insertion is done later in the code based on the reservation status.
IMHO... Although "reserved" might be pertinent at the point of
assignment, its applicability promptly diminishes in the subsequent
uses. When the variable is first assigned, we know the record will
insert some bytes and advance the LSN. In other words, the variable
suggests "to be inserted", and promptly thereafter, the variable
indicates that the record "has been inserted". Given this, "inserted"
seems to be a better fit than "reserved".
In short, I would keep the variable name as it is.
regards.
--
Kyotaro Horiguchi
NTT Open Source Software Center