提交 95e085a5 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Add CLOB test to TestBigResult

上级 453dbd2e
......@@ -6,6 +6,7 @@
package org.h2.test.db;
import java.sql.Blob;
import java.sql.Clob;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
......@@ -299,7 +300,8 @@ public class TestBigResult extends TestBase {
stat.execute("SET MAX_MEMORY_ROWS " + 1);
stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, VALUE BLOB NOT NULL)");
PreparedStatement ps = conn.prepareStatement("INSERT INTO TEST VALUES (?, ?)");
byte[] data = new byte[1_000_000];
int length = 1_000_000;
byte[] data = new byte[length];
for (int i = 1; i <= 10; i++) {
ps.setInt(1, i);
Arrays.fill(data, (byte) i);
......@@ -322,6 +324,32 @@ public class TestBigResult extends TestBase {
assertEquals(data, bytes);
b.free();
}
stat.execute("DROP TABLE TEST");
stat.execute("CREATE TABLE TEST(ID INT PRIMARY KEY, VALUE CLOB NOT NULL)");
ps = conn.prepareStatement("INSERT INTO TEST VALUES (?, ?)");
char[] cdata = new char[length];
for (int i = 1; i <= 10; i++) {
ps.setInt(1, i);
Arrays.fill(cdata, (char) i);
ps.setString(2, new String(cdata));
ps.executeUpdate();
}
Clob[] clobs = new Clob[10];
rs = stat.executeQuery("SELECT * FROM TEST");
for (int i = 1; i <= 10; i++) {
assertTrue(rs.next());
assertEquals(i, rs.getInt(1));
clobs[i - 1] = rs.getClob(2);
}
assertFalse(rs.next());
rs.close();
for (int i = 1; i <= 10; i++) {
Clob c = clobs[i - 1];
String string = c.getSubString(1, (int) c.length());
Arrays.fill(cdata, (char) i);
assertEquals(new String(cdata), string);
c.free();
}
conn.close();
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论