提交 e72e4504 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Fix ConditionInSelect used as JOIN ON condition

上级 9d0a8827
...@@ -21,12 +21,14 @@ Change Log ...@@ -21,12 +21,14 @@ Change Log
<h2>Next Version (unreleased)</h2> <h2>Next Version (unreleased)</h2>
<ul> <ul>
<li>- <li>Issue #1750: JOIN t ON t.col IN (SELECT ...) throws AssertionError
</li> </li>
</ul> </ul>
<h2>Version 1.4.198 (2019-02-22)</h2> <h2>Version 1.4.198 (2019-02-22)</h2>
<ul> <ul>
<li>Issue #1746: Infinite loop in TestConcurrent.testConcurrentChangeAndGetVersion()
</li>
<li>Issue #1739: Table and view names not case sensitive when using DATABASE_TO_UPPER=FALSE <li>Issue #1739: Table and view names not case sensitive when using DATABASE_TO_UPPER=FALSE
</li> </li>
<li>Issue #848: H2 PostgreSQL Compatibility Mode: lowercase metadata <li>Issue #848: H2 PostgreSQL Compatibility Mode: lowercase metadata
......
...@@ -41,6 +41,11 @@ public class ConditionInSelect extends Condition { ...@@ -41,6 +41,11 @@ public class ConditionInSelect extends Condition {
this.database = database; this.database = database;
this.left = left; this.left = left;
this.query = query; this.query = query;
/*
* Need to do it now because other methods may be invoked in different
* order.
*/
query.setRandomAccessResult(true);
this.all = all; this.all = all;
this.compareType = compareType; this.compareType = compareType;
} }
...@@ -140,7 +145,6 @@ public class ConditionInSelect extends Condition { ...@@ -140,7 +145,6 @@ public class ConditionInSelect extends Condition {
@Override @Override
public Expression optimize(Session session) { public Expression optimize(Session session) {
left = left.optimize(session); left = left.optimize(session);
query.setRandomAccessResult(true);
session.optimizeQueryExpression(query); session.optimizeQueryExpression(query);
// Can not optimize: the data may change // Can not optimize: the data may change
return this; return this;
......
...@@ -654,3 +654,14 @@ SELECT _ROWID_ S1, TEST._ROWID_ S2, PUBLIC.TEST._ROWID_ S3, SCRIPT.PUBLIC.TEST._ ...@@ -654,3 +654,14 @@ SELECT _ROWID_ S1, TEST._ROWID_ S2, PUBLIC.TEST._ROWID_ S3, SCRIPT.PUBLIC.TEST._
DROP TABLE TEST; DROP TABLE TEST;
> ok > ok
CREATE TABLE TEST(ID BIGINT PRIMARY KEY);
> ok
SELECT X.ID FROM TEST X JOIN TEST Y ON Y.ID IN (SELECT 1);
> ID
> --
> rows: 0
DROP TABLE TEST;
> ok
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论