sel.setAutoDistinct((exps.distinct & exps.DISTINCT_AUTO) != 0);
sel.setJoinSyntax(ctx.fetch.getJoinSyntax());
sel.setParent(parent, alias);
Context[] qryCtx = JDBCStoreQuery.getThreadLocalContext();
Context lctx = null;
for (int i = 0; i < qryCtx.length; i++) {
if (qryCtx[i].cloneFrom == exps.ctx()) {
lctx = qryCtx[i];
break;
}
}
if (sel.ctx() == null)
sel.setContext(lctx);
if (parent == null && lctx.getSubselContexts() != null) {
// this is the case subselect was created before parent got created
List<Context> subselCtxs = lctx.getSubselContexts();
for (Context subselCtx : subselCtxs) {
Select subsel = (Select) subselCtx.getSelect();
Subquery subquery = subselCtx.getSubquery();
subsel.setParent(sel, subquery.getCandidateAlias());
}