提交 05cdc302 authored 作者: Thomas Mueller's avatar Thomas Mueller

Concurrently preparing a statement and altering a table could throw a table not found exception.

上级 8efb6c8d
...@@ -370,8 +370,10 @@ public class Session extends SessionWithState { ...@@ -370,8 +370,10 @@ public class Session extends SessionWithState {
} }
public CommandInterface prepareCommand(String sql, int fetchSize) { public CommandInterface prepareCommand(String sql, int fetchSize) {
synchronized (database) {
return prepareLocal(sql); return prepareLocal(sql);
} }
}
/** /**
* Parse and prepare the given SQL statement. This method also checks the * Parse and prepare the given SQL statement. This method also checks the
......
...@@ -49,10 +49,33 @@ public class TestMultiThread extends TestBase implements Runnable { ...@@ -49,10 +49,33 @@ public class TestMultiThread extends TestBase implements Runnable {
} }
public void test() throws Exception { public void test() throws Exception {
testConcurrentAlter();
testConcurrentAnalyze(); testConcurrentAnalyze();
testConcurrentInsertUpdateSelect(); testConcurrentInsertUpdateSelect();
} }
private void testConcurrentAlter() throws Exception {
deleteDb("concurrentAlter");
final Connection conn = getConnection("concurrentAlter");
Statement stat = conn.createStatement();
Task t = new Task() {
public void call() throws Exception {
while (!stop) {
conn.prepareStatement("select * from test");
}
}
};
stat.execute("create table test(id int)");
t.execute();
for (int i = 0; i < 200; i++) {
stat.execute("alter table test add column x int");
stat.execute("alter table test drop column x");
}
t.get();
conn.close();
deleteDb("concurrentAlter");
}
private void testConcurrentAnalyze() throws Exception { private void testConcurrentAnalyze() throws Exception {
if (config.mvcc) { if (config.mvcc) {
return; return;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论