提交 2c4b50c4 authored 作者: Thomas Mueller's avatar Thomas Mueller

Issue 288: Some right outer join queries failed to produce the correct result or…

Issue 288: Some right outer join queries failed to produce the correct result or threw exceptions such as "column x must be in the group by list". Some right outer joins with invalid column referenced (typos) threw a NullPointerException instead of "column not found" exception.
上级 543cf97b
......@@ -18,7 +18,11 @@ Change Log
<h1>Change Log</h1>
<h2>Next Version (unreleased)</h2>
<ul><li>New database setting EARLY_FILTER to allow table implementations
<ul><li>Issue 288: Some right outer join queries failed to produce the correct result or
threw exceptions such as "column x must be in the group by list".
</li><li>Some right outer joins with invalid column referenced (typos) threw a NullPointerException instead of
"column not found" exception.
</li><li>New database setting EARLY_FILTER to allow table implementations
to apply filter conditions early on.
</li><li>Cluster: in a two node cluster, if cluster node stopped, and autocommit was enabled,
then changes on the remaining cluster node didn't get committed automatically.
......
......@@ -941,7 +941,7 @@ public class ErrorCode {
* INSERT INTO TEST VALUES(1, 1), (2, 1);
* ALTER TABLE TEST ADD CONSTRAINT TEST_ID_PARENT
* FOREIGN KEY(PARENT) REFERENCES(ID) ON DELETE SET DEFAULT;
* DELETE FROM TEST WHERE ID=1;
* DELETE FROM TEST WHERE ID=1;
* </pre>
*/
public static final int NO_DEFAULT_SET_1 = 90056;
......
......@@ -222,6 +222,11 @@ public class TableFilter implements ColumnResolver {
* @param item the plan item
*/
public void setPlanItem(PlanItem item) {
if (item == null) {
// invalid plan, most likely because a column wasn't found
// this will result in an exception later on
return;
}
setIndex(item.getIndex());
if (nestedJoin != null) {
if (item.getNestedJoinPlan() != null) {
......@@ -794,7 +799,11 @@ public class TableFilter implements ColumnResolver {
joinCondition.setEvaluatable(filter, b);
}
if (nestedJoin != null) {
nestedJoin.setEvaluatable(nestedJoin, b);
// don't enable / disable the nested join filters
// if enabling a filter in a joined filter
if (this == filter) {
nestedJoin.setEvaluatable(nestedJoin, b);
}
}
if (join != null) {
join.setEvaluatable(filter, b);
......
......@@ -16,6 +16,7 @@ import java.sql.Statement;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Random;
import org.h2.constant.ErrorCode;
import org.h2.test.TestBase;
import org.h2.util.IOUtils;
import org.h2.util.New;
......@@ -240,6 +241,24 @@ public class TestNestedJoins extends TestBase {
ResultSet rs;
String sql;
// Issue 288
try {
stat.execute("select 1 from dual a right outer join (select b.x from dual b) c on unknown.x = c.x, dual d");
fail();
} catch (SQLException e) {
// this threw a NullPointerException
assertEquals(ErrorCode.COLUMN_NOT_FOUND_1, e.getErrorCode());
}
// Issue 288
stat.execute("create table test(id int primary key)");
stat.execute("insert into test values(1)");
// this threw the exception Column "T.ID" must be in the GROUP BY list
stat.execute("select * from test t right outer join " +
"(select t2.id, count(*) c from test t2 group by t2.id) x on x.id = t.id " +
"where t.id = 1");
stat.execute("drop table test");
// Issue 288
/*
create table test(id int);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论