public override void AddToPlanTree() { var columnNames = expression.DiscoverReferences(); var tablePlan = planner.JoinPlansForColumns(columnNames); tablePlan.UpdatePlan(new ExhaustiveSelectNode(tablePlan.Plan, expression)); }
private void EvaluateSingles(List <SqlBinaryExpression> list, List <ExpressionPlan> plans) { // The list of simple expression plans (lhs = single) var simplePlanList = new List <SingleColumnPlan>(); // The list of complex function expression plans (lhs = expression) var complexPlanList = new List <SingleColumnPlan>(); foreach (var expression in list) { // The single var ObjectName singleVar; SqlExpressionType op = expression.ExpressionType; SqlExpression left = expression.Left, right = expression.Right; if (op.IsSubQuery()) { singleVar = expression.Left.AsReferenceName(); if (singleVar != null) { plans.Add(new SimpleSelectPlan(this, singleVar, op, expression.Right)); } else { singleVar = expression.Left.DiscoverReferences().First(); plans.Add(new ComplexSinglePlan(this, singleVar, expression)); } } else { singleVar = expression.Left.DiscoverReferences().FirstOrDefault(); if (singleVar == null) { // Reverse the expressions and the operator var tempExp = left; left = right; right = tempExp; op = op.Reverse(); singleVar = left.DiscoverReferences().First(); } var tableSource = FindPlan(singleVar); // Simple LHS? var v = left.AsReferenceName(); if (v != null) { AddSingleColumnPlan(simplePlanList, tableSource, v, singleVar, new [] { left, right }, op); } else { // No, complex lhs AddSingleColumnPlan(complexPlanList, tableSource, null, singleVar, new [] { left, right }, op); } } } plans.AddRange(simplePlanList.Select(plan => new SimpleSinglePlan(this, plan.UniqueName, plan.Expression)).Cast <ExpressionPlan>()); plans.AddRange(complexPlanList.Select(plan => new ComplexSinglePlan(this, plan.UniqueName, plan.Expression)).Cast <ExpressionPlan>()); }