提交 b13d1556 authored 作者: Thomas Mueller's avatar Thomas Mueller

Issue 464: [MVStore] org.h2.mvstore.db.MVTable throws java.lang.NullPointerException

上级 ac913fb4
...@@ -23,7 +23,7 @@ Change Log ...@@ -23,7 +23,7 @@ Change Log
in a strange exception of the type "column x must be included in the group by list". in a strange exception of the type "column x must be included in the group by list".
</li><li>Issue 454: Use Charset for type-safety. </li><li>Issue 454: Use Charset for type-safety.
</li><li>Queries with both LIMIT and OFFSET could throw an IllegalArgumentException. </li><li>Queries with both LIMIT and OFFSET could throw an IllegalArgumentException.
</li><li>MVStore: multiple issues were fixed: 460, 461, 462. </li><li>MVStore: multiple issues were fixed: 460, 461, 462, 464.
</li><li>MVStore: larger stores (multiple GB) are now much faster. </li><li>MVStore: larger stores (multiple GB) are now much faster.
</li><li>When using local temporary tables and not dropping them manually before closing the session, </li><li>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 and then killing the process could result in a database that couldn't be opened (except when using
......
...@@ -642,6 +642,7 @@ public class MVTable extends TableBase { ...@@ -642,6 +642,7 @@ public class MVTable extends TableBase {
} }
primaryIndex.remove(session); primaryIndex.remove(session);
database.removeMeta(session, getId()); database.removeMeta(session, getId());
database.getMvStore().removeTable(this);
primaryIndex = null; primaryIndex = null;
close(session); close(session);
invalidate(); invalidate();
......
...@@ -100,6 +100,10 @@ public class MVTableEngine implements TableEngine { ...@@ -100,6 +100,10 @@ public class MVTableEngine implements TableEngine {
public List<MVTable> getTables() { public List<MVTable> getTables() {
return openTables; return openTables;
} }
public void removeTable(MVTable table) {
openTables.remove(table);
}
/** /**
* Store all pending changes. * Store all pending changes.
......
...@@ -476,6 +476,7 @@ public class ValueLob extends Value { ...@@ -476,6 +476,7 @@ public class ValueLob extends Value {
if (fileName != null) { if (fileName != null) {
if (tempFile != null) { if (tempFile != null) {
tempFile.stopAutoDelete(); tempFile.stopAutoDelete();
tempFile = null;
} }
deleteFile(handler, fileName); deleteFile(handler, fileName);
} }
......
...@@ -114,27 +114,30 @@ int test; ...@@ -114,27 +114,30 @@ int test;
Statement stat; Statement stat;
ResultSet rs; ResultSet rs;
conn = getConnection("mvstore"); conn = getConnection("mvstore");
stat = conn.createStatement(); for (int i = 0; i < 2; i++) {
stat.execute("create table test(id int primary key, name varchar) " stat = conn.createStatement();
+ "engine \"org.h2.mvstore.db.MVTableEngine\""); stat.execute("create table test(id int primary key, name varchar) "
conn.setAutoCommit(false); + "engine \"org.h2.mvstore.db.MVTableEngine\"");
stat.execute("insert into test values(1, 'Hello')"); conn.setAutoCommit(false);
stat.execute("insert into test values(2, 'World')"); stat.execute("insert into test values(1, 'Hello')");
rs = stat.executeQuery("select count(*) from test"); stat.execute("insert into test values(2, 'World')");
rs.next(); rs = stat.executeQuery("select count(*) from test");
assertEquals(2, rs.getInt(1)); rs.next();
conn.rollback(); assertEquals(2, rs.getInt(1));
rs = stat.executeQuery("select count(*) from test"); conn.rollback();
rs.next(); rs = stat.executeQuery("select count(*) from test");
assertEquals(0, rs.getInt(1)); rs.next();
assertEquals(0, rs.getInt(1));
stat.execute("insert into test values(1, 'Hello')");
Savepoint sp = conn.setSavepoint(); stat.execute("insert into test values(1, 'Hello')");
stat.execute("insert into test values(2, 'World')"); Savepoint sp = conn.setSavepoint();
conn.rollback(sp); stat.execute("insert into test values(2, 'World')");
rs = stat.executeQuery("select count(*) from test"); conn.rollback(sp);
rs.next(); rs = stat.executeQuery("select count(*) from test");
assertEquals(1, rs.getInt(1)); rs.next();
assertEquals(1, rs.getInt(1));
stat.execute("drop table test");
}
conn.close(); conn.close();
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论