Table table = rangeTable;
SubQuery subQuery = table.getSubQuery();
if (subQuery != null && !subQuery.isResolved()) {
if (subQuery.dataExpression != null) {
HsqlList unresolved =
subQuery.dataExpression.resolveColumnReferences(session,
RangeVariable.emptyArray, null);
if (unresolved != null) {
unresolved =
subQuery.dataExpression.resolveColumnReferences(
session, rangeVariables, rangeCount, null, true);
}
if (unresolved != null) {
unresolved =
subQuery.dataExpression.resolveColumnReferences(
session, outerRanges, null);
}
if (unresolved != null) {
throw Error.error(
ErrorCode.X_42501,
((Expression) unresolved.get(0)).getSQL());
}
subQuery.dataExpression.resolveTypes(session, null);
setRangeTableVariables();
}
if (subQuery.queryExpression != null) {
subQuery.queryExpression.resolveReferences(session,
outerRanges);
HsqlList list =
subQuery.queryExpression.getUnresolvedExpressions();
// todo resolve against i ranges
HsqlList unresolved = Expression.resolveColumnSet(session,
rangeVariables, rangeCount, list, null);
if (unresolved != null) {
throw Error.error(
ErrorCode.X_42501,
((Expression) unresolved.get(0)).getSQL());
}
subQuery.queryExpression.resolveTypes(session);
subQuery.prepareTable(session);
subQuery.setCorrelated();