Re: EXPLAIN Verbose issue - custom_scan_tlist can directly refer CTE and Subquery

From: Andrey Lepikhov <a(dot)lepikhov(at)postgrespro(dot)ru>
To: Richard Guo <guofenglinux(at)gmail(dot)com>, Lepikhov Andrei <lepikhov(at)fastmail(dot)com>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org, tgl(at)sss(dot)pgh(dot)pa(dot)us, Алена Рыбакина <a(dot)rybakina(at)postgrespro(dot)ru>, Дамир Белялов <d(dot)belyalov(at)postgrespro(dot)ru>
Subject: Re: EXPLAIN Verbose issue - custom_scan_tlist can directly refer CTE and Subquery
Date: 2023-09-28 06:32:25
Message-ID: ca3f78bc-9775-4c12-97b5-5e03282df3ea@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On 11/9/2023 13:28, Richard Guo wrote:
> So it seems that we need to assign a proper INNER referent for
> CustomScan node in set_deparse_plan().  I tried 'trick.diff' in [1]
> which uses linitial(dpns->subplans), it fixes the query there but would
> crash the query below.
>
> explain (verbose, costs off)
> select (rr).column2 from
>   (select r from (values(1,2),(3,4)) r) s join
>   (select rr from (values(1,7),(3,8)) rr limit 2) ss
>   on (r).column1 = (rr).column1;
> server closed the connection unexpectedly
>
> Maybe we can use the first plan in CustomScan->custom_plans as the INNER
> referent?  I'm not sure.

Looking into this issue more, I figured out that we can't be sure from
which side the current varno of custom_scan_tlist was produced: from
inner, outer or one of the custom subplans. In one of my previous R&D
projects, I remember that the CustomScan node received tuples from the
network, gathering them from other pg-instances.
So, as we already have an optional ExplainCustomScan routine, maybe add
one more for the show_plan_tlist routine? It can print a target list or
ignore it as the Append node does.

--
regards,
Andrey Lepikhov
Postgres Professional

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Michael Paquier 2023-09-28 07:07:35 Re: BUG #18135: Incorrect memory access occurs when attaching a partition with an index
Previous Message Andrey Lepikhov 2023-09-28 05:07:48 Missed TidRangePath in the print_path switch