提交 4b88dc6d authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Use Value.convertTo() with TypeInfo in more places

上级 56a9668f
...@@ -99,11 +99,10 @@ public class BinaryOperation extends Expression { ...@@ -99,11 +99,10 @@ public class BinaryOperation extends Expression {
@Override @Override
public Value getValue(Session session) { public Value getValue(Session session) {
Mode mode = session.getDatabase().getMode(); Mode mode = session.getDatabase().getMode();
int dataType = type.getValueType(); Value l = left.getValue(session).convertTo(type, mode, null);
Value l = left.getValue(session).convertTo(dataType, mode);
Value r = right.getValue(session); Value r = right.getValue(session);
if (convertRight) { if (convertRight) {
r = r.convertTo(dataType, mode); r = r.convertTo(type, mode, null);
} }
switch (opType) { switch (opType) {
case CONCAT: { case CONCAT: {
......
...@@ -34,7 +34,7 @@ public class UnaryOperation extends Expression { ...@@ -34,7 +34,7 @@ public class UnaryOperation extends Expression {
@Override @Override
public Value getValue(Session session) { public Value getValue(Session session) {
Value a = arg.getValue(session).convertTo(type.getValueType(), session.getDatabase().getMode()); Value a = arg.getValue(session).convertTo(type, session.getDatabase().getMode(), null);
return a == ValueNull.INSTANCE ? a : a.negate(); return a == ValueNull.INSTANCE ? a : a.negate();
} }
......
...@@ -19,6 +19,7 @@ import org.h2.result.ResultInterface; ...@@ -19,6 +19,7 @@ import org.h2.result.ResultInterface;
import org.h2.table.ColumnResolver; import org.h2.table.ColumnResolver;
import org.h2.table.TableFilter; import org.h2.table.TableFilter;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
import org.h2.value.TypeInfo;
import org.h2.value.Value; import org.h2.value.Value;
import org.h2.value.ValueBoolean; import org.h2.value.ValueBoolean;
import org.h2.value.ValueNull; import org.h2.value.ValueNull;
...@@ -72,8 +73,8 @@ public class ConditionInSelect extends Condition { ...@@ -72,8 +73,8 @@ public class ConditionInSelect extends Condition {
return ValueBoolean.TRUE; return ValueBoolean.TRUE;
} }
} else { } else {
int dataType = rows.getColumnType(0).getValueType(); TypeInfo colType = rows.getColumnType(0);
if (dataType == Value.NULL) { if (colType.getValueType() == Value.NULL) {
return ValueBoolean.FALSE; return ValueBoolean.FALSE;
} }
if (l.getValueType() == Value.ROW) { if (l.getValueType() == Value.ROW) {
...@@ -83,7 +84,7 @@ public class ConditionInSelect extends Condition { ...@@ -83,7 +84,7 @@ public class ConditionInSelect extends Condition {
} }
l = leftList[0]; l = leftList[0];
} }
l = l.convertTo(dataType, database.getMode()); l = l.convertTo(colType, database.getMode(), null);
if (rows.containsDistinct(new Value[] { l })) { if (rows.containsDistinct(new Value[] { l })) {
return ValueBoolean.TRUE; return ValueBoolean.TRUE;
} }
......
...@@ -97,10 +97,10 @@ public class HashIndex extends BaseIndex { ...@@ -97,10 +97,10 @@ public class HashIndex extends BaseIndex {
/* /*
* Sometimes the incoming search is a similar, but not the same type * Sometimes the incoming search is a similar, but not the same type
* e.g. the search value is INT, but the index column is LONG. In which * e.g. the search value is INT, but the index column is LONG. In which
* case we need to convert, otherwise the ValueHashMap will not find the * case we need to convert, otherwise the HashMap will not find the
* result. * result.
*/ */
v = v.convertTo(tableData.getColumn(indexColumn).getType().getValueType(), database.getMode()); v = v.convertTo(tableData.getColumn(indexColumn).getType(), database.getMode(), null);
Row result; Row result;
Long pos = rows.get(v); Long pos = rows.get(v);
if (pos == null) { if (pos == null) {
......
...@@ -105,10 +105,10 @@ public class NonUniqueHashIndex extends BaseIndex { ...@@ -105,10 +105,10 @@ public class NonUniqueHashIndex extends BaseIndex {
/* /*
* Sometimes the incoming search is a similar, but not the same type * Sometimes the incoming search is a similar, but not the same type
* e.g. the search value is INT, but the index column is LONG. In which * e.g. the search value is INT, but the index column is LONG. In which
* case we need to convert, otherwise the ValueHashMap will not find the * case we need to convert, otherwise the HashMap will not find the
* result. * result.
*/ */
v = v.convertTo(tableData.getColumn(indexColumn).getType().getValueType(), database.getMode()); v = v.convertTo(tableData.getColumn(indexColumn).getType(), database.getMode(), null);
ArrayList<Long> positions = rows.get(v); ArrayList<Long> positions = rows.get(v);
return new NonUniqueHashCursor(session, tableData, positions); return new NonUniqueHashCursor(session, tableData, positions);
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论