提交 194ebf95 authored 作者: Thomas Mueller Graf's avatar Thomas Mueller Graf

Local temporary tables with many rows did not work correctly due to automatic analyze.

上级 ad7c0e92
...@@ -21,6 +21,8 @@ Change Log ...@@ -21,6 +21,8 @@ Change Log
<h2>Next Version (unreleased)</h2> <h2>Next Version (unreleased)</h2>
<ul> <ul>
<li>Local temporary tables with many rows did not work correctly due to automatic analyze.
</li>
<li>Server mode: concurrently using the same connection could throw an exception <li>Server mode: concurrently using the same connection could throw an exception
"Connection is broken: unexpected status". "Connection is broken: unexpected status".
</li> </li>
......
...@@ -1620,6 +1620,8 @@ public class Database implements DataHandler { ...@@ -1620,6 +1620,8 @@ public class Database implements DataHandler {
int id = obj.getId(); int id = obj.getId();
removeMeta(session, id); removeMeta(session, id);
addMeta(session, obj); addMeta(session, obj);
// for temporary objects
objectIds.set(id);
} }
/** /**
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
package org.h2.test.db; package org.h2.test.db;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.sql.Statement; import java.sql.Statement;
...@@ -32,6 +33,7 @@ public class TestTempTables extends TestBase { ...@@ -32,6 +33,7 @@ public class TestTempTables extends TestBase {
@Override @Override
public void test() throws SQLException { public void test() throws SQLException {
deleteDb("tempTables"); deleteDb("tempTables");
testAnalyzeReuseObjectId();
testTempSequence(); testTempSequence();
testTempFileResultSet(); testTempFileResultSet();
testTempTableResultSet(); testTempTableResultSet();
...@@ -49,6 +51,19 @@ public class TestTempTables extends TestBase { ...@@ -49,6 +51,19 @@ public class TestTempTables extends TestBase {
deleteDb("tempTables"); deleteDb("tempTables");
} }
private void testAnalyzeReuseObjectId() throws SQLException {
deleteDb("tempTables");
Connection conn = getConnection("tempTables");
Statement stat = conn.createStatement();
stat.execute("create local temporary table test(id identity)");
PreparedStatement prep = conn.prepareStatement("insert into test values(null)");
for(int i=0; i<10000; i++) {
prep.execute();
}
stat.execute("create local temporary table test2(id identity) as select x from system_range(1, 10)");
conn.close();
}
private void testTempSequence() throws SQLException { private void testTempSequence() throws SQLException {
deleteDb("tempTables"); deleteDb("tempTables");
Connection conn = getConnection("tempTables"); Connection conn = getConnection("tempTables");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论