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