Re: Violation of principle that plan trees are read-only
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andres Freund <andres@anarazel.de>
Cc: pgsql-hackers@lists.postgresql.org
Date: 2025-05-20T20:18:57Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
In ExecInitModifyTable, don't scribble on the source plan.
- d376ab570ef9 18.0 landed
-
Rely on executor utils to build targetlist for DML RETURNING.
- 4717fdb14cf0 11.0 cited
Andres Freund <andres@anarazel.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