v3-0001-cleanup-rename-loop-variables-to-avoid-local-shad.patch

application/octet-stream

Filename: v3-0001-cleanup-rename-loop-variables-to-avoid-local-shad.patch
Type: application/octet-stream
Part: 0
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 v3-0001
Subject: cleanup: rename loop variables to avoid local shadowing
File+
src/backend/backup/basebackup_incremental.c 2 3
src/backend/parser/parse_target.c 4 6
From efb7eac54f959791ea777df79586f0a724ea9edf Mon Sep 17 00:00:00 2001
From: "Chao Li (Evan)" <lic@highgo.com>
Date: Tue, 2 Dec 2025 09:22:47 +0800
Subject: [PATCH v3 01/13] cleanup: rename loop variables to avoid local
 shadowing

This commit adjusts several code locations where a local variable was
shadowed by another in the same scope. The changes update loop-variable
names in basebackup_incremental.c and parse_target.c so that each
variable is uniquely scoped within its block.

Author: Chao Li <lic@highgo.com>
Discussion: https://postgr.es/m/CAEoWx2kQ2x5gMaj8tHLJ3=jfC+p5YXHkJyHrDTiQw2nn2FJTmQ@mail.gmail.com
---
 src/backend/backup/basebackup_incremental.c |  5 ++---
 src/backend/parser/parse_target.c           | 10 ++++------
 2 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/src/backend/backup/basebackup_incremental.c b/src/backend/backup/basebackup_incremental.c
index 852ab577045..44f8de6fdac 100644
--- a/src/backend/backup/basebackup_incremental.c
+++ b/src/backend/backup/basebackup_incremental.c
@@ -596,16 +596,15 @@ PrepareForIncrementalBackup(IncrementalBackupInfo *ib,
 			while (1)
 			{
 				unsigned	nblocks;
-				unsigned	i;
 
 				nblocks = BlockRefTableReaderGetBlocks(reader, blocks,
 													   BLOCKS_PER_READ);
 				if (nblocks == 0)
 					break;
 
-				for (i = 0; i < nblocks; ++i)
+				for (unsigned u = 0; u < nblocks; ++u)
 					BlockRefTableMarkBlockModified(ib->brtab, &rlocator,
-												   forknum, blocks[i]);
+												   forknum, blocks[u]);
 			}
 		}
 		DestroyBlockRefTableReader(reader);
diff --git a/src/backend/parser/parse_target.c b/src/backend/parser/parse_target.c
index 905c975d83b..046f96d4132 100644
--- a/src/backend/parser/parse_target.c
+++ b/src/backend/parser/parse_target.c
@@ -1609,10 +1609,9 @@ expandRecordVariable(ParseState *pstate, Var *var, int levelsup)
 					 * subselect must have that outer level as parent.
 					 */
 					ParseState	mypstate = {0};
-					Index		levelsup;
 
 					/* this loop must work, since GetRTEByRangeTablePosn did */
-					for (levelsup = 0; levelsup < netlevelsup; levelsup++)
+					for (Index level = 0; level < netlevelsup; level++)
 						pstate = pstate->parentParseState;
 					mypstate.parentParseState = pstate;
 					mypstate.p_rtable = rte->subquery->rtable;
@@ -1667,12 +1666,11 @@ expandRecordVariable(ParseState *pstate, Var *var, int levelsup)
 					 * could be an outer CTE (compare SUBQUERY case above).
 					 */
 					ParseState	mypstate = {0};
-					Index		levelsup;
 
 					/* this loop must work, since GetCTEForRTE did */
-					for (levelsup = 0;
-						 levelsup < rte->ctelevelsup + netlevelsup;
-						 levelsup++)
+					for (Index level = 0;
+						 level < rte->ctelevelsup + netlevelsup;
+						 level++)
 						pstate = pstate->parentParseState;
 					mypstate.parentParseState = pstate;
 					mypstate.p_rtable = ((Query *) cte->ctequery)->rtable;
-- 
2.39.5 (Apple Git-154)