Re: Fix a recent "shadow warning" in subscriptioncmds.c

Amit Kapila <amit.kapila16@gmail.com>

From: Amit Kapila <amit.kapila16@gmail.com>
To: Peter Smith <smithpb2250@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-11-28T06:13:24Z
Lists: pgsql-hackers
On Fri, Nov 28, 2025 at 9:29 AM Peter Smith <smithpb2250@gmail.com> wrote:
>
> I noticed that recently, a shadow warning has crept into the code I am building.
>
> ----------
> subscriptioncmds.c:1125:30: warning: declaration of ‘rel’ shadows a
> previous local [-Wshadow]
>    foreach_ptr(SubRemoveRels, rel, sub_remove_rels)
>                               ^
> ../../../src/include/nodes/pg_list.h:482:20: note: in definition of
> macro ‘foreach_internal’
>   for (type pointer var = 0, pointer var##__outerloop = (type pointer) 1; \
>                     ^
> subscriptioncmds.c:1125:3: note: in expansion of macro ‘foreach_ptr’
>    foreach_ptr(SubRemoveRels, rel, sub_remove_rels)
>    ^
> subscriptioncmds.c:934:11: warning: shadowed declaration is here [-Wshadow]
>   Relation rel = NULL;
>            ^
> ----------
>
> This seems to have been introduced recently by the REFRESH SEQUENCES
> commit f0b3573.
>
> IIUC, this particular case is harmless, but IMO it's still worth
> fixing to avoid recurring doubts about potential issues every time it
> appears.
>

Sounds reasonable and it appears to bring some code clarity as well.
I'll push this early next week unless someone thinks differently.

-- 
With Regards,
Amit Kapila.



Commits

  1. Fix shadow variable warning in subscriptioncmds.c.

  2. Introduce "REFRESH SEQUENCES" for subscriptions.