v6-0004-cleanup-fix-macro-induced-variable-shadowing-in-i.patch

application/octet-stream

Filename: v6-0004-cleanup-fix-macro-induced-variable-shadowing-in-i.patch
Type: application/octet-stream
Part: 3
Message: Re: Cleanup shadows variable warnings, round 1

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: format-patch
Series: patch v6-0004
Subject: cleanup: fix macro-induced variable shadowing in inval.c
File+
src/backend/utils/cache/inval.c 22 22
From 7720a3271dbeee7d4bf753363e7b1d167897ebfa Mon Sep 17 00:00:00 2001
From: "Chao Li (Evan)" <lic@highgo.com>
Date: Tue, 2 Dec 2025 12:08:03 +0800
Subject: [PATCH v6 04/13] cleanup: fix macro-induced variable shadowing in
 inval.c

This commit resolves a shadowing issue in inval.c where variables defined
inside the ProcessMessageSubGroup and ProcessMessageSubGroupMulti macros
conflicted with an existing local name. The fix renames the macro-scoped
variable so it no longer shadows the local variable at the call site.

Author: Chao Li <lic@highgo.com>
Discussion: https://postgr.es/m/CAEoWx2kQ2x5gMaj8tHLJ3=jfC+p5YXHkJyHrDTiQw2nn2FJTmQ@mail.gmail.com
---
 src/backend/utils/cache/inval.c | 44 ++++++++++++++++-----------------
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/src/backend/utils/cache/inval.c b/src/backend/utils/cache/inval.c
index d59216b28f1..4072aa06703 100644
--- a/src/backend/utils/cache/inval.c
+++ b/src/backend/utils/cache/inval.c
@@ -387,7 +387,7 @@ AppendInvalidationMessageSubGroup(InvalidationMsgsGroup *dest,
 		int		_endmsg = (group)->nextmsg[subgroup]; \
 		for (; _msgindex < _endmsg; _msgindex++) \
 		{ \
-			SharedInvalidationMessage *msg = \
+			SharedInvalidationMessage *_msg = \
 				&InvalMessageArrays[subgroup].msgs[_msgindex]; \
 			codeFragment; \
 		} \
@@ -403,7 +403,7 @@ AppendInvalidationMessageSubGroup(InvalidationMsgsGroup *dest,
 	do { \
 		int		n = NumMessagesInSubGroup(group, subgroup); \
 		if (n > 0) { \
-			SharedInvalidationMessage *msgs = \
+			SharedInvalidationMessage *_msgs = \
 				&InvalMessageArrays[subgroup].msgs[(group)->firstmsg[subgroup]]; \
 			codeFragment; \
 		} \
@@ -479,9 +479,9 @@ AddRelcacheInvalidationMessage(InvalidationMsgsGroup *group,
 	 * don't need to add individual ones when it is present.
 	 */
 	ProcessMessageSubGroup(group, RelCacheMsgs,
-						   if (msg->rc.id == SHAREDINVALRELCACHE_ID &&
-							   (msg->rc.relId == relId ||
-								msg->rc.relId == InvalidOid))
+						   if (_msg->rc.id == SHAREDINVALRELCACHE_ID &&
+							   (_msg->rc.relId == relId ||
+								_msg->rc.relId == InvalidOid))
 						   return);
 
 	/* OK, add the item */
@@ -509,9 +509,9 @@ AddRelsyncInvalidationMessage(InvalidationMsgsGroup *group,
 
 	/* Don't add a duplicate item. */
 	ProcessMessageSubGroup(group, RelCacheMsgs,
-						   if (msg->rc.id == SHAREDINVALRELSYNC_ID &&
-							   (msg->rc.relId == relId ||
-								msg->rc.relId == InvalidOid))
+						   if (_msg->rc.id == SHAREDINVALRELSYNC_ID &&
+							   (_msg->rc.relId == relId ||
+								_msg->rc.relId == InvalidOid))
 						   return);
 
 	/* OK, add the item */
@@ -538,8 +538,8 @@ AddSnapshotInvalidationMessage(InvalidationMsgsGroup *group,
 	/* Don't add a duplicate item */
 	/* We assume dbId need not be checked because it will never change */
 	ProcessMessageSubGroup(group, RelCacheMsgs,
-						   if (msg->sn.id == SHAREDINVALSNAPSHOT_ID &&
-							   msg->sn.relId == relId)
+						   if (_msg->sn.id == SHAREDINVALSNAPSHOT_ID &&
+							   _msg->sn.relId == relId)
 						   return);
 
 	/* OK, add the item */
@@ -574,8 +574,8 @@ static void
 ProcessInvalidationMessages(InvalidationMsgsGroup *group,
 							void (*func) (SharedInvalidationMessage *msg))
 {
-	ProcessMessageSubGroup(group, CatCacheMsgs, func(msg));
-	ProcessMessageSubGroup(group, RelCacheMsgs, func(msg));
+	ProcessMessageSubGroup(group, CatCacheMsgs, func(_msg));
+	ProcessMessageSubGroup(group, RelCacheMsgs, func(_msg));
 }
 
 /*
@@ -586,8 +586,8 @@ static void
 ProcessInvalidationMessagesMulti(InvalidationMsgsGroup *group,
 								 void (*func) (const SharedInvalidationMessage *msgs, int n))
 {
-	ProcessMessageSubGroupMulti(group, CatCacheMsgs, func(msgs, n));
-	ProcessMessageSubGroupMulti(group, RelCacheMsgs, func(msgs, n));
+	ProcessMessageSubGroupMulti(group, CatCacheMsgs, func(_msgs, n));
+	ProcessMessageSubGroupMulti(group, RelCacheMsgs, func(_msgs, n));
 }
 
 /* ----------------------------------------------------------------
@@ -1053,25 +1053,25 @@ xactGetCommittedInvalidationMessages(SharedInvalidationMessage **msgs,
 	ProcessMessageSubGroupMulti(&transInvalInfo->PriorCmdInvalidMsgs,
 								CatCacheMsgs,
 								(memcpy(msgarray + nmsgs,
-										msgs,
+										_msgs,
 										n * sizeof(SharedInvalidationMessage)),
 								 nmsgs += n));
 	ProcessMessageSubGroupMulti(&transInvalInfo->ii.CurrentCmdInvalidMsgs,
 								CatCacheMsgs,
 								(memcpy(msgarray + nmsgs,
-										msgs,
+										_msgs,
 										n * sizeof(SharedInvalidationMessage)),
 								 nmsgs += n));
 	ProcessMessageSubGroupMulti(&transInvalInfo->PriorCmdInvalidMsgs,
 								RelCacheMsgs,
 								(memcpy(msgarray + nmsgs,
-										msgs,
+										_msgs,
 										n * sizeof(SharedInvalidationMessage)),
 								 nmsgs += n));
 	ProcessMessageSubGroupMulti(&transInvalInfo->ii.CurrentCmdInvalidMsgs,
 								RelCacheMsgs,
 								(memcpy(msgarray + nmsgs,
-										msgs,
+										_msgs,
 										n * sizeof(SharedInvalidationMessage)),
 								 nmsgs += n));
 	Assert(nmsgs == nummsgs);
@@ -1109,13 +1109,13 @@ inplaceGetInvalidationMessages(SharedInvalidationMessage **msgs,
 	ProcessMessageSubGroupMulti(&inplaceInvalInfo->CurrentCmdInvalidMsgs,
 								CatCacheMsgs,
 								(memcpy(msgarray + nmsgs,
-										msgs,
+										_msgs,
 										n * sizeof(SharedInvalidationMessage)),
 								 nmsgs += n));
 	ProcessMessageSubGroupMulti(&inplaceInvalInfo->CurrentCmdInvalidMsgs,
 								RelCacheMsgs,
 								(memcpy(msgarray + nmsgs,
-										msgs,
+										_msgs,
 										n * sizeof(SharedInvalidationMessage)),
 								 nmsgs += n));
 	Assert(nmsgs == nummsgs);
@@ -1959,10 +1959,10 @@ LogLogicalInvalidations(void)
 		XLogBeginInsert();
 		XLogRegisterData(&xlrec, MinSizeOfXactInvals);
 		ProcessMessageSubGroupMulti(group, CatCacheMsgs,
-									XLogRegisterData(msgs,
+									XLogRegisterData(_msgs,
 													 n * sizeof(SharedInvalidationMessage)));
 		ProcessMessageSubGroupMulti(group, RelCacheMsgs,
-									XLogRegisterData(msgs,
+									XLogRegisterData(_msgs,
 													 n * sizeof(SharedInvalidationMessage)));
 		XLogInsert(RM_XACT_ID, XLOG_XACT_INVALIDATIONS);
 	}
-- 
2.50.1 (Apple Git-155)