Re: Violation of principle that plan trees are read-only

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

Andres Freund <andres(at)anarazel(dot)de> writes:
> Largely makes sense, the only thing I see is that the !returningLists branch
> does:
> /*
> * We still must construct a dummy result tuple type, because InitPlan
> * expects one (maybe should change that?).
> */
> mtstate->ps.plan->targetlist = NIL;

> which we presumably shouldn't do anymore either. It never changes anything
> afaict, but still.

D'oh ... I had seen that branch before, but missed fixing it.
Yeah, the targetlist will be NIL already, but it's still wrong.

>> I'm tempted to back-patch this: the plan tree damage seems harmless at
>> present, but maybe it'd become less harmless with future fixes.

> There are *some* cases where this changes the explain output, but but the new
> output is more correct, I think:
> ...
> I suspect this is an argument for backpatching, not against - seems that
> deparsing could end up creating bogus output in cases where it could matter?
> Not sure if such cases are reachable via views (and thus pg_dump) or
> postgres_fdw, but it seems possible.

I don't believe that we guarantee EXPLAIN output to be 100% valid SQL,
so I doubt there's a correctness argument here; certainly it'd not
affect pg_dump. I'm curious though: what was the test case you were
looking at?

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2025-05-20 20:28:01 Re: proposal: schema variables
Previous Message Peter Geoghegan 2025-05-20 20:13:41 Re: Adding skip scan (including MDAM style range skip scan) to nbtree