Re: Fix trigger memory leak

From: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
To: Paul A Jungwirth <pj(at)illuminatedcomputing(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de>
Subject: Re: Fix trigger memory leak
Date: 2026-11-02 05:34:47
Message-ID: 098393C3-334D-423E-A70D-25D392AEEBE9@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On Nov 1, 2026, at 01:17, Paul A Jungwirth <pj(at)illuminatedcomputing(dot)com> wrote:
>
> Hi Hackers,
>
> Here is a patch to fix some memory leaks in BEFORE/INSTEAD OF triggers.
>
> Andres reported the problem in [0] while reviewing FOR PORTION OF, but
> as he suspected, it is a problem on master too. It goes back to v14 at
> least. You can reach it if (1) the rel is not a regular table (e.g. a
> view) and (2) the trigger returns NEW without changing it (or NULL in
> ExecIRInsertTriggers).
>
> [0] https://www.postgresql.org/message-id/yfers7d2kizq6ockz4nu7e7avq3gj5anpd7ilxkazyvicv4qgy@3cesow2bbhnx
>
> Yours,
>
> --
> Paul ~{:-)
> pj(at)illuminatedcomputing(dot)com
> <v1-0001-Free-the-tuple-fetched-for-BEFORE-INSTEAD-OF-row-.patch>

V1 overall looks good to me. There seems a typo in the commit message:
```
heap slot) and (2) the trigger returned NEW unchanged (or NULL in
ExecIRInsertTriggers).
```

I think it should be “or NULL in ExecIRUpdateTriggers”.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/

In response to

Browse pgsql-hackers by date

  From Date Subject
Previous Message Hayato Kuroda (Fujitsu) 2026-11-02 05:33:35 RE: Incorrect CONTEXT reported for errors from parallel apply worker in logical replication