Attaching derby-5779-04-ab-subqueriesInFromList.diff. Second rev of patch to fix correlated references to outer tables by arguments to VTIs/tableFunctions invoked inside subqueries. I am running regression tests now.
Touches the following files:
At bind time, a subquery in the FROM list now pokes the FROM list into any VTIs invoked inside it.
When binding VTI arguments, we check to see if they contain correlated references to outer query blocks. If so, we make sure that those references are not to tables on the FROM lists which were poked into the VTI by outer subqueries.
We hit an NPE if we permute the join order, putting the subquery in the FROM list ahead of the tables referenced by args in its nested VTIs. We replace that NPE with an error message saying that we have detected an illegal reference in a VTI argument.
We reword the 42ZB7 message to reflect the fact that it is being raised in more situations now.
Additional test cases.