提交 2daa26ba authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Remove unused display size parameters

上级 584b1c8d
......@@ -169,7 +169,7 @@ public class BinaryOperation extends Expression {
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);
type = TypeInfo.getTypeInfo(Value.STRING, precision, 0, null);
break;
}
}
......
......@@ -421,8 +421,7 @@ public class ValueDataType implements DataType {
TypeInfo columnType = result.getColumnType(i);
buff.putVarInt(columnType.getValueType()).
putVarLong(columnType.getPrecision()).
putVarInt(columnType.getScale()).
putVarInt(columnType.getDisplaySize());
putVarInt(columnType.getScale());
}
while (result.next()) {
buff.put((byte) 1);
......@@ -634,7 +633,7 @@ public class ValueDataType implements DataType {
SimpleResult rs = new SimpleResult();
int columns = readVarInt(buff);
for (int i = 0; i < columns; i++) {
rs.addColumn(readString(buff), readString(buff), readVarInt(buff), readVarLong(buff), readVarInt(buff),
rs.addColumn(readString(buff), readString(buff), readVarInt(buff), readVarLong(buff),
readVarInt(buff));
}
while (buff.get() != 0) {
......
......@@ -31,14 +31,13 @@ public class SimpleResult implements ResultInterface {
/** Column type. */
final TypeInfo columnType;
Column(String alias, String columnName, int columnType, long columnPrecision, int columnScale,
int displaySize) {
Column(String alias, String columnName, int columnType, long columnPrecision, int columnScale) {
if (alias == null || columnName == null) {
throw new NullPointerException();
}
this.alias = alias;
this.columnName = columnName;
this.columnType = TypeInfo.getTypeInfo(columnType, columnPrecision, columnScale, displaySize, null);
this.columnType = TypeInfo.getTypeInfo(columnType, columnPrecision, columnScale, null);
}
Column(String alias, String columnName, TypeInfo columnType) {
......@@ -108,11 +107,9 @@ public class SimpleResult implements ResultInterface {
* @param columnType Column's value type.
* @param columnPrecision Column's precision.
* @param columnScale Column's scale.
* @param displaySize Column's display data size.
*/
public void addColumn(String alias, String columnName, int columnType, long columnPrecision, int columnScale,
int displaySize) {
addColumn(new Column(alias, columnName, columnType, columnPrecision, columnScale, displaySize));
public void addColumn(String alias, String columnName, int columnType, long columnPrecision, int columnScale) {
addColumn(new Column(alias, columnName, columnType, columnPrecision, columnScale));
}
/**
......
......@@ -684,7 +684,6 @@ public class Data {
writeVarInt(columnType.getValueType());
writeVarLong(columnType.getPrecision());
writeVarInt(columnType.getScale());
writeVarInt(columnType.getDisplaySize());
}
while (result.next()) {
writeByte((byte) 1);
......@@ -908,7 +907,7 @@ public class Data {
SimpleResult rs = new SimpleResult();
int columns = readVarInt();
for (int i = 0; i < columns; i++) {
rs.addColumn(readString(), readString(), readVarInt(), readVarLong(), readVarInt(), readVarInt());
rs.addColumn(readString(), readString(), readVarInt(), readVarLong(), readVarInt());
}
while (readByte() != 0) {
Value[] o = new Value[columns];
......@@ -1172,7 +1171,6 @@ public class Data {
len += getVarIntLen(columnType.getValueType());
len += getVarLongLen(columnType.getPrecision());
len += getVarIntLen(columnType.getScale());
len += getVarIntLen(columnType.getDisplaySize());
}
while (result.next()) {
len++;
......
......@@ -518,14 +518,12 @@ public class Transfer {
writeString(result.getColumnName(i));
writeInt(columnType.getValueType());
writeLong(columnType.getPrecision());
writeInt(columnType.getScale());
writeInt(columnType.getDisplaySize());
} else {
writeString(result.getColumnName(i));
writeInt(DataType.getDataType(columnType.getValueType()).sqlType);
writeInt(MathUtils.convertLongToInt(columnType.getPrecision()));
writeInt(columnType.getScale());
}
writeInt(columnType.getScale());
}
while (result.next()) {
writeBoolean(true);
......@@ -739,11 +737,10 @@ public class Transfer {
int columns = readInt();
for (int i = 0; i < columns; i++) {
if (version >= Constants.TCP_PROTOCOL_VERSION_18) {
rs.addColumn(readString(), readString(), readInt(), readLong(), readInt(), readInt());
rs.addColumn(readString(), readString(), readInt(), readLong(), readInt());
} else {
String name = readString();
rs.addColumn(name, name, DataType.convertSQLTypeToValueType(readInt()), readInt(), readInt(),
Integer.MAX_VALUE);
rs.addColumn(name, name, DataType.convertSQLTypeToValueType(readInt()), readInt(), readInt());
}
}
while (readBoolean()) {
......
......@@ -227,13 +227,11 @@ public class TypeInfo {
* the precision
* @param scale
* the scale
* @param displaySize
* the display size in characters
* @param extTypeInfo
* the extended type information, or null
* @return the data type with parameters object
*/
public static TypeInfo getTypeInfo(int type, long precision, int scale, int displaySize, ExtTypeInfo extTypeInfo) {
public static TypeInfo getTypeInfo(int type, long precision, int scale, ExtTypeInfo extTypeInfo) {
switch (type) {
case Value.NULL:
case Value.BOOLEAN:
......
......@@ -58,8 +58,7 @@ public class ValueResultSet extends Value {
meta.getColumnTypeName(i + 1));
int precision = meta.getPrecision(i + 1);
int scale = meta.getScale(i + 1);
int displaySize = meta.getColumnDisplaySize(i + 1);
simple.addColumn(alias, name, columnType, precision, scale, displaySize);
simple.addColumn(alias, name, columnType, precision, scale);
}
for (int i = 0; i < maxrows && rs.next(); i++) {
Value[] list = new Value[columnCount];
......
......@@ -208,8 +208,8 @@ public class TestDataPage extends TestBase implements DataHandler {
ValueInt.get(10) }));
SimpleResult rs = new SimpleResult();
rs.addColumn("ID", "ID", Value.INT, 0, 0, ValueInt.DISPLAY_SIZE);
rs.addColumn("NAME", "NAME", Value.STRING, 255, 0, 255);
rs.addColumn("ID", "ID", Value.INT, 0, 0);
rs.addColumn("NAME", "NAME", Value.STRING, 255, 0);
rs.addRow(ValueInt.get(1), ValueString.get("Hello"));
rs.addRow(ValueInt.get(2), ValueString.get("World"));
rs.addRow(ValueInt.get(3), ValueString.get("Peace"));
......
......@@ -205,7 +205,7 @@ public class TestValue extends TestDb {
assertEquals(10, v.convertPrecision(10, true).getType().getPrecision());
SimpleResult rs = new SimpleResult();
rs.addColumn("X", "X", Value.INT, 0, 0, ValueInt.DISPLAY_SIZE);
rs.addColumn("X", "X", Value.INT, 0, 0);
rs.addRow(ValueInt.get(1));
v = ValueResultSet.get(rs);
assertEquals(Integer.MAX_VALUE, v.getType().getPrecision());
......@@ -236,8 +236,8 @@ public class TestValue extends TestDb {
testValueResultSetTest(ValueResultSet.get(null, rs, 2), 2, true);
SimpleResult result = new SimpleResult();
result.addColumn("ID", "ID", Value.INT, 0, 0, ValueInt.DISPLAY_SIZE);
result.addColumn("NAME", "NAME", Value.STRING, 255, 0, 255);
result.addColumn("ID", "ID", Value.INT, 0, 0);
result.addColumn("NAME", "NAME", Value.STRING, 255, 0);
result.addRow(ValueInt.get(1), ValueString.get("Hello"));
result.addRow(ValueInt.get(2), ValueString.get("World"));
result.addRow(ValueInt.get(3), ValueString.get("Peace"));
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论