pgsql: Remove buggy and dead code from CreateTriggerFiringOn - Mailing list pgsql-committers

From David Rowley
Subject pgsql: Remove buggy and dead code from CreateTriggerFiringOn
Date
Msg-id E1oVPdU-001eNB-Nq@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Remove buggy and dead code from CreateTriggerFiringOn

Here we remove some dead code from CreateTriggerFiringOn() which was
attempting to find the relevant child partition index corresponding to the
given indexOid.  As it turned out, thanks to -Wshadow=compatible-local,
this code was buggy as the code which was finding the child indexes
assigned those to a shadowed variable that directly went out of scope.
The code which thought it was looking at the List of child indexes was
always referencing an empty List.

On further investigation, this code is dead.  We never call
CreateTriggerFiringOn() passing a valid indexOid in a way that the
function would actually ever execute the code in question.  So, for lack
of a way to test if a fix actually works, let's just remove the dead code
instead.

As a reminder, if there is ever a need to resurrect this code, an Assert()
has been added to remind future feature developers that they might need to
write some code to find the corresponding child index.

Reported-by: Justin Pryzby
Reviewed-by: Justin Pryzby
Discussion: https://postgr.es/m/20220819211824.GX26426@telsasoft.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/16d69ec29b1199831c74504845f5d6117dbfc738

Modified Files
--------------
src/backend/commands/trigger.c | 44 +++++-------------------------------------
1 file changed, 5 insertions(+), 39 deletions(-)


pgsql-committers by date:

Previous
From: John Naylor
Date:
Subject: Re: pgsql: Build all Flex files standalone
Next
From: Andres Freund
Date:
Subject: Re: pgsql: Build all Flex files standalone