提交 6f8a82af authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Fix ValueResultSet support in Transfer

上级 72497459
......@@ -56,6 +56,9 @@ Update org.h2.engine.Constants.java:
set BUILD_DATE to today
increment BUILD_ID
Update org.h2.value.Transfer.java:
if the last TCP_PROTOCOL_VERSION_## doesn't have a release date set it to current BUILD_DATE
Update changelog.html:
* create a new "Next Version (unreleased)" with an empty list
* add a new version
......
......@@ -105,6 +105,12 @@ public class Constants {
*/
public static final int TCP_PROTOCOL_VERSION_17 = 17;
/**
* The TCP protocol version number 18.
* @since 1.4.198 (TODO)
*/
public static final int TCP_PROTOCOL_VERSION_18 = 18;
/**
* Minimum supported version of TCP protocol.
*/
......@@ -113,7 +119,7 @@ public class Constants {
/**
* Maximum supported version of TCP protocol.
*/
public static final int TCP_PROTOCOL_VERSION_MAX_SUPPORTED = TCP_PROTOCOL_VERSION_17;
public static final int TCP_PROTOCOL_VERSION_MAX_SUPPORTED = TCP_PROTOCOL_VERSION_18;
/**
* The major version of this database.
......
......@@ -481,10 +481,19 @@ public class Transfer {
int columnCount = result.getVisibleColumnCount();
writeInt(columnCount);
for (int i = 0; i < columnCount; i++) {
writeString(result.getColumnName(i));
writeInt(result.getColumnType(i));
writeInt(MathUtils.convertLongToInt(result.getColumnPrecision(i)));
writeInt(result.getColumnScale(i));
if (version >= Constants.TCP_PROTOCOL_VERSION_18) {
writeString(result.getAlias(i));
writeString(result.getColumnName(i));
writeInt(result.getColumnType(i));
writeLong(result.getColumnPrecision(i));
writeInt(result.getColumnScale(i));
writeInt(result.getDisplaySize(i));
} else {
writeString(result.getColumnName(i));
writeInt(DataType.getDataType(result.getColumnType(i)).sqlType);
writeInt(MathUtils.convertLongToInt(result.getColumnPrecision(i)));
writeInt(result.getColumnScale(i));
}
}
while (result.next()) {
writeBoolean(true);
......@@ -677,9 +686,13 @@ public class Transfer {
SimpleResult rs = new SimpleResult();
int columns = readInt();
for (int i = 0; i < columns; i++) {
String name = readString();
rs.addColumn(name, name, DataType.convertSQLTypeToValueType(readInt()), readInt(), readInt(),
Integer.MAX_VALUE);
if (version >= Constants.TCP_PROTOCOL_VERSION_18) {
rs.addColumn(readString(), readString(), readInt(), readLong(), readInt(), readInt());
} else {
String name = readString();
rs.addColumn(name, name, DataType.convertSQLTypeToValueType(readInt()), readInt(), readInt(),
Integer.MAX_VALUE);
}
}
while (readBoolean()) {
Value[] o = new Value[columns];
......
......@@ -53,7 +53,8 @@ public class ValueResultSet extends Value {
for (int i = 0; i < columnCount; i++) {
String alias = meta.getColumnLabel(i + 1);
String name = meta.getColumnName(i + 1);
int columnType = DataType.convertSQLTypeToValueType(meta.getColumnType(i + 1));
int columnType = DataType.convertSQLTypeToValueType(meta.getColumnType(i + 1),
meta.getColumnTypeName(i + 1));
int precision = meta.getPrecision(i + 1);
int scale = meta.getScale(i + 1);
int displaySize = meta.getColumnDisplaySize(i + 1);
......
......@@ -717,6 +717,11 @@ public class TestSpatial extends TestDb {
assertEquals("geometry",
columnMeta.getString("TYPE_NAME").toLowerCase());
assertFalse(columnMeta.next());
ResultSet rs = stat.executeQuery("select point_table(1, 1)");
assertTrue(rs.next());
ResultSet rs2 = (ResultSet) rs.getObject(1);
assertEquals("GEOMETRY", rs2.getMetaData().getColumnTypeName(1));
}
deleteDb("spatial");
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论