}
return newCtx;
}
private static Context clone(Context orig, Context parent) {
Context myParent = null;
if (parent == null) {
Context origParent = orig.getParent();
if (origParent != null)
myParent = clone(orig.getParent(), null);
} else
myParent = parent;
Context newCtx = new Context(orig.parsed, null, myParent);
newCtx.from = orig.from;
newCtx.meta = orig.meta;
newCtx.schemaAlias = orig.schemaAlias;
newCtx.setSchemas(orig.getSchemas());
newCtx.setVariables(orig.getVariables());
newCtx.cloneFrom = orig;
Object select = orig.getSelect();
if (select != null)
newCtx.setSelect(((SelectImpl)select).clone(newCtx));
newCtx.subquery = orig.subquery;
List<Context> subsels = orig.getSubselContexts();
if (subsels != null) {
for (Context subsel : subsels)
newCtx.addSubselContext(clone(subsel, newCtx));
}
return newCtx;
}