提交 3488d9e6 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Update ValueResultSet format for temporary storages

上级 3a91dec0
...@@ -24,7 +24,6 @@ import org.h2.result.SimpleResult; ...@@ -24,7 +24,6 @@ import org.h2.result.SimpleResult;
import org.h2.result.SortOrder; import org.h2.result.SortOrder;
import org.h2.store.DataHandler; import org.h2.store.DataHandler;
import org.h2.util.JdbcUtils; import org.h2.util.JdbcUtils;
import org.h2.util.MathUtils;
import org.h2.util.Utils; import org.h2.util.Utils;
import org.h2.value.CompareMode; import org.h2.value.CompareMode;
import org.h2.value.Value; import org.h2.value.Value;
...@@ -408,10 +407,12 @@ public class ValueDataType implements DataType { ...@@ -408,10 +407,12 @@ public class ValueDataType implements DataType {
int columnCount = result.getVisibleColumnCount(); int columnCount = result.getVisibleColumnCount();
buff.putVarInt(columnCount); buff.putVarInt(columnCount);
for (int i = 0; i < columnCount; i++) { for (int i = 0; i < columnCount; i++) {
writeString(buff, result.getAlias(i));
writeString(buff, result.getColumnName(i)); writeString(buff, result.getColumnName(i));
buff.putVarInt(org.h2.value.DataType.getDataType(result.getColumnType(i)).sqlType). buff.putVarInt(result.getColumnType(i)).
putVarInt(MathUtils.convertLongToInt(result.getColumnPrecision(i))). putVarLong(result.getColumnPrecision(i)).
putVarInt(result.getColumnScale(i)); putVarInt(result.getColumnScale(i)).
putVarInt(result.getDisplaySize(i));
} }
while (result.next()) { while (result.next()) {
buff.put((byte) 1); buff.put((byte) 1);
...@@ -621,9 +622,8 @@ public class ValueDataType implements DataType { ...@@ -621,9 +622,8 @@ 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++) {
String name = readString(buff); rs.addColumn(readString(buff), readString(buff), readVarInt(buff), readVarLong(buff), readVarInt(buff),
rs.addColumn(name, name, org.h2.value.DataType.convertSQLTypeToValueType(readVarInt(buff)), readVarInt(buff));
readVarInt(buff), readVarInt(buff), Integer.MAX_VALUE);
} }
while (buff.get() != 0) { while (buff.get() != 0) {
Value[] o = new Value[columns]; Value[] o = new Value[columns];
......
...@@ -27,7 +27,6 @@ import org.h2.util.DateTimeUtils; ...@@ -27,7 +27,6 @@ import org.h2.util.DateTimeUtils;
import org.h2.util.JdbcUtils; import org.h2.util.JdbcUtils;
import org.h2.util.MathUtils; import org.h2.util.MathUtils;
import org.h2.util.Utils; import org.h2.util.Utils;
import org.h2.value.DataType;
import org.h2.value.Value; import org.h2.value.Value;
import org.h2.value.ValueArray; import org.h2.value.ValueArray;
import org.h2.value.ValueBoolean; import org.h2.value.ValueBoolean;
...@@ -634,10 +633,12 @@ public class Data { ...@@ -634,10 +633,12 @@ public class Data {
int columnCount = result.getVisibleColumnCount(); int columnCount = result.getVisibleColumnCount();
writeVarInt(columnCount); writeVarInt(columnCount);
for (int i = 0; i < columnCount; i++) { for (int i = 0; i < columnCount; i++) {
writeString(result.getAlias(i));
writeString(result.getColumnName(i)); writeString(result.getColumnName(i));
writeVarInt(DataType.getDataType(result.getColumnType(i)).sqlType); writeVarInt(result.getColumnType(i));
writeVarInt(MathUtils.convertLongToInt(result.getColumnPrecision(i))); writeVarLong(result.getColumnPrecision(i));
writeVarInt(result.getColumnScale(i)); writeVarInt(result.getColumnScale(i));
writeVarInt(result.getDisplaySize(i));
} }
while (result.next()) { while (result.next()) {
writeByte((byte) 1); writeByte((byte) 1);
...@@ -859,9 +860,7 @@ public class Data { ...@@ -859,9 +860,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++) {
String name = readString(); rs.addColumn(readString(), readString(), readVarInt(), readVarLong(), readVarInt(), readVarInt());
rs.addColumn(name, name, DataType.convertSQLTypeToValueType(readVarInt()), readVarInt(), readVarInt(),
Integer.MAX_VALUE);
} }
while (readByte() != 0) { while (readByte() != 0) {
Value[] o = new Value[columns]; Value[] o = new Value[columns];
...@@ -1097,10 +1096,12 @@ public class Data { ...@@ -1097,10 +1096,12 @@ public class Data {
int columnCount = result.getVisibleColumnCount(); int columnCount = result.getVisibleColumnCount();
len += getVarIntLen(columnCount); len += getVarIntLen(columnCount);
for (int i = 0; i < columnCount; i++) { for (int i = 0; i < columnCount; i++) {
len += getStringLen(result.getAlias(i));
len += getStringLen(result.getColumnName(i)); len += getStringLen(result.getColumnName(i));
len += getVarIntLen(DataType.getDataType(result.getColumnType(i)).sqlType); len += getVarIntLen(result.getColumnType(i));
len += getVarIntLen(MathUtils.convertLongToInt(result.getColumnPrecision(i))); len += getVarLongLen(result.getColumnPrecision(i));
len += getVarIntLen(result.getColumnScale(i)); len += getVarIntLen(result.getColumnScale(i));
len += getVarIntLen(result.getDisplaySize(i));
} }
while (result.next()) { while (result.next()) {
len++; len++;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论