it would be great to fix this problem - I've seen this issue a few times.
Thanks for the input. I guess this is not rare in the real world. If the subquery contains lateral reference to a Var that also appears in the subquery's join clauses, we'd probably suffer from this issue.