提交 0576eb3e authored 作者: Thomas Mueller's avatar Thomas Mueller

Backup: if the database contained CLOB or BLOB data, the backup included a file…

Backup: if the database contained CLOB or BLOB data, the backup included a file entry for the LOB directory.
上级 52d20c1c
......@@ -116,6 +116,9 @@ public class Backup extends Tool {
if (!f.startsWith(base)) {
Message.throwInternalError(f + " does not start with " + base);
}
if (FileUtils.isDirectory(fileName)) {
continue;
}
f = f.substring(base.length());
f = BackupCommand.correctFileName(f);
ZipEntry entry = new ZipEntry(f);
......
......@@ -168,6 +168,9 @@ public class ChangeFileEncryption extends Tool {
}
private void copy(String fileName, FileStore in, byte[] key) throws SQLException {
if (FileUtils.isDirectory(fileName)) {
return;
}
String temp = dir + "/temp.db";
FileUtils.delete(temp);
FileStore fileOut;
......
......@@ -11,6 +11,7 @@ import java.sql.SQLException;
import java.sql.Statement;
import org.h2.test.TestBase;
import org.h2.tools.Backup;
import org.h2.tools.Restore;
import org.h2.util.FileUtils;
......@@ -32,10 +33,32 @@ public class TestBackup extends TestBase {
if (config.memory || config.logMode == 0) {
return;
}
testBackupRestoreLobStatement();
testBackupRestoreLob();
testBackup();
deleteDb("backup");
}
private void testBackupRestoreLob() throws SQLException {
deleteDb("backup");
Connection conn = getConnection("backup");
conn.createStatement().execute("create table test(x clob) as select space(10000)");
conn.close();
Backup.execute(getTestDir("") + "/backup.zip", getTestDir(""), "backup", true);
deleteDb("backup");
Restore.execute(getTestDir("") + "/backup.zip", getTestDir(""), "backup", true);
}
private void testBackupRestoreLobStatement() throws SQLException {
deleteDb("backup");
Connection conn = getConnection("backup");
conn.createStatement().execute("create table test(x clob) as select space(10000)");
conn.createStatement().execute("backup to '"+getTestDir("") + "/backup.zip"+"'");
conn.close();
deleteDb("backup");
Restore.execute(getTestDir("") + "/backup.zip", getTestDir(""), "backup", true);
}
private void testBackup() throws SQLException {
deleteDb("backup");
Connection conn1, conn2, conn3;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论