提交 55e9b945 authored 作者: Noel Grandin's avatar Noel Grandin

Fix bug where table locks were not dropped when the connection closed

上级 c98088c7
......@@ -21,6 +21,8 @@ Change Log
<h2>Next Version (unreleased)</h2>
<ul>
<li>Fix bug where table locks were not dropped when the connection closed
</li>
<li>Fix extra CPU usage caused by query planner enhancement in 1.4.191
</li>
<li>improve performance of queries that use LIKE 'foo%' - 10x in the case of one of my queries
......
......@@ -809,6 +809,7 @@ public class Session extends SessionWithState {
if (!closed) {
try {
database.checkPowerOff();
rollback();
removeTemporaryLobs(false);
cleanTempTables(true);
undoLog.clear();
......
......@@ -14,7 +14,6 @@ import java.sql.Savepoint;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Random;
import org.h2.api.ErrorCode;
import org.h2.test.TestBase;
import org.h2.util.New;
......@@ -36,6 +35,7 @@ public class TestTransaction extends TestBase {
@Override
public void test() throws SQLException {
testClosingConnectionWithLockedTable();
testConstraintCreationRollback();
testCommitOnAutoCommitChange();
testConcurrentSelectForUpdate();
......@@ -334,6 +334,26 @@ public class TestTransaction extends TestBase {
c2.close();
}
private void testClosingConnectionWithLockedTable() throws SQLException {
deleteDb("transaction");
Connection c1 = getConnection("transaction");
Connection c2 = getConnection("transaction");
c1.setAutoCommit(false);
c2.setAutoCommit(false);
Statement s1 = c1.createStatement();
s1.execute("create table a (id integer identity not null, " +
"code varchar(10) not null, primary key(id))");
s1.executeUpdate("insert into a(code) values('one')");
c1.commit();
s1.executeQuery("select * from a for update");
c1.close();
Statement s2 = c2.createStatement();
s2.executeQuery("select * from a for update");
c2.close();
}
private void testSavepoint() throws SQLException {
deleteDb("transaction");
Connection conn = getConnection("transaction");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论