There's been no progress on this in the past discussions. https://www.postgresql.org/message-id/flat/877k1psmpf.fsf%40mailbox.samurai.com https://www.postgresql.org/message-id/flat/CAApHDvpqBR7u9yzW4yggjG%3DQfN%3DFZsc8Wo2ckokpQtif-%2BiQ2A%40mail.gmail.com#2d900bfe18fce17f97ec1f00800c8e27 https://www.postgresql.org/message-id/flat/MN2PR18MB2927F7B5F690065E1194B258E35D0%40MN2PR18MB2927.namprd18.prod.outlook.com
But an unfortunate consequence of not fixing the historic issues is that it precludes the possibility that anyone could be expected to notice if they introduce more instances of the same problem (as in the first half of these patches). Then the hole which has already been dug becomes deeper, further increasing the burden of fixing the historic issues before being able to use -Wshadow. The first half of the patches fix shadow variables newly-introduced in v15 (including one of my own patches), the rest are fixing the lowest hanging fruit of the "short list" from COPT=-Wshadow=compatible-local I can't see that any of these are bugs, but it seems like a good goal to move towards allowing use of the -Wshadow* options to help avoid future errors, as well as cleanliness and readability (rather than allowing it to get harder to use -Wshadow). -- Justin
>From 0b05b375a87d89f5d88e87d11956cf2ac15ea00f Mon Sep 17 00:00:00 2001 From: Justin Pryzby <pryz...@telsasoft.com> Date: Tue, 16 Aug 2022 19:38:57 -0500 Subject: [PATCH 01/17] avoid shadow vars: pg_dump.c: i_oid backpatch to v15 commit d498e052b4b84ae21b3b68d5b3fda6ead65d1d4d Author: Robert Haas <rh...@postgresql.org> Date: Fri Jul 8 10:15:19 2022 -0400 Preserve relfilenode of pg_largeobject and its index across pg_upgrade. --- src/bin/pg_dump/pg_dump.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index da6605175a0..322947c5609 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -3144,7 +3144,6 @@ dumpDatabase(Archive *fout) PQExpBuffer loHorizonQry = createPQExpBuffer(); int i_relfrozenxid, i_relfilenode, - i_oid, i_relminmxid; /* -- 2.17.1
>From a76bac21fe428cdd6241bff6827e08d9d71e1bdf Mon Sep 17 00:00:00 2001 From: Justin Pryzby <pryz...@telsasoft.com> Date: Tue, 16 Aug 2022 15:55:13 -0500 Subject: [PATCH 02/17] avoid shadow vars: pg_dump.c: tbinfo backpatch to v15 commit 9895961529ef8ff3fc12b39229f9a93e08bca7b7 Author: Tom Lane <t...@sss.pgh.pa.us> Date: Mon Dec 6 13:07:31 2021 -0500 Avoid per-object queries in performance-critical paths in pg_dump. --- src/bin/pg_dump/pg_dump.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 322947c5609..5c196d66985 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -7080,21 +7080,21 @@ getConstraints(Archive *fout, TableInfo tblinfo[], int numTables) appendPQExpBufferChar(tbloids, '{'); for (int i = 0; i < numTables; i++) { - TableInfo *tbinfo = &tblinfo[i]; + TableInfo *mytbinfo = &tblinfo[i]; /* * For partitioned tables, foreign keys have no triggers so they must * be included anyway in case some foreign keys are defined. */ - if ((!tbinfo->hastriggers && - tbinfo->relkind != RELKIND_PARTITIONED_TABLE) || - !(tbinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)) + if ((!mytbinfo->hastriggers && + mytbinfo->relkind != RELKIND_PARTITIONED_TABLE) || + !(mytbinfo->dobj.dump & DUMP_COMPONENT_DEFINITION)) continue; /* OK, we need info for this table */ if (tbloids->len > 1) /* do we have more than the '{'? */ appendPQExpBufferChar(tbloids, ','); - appendPQExpBuffer(tbloids, "%u", tbinfo->dobj.catId.oid); + appendPQExpBuffer(tbloids, "%u", mytbinfo->dobj.catId.oid); } appendPQExpBufferChar(tbloids, '}'); -- 2.17.1
>From f6a814fd50800942081250b05f8e6d143b8d8266 Mon Sep 17 00:00:00 2001 From: Justin Pryzby <pryz...@telsasoft.com> Date: Tue, 16 Aug 2022 16:22:52 -0500 Subject: [PATCH 03/17] avoid shadow vars: pg_dump.c: owning_tab backpatch to v15 commit 344d62fb9a978a72cf8347f0369b9ee643fd0b31 Author: Peter Eisentraut <pe...@eisentraut.org> Date: Thu Apr 7 16:13:23 2022 +0200 Unlogged sequences --- src/bin/pg_dump/pg_dump.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 5c196d66985..ecf29f3c52a 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -16799,7 +16799,7 @@ dumpSequence(Archive *fout, const TableInfo *tbinfo) */ if (OidIsValid(tbinfo->owning_tab) && !tbinfo->is_identity_sequence) { - TableInfo *owning_tab = findTableByOid(tbinfo->owning_tab); + owning_tab = findTableByOid(tbinfo->owning_tab); if (owning_tab == NULL) pg_fatal("failed sanity check, parent table with OID %u of sequence with OID %u not found", -- 2.17.1
>From 1a979be65baab871754f86669c5f0327fad6cab5 Mon Sep 17 00:00:00 2001 From: Justin Pryzby <pryz...@telsasoft.com> Date: Wed, 17 Aug 2022 08:52:03 -0500 Subject: [PATCH 04/17] avoid shadow vars: tablesync.c: first backpatch to v15 commit 923def9a533a7d986acfb524139d8b9e5466d0a5 Author: Tomas Vondra <tomas.von...@postgresql.org> Date: Sat Mar 26 00:45:21 2022 +0100 Allow specifying column lists for logical replication --- src/backend/replication/logical/tablesync.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/replication/logical/tablesync.c b/src/backend/replication/logical/tablesync.c index 6a01ffd273f..95d1081f4ec 100644 --- a/src/backend/replication/logical/tablesync.c +++ b/src/backend/replication/logical/tablesync.c @@ -762,8 +762,8 @@ fetch_remote_table_info(char *nspname, char *relname, TupleTableSlot *slot; Oid attrsRow[] = {INT2VECTOROID}; StringInfoData pub_names; - bool first = true; + first = true; initStringInfo(&pub_names); foreach(lc, MySubscription->publications) { -- 2.17.1
>From 555a4545460f3086fd69ca95ac41f18c6ceaab80 Mon Sep 17 00:00:00 2001 From: Justin Pryzby <pryz...@telsasoft.com> Date: Tue, 16 Aug 2022 19:01:16 -0500 Subject: [PATCH 05/17] avoid shadow vars: tablesync.c: slot backpatch to v15 commit 923def9a533a7d986acfb524139d8b9e5466d0a5 Author: Tomas Vondra <tomas.von...@postgresql.org> Date: Sat Mar 26 00:45:21 2022 +0100 Allow specifying column lists for logical replication --- src/backend/replication/logical/tablesync.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/backend/replication/logical/tablesync.c b/src/backend/replication/logical/tablesync.c index 95d1081f4ec..5bb9b545e9a 100644 --- a/src/backend/replication/logical/tablesync.c +++ b/src/backend/replication/logical/tablesync.c @@ -759,7 +759,6 @@ fetch_remote_table_info(char *nspname, char *relname, if (walrcv_server_version(LogRepWorkerWalRcvConn) >= 150000) { WalRcvExecResult *pubres; - TupleTableSlot *slot; Oid attrsRow[] = {INT2VECTOROID}; StringInfoData pub_names; -- 2.17.1
>From 5ac6d302f769db6f4625be0cf6a5bae4aa60de40 Mon Sep 17 00:00:00 2001 From: Justin Pryzby <pryz...@telsasoft.com> Date: Tue, 16 Aug 2022 18:51:10 -0500 Subject: [PATCH 06/17] avoid shadow vars: basebackup_target.c: ttype backpatch to v15 commit e4ba69f3f4a1b997aa493cc02e563a91c0f35b87 Author: Robert Haas <rh...@postgresql.org> Date: Tue Mar 15 13:22:04 2022 -0400 Allow extensions to add new backup targets. --- src/backend/backup/basebackup_target.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/backup/basebackup_target.c b/src/backend/backup/basebackup_target.c index 83928e32055..8d10fe15530 100644 --- a/src/backend/backup/basebackup_target.c +++ b/src/backend/backup/basebackup_target.c @@ -73,7 +73,7 @@ BaseBackupAddTarget(char *name, /* Search the target type list for an existing entry with this name. */ foreach(lc, BaseBackupTargetTypeList) { - BaseBackupTargetType *ttype = lfirst(lc); + ttype = lfirst(lc); if (strcmp(ttype->name, name) == 0) { -- 2.17.1
>From 744cb8dd010d61bef46f9623511a253429bb46cb Mon Sep 17 00:00:00 2001 From: Justin Pryzby <pryz...@telsasoft.com> Date: Tue, 16 Aug 2022 19:45:28 -0500 Subject: [PATCH 07/17] avoid shadow vars: parse_jsontable.c: jtc backpatch to v15 commit fadb48b00e02ccfd152baa80942de30205ab3c4f Author: Andrew Dunstan <and...@dunslane.net> Date: Tue Apr 5 14:09:04 2022 -0400 PLAN clauses for JSON_TABLE --- src/backend/parser/parse_jsontable.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/parser/parse_jsontable.c b/src/backend/parser/parse_jsontable.c index bc3272017ef..c2318b126f2 100644 --- a/src/backend/parser/parse_jsontable.c +++ b/src/backend/parser/parse_jsontable.c @@ -341,9 +341,9 @@ transformJsonTableChildPlan(JsonTableContext *cxt, JsonTablePlan *plan, /* transform all nested columns into cross/union join */ foreach(lc, columns) { - JsonTableColumn *jtc = castNode(JsonTableColumn, lfirst(lc)); Node *node; + jtc = castNode(JsonTableColumn, lfirst(lc)); if (jtc->coltype != JTC_NESTED) continue; -- 2.17.1
>From 660a31762a9122c240227f1f542ac4e284b5e4c5 Mon Sep 17 00:00:00 2001 From: Justin Pryzby <pryz...@telsasoft.com> Date: Wed, 17 Aug 2022 00:22:45 -0500 Subject: [PATCH 08/17] avoid shadow vars: res backpatch to v15 commit 1a36bc9dba8eae90963a586d37b6457b32b2fed4 Author: Andrew Dunstan <and...@dunslane.net> Date: Thu Mar 3 13:11:14 2022 -0500 SQL/JSON query functions --- src/backend/utils/adt/jsonpath_exec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/utils/adt/jsonpath_exec.c b/src/backend/utils/adt/jsonpath_exec.c index 10c7e64aab3..d1e3385975a 100644 --- a/src/backend/utils/adt/jsonpath_exec.c +++ b/src/backend/utils/adt/jsonpath_exec.c @@ -3109,10 +3109,10 @@ JsonItemFromDatum(Datum val, Oid typid, int32 typmod, JsonbValue *res) if (JsonContainerIsScalar(&jb->root)) { - bool res PG_USED_FOR_ASSERTS_ONLY; + bool tmp PG_USED_FOR_ASSERTS_ONLY; - res = JsonbExtractScalar(&jb->root, jbv); - Assert(res); + tmp = JsonbExtractScalar(&jb->root, jbv); + Assert(tmp); } else JsonbInitBinary(jbv, jb); -- 2.17.1
>From ba98717eba1ffa94dd2dd23a0dd29f30b035f56b Mon Sep 17 00:00:00 2001 From: Justin Pryzby <pryz...@telsasoft.com> Date: Tue, 16 Aug 2022 19:43:15 -0500 Subject: [PATCH 09/17] avoid shadow vars: clauses.c: querytree_list commit e717a9a18b2e34c9c40e5259ad4d31cd7e420750 Author: Peter Eisentraut <pe...@eisentraut.org> Date: Wed Apr 7 21:30:08 2021 +0200 SQL-standard function body --- src/backend/optimizer/util/clauses.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/backend/optimizer/util/clauses.c b/src/backend/optimizer/util/clauses.c index 533df86ff77..e846d414f00 100644 --- a/src/backend/optimizer/util/clauses.c +++ b/src/backend/optimizer/util/clauses.c @@ -4540,7 +4540,6 @@ inline_function(Oid funcid, Oid result_type, Oid result_collid, if (!isNull) { Node *n; - List *querytree_list; n = stringToNode(TextDatumGetCString(tmp)); if (IsA(n, List)) -- 2.17.1
>From a20657e50017676f04d11a24cbd046ce768af248 Mon Sep 17 00:00:00 2001 From: Justin Pryzby <pryz...@telsasoft.com> Date: Tue, 16 Aug 2022 20:28:02 -0500 Subject: [PATCH 10/17] avoid shadow vars: tablecmds.c: constraintOid commit eb7ed3f3063401496e4aa4bd68fa33f0be31a72f Author: Alvaro Herrera <alvhe...@alvh.no-ip.org> Date: Mon Feb 19 16:59:37 2018 -0300 Allow UNIQUE indexes on partitioned tables --- src/backend/commands/tablecmds.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 70b94bbb397..1c0cf7c1a06 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -18098,7 +18098,6 @@ AttachPartitionEnsureIndexes(Relation rel, Relation attachrel) if (!found) { IndexStmt *stmt; - Oid constraintOid; stmt = generateClonedIndexStmt(NULL, idxRel, attmap, -- 2.17.1
>From 6866edb3c2a738cf14abf3df79db4fc4ce8ec1e4 Mon Sep 17 00:00:00 2001 From: Justin Pryzby <pryz...@telsasoft.com> Date: Tue, 16 Aug 2022 20:17:46 -0500 Subject: [PATCH 11/17] avoid shadow vars: tablecmds.c: copyTuple commit 6f70d7ca1d1937a9f7b79eff6fb18ed1bb2a4c47 Author: Alvaro Herrera <alvhe...@alvh.no-ip.org> Date: Wed May 5 12:14:21 2021 -0400 Have ALTER CONSTRAINT recurse on partitioned tables --- src/backend/commands/tablecmds.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 1c0cf7c1a06..d6483cf1f9a 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -10865,7 +10865,6 @@ ATExecAlterConstrRecurse(Constraint *cmdcon, Relation conrel, Relation tgrel, { Form_pg_trigger tgform = (Form_pg_trigger) GETSTRUCT(tgtuple); Form_pg_trigger copy_tg; - HeapTuple copyTuple; /* * Remember OIDs of other relation(s) involved in FK constraint. -- 2.17.1
>From 639a1b6bc67c52e242f5cbe4f14070fdce1d5497 Mon Sep 17 00:00:00 2001 From: Justin Pryzby <pryz...@telsasoft.com> Date: Tue, 16 Aug 2022 16:55:10 -0500 Subject: [PATCH 12/17] avoid shadow vars: copyfrom.c: attnum commit 3a1433674696fbb968bc2120ebd36d9766f49af5 Author: Bruce Momjian <br...@momjian.us> Date: Thu Apr 15 22:36:03 2004 +0000 Modify COPY for() loop to use attnum as a variable name, not 'i'. --- src/backend/commands/copyfrom.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/backend/commands/copyfrom.c b/src/backend/commands/copyfrom.c index a976008b3d4..e8bb168aea8 100644 --- a/src/backend/commands/copyfrom.c +++ b/src/backend/commands/copyfrom.c @@ -1202,7 +1202,6 @@ BeginCopyFrom(ParseState *pstate, num_defaults; FmgrInfo *in_functions; Oid *typioparams; - int attnum; Oid in_func_oid; int *defmap; ExprState **defexprs; @@ -1401,7 +1400,7 @@ BeginCopyFrom(ParseState *pstate, defmap = (int *) palloc(num_phys_attrs * sizeof(int)); defexprs = (ExprState **) palloc(num_phys_attrs * sizeof(ExprState *)); - for (attnum = 1; attnum <= num_phys_attrs; attnum++) + for (int attnum = 1; attnum <= num_phys_attrs; attnum++) { Form_pg_attribute att = TupleDescAttr(tupDesc, attnum - 1); -- 2.17.1
>From f4eb4dab974b60e62f2444cc19bb50eeb1933018 Mon Sep 17 00:00:00 2001 From: Justin Pryzby <pryz...@telsasoft.com> Date: Tue, 16 Aug 2022 18:36:13 -0500 Subject: [PATCH 13/17] avoid shadow vars: nodeAgg: transno commit db80acfc9d50ac56811d22802ab3d822ab313055 Author: Heikki Linnakangas <heikki.linnakan...@iki.fi> Date: Tue Dec 20 09:20:17 2016 +0200 Fix sharing Agg transition state of DISTINCT or ordered aggs. --- src/backend/executor/nodeAgg.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c index 96d200e4461..933c3049016 100644 --- a/src/backend/executor/nodeAgg.c +++ b/src/backend/executor/nodeAgg.c @@ -1296,13 +1296,12 @@ finalize_aggregates(AggState *aggstate, Datum *aggvalues = econtext->ecxt_aggvalues; bool *aggnulls = econtext->ecxt_aggnulls; int aggno; - int transno; /* * If there were any DISTINCT and/or ORDER BY aggregates, sort their * inputs and run the transition functions. */ - for (transno = 0; transno < aggstate->numtrans; transno++) + for (int transno = 0; transno < aggstate->numtrans; transno++) { AggStatePerTrans pertrans = &aggstate->pertrans[transno]; AggStatePerGroup pergroupstate; -- 2.17.1
>From d8467edb33575a56ae522e97ecfb329a27b1f462 Mon Sep 17 00:00:00 2001 From: Justin Pryzby <pryz...@telsasoft.com> Date: Tue, 16 Aug 2022 19:36:12 -0500 Subject: [PATCH 14/17] avoid shadow vars: trigger.c: partitionId commit 80ba4bb383538a2ee846fece6a7b8da9518b6866 Author: Alvaro Herrera <alvhe...@alvh.no-ip.org> Date: Thu Jul 22 18:33:47 2021 -0400 Make ALTER TRIGGER RENAME consistent for partitioned tables --- src/backend/commands/trigger.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c index 62a09fb131b..bb4385c6ea9 100644 --- a/src/backend/commands/trigger.c +++ b/src/backend/commands/trigger.c @@ -1726,9 +1726,9 @@ renametrig_partition(Relation tgrel, Oid partitionId, Oid parentTriggerOid, for (int i = 0; i < partdesc->nparts; i++) { - Oid partitionId = partdesc->oids[i]; + Oid partid = partdesc->oids[i]; - renametrig_partition(tgrel, partitionId, tgform->oid, newname, + renametrig_partition(tgrel, partid, tgform->oid, newname, NameStr(tgform->tgname)); } } -- 2.17.1
>From f24e62293892170cc500907b15e70d75b2503ae1 Mon Sep 17 00:00:00 2001 From: Justin Pryzby <pryz...@telsasoft.com> Date: Tue, 16 Aug 2022 20:20:38 -0500 Subject: [PATCH 15/17] avoid shadow vars: execPartition.c: found_whole_row commit 158b7bc6d77948d2f474dc9f2777c87f81d1365a Author: Alvaro Herrera <alvhe...@alvh.no-ip.org> Date: Mon Apr 16 15:50:57 2018 -0300 Ignore whole-rows in INSERT/CONFLICT with partitioned tables See also: commit 555ee77a9668e3f1b03307055b5027e13bf1a715 Author: Alvaro Herrera <alvhe...@alvh.no-ip.org> Date: Mon Mar 26 10:43:54 2018 -0300 Handle INSERT .. ON CONFLICT with partitioned tables --- src/backend/executor/execPartition.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/backend/executor/execPartition.c b/src/backend/executor/execPartition.c index eb491061024..6998ba8ae23 100644 --- a/src/backend/executor/execPartition.c +++ b/src/backend/executor/execPartition.c @@ -768,7 +768,6 @@ ExecInitPartitionInfo(ModifyTableState *mtstate, EState *estate, { List *onconflset; List *onconflcols; - bool found_whole_row; /* * Translate expressions in onConflictSet to account for -- 2.17.1
>From 79fe22270a9ab91c7a561c2bff2a64b20c1797e7 Mon Sep 17 00:00:00 2001 From: Justin Pryzby <pryz...@telsasoft.com> Date: Tue, 16 Aug 2022 17:10:55 -0500 Subject: [PATCH 16/17] avoid shadow vars: brin keyno commit a681e3c107aa97eb554f118935c4d2278892c3dd Author: Tomas Vondra <tomas.von...@postgresql.org> Date: Fri Mar 26 13:17:56 2021 +0100 Support the old signature of BRIN consistent function --- src/backend/access/brin/brin.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/backend/access/brin/brin.c b/src/backend/access/brin/brin.c index e88f7efa7e4..69f21abfb59 100644 --- a/src/backend/access/brin/brin.c +++ b/src/backend/access/brin/brin.c @@ -372,7 +372,6 @@ bringetbitmap(IndexScanDesc scan, TIDBitmap *tbm) **nullkeys; int *nkeys, *nnullkeys; - int keyno; char *ptr; Size len; char *tmp PG_USED_FOR_ASSERTS_ONLY; @@ -454,7 +453,7 @@ bringetbitmap(IndexScanDesc scan, TIDBitmap *tbm) memset(nnullkeys, 0, sizeof(int) * bdesc->bd_tupdesc->natts); /* Preprocess the scan keys - split them into per-attribute arrays. */ - for (keyno = 0; keyno < scan->numberOfKeys; keyno++) + for (int keyno = 0; keyno < scan->numberOfKeys; keyno++) { ScanKey key = &scan->keyData[keyno]; AttrNumber keyattno = key->sk_attno; -- 2.17.1
>From 50ded6f49a3f2e7ce4b221201ea6d38a5bda83c5 Mon Sep 17 00:00:00 2001 From: Justin Pryzby <pryz...@telsasoft.com> Date: Tue, 16 Aug 2022 23:52:21 -0500 Subject: [PATCH 17/17] avoid shadow vars: bufmgr.c: j commit bea449c635c0e68e21610593594c1e5d52842cdd Author: Amit Kapila <akap...@postgresql.org> Date: Wed Jan 13 07:46:11 2021 +0530 Optimize DropRelFileNodesAllBuffers() for recovery. --- src/backend/storage/buffer/bufmgr.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c index 9c1bd508d36..a748efdb942 100644 --- a/src/backend/storage/buffer/bufmgr.c +++ b/src/backend/storage/buffer/bufmgr.c @@ -3183,7 +3183,6 @@ void DropRelationsAllBuffers(SMgrRelation *smgr_reln, int nlocators) { int i; - int j; int n = 0; SMgrRelation *rels; BlockNumber (*block)[MAX_FORKNUM + 1]; @@ -3232,7 +3231,7 @@ DropRelationsAllBuffers(SMgrRelation *smgr_reln, int nlocators) */ for (i = 0; i < n && cached; i++) { - for (j = 0; j <= MAX_FORKNUM; j++) + for (int j = 0; j <= MAX_FORKNUM; j++) { /* Get the number of blocks for a relation's fork. */ block[i][j] = smgrnblocks_cached(rels[i], j); @@ -3259,7 +3258,7 @@ DropRelationsAllBuffers(SMgrRelation *smgr_reln, int nlocators) { for (i = 0; i < n; i++) { - for (j = 0; j <= MAX_FORKNUM; j++) + for (int j = 0; j <= MAX_FORKNUM; j++) { /* ignore relation forks that doesn't exist */ if (!BlockNumberIsValid(block[i][j])) -- 2.17.1