提交 b1858d05 authored 作者: Thomas Mueller's avatar Thomas Mueller

The wrong error message was thrown when trying to open a database where the…

The wrong error message was thrown when trying to open a database where the database file could not be read for some reason (for example because the split file system was used, and the file was split at the wrong position). 
上级 2b8c95ff
......@@ -234,6 +234,9 @@ public class FileSystemSplit extends FileSystem {
maxLength = defaultMaxSize;
}
} else {
if (maxLength == 0) {
closeAndThrow(array, array[0], maxLength);
}
for (int i = 1; i < array.length - 1; i++) {
o = array[i];
long l = o.length();
......
......@@ -67,18 +67,21 @@ public class TestOpenClose extends TestBase implements DatabaseEventListener {
if (config.memory) {
return;
}
deleteDb("split:" + getBaseDir(), "openClose");
deleteDb("openClose");
FileSystem.getInstance("split:").delete("split:" + getBaseDir() + "/openClose2.h2.db");
Connection conn;
conn = DriverManager.getConnection("jdbc:h2:split:12:" + getBaseDir() + "/openClose");
conn = DriverManager.getConnection("jdbc:h2:split:18:" + getBaseDir() + "/openClose2");
conn.createStatement().execute("create table test(id int, name varchar) as select 1, space(1000000)");
conn.close();
FileObject f = FileSystem.getInstance(getBaseDir()).openFileObject(getBaseDir() + "/openClose.h2.db.1.part", "rw");
FileObject f = FileSystem.getInstance(getBaseDir()).openFileObject(getBaseDir() + "/openClose2.h2.db.1.part", "rw");
f.setFileLength(f.length() * 2);
f.close();
try {
DriverManager.getConnection("jdbc:h2:split:12:" + getBaseDir() + "/openClose");
DriverManager.getConnection("jdbc:h2:split:18:" + getBaseDir() + "/openClose2");
fail();
} catch (SQLException e) {
assertEquals(ErrorCode.IO_EXCEPTION_2, e.getErrorCode());
}
FileSystem.getInstance("split:").delete("split:" + getBaseDir() + "/openClose2.h2.db");
}
private void testCloseDelay() throws Exception {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论