pg.ddx.io pgsql-committers@postgresql.org mailing list archive
help / color / mirror / Atom feedpgsql: Add optional parameter to PG_TRY() macros
5+ messages / 3 participants
[nested] [flat]
* pgsql: Add optional parameter to PG_TRY() macros
@ 2022-10-05 21:09 David Rowley <drowley@postgresql.org>
0 siblings, 0 replies; 5+ messages in thread
From: David Rowley @ 2022-10-05 21:09 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Add optional parameter to PG_TRY() macros
This optional parameter can be specified in cases where there are nested
PG_TRY() statements within a function in order to stop the compiler from
issuing warnings about shadowed local variables when compiling with
-Wshadow. The optional parameter is used as a suffix on the variable
names declared within the PG_TRY(), PG_CATCH(), PG_FINALLY() and
PG_END_TRY() macros. The parameter, if specified, must be the same in
each component macro of the given PG_TRY() block.
This also adjusts the single case where we have nested PG_TRY() statements
to add a parameter to the inner-most PG_TRY().
This reduces the number of compiler warnings when compiling with
-Wshadow=compatible-local from 5 down to 1.
Author: David Rowley
Discussion: https://postgr.es/m/CAApHDvqWGMdB_pATeUqE=JCtNqNxObPOJ00jFEa2_sZ20j_Wvg@mail.gmail.com
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/112f0225dbfe8af217294bfa0bd227f3302a1658
Modified Files
--------------
src/backend/tcop/utility.c | 6 +++---
src/include/utils/elog.h | 44 ++++++++++++++++++++++++++------------------
2 files changed, 29 insertions(+), 21 deletions(-)
^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: Add optional parameter to PG_TRY() macros
@ 2026-11-10 21:12 Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 5+ messages in thread
From: Tom Lane @ 2026-11-10 21:12 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Add optional parameter to PG_TRY() macros
This commit back-patches v16-era commit 112f0225d into v15 and v14.
We need this now because the back-patches of daafcbd11 expect PG_TRY()
to take an optional parameter, and it doesn't. We'd missed that
problem in testing because it only happens in the MINGW-64 code path.
With pgsql-release's concurrence, I'm putting this into v14 too.
We're not currently planning any more releases of v14, but fix it
there anyway to save trouble for anyone needing to build v14
in future.
Author: David Rowley
Discussion: https://postgr.es/m/CAApHDvqWGMdB_pATeUqE=JCtNqNxObPOJ00jFEa2_sZ20j_Wvg@mail.gmail.com
Branch
------
REL_15_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/45f608a1eb729e9c3a6b2b813f58df9537097f4a
Modified Files
--------------
src/include/utils/elog.h | 44 ++++++++++++++++++++++++++------------------
1 file changed, 26 insertions(+), 18 deletions(-)
^ permalink raw reply [nested|flat] 5+ messages in thread
* pgsql: Add optional parameter to PG_TRY() macros
@ 2026-11-10 21:12 Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 5+ messages in thread
From: Tom Lane @ 2026-11-10 21:12 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
Add optional parameter to PG_TRY() macros
This commit back-patches v16-era commit 112f0225d into v15 and v14.
We need this now because the back-patches of daafcbd11 expect PG_TRY()
to take an optional parameter, and it doesn't. We'd missed that
problem in testing because it only happens in the MINGW-64 code path.
With pgsql-release's concurrence, I'm putting this into v14 too.
We're not currently planning any more releases of v14, but fix it
there anyway to save trouble for anyone needing to build v14
in future.
Author: David Rowley
Discussion: https://postgr.es/m/CAApHDvqWGMdB_pATeUqE=JCtNqNxObPOJ00jFEa2_sZ20j_Wvg@mail.gmail.com
Branch
------
REL_14_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/853b35f35b1c3e5b80d392568659662632e7eba8
Modified Files
--------------
src/include/utils/elog.h | 44 ++++++++++++++++++++++++++------------------
1 file changed, 26 insertions(+), 18 deletions(-)
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: pgsql: Add optional parameter to PG_TRY() macros
@ 2026-11-10 21:45 David Rowley <dgrowleyml@gmail.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 5+ messages in thread
From: David Rowley @ 2026-11-10 21:45 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-committers@lists.postgresql.org
On Wed, 11 Nov 2026 at 10:12, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> Add optional parameter to PG_TRY() macros
There's no public discussion about it, and I didn't think it critical
enough to open a new thread about. I believe the newly added
PG_PERL_TRY() macros would need a ##__VA_ARGS__ suffix on all the
local variables, else we'd get shadow warnings if we ever nested
PG_PERL_TRYs.
David
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: pgsql: Add optional parameter to PG_TRY() macros
@ 2026-11-10 22:14 Tom Lane <tgl@sss.pgh.pa.us>
parent: David Rowley <dgrowleyml@gmail.com>
0 siblings, 0 replies; 5+ messages in thread
From: Tom Lane @ 2026-11-10 22:14 UTC (permalink / raw)
To: David Rowley <dgrowleyml@gmail.com>; +Cc: pgsql-committers@lists.postgresql.org
David Rowley <dgrowleyml@gmail.com> writes:
> There's no public discussion about it, and I didn't think it critical
> enough to open a new thread about. I believe the newly added
> PG_PERL_TRY() macros would need a ##__VA_ARGS__ suffix on all the
> local variables, else we'd get shadow warnings if we ever nested
> PG_PERL_TRYs.
We would get some warnings for that anyway, because we don't have the
ability to change the name of the variable that Perl's dJMPENV macro
creates. So I didn't bother for the variables that are specific to
PG_PERL_TRY. The case I was mainly worried about was not gettimg
shadow warnings for PG_PERL_TRY nested within PG_TRY, which is a
pattern that exists now; so it's worth having the ##__VA_ARGS__
business on the variables that would conflict with PG_TRY.
regards, tom lane
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2026-11-10 22:14 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2022-10-05 21:09 pgsql: Add optional parameter to PG_TRY() macros David Rowley <drowley@postgresql.org>
2026-11-10 21:12 pgsql: Add optional parameter to PG_TRY() macros Tom Lane <tgl@sss.pgh.pa.us>
2026-11-10 21:12 pgsql: Add optional parameter to PG_TRY() macros Tom Lane <tgl@sss.pgh.pa.us>
2026-11-10 21:45 ` David Rowley <dgrowleyml@gmail.com>
2026-11-10 22:14 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox