提交 96c47e8c authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Add some missing getSubexpression() implementations

上级 15476b8b
...@@ -19,7 +19,7 @@ import org.h2.expression.Alias; ...@@ -19,7 +19,7 @@ import org.h2.expression.Alias;
import org.h2.expression.Expression; import org.h2.expression.Expression;
import org.h2.expression.ExpressionColumn; import org.h2.expression.ExpressionColumn;
import org.h2.expression.ExpressionVisitor; import org.h2.expression.ExpressionVisitor;
import org.h2.expression.Function; import org.h2.expression.FunctionCall;
import org.h2.expression.Parameter; import org.h2.expression.Parameter;
import org.h2.expression.ValueExpression; import org.h2.expression.ValueExpression;
import org.h2.message.DbException; import org.h2.message.DbException;
...@@ -555,8 +555,8 @@ public abstract class Query extends Prepared { ...@@ -555,8 +555,8 @@ public abstract class Query extends Prepared {
} }
} }
int count = expr.getSubexpressionCount(); int count = expr.getSubexpressionCount();
if (expr instanceof Function) { if (expr instanceof FunctionCall) {
if (!((Function) expr).isDeterministic()) { if (!((FunctionCall) expr).isDeterministic()) {
return false; return false;
} }
} else if (count <= 0) { } else if (count <= 0) {
......
...@@ -517,4 +517,26 @@ public class CompareLike extends Condition { ...@@ -517,4 +517,26 @@ public class CompareLike extends Condition {
return left.getCost() + right.getCost() + 3; return left.getCost() + right.getCost() + 3;
} }
@Override
public int getSubexpressionCount() {
return escape == null ? 2 : 3;
}
@Override
public Expression getSubexpression(int index) {
switch (index) {
case 0:
return left;
case 1:
return right;
case 2:
if (escape != null) {
return escape;
}
//$FALL-THROUGH$
default:
throw new IndexOutOfBoundsException();
}
}
} }
...@@ -207,4 +207,20 @@ public class ConditionIn extends Condition { ...@@ -207,4 +207,20 @@ public class ConditionIn extends Condition {
} }
return null; return null;
} }
@Override
public int getSubexpressionCount() {
return 1 + valueList.size();
}
@Override
public Expression getSubexpression(int index) {
if (index == 0) {
return left;
} else if (index > 0 && index <= valueList.size()) {
return valueList.get(index - 1);
}
throw new IndexOutOfBoundsException();
}
} }
...@@ -176,4 +176,20 @@ public class ConditionInConstantSet extends Condition { ...@@ -176,4 +176,20 @@ public class ConditionInConstantSet extends Condition {
} }
return null; return null;
} }
@Override
public int getSubexpressionCount() {
return 1 + valueList.size();
}
@Override
public Expression getSubexpression(int index) {
if (index == 0) {
return left;
} else if (index > 0 && index <= valueList.size()) {
return valueList.get(index - 1);
}
throw new IndexOutOfBoundsException();
}
} }
...@@ -132,4 +132,14 @@ public class ExpressionList extends Expression { ...@@ -132,4 +132,14 @@ public class ExpressionList extends Expression {
return expr; return expr;
} }
@Override
public int getSubexpressionCount() {
return list.length;
}
@Override
public Expression getSubexpression(int index) {
return list[index];
}
} }
...@@ -312,22 +312,21 @@ public class IntervalOperation extends Expression { ...@@ -312,22 +312,21 @@ public class IntervalOperation extends Expression {
return left.getCost() + 1 + right.getCost(); return left.getCost() + 1 + right.getCost();
} }
/** @Override
* Get the left sub-expression of this operation. public int getSubexpressionCount() {
* return 2;
* @return the left sub-expression
*/
public Expression getLeftSubExpression() {
return left;
} }
/** @Override
* Get the right sub-expression of this operation. public Expression getSubexpression(int index) {
* switch (index) {
* @return the right sub-expression case 0:
*/ return left;
public Expression getRightSubExpression() { case 1:
return right; return right;
default:
throw new IndexOutOfBoundsException();
}
} }
} }
...@@ -178,4 +178,14 @@ public class JavaFunction extends Expression implements FunctionCall { ...@@ -178,4 +178,14 @@ public class JavaFunction extends Expression implements FunctionCall {
return functionAlias.isBufferResultSetToLocalTemp(); return functionAlias.isBufferResultSetToLocalTemp();
} }
@Override
public int getSubexpressionCount() {
return args.length;
}
@Override
public Expression getSubexpression(int index) {
return args[index];
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论