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

Fix ValueResultSet support in Transfer

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