Re: [DEPARSE] EXPLAIN prints another ModifyTable's RETURNING aliases in a SubPlan

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
Cc: Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com>, assam258(at)gmail(dot)com, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [DEPARSE] EXPLAIN prints another ModifyTable's RETURNING aliases in a SubPlan
Date: 2026-10-21 16:38:32
Message-ID: 2208434.1792600712@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com> writes:
> I think just dropping the Asserts is the better solution, because
> showing "Output: n.a" in the EXPLAIN output is likely to lead to
> confusion, since there was no relation with alias "n" in the
> triggering query, and "n" isn't mentioned anywhere else in the EXPLAIN
> output. The user would have to lookup the rule definition to figure
> out what "n" means.

But wait a minute: there's still something pretty strange
going on here. In the first place, Ayush's test case doesn't
crash if the outer query doesn't try to use alias "new" for v:

EXPLAIN (VERBOSE, COSTS OFF)
INSERT INTO v AS foo VALUES (1) RETURNING *;
QUERY PLAN
--------------------
Insert on public.t
Output: new.a
-> Result
Output: 1
(4 rows)

In the second place, where did "new" come from here? If it came out
of the rule, why isn't it "n"? Seems like we're exposing details of
the rule anyway, but inconsistently.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2026-10-21 17:09:38 Re: [DEPARSE] EXPLAIN prints another ModifyTable's RETURNING aliases in a SubPlan
Previous Message Tom Lane 2026-10-21 16:17:46 Re: [DEPARSE] EXPLAIN prints another ModifyTable's RETURNING aliases in a SubPlan