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