提交 584b1c8d authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Calculate precision of || result and add missing case label

上级 f2b73153
...@@ -164,9 +164,18 @@ public class BinaryOperation extends Expression { ...@@ -164,9 +164,18 @@ public class BinaryOperation extends Expression {
left = left.optimize(session); left = left.optimize(session);
right = right.optimize(session); right = right.optimize(session);
switch (opType) { switch (opType) {
case CONCAT: case CONCAT: {
TypeInfo l = left.getType(), r = right.getType();
if (DataType.isStringType(l.getValueType()) && DataType.isStringType(r.getValueType())) {
long precision = l.getPrecision() + r.getPrecision();
if (precision >= 0 && precision < Integer.MAX_VALUE) {
type = TypeInfo.getTypeInfo(Value.STRING, precision, 0, (int) precision, null);
break;
}
}
type = TypeInfo.TYPE_STRING_DEFAULT; type = TypeInfo.TYPE_STRING_DEFAULT;
break; break;
}
case PLUS: case PLUS:
case MINUS: case MINUS:
case MULTIPLY: case MULTIPLY:
......
...@@ -240,6 +240,7 @@ public class TypeInfo { ...@@ -240,6 +240,7 @@ public class TypeInfo {
case Value.BYTE: case Value.BYTE:
case Value.SHORT: case Value.SHORT:
case Value.INT: case Value.INT:
case Value.LONG:
case Value.DOUBLE: case Value.DOUBLE:
case Value.FLOAT: case Value.FLOAT:
case Value.DATE: case Value.DATE:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论