提交 70862ee8 authored 作者: Thomas Mueller's avatar Thomas Mueller

Recover tool: the script generated by the recover tool didn't work if fulltext…

Recover tool: the script generated by the recover tool didn't work if fulltext search was used, because the triggers were created before the primary keys.
上级 652c0c30
...@@ -1184,8 +1184,7 @@ public class Recover extends Tool implements DataHandler { ...@@ -1184,8 +1184,7 @@ public class Recover extends Tool implements DataHandler {
writer.println("---- Schema ----"); writer.println("---- Schema ----");
Collections.sort(schema); Collections.sort(schema);
for (MetaRecord m : schema) { for (MetaRecord m : schema) {
int t = m.getObjectType(); if (!isSchemaObjectTypeDelayed(m)) {
if (t != DbObject.INDEX && t != DbObject.CONSTRAINT) {
// create, but not referential integrity constraints and so on // create, but not referential integrity constraints and so on
// because they could fail on duplicate keys // because they could fail on duplicate keys
String sql = m.getSQL(); String sql = m.getSQL();
...@@ -1234,15 +1233,23 @@ public class Recover extends Tool implements DataHandler { ...@@ -1234,15 +1233,23 @@ public class Recover extends Tool implements DataHandler {
writer.println("DELETE FROM INFORMATION_SCHEMA.LOBS WHERE TABLE = " + LobStorage.TABLE_TEMP + ";"); writer.println("DELETE FROM INFORMATION_SCHEMA.LOBS WHERE TABLE = " + LobStorage.TABLE_TEMP + ";");
} }
for (MetaRecord m : schema) { for (MetaRecord m : schema) {
int t = m.getObjectType(); if (isSchemaObjectTypeDelayed(m)) {
if (t == DbObject.INDEX || t == DbObject.CONSTRAINT) {
// create indexes and constraints
String sql = m.getSQL(); String sql = m.getSQL();
writer.println(sql + ";"); writer.println(sql + ";");
} }
} }
} }
private boolean isSchemaObjectTypeDelayed(MetaRecord m) {
switch (m.getObjectType()) {
case DbObject.INDEX:
case DbObject.CONSTRAINT:
case DbObject.TRIGGER:
return true;
}
return false;
}
private void createTemporaryTable(PrintWriter writer) { private void createTemporaryTable(PrintWriter writer) {
if (!objectIdSet.contains(storageId)) { if (!objectIdSet.contains(storageId)) {
objectIdSet.add(storageId); objectIdSet.add(storageId);
......
...@@ -36,6 +36,7 @@ public class TestRecovery extends TestBase { ...@@ -36,6 +36,7 @@ public class TestRecovery extends TestBase {
} }
public void test() throws Exception { public void test() throws Exception {
testRecoverFulltext();
testRedoTransactions(); testRedoTransactions();
testCorrupt(); testCorrupt();
testWithTransactionLog(); testWithTransactionLog();
...@@ -43,6 +44,21 @@ public class TestRecovery extends TestBase { ...@@ -43,6 +44,21 @@ public class TestRecovery extends TestBase {
testRunScript(); testRunScript();
} }
private void testRecoverFulltext() throws Exception {
DeleteDbFiles.execute(getBaseDir(), "recovery", true);
Connection conn = getConnection("recovery");
Statement stat = conn.createStatement();
stat.execute("CREATE ALIAS IF NOT EXISTS FTL_INIT FOR \"org.h2.fulltext.FullTextLucene.init\"");
stat.execute("CALL FTL_INIT()");
stat.execute("create table test(id int primary key, name varchar) as select 1, 'Hello'");
stat.execute("CALL FTL_CREATE_INDEX('PUBLIC', 'TEST', 'NAME')");
conn.close();
Recover.main("-dir", getBaseDir(), "-db", "recovery");
DeleteDbFiles.execute(getBaseDir(), "recovery", true);
conn = getConnection("recovery;init=runscript from '" + getBaseDir() + "/recovery.h2.sql'");
conn.close();
}
private void testRedoTransactions() throws Exception { private void testRedoTransactions() throws Exception {
DeleteDbFiles.execute(getBaseDir(), "recovery", true); DeleteDbFiles.execute(getBaseDir(), "recovery", true);
Connection conn = getConnection("recovery"); Connection conn = getConnection("recovery");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论