提交 7a808136 authored 作者: Thomas Mueller's avatar Thomas Mueller

When using local temporary tables and not dropping them manually before closing…

When using local temporary tables and not dropping them manually before closing the session, and then killing the process could result in a database that couldn't be opened (except when using the recover tool).
上级 51386e8e
......@@ -681,6 +681,11 @@ public class Session extends SessionWithState {
table.setModified();
localTempTables.remove(table.getName());
table.removeChildrenAndResources(this);
if (closeSession) {
// need to commit, otherwise recovery might
// ignore the table removal
database.commit(this);
}
} else if (table.getOnCommitTruncate()) {
table.truncate(this);
}
......
......@@ -46,6 +46,7 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
}
public void test() throws Exception {
testDropTempTable();
testLogLimitFalsePositive();
testLogLimit();
testRecoverLobInDatabase();
......@@ -77,6 +78,33 @@ public class TestPageStore extends TestBase implements DatabaseEventListener {
testFuzzOperations();
deleteDb("pageStore");
}
private void testDropTempTable() throws SQLException {
deleteDb("pageStoreDropTemp");
Connection c1 = getConnection("pageStoreDropTemp");
Connection c2 = getConnection("pageStoreDropTemp");
c1.setAutoCommit(false);
c2.setAutoCommit(false);
Statement s1 = c1.createStatement();
Statement s2 = c2.createStatement();
s1.execute("create local temporary table a(id int primary key)");
s1.execute("insert into a values(1)");
c1.commit();
c1.close();
s2.execute("create table b(id int primary key)");
s2.execute("insert into b values(1)");
c2.commit();
s2.execute("checkpoint sync");
s2.execute("shutdown immediately");
try {
c2.close();
} catch (SQLException e) {
// ignore
}
c1 = getConnection("pageStoreDropTemp");
c1.close();
deleteDb("pageStoreDropTemp");
}
private void testLogLimit() throws Exception {
deleteDb("pageStore");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论