private void SetEqaulityConditions(RangeVariable.RangeVariableConditions conditions, List <Expression> exprList) { Index index = conditions.RangeVar.RangeTable.GetIndexForColumns(this.session, this._colIndexSetEqual, false); if (index != null) { int[] columns = index.GetColumns(); int length = columns.Length; Expression[] expressionArray = new Expression[columns.Length]; for (int i = 0; i < exprList.Count; i++) { Expression e = exprList[i]; if (e != null) { switch (e.GetExprType()) { case 0x29: case 0x2f: { if (e.GetLeftNode().GetRangeVariable() != conditions.RangeVar) { continue; } int num4 = ArrayUtil.Find(columns, e.GetLeftNode().GetColumnIndex()); if ((num4 != -1) && (expressionArray[num4] == null)) { expressionArray[num4] = e; exprList[i] = null; continue; } break; } } conditions.AddCondition(e); exprList[i] = null; } } bool flag = false; for (int j = 0; j < expressionArray.Length; j++) { Expression e = expressionArray[j]; if (e == null) { if (length == columns.Length) { length = j; } flag = true; } else if (flag) { conditions.AddCondition(e); expressionArray[j] = null; } } conditions.AddIndexCondition(expressionArray, index, length); } }
private static void AssignToRangeVariable(RangeVariable.RangeVariableConditions conditions, List <Expression> exprList) { int num = 0; int count = exprList.Count; while (num < count) { Expression e = exprList[num]; conditions.AddCondition(e); num++; } }
private void SetInConditionsAsTables() { for (int i = this.RangeVariables.Length - 1; i >= 0; i--) { RangeVariable range = this.RangeVariables[i]; ExpressionLogical e = (ExpressionLogical)this._inExpressions[i]; if (e != null) { OrderedIntHashSet set = new OrderedIntHashSet(); e.AddLeftColumnsForAllAny(range, set); Index index = range.RangeTable.GetIndexForColumns(this.session, set, false); int num2 = 0; for (int j = 0; j < index.GetColumnCount(); j++) { if (set.Contains(index.GetColumns()[j])) { num2++; } } RangeVariable addition = new RangeVariable(e.GetRightNode().GetTable(), null, null, null, this._compileContext) { IsGenerated = true }; RangeVariable[] dest = new RangeVariable[this.RangeVariables.Length + 1]; ArrayUtil.CopyAdjustArray <RangeVariable>(this.RangeVariables, dest, addition, i, 1); this.RangeVariables = dest; Expression[] exprList = new Expression[num2]; for (int k = 0; k < num2; k++) { int num5 = index.GetColumns()[k]; int colIndexRight = set.GetIndex(num5); exprList[k] = new ExpressionLogical(range, num5, addition, colIndexRight); } bool flag = this.RangeVariables[i].IsLeftJoin || this.RangeVariables[i].IsRightJoin; RangeVariable.RangeVariableConditions conditions1 = (!this._inInJoin[i] & flag) ? range.WhereConditions[0] : range.JoinConditions[0]; conditions1.AddIndexCondition(exprList, index, exprList.Length); conditions1.AddCondition(e); } } }
private void SetIndexConditions(RangeVariable.RangeVariableConditions conditions, List <Expression> exprList, int rangeVarIndex, bool includeOr) { this._colIndexSetEqual.Clear(); this._colIndexSetOther.Clear(); int num = 0; int count = exprList.Count; while (num < count) { Expression expression = exprList[num]; if ((expression != null) && expression.IsIndexable(conditions.RangeVar)) { switch (expression.GetExprType()) { case 0x29: if (((expression.ExprSubType != 0x34) && (expression.ExprSubType != 0x33)) && (expression.GetLeftNode().GetRangeVariable() == conditions.RangeVar)) { int columnIndex = expression.GetLeftNode().GetColumnIndex(); this._colIndexSetEqual.Add(columnIndex); } goto Label_01C9; case 0x2a: case 0x2b: case 0x2c: case 0x2d: if (expression.GetLeftNode().GetRangeVariable() == conditions.RangeVar) { int num8; int columnIndex = expression.GetLeftNode().GetColumnIndex(); if (!this._colIndexSetOther.TryGetValue(columnIndex, out num8)) { num8 = 0; } this._colIndexSetOther[columnIndex] = num8 + 1; } goto Label_01C9; case 0x2f: if (expression.GetLeftNode().GetRangeVariable() == conditions.RangeVar) { int columnIndex = expression.GetLeftNode().GetColumnIndex(); this._colIndexSetEqual.Add(columnIndex); } goto Label_01C9; case 0x30: if (expression.GetLeftNode().GetLeftNode().GetRangeVariable() == conditions.RangeVar) { int num11; int columnIndex = expression.GetLeftNode().GetLeftNode().GetColumnIndex(); if (!this._colIndexSetOther.TryGetValue(columnIndex, out num11)) { num11 = 0; } this._colIndexSetOther[columnIndex] = num11 + 1; } goto Label_01C9; case 50: case 2: goto Label_01C9; } Error.RuntimeError(0xc9, "RangeVariableResolver"); } Label_01C9: num++; } this.SetEqaulityConditions(conditions, exprList); if (!conditions.HasIndexCondition()) { this.SetNonEqualityConditions(conditions, exprList); } bool flag = conditions.HasIndexCondition(); bool flag2 = false; if (!flag & includeOr) { int num12 = 0; int num13 = exprList.Count; while (num12 < num13) { Expression expression2 = exprList[num12]; if (expression2 != null) { if (expression2.GetExprType() == 50) { flag = expression2.IsIndexable(conditions.RangeVar); if (flag) { flag = this.SetOrConditions(conditions, (ExpressionLogical)expression2, rangeVarIndex); } if (!flag) { goto Label_02FC; } exprList[num12] = null; flag2 = true; break; } if (((expression2.GetExprType() == 0x29) && (expression2.ExprSubType == 0x34)) && !expression2.GetRightNode().IsCorrelated()) { OrderedIntHashSet set = new OrderedIntHashSet(); ((ExpressionLogical)expression2).AddLeftColumnsForAllAny(conditions.RangeVar, set); if ((conditions.RangeVar.RangeTable.GetIndexForColumns(this.session, set, false) != null) && (this._inExpressions[rangeVarIndex] == null)) { this._inExpressions[rangeVarIndex] = expression2; this._inInJoin[rangeVarIndex] = conditions.IsJoin; this._inExpressionCount++; exprList[num12] = null; break; } } } Label_02FC: num12++; } } int num3 = 0; int num4 = exprList.Count; while (num3 < num4) { Expression expression3 = exprList[num3]; if (expression3 != null) { if (flag2) { for (int i = 0; i < conditions.RangeVar.JoinConditions.Length; i++) { if (conditions.IsJoin) { conditions.RangeVar.JoinConditions[i].NonIndexCondition = ExpressionLogical.AndExpressions(expression3, conditions.RangeVar.JoinConditions[i].NonIndexCondition); } else { conditions.RangeVar.WhereConditions[i].NonIndexCondition = ExpressionLogical.AndExpressions(expression3, conditions.RangeVar.WhereConditions[i].NonIndexCondition); } } } else { conditions.AddCondition(expression3); } } num3++; } }