private static int AssertBeNaturalJoin(TablePlan plan1, TablePlan plan2)
{
if (plan1.LeftPlan == plan2 || plan1.RightPlan == plan2)
return 0;
if (plan1.LeftPlan != null && plan2.LeftPlan != null)
// This is a left clash
return 2;
if (plan1.RightPlan != null && plan2.RightPlan != null)
// This is a right clash
return 1;
if ((plan1.LeftPlan == null && plan2.RightPlan == null) ||
(plan1.RightPlan == null && plan2.LeftPlan == null))
// This means a merge between the plans is fine
return 0;
// Must be a left and right clash
return 2;
}