Violation of principle that plan trees are read-only

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Cc: Andres Freund <andres(at)anarazel(dot)de>
Subject: Violation of principle that plan trees are read-only
Date: 2025-05-18 23:31:33
Message-ID: 213261.1747611093@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

While chasing down Valgrind leakage reports, I was disturbed
to realize that some of them arise from a case where the
executor scribbles on the plan tree it's given, which it is
absolutely not supposed to do:

/*
* Initialize result tuple slot and assign its rowtype using the first
* RETURNING list. We assume the rest will look the same.
*/
mtstate->ps.plan->targetlist = (List *) linitial(returningLists);

A bit of git archaeology fingers Andres' commit 4717fdb14, which we
can't easily revert since he later got rid of ExecAssignResultType
altogether. But I think we need to do something about it --- it's
purest luck that this doesn't cause serious problems in some cases.

regards, tom lane

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2025-05-18 23:48:00 Re: Suggestion: Update Copyright Year to 2025 in Recently Added Files
Previous Message Alexander Korotkov 2025-05-18 21:25:36 Re: Slot's restart_lsn may point to removed WAL segment after hard restart unexpectedly