Re: Fix trigger memory leak

From: Paul A Jungwirth <pj(at)illuminatedcomputing(dot)com>
To: surya poondla <suryapoondla4(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de>, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Subject: Re: Fix trigger memory leak
Date: 2026-11-04 04:27:29
Message-ID: CA+renyXA8ybj=F5wM=j6FN5XDJx6kJbzz9Er-4BRjg11pFtwMg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Nov 2, 2026 at 5:34 AM Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> wrote:
> 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".

Thank you for the review! You're right; fixed.

On Mon, Nov 2, 2026 at 11:03 PM surya poondla <suryapoondla4(at)gmail(dot)com> wrote:
> I also found that you don't need a view to hit this. A plain BEFORE
> INSERT trigger on a partitioned table leaks just as much when the row is
> routed to a partition with the same column layout as the parent. In that
> case there's no conversion map, so ExecPrepareTupleRouting() passes the
> root's virtual slot straight through and ExecBRInsertTriggers() ends up
> with a copy it never frees. Inserting directly into the partition, or
> routing to one with a different column order, doesn't leak. Maybe we can
> put that in the commit message but not really needed.

Thank you too! I updated the commit message to mention that case.

v2 attached.

Yours,

--
Paul ~{:-)
pj(at)illuminatedcomputing(dot)com

Attachment Content-Type Size
v2-0001-Free-the-tuple-fetched-for-BEFORE-INSTEAD-OF-row-.patch text/x-patch 3.4 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message shveta malik 2026-11-04 04:35:06 Re: Proposal: Conflict log history table for Logical Replication
Previous Message Paul A Jungwirth 2026-11-04 04:11:41 Re: Reject wholerow references where ColumnRef is forbidden