提交 ad92b287 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Remove unnecessary precision argument of Value.convertTo(int, int, Mode)

上级 feb11859
......@@ -143,7 +143,7 @@ public class SelectUnion extends Query {
Mode mode = session.getDatabase().getMode();
for (int i = 0; i < columnCount; i++) {
Expression e = expressions.get(i);
newValues[i] = values[i].convertTo(e.getType(), -1, mode);
newValues[i] = values[i].convertTo(e.getType(), mode);
}
return newValues;
}
......
......@@ -412,11 +412,11 @@ public class FunctionAlias extends SchemaObjectBase {
paramClass.getComponentType());
Mode mode = session.getDatabase().getMode();
for (int i = 0; i < objArray.length; i++) {
objArray[i] = array[i].convertTo(componentType, -1, mode).getObject();
objArray[i] = array[i].convertTo(componentType, mode).getObject();
}
o = objArray;
} else {
v = v.convertTo(type, -1, session.getDatabase().getMode());
v = v.convertTo(type, session.getDatabase().getMode());
o = v.getObject();
}
if (o == null) {
......
......@@ -60,7 +60,7 @@ public class ConditionInConstantSet extends Condition {
}
} else {
for (Expression expression : valueList) {
valueSet.add(expression.getValue(session).convertTo(type, -1, mode));
valueSet.add(expression.getValue(session).convertTo(type, mode));
}
}
}
......@@ -172,7 +172,7 @@ public class ConditionInConstantSet extends Condition {
if (type == Value.ENUM) {
valueSet.add(add.getValue(session).convertToEnum(enumerators));
} else {
valueSet.add(add.getValue(session).convertTo(type, -1, session.getDatabase().getMode()));
valueSet.add(add.getValue(session).convertTo(type, session.getDatabase().getMode()));
}
return this;
}
......
......@@ -62,7 +62,7 @@ public class ConditionInSelect extends Condition {
if (dataType == Value.NULL) {
return ValueBoolean.FALSE;
}
l = l.convertTo(dataType, -1, database.getMode());
l = l.convertTo(dataType, database.getMode());
if (rows.containsDistinct(new Value[] { l })) {
return ValueBoolean.TRUE;
}
......
......@@ -873,7 +873,7 @@ public class Function extends Expression implements FunctionCall {
case CAST:
case CONVERT: {
Mode mode = database.getMode();
v0 = v0.convertTo(dataType, -1, mode);
v0 = v0.convertTo(dataType, mode);
v0 = v0.convertScale(mode.convertOnlyToSmallerScale, scale);
v0 = v0.convertPrecision(getPrecision(), false);
result = v0;
......@@ -902,7 +902,7 @@ public class Function extends Expression implements FunctionCall {
if (v0 == ValueNull.INSTANCE) {
result = getNullOrValue(session, args, values, 1);
}
result = result.convertTo(dataType, -1, database.getMode());
result = result.convertTo(dataType, database.getMode());
break;
}
case CASEWHEN: {
......
......@@ -110,14 +110,14 @@ public class Operation extends Expression {
@Override
public Value getValue(Session session) {
Mode mode = session.getDatabase().getMode();
Value l = left.getValue(session).convertTo(dataType, -1, mode);
Value l = left.getValue(session).convertTo(dataType, mode);
Value r;
if (right == null) {
r = null;
} else {
r = right.getValue(session);
if (convertRight) {
r = r.convertTo(dataType, -1, mode);
r = r.convertTo(dataType, mode);
}
}
switch (opType) {
......
......@@ -77,7 +77,7 @@ public class HashIndex extends BaseIndex {
* case we need to convert, otherwise the ValueHashMap will not find the
* result.
*/
v = v.convertTo(tableData.getColumn(indexColumn).getType(), -1, database.getMode());
v = v.convertTo(tableData.getColumn(indexColumn).getType(), database.getMode());
Row result;
Long pos = rows.get(v);
if (pos == null) {
......
......@@ -101,7 +101,7 @@ public class NonUniqueHashIndex extends BaseIndex {
* case we need to convert, otherwise the ValueHashMap will not find the
* result.
*/
v = v.convertTo(tableData.getColumn(indexColumn).getType(), -1, database.getMode());
v = v.convertTo(tableData.getColumn(indexColumn).getType(), database.getMode());
ArrayList<Long> positions = rows.get(v);
return new NonUniqueHashCursor(session, tableData, positions);
}
......
......@@ -562,7 +562,7 @@ public class JdbcPreparedStatement extends JdbcStatement implements
setParameter(parameterIndex, ValueNull.INSTANCE);
} else {
Value v = DataType.convertToValue(conn.getSession(), x, type);
setParameter(parameterIndex, v.convertTo(type, -1, conn.getMode()));
setParameter(parameterIndex, v.convertTo(type, conn.getMode()));
}
} catch (Exception e) {
throw logAndConvert(e);
......
......@@ -1066,7 +1066,7 @@ public class JdbcResultSet extends TraceObject implements ResultSet, JdbcResultS
public byte[] getBytes(int columnIndex) throws SQLException {
try {
debugCodeCall("getBytes", columnIndex);
return get(columnIndex).convertTo(Value.BYTES, -1, conn.getMode()).getBytes();
return get(columnIndex).convertTo(Value.BYTES, conn.getMode()).getBytes();
} catch (Exception e) {
throw logAndConvert(e);
}
......
......@@ -589,7 +589,7 @@ public abstract class Value {
public Value convertTo(int targetType) {
// Use -1 to indicate "default behaviour" where value conversion should not
// depend on any datatype precision.
return convertTo(targetType, -1, null);
return convertTo(targetType, null);
}
/**
......@@ -607,14 +607,11 @@ public abstract class Value {
* Compare a value to the specified type.
*
* @param targetType the type of the returned value
* @param precision the precision of the column to convert this value to.
* The special constant <code>-1</code> is used to indicate that
* the precision plays no role when converting the value
* @param mode the mode
* @return the converted value
*/
public final Value convertTo(int targetType, int precision, Mode mode) {
return convertTo(targetType, precision, mode, null, null);
public final Value convertTo(int targetType, Mode mode) {
return convertTo(targetType, -1, mode, null, null);
}
/**
......@@ -1193,8 +1190,8 @@ public abstract class Value {
l = l.convertToEnum(enumerators);
v = v.convertToEnum(enumerators);
} else {
l = l.convertTo(dataType, -1, databaseMode);
v = v.convertTo(dataType, -1, databaseMode);
l = l.convertTo(dataType, databaseMode);
v = v.convertTo(dataType, databaseMode);
}
}
return l.compareSecure(v, compareMode);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论