提交 38efd2c5 authored 作者: Thomas Mueller's avatar Thomas Mueller

Automatic conversion of old databases to the page store format failed if the…

Automatic conversion of old databases to the page store format failed if the database contained LOB files.
上级 c621535e
......@@ -11,7 +11,6 @@ import java.util.ArrayList;
import org.h2.engine.Constants;
import org.h2.store.FileLister;
import org.h2.store.fs.FileSystem;
import org.h2.util.FileUtils;
import org.h2.util.Tool;
......@@ -101,7 +100,8 @@ public class DeleteDbFiles extends Tool {
private void process(String fileName, boolean quiet) throws SQLException {
if (FileUtils.isDirectory(fileName)) {
FileSystem.getInstance(fileName).deleteRecursive(fileName, quiet);
// only delete empty directories
FileUtils.tryDelete(fileName);
} else if (quiet || fileName.endsWith(Constants.SUFFIX_TEMP_FILE) || fileName.endsWith(Constants.SUFFIX_TRACE_FILE)) {
FileUtils.tryDelete(fileName);
} else {
......
......@@ -1877,7 +1877,11 @@ public class Recover extends Tool implements DataHandler {
public static void deleteRecoverFiles(String dir, String db) throws SQLException {
ArrayList<String> files = getRecoverFiles(dir, db);
for (String s : files) {
FileUtils.delete(s);
if (FileUtils.isDirectory(s)) {
FileUtils.tryDelete(s);
} else {
FileUtils.delete(s);
}
}
}
......@@ -1904,6 +1908,7 @@ public class Recover extends Tool implements DataHandler {
if (start == null || FileUtils.fileStartsWith(f, start + ".")) {
files.addAll(getRecoverFiles(f, null));
}
ok = true;
} else if (f.endsWith(".lob.comp.txt")) {
ok = true;
} else if (f.endsWith(".lob.db.txt")) {
......
......@@ -214,23 +214,40 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
deleteDb("pageStore");
Connection conn;
conn = getConnection("pageStore;PAGE_STORE=FALSE");
conn.createStatement().execute("create table test(id int, data clob)");
conn.createStatement().execute("insert into test select x, space(10000) from system_range(1, 2)");
conn.createStatement().execute("shutdown immediately");
Statement stat = conn.createStatement();
stat.execute("create table test(id int, data clob)");
stat.execute("insert into test select x, space(10000) from system_range(1, 2)");
stat.execute("checkpoint");
stat.execute("set write_delay 0");
stat.execute("insert into test select x, 'empty' from system_range(10, 20)");
stat.execute("shutdown immediately");
try {
conn.close();
} catch (SQLException e) {
// ignore
}
// a database that was not closed normally can't be converted
try {
getConnection("pageStore;PAGE_STORE=TRUE");
fail();
} catch (SQLException e) {
assertKnownException(e);
}
// now open and close the database normally
conn = getConnection("pageStore");
conn.close();
// convert it
conn = getConnection("pageStore;PAGE_STORE=TRUE");
stat = conn.createStatement();
ResultSet rs = stat.executeQuery("select * from test order by id");
while (rs.next()) {
rs.getString(1);
rs.getString(2);
}
stat.execute("drop table test");
conn.close();
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论