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

Remove unused display size parameters

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