private QueryTablePlanner Clone()
{
var copy = new QueryTablePlanner();
int sz = tablePlans.Count;
for (int i = 0; i < sz; ++i) {
copy.tablePlans.Add(tablePlans[i].Clone());
}
// Copy the left and right links in the PlanTableSource
for (int i = 0; i < sz; ++i) {
var src = tablePlans[i];
var mod = copy.tablePlans[i];
// See how the left plan links to which index,
if (src.LeftPlan != null) {
int n = IndexOfPlan(src.LeftPlan);
mod.LeftJoin(copy.tablePlans[n], src.LeftJoinType, src.LeftOnExpression);
}
// See how the right plan links to which index,
if (src.RightPlan != null) {
int n = IndexOfPlan(src.RightPlan);
mod.RightJoin(copy.tablePlans[n], src.RightJoinType, src.RightOnExpression);
}
}
return copy;
}