提交 99c7bb02 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Move containsDistinct() from ResultInterface to LocalResult

上级 68f46168
...@@ -2811,8 +2811,6 @@ public class Parser { ...@@ -2811,8 +2811,6 @@ public class Parser {
} else { } else {
if (isSelect()) { if (isSelect()) {
Query query = parseSelect(); Query query = parseSelect();
// TODO lazy result causes timeout in TestFuzzOptimizations
query.setNeverLazy(true);
r = new ConditionInSelect(database, r, query, false, r = new ConditionInSelect(database, r, query, false,
Comparison.EQUAL); Comparison.EQUAL);
} else { } else {
......
...@@ -11,6 +11,7 @@ import org.h2.engine.Database; ...@@ -11,6 +11,7 @@ import org.h2.engine.Database;
import org.h2.engine.Session; import org.h2.engine.Session;
import org.h2.index.IndexCondition; import org.h2.index.IndexCondition;
import org.h2.message.DbException; import org.h2.message.DbException;
import org.h2.result.LocalResult;
import org.h2.result.ResultInterface; import org.h2.result.ResultInterface;
import org.h2.table.ColumnResolver; import org.h2.table.ColumnResolver;
import org.h2.table.TableFilter; import org.h2.table.TableFilter;
...@@ -43,8 +44,10 @@ public class ConditionInSelect extends Condition { ...@@ -43,8 +44,10 @@ public class ConditionInSelect extends Condition {
@Override @Override
public Value getValue(Session session) { public Value getValue(Session session) {
query.setSession(session); query.setSession(session);
// We need a LocalResult
query.setNeverLazy(true);
query.setDistinctIfPossible(); query.setDistinctIfPossible();
ResultInterface rows = query.query(0); LocalResult rows = (LocalResult) query.query(0);
Value l = left.getValue(session); Value l = left.getValue(session);
if (!rows.hasNext()) { if (!rows.hasNext()) {
return ValueBoolean.get(all); return ValueBoolean.get(all);
......
...@@ -185,11 +185,4 @@ public abstract class LazyResult implements ResultInterface { ...@@ -185,11 +185,4 @@ public abstract class LazyResult implements ResultInterface {
return null; return null;
} }
@Override
public boolean containsDistinct(Value[] values) {
// We have to make sure that we do not allow lazy
// evaluation when this call is needed:
// WHERE x IN (SELECT ...).
throw DbException.throwInternalError();
}
} }
...@@ -41,6 +41,14 @@ public interface LocalResult extends ResultInterface, ResultTarget { ...@@ -41,6 +41,14 @@ public interface LocalResult extends ResultInterface, ResultTarget {
*/ */
public void setDistinct(int[] distinctIndexes); public void setDistinct(int[] distinctIndexes);
/**
* Check if this result set contains the given row.
*
* @param values the row
* @return true if the row exists
*/
boolean containsDistinct(Value[] values);
/** /**
* Remove the row from the result set if it exists. * Remove the row from the result set if it exists.
* *
......
...@@ -202,11 +202,4 @@ public interface ResultInterface extends AutoCloseable { ...@@ -202,11 +202,4 @@ public interface ResultInterface extends AutoCloseable {
*/ */
ResultInterface createShallowCopy(SessionInterface targetSession); ResultInterface createShallowCopy(SessionInterface targetSession);
/**
* Check if this result set contains the given row.
*
* @param values the row
* @return true if the row exists
*/
boolean containsDistinct(Value[] values);
} }
...@@ -281,9 +281,4 @@ public class ResultRemote implements ResultInterface { ...@@ -281,9 +281,4 @@ public class ResultRemote implements ResultInterface {
return result == null; return result == null;
} }
@Override
public boolean containsDistinct(Value[] values) {
// We should never do this on remote result.
throw DbException.throwInternalError();
}
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论