In AfterTriggerSaveEvent(), the "new_shared" variable is not used outside the "for" loop, so I think it should be defined only within the loop. The following patch makes reading the code a little bit more convenient for me.
diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c index 409bee24f8..d95c57f244 100644 --- a/src/backend/commands/trigger.c +++ b/src/backend/commands/trigger.c @@ -5743,7 +5743,6 @@ AfterTriggerSaveEvent(EState *estate, ResultRelInfo *relinfo, Relation rel = relinfo->ri_RelationDesc; TriggerDesc *trigdesc = relinfo->ri_TrigDesc; AfterTriggerEventData new_event; - AfterTriggerSharedData new_shared; char relkind = rel->rd_rel->relkind; int tgtype_event; int tgtype_level; @@ -5937,6 +5936,7 @@ AfterTriggerSaveEvent(EState *estate, ResultRelInfo *relinfo, for (i = 0; i < trigdesc->numtriggers; i++) { Trigger *trigger = &trigdesc->triggers[i]; + AfterTriggerSharedData new_shared; if (!TRIGGER_TYPE_MATCHES(trigger->tgtype, tgtype_level, -- Antonin Houska https://www.cybertec-postgresql.com