use of org.h2.tools.Backup in project h2database by h2database.
the class TestMVTableEngine method testRollbackAfterCrash.
private void testRollbackAfterCrash() throws Exception {
if (config.memory) {
return;
}
Connection conn;
Statement stat;
deleteDb(getTestName());
String url = getTestName() + ";MV_STORE=TRUE";
String url2 = getTestName() + "2;MV_STORE=TRUE";
conn = getConnection(url);
stat = conn.createStatement();
stat.execute("create table test(id int)");
stat.execute("insert into test values(0)");
stat.execute("set write_delay 0");
conn.setAutoCommit(false);
stat.execute("insert into test values(1)");
stat.execute("shutdown immediately");
JdbcUtils.closeSilently(conn);
conn = getConnection(url);
stat = conn.createStatement();
ResultSet rs = stat.executeQuery("select row_count_estimate " + "from information_schema.tables where table_name='TEST'");
rs.next();
assertEquals(1, rs.getLong(1));
stat.execute("drop table test");
stat.execute("create table test(id int primary key, data clob)");
stat.execute("insert into test values(1, space(10000))");
conn.setAutoCommit(false);
stat.execute("delete from test");
stat.execute("checkpoint");
stat.execute("shutdown immediately");
JdbcUtils.closeSilently(conn);
conn = getConnection(url);
stat = conn.createStatement();
rs = stat.executeQuery("select * from test");
assertTrue(rs.next());
stat.execute("drop all objects delete files");
conn.close();
conn = getConnection(url);
stat = conn.createStatement();
stat.execute("create table test(id int primary key, name varchar)");
stat.execute("create index idx_name on test(name, id)");
stat.execute("insert into test select x, x || space(200 * x) " + "from system_range(1, 10)");
conn.setAutoCommit(false);
stat.execute("delete from test where id > 5");
stat.execute("backup to '" + getBaseDir() + "/" + getTestName() + ".zip'");
conn.rollback();
Restore.execute(getBaseDir() + "/" + getTestName() + ".zip", getBaseDir(), getTestName() + "2");
Connection conn2;
conn2 = getConnection(url2);
conn.close();
conn2.close();
}
Aggregations