提交 0f74ce2d authored 作者: Thomas Mueller's avatar Thomas Mueller

MVStore: temporary tables from result sets could survive re-opening a database,…

MVStore: temporary tables from result sets could survive re-opening a database, which could result in a ClassCastException.
上级 6e972a35
......@@ -1299,9 +1299,8 @@ public class TestMVStore extends TestBase {
m.remove(i);
}
s.commit();
assertTrue(s.compact(100, 1));
assertTrue(s.compact(100, 1));
assertTrue(s.compact(100, 1));
assertTrue(s.compact(100, 50 * 1024));
assertTrue(s.compact(100, 1024));
s.close();
long len2 = FileUtils.size(fileName);
assertTrue("len2: " + len2 + " len: " + len, len2 < len);
......@@ -1319,7 +1318,7 @@ public class TestMVStore extends TestBase {
assertEquals(i + 1, m.size());
}
assertEquals(1000, m.size());
assertEquals(285, s.getUnsavedPageCount());
assertEquals(131896, s.getUnsavedMemory());
s.commit();
assertEquals(2, s.getFileStore().getWriteCount());
s.close();
......@@ -1672,7 +1671,7 @@ public class TestMVStore extends TestBase {
assertTrue(chunkCount2 >= chunkCount1);
m = s.openMap("data");
assertTrue(s.compact(80, 16 * 1024));
assertTrue(s.compact(80, 50 * 1024));
assertFalse(s.compact(80, 1024));
int chunkCount3 = 0;
......
......@@ -49,6 +49,7 @@ public class TestMVTableEngine extends TestBase {
@Override
public void test() throws Exception {
testTemporaryTables();
testUniqueIndex();
testSecondaryIndex();
testGarbageCollectionForLOB();
......@@ -78,6 +79,34 @@ public class TestMVTableEngine extends TestBase {
testSimple();
}
private void testTemporaryTables() throws SQLException {
FileUtils.deleteRecursive(getBaseDir(), true);
Connection conn;
Statement stat;
String url = "mvstore;MV_STORE=TRUE";
url = getURL(url, true);
conn = getConnection(url);
stat = conn.createStatement();
stat.execute("set max_memory_rows 100");
stat.execute("create table t1 as select x from system_range(1, 200)");
stat.execute("create table t2 as select x from system_range(1, 200)");
for (int i = 0; i < 20; i++) {
// this will create temporary results that
// internally use temporary tables, which are not all closed
stat.execute("select count(*) from t1 where t1.x in (select t2.x from t2)");
}
conn.close();
conn = getConnection(url);
stat = conn.createStatement();
for (int i = 0; i < 20; i++) {
stat.execute("create table a" + i + "(id int primary key)");
ResultSet rs = stat.executeQuery("select count(*) from a" + i);
rs.next();
assertEquals(0, rs.getInt(1));
}
conn.close();
}
private void testUniqueIndex() throws SQLException {
FileUtils.deleteRecursive(getBaseDir(), true);
Connection conn;
......
......@@ -64,7 +64,7 @@ public class TestStreamStore extends TestBase {
StreamStore streamStore = new StreamStore(map);
int blockSize = 256 * 1024;
assertEquals(blockSize, streamStore.getMaxBlockSize());
for (int i = 0; i < 4 * 16; i++) {
for (int i = 0; i < 8 * 16; i++) {
streamStore.put(new RandomStream(blockSize, i));
}
long writeCount = s.getFileStore().getWriteCount();
......@@ -126,7 +126,7 @@ public class TestStreamStore extends TestBase {
return new StreamStore(map) {
@Override
protected void onStore(int len) {
if (s.getUnsavedPageCount() > s.getAutoCommitPageCount() / 2) {
if (s.getUnsavedMemory() > s.getAutoCommitMemory() / 2) {
s.commit();
}
}
......
......@@ -176,7 +176,7 @@ public class TestBtreeIndex extends TestBase {
testCount = 0;
while (rs.next() && rs2.next()) {
if (!rs.getString(1).equals(rs2.getString(1))) {
assertEquals("" + testCount, rs.getString(1), rs.getString(2));
assertEquals("" + testCount, rs.getString(1), rs2.getString(1));
}
testCount++;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论