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