> After some thought and experimentation, the best fix seems to be to
> eliminate the ambiguity by wrapping subquery outputs in PlaceHolderVars
> whenever there is a risk of confusion. The attached crude patch fixes
> both test cases. It needs work (more comments and a regression test
> case would be good), but barring objection I'll push forward with doing
> it this way.
Thank you, your patch fixes original query too.
--
Teodor Sigaev E-mail: teodor(at)sigaev(dot)ru
WWW: http://www.sigaev.ru/