提交 3eb61303 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Add simple test for LOB in ValueResultSet

上级 0476f080
...@@ -23,6 +23,7 @@ import java.sql.ResultSet; ...@@ -23,6 +23,7 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Savepoint; import java.sql.Savepoint;
import java.sql.Statement; import java.sql.Statement;
import java.sql.Types;
import java.util.Random; import java.util.Random;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.h2.api.ErrorCode; import org.h2.api.ErrorCode;
...@@ -33,6 +34,7 @@ import org.h2.store.fs.FileUtils; ...@@ -33,6 +34,7 @@ import org.h2.store.fs.FileUtils;
import org.h2.test.TestBase; import org.h2.test.TestBase;
import org.h2.test.TestDb; import org.h2.test.TestDb;
import org.h2.tools.Recover; import org.h2.tools.Recover;
import org.h2.tools.SimpleResultSet;
import org.h2.util.IOUtils; import org.h2.util.IOUtils;
import org.h2.util.JdbcUtils; import org.h2.util.JdbcUtils;
import org.h2.util.StringUtils; import org.h2.util.StringUtils;
...@@ -114,6 +116,7 @@ public class TestLob extends TestDb { ...@@ -114,6 +116,7 @@ public class TestLob extends TestDb {
testLob(true); testLob(true);
testJavaObject(); testJavaObject();
testLobGrowth(); testLobGrowth();
testLobInValueResultSet();
deleteDb("lob"); deleteDb("lob");
} }
...@@ -1720,4 +1723,42 @@ public class TestLob extends TestDb { ...@@ -1720,4 +1723,42 @@ public class TestLob extends TestDb {
conn.createStatement().execute("drop table test"); conn.createStatement().execute("drop table test");
conn.close(); conn.close();
} }
private void testLobInValueResultSet() throws SQLException {
deleteDb("lob");
JdbcConnection conn = (JdbcConnection) getConnection("lob");
Statement stat = conn.createStatement();
stat.execute("CREATE ALIAS VRS FOR \"" + getClass().getName() + ".testLobInValueResultSetGet\"");
ResultSet rs = stat.executeQuery("SELECT VRS()");
assertTrue(rs.next());
ResultSet rs2 = (ResultSet) rs.getObject(1);
assertFalse(rs.next());
assertTrue(rs2.next());
Clob clob = rs2.getClob(1);
assertFalse(rs2.next());
assertEquals(MORE_THAN_128_CHARS, clob.getSubString(1, Integer.MAX_VALUE));
conn.close();
}
/**
* This method is called via reflection from the database.
*
* @param conn connection
* @return the result set
* @throws SQLException on exception
*/
public static SimpleResultSet testLobInValueResultSetGet(Connection conn) throws SQLException {
final Clob c = conn.createClob();
c.setString(1, MORE_THAN_128_CHARS);
SimpleResultSet rs = new SimpleResultSet() {
@Override
public Object getObject(int columnIndex) throws SQLException {
return c;
}
};
rs.addColumn("L", Types.CLOB, 1000, 0);
rs.addRow(MORE_THAN_128_CHARS);
return rs;
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论