pgsql: Remove buggy and dead code from CreateTriggerFiringOn

From: David Rowley <drowley(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Remove buggy and dead code from CreateTriggerFiringOn
Date: 2022-09-06 03:52:29
Message-ID: E1oVPdU-001eNB-Nq@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Andres Freund 2022-09-06 03:54:11 Re: pgsql: Build all Flex files standalone
Previous Message John Naylor 2022-09-06 03:33:37 Re: pgsql: Build all Flex files standalone