提交 f03f4781 authored 作者: tledkov's avatar tledkov

#1057, #1072 fix NPE on CTE

上级 32cc2c52
...@@ -873,11 +873,12 @@ public class Select extends Query { ...@@ -873,11 +873,12 @@ public class Select extends Query {
for (; f != null; f = f.getJoin()) { for (; f != null; f = f.getJoin()) {
if (f.getTable().getTableType() == TableType.VIEW) { if (f.getTable().getTableType() == TableType.VIEW) {
ViewIndex idx = (ViewIndex) f.getIndex(); ViewIndex idx = (ViewIndex) f.getIndex();
if (idx != null && idx.getQuery() != null) {
idx.getQuery().setNeverLazy(true); idx.getQuery().setNeverLazy(true);
} }
} }
} }
}
/** /**
* Reset the batch-join after the query result is closed. * Reset the batch-join after the query result is closed.
......
...@@ -58,13 +58,13 @@ public class TestSubqueryPerformanceOnLazyExecutionMode extends TestDb { ...@@ -58,13 +58,13 @@ public class TestSubqueryPerformanceOnLazyExecutionMode extends TestDb {
} }
} }
public void testSubqueryInCondition(Statement stmt) throws Exception { private void testSubqueryInCondition(Statement stmt) throws Exception {
String sql = "SELECT COUNT (*) FROM one WHERE x IN (SELECT y FROM one WHERE y < 50)"; String sql = "SELECT COUNT (*) FROM one WHERE x IN (SELECT y FROM one WHERE y < 50)";
checkExecutionTime(stmt, sql); checkExecutionTime(stmt, sql);
} }
public void testSubqueryInJoin(Statement stmt) throws Exception { private void testSubqueryInJoin(Statement stmt) throws Exception {
String sql = String sql =
"SELECT COUNT (one.x) FROM one " + "SELECT COUNT (one.x) FROM one " +
"JOIN (SELECT y AS val FROM one WHERE y < 50) AS subq ON subq.val=one.x"; "JOIN (SELECT y AS val FROM one WHERE y < 50) AS subq ON subq.val=one.x";
...@@ -72,7 +72,7 @@ public class TestSubqueryPerformanceOnLazyExecutionMode extends TestDb { ...@@ -72,7 +72,7 @@ public class TestSubqueryPerformanceOnLazyExecutionMode extends TestDb {
checkExecutionTime(stmt, sql); checkExecutionTime(stmt, sql);
} }
public void testSubqueryInJoinFirst(Statement stmt) throws Exception { private void testSubqueryInJoinFirst(Statement stmt) throws Exception {
String sql = String sql =
"SELECT COUNT (one.x) FROM " + "SELECT COUNT (one.x) FROM " +
"(SELECT y AS val FROM one WHERE y < 50) AS subq " + "(SELECT y AS val FROM one WHERE y < 50) AS subq " +
...@@ -81,7 +81,7 @@ public class TestSubqueryPerformanceOnLazyExecutionMode extends TestDb { ...@@ -81,7 +81,7 @@ public class TestSubqueryPerformanceOnLazyExecutionMode extends TestDb {
checkExecutionTime(stmt, sql); checkExecutionTime(stmt, sql);
} }
public void testJoinTwoSubqueries(Statement stmt) throws Exception { private void testJoinTwoSubqueries(Statement stmt) throws Exception {
String sql = String sql =
"SELECT COUNT (one_sub.x) FROM " + "SELECT COUNT (one_sub.x) FROM " +
"(SELECT y AS val FROM one WHERE y < 50) AS subq " + "(SELECT y AS val FROM one WHERE y < 50) AS subq " +
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论