On Mon, Sep 11, 2023, at 1:28 PM, Richard Guo wrote:
> Maybe we can use the first plan in CustomScan->custom_plans as the INNER
> referent? I'm not sure.
After some exploration of ruleutils.c I grasped more on this issue.
If we have come to the CTE or SubPlan entry by the INDEX_VAR link from custom_scan_tlist, we don't have any information
onwhich subplan to go further (entry info already removed because of optimization).
To find a specific subplan, we must pass through the custom node subtree and find CteScan or SubqueryScan, whose target
listrefers to this entry. After that, we can go into the subplan to correctly explain the var.
It looks like a lot of work. One vague idea is to change set_customscan_references and wrap up CustomScan with useful
data.
Or, maybe it is better not to try to go under the custom_scan_tlist and explain CTE and Subquery right on the level of
theCustomScan?
--
Regards,
Andrei Lepikhov