提交 d0282e54 authored 作者: Noel Grandin's avatar Noel Grandin

Issue #430: Subquery not cached if number of rows exceeds MAX_MEMORY_ROWS

上级 b6a60e98
...@@ -21,6 +21,8 @@ Change Log ...@@ -21,6 +21,8 @@ Change Log
<h2>Next Version (unreleased)</h2> <h2>Next Version (unreleased)</h2>
<ul> <ul>
<li>#430: Subquery not cached if number of rows exceeds MAX_MEMORY_ROWS
</li>
<li>#411: "TIMEZONE" should be "TIME ZONE" in type "TIMESTAMP WITH TIMEZONE" <li>#411: "TIMEZONE" should be "TIME ZONE" in type "TIMESTAMP WITH TIMEZONE"
</li> </li>
<li>PR #418, Implement Connection#createArrayOf and PreparedStatement#setArray <li>PR #418, Implement Connection#createArrayOf and PreparedStatement#setArray
......
...@@ -46,33 +46,32 @@ public class ConditionInSelect extends Condition { ...@@ -46,33 +46,32 @@ public class ConditionInSelect extends Condition {
if (!query.hasOrder()) { if (!query.hasOrder()) {
query.setDistinct(true); query.setDistinct(true);
} }
try (LocalResult rows = query.query(0)) { LocalResult rows = query.query(0);
Value l = left.getValue(session); Value l = left.getValue(session);
if (rows.getRowCount() == 0) { if (rows.getRowCount() == 0) {
return ValueBoolean.get(all); return ValueBoolean.get(all);
} else if (l == ValueNull.INSTANCE) { } else if (l == ValueNull.INSTANCE) {
return l; return l;
} }
if (!session.getDatabase().getSettings().optimizeInSelect) { if (!session.getDatabase().getSettings().optimizeInSelect) {
return getValueSlow(rows, l); return getValueSlow(rows, l);
} }
if (all || (compareType != Comparison.EQUAL && if (all || (compareType != Comparison.EQUAL &&
compareType != Comparison.EQUAL_NULL_SAFE)) { compareType != Comparison.EQUAL_NULL_SAFE)) {
return getValueSlow(rows, l); return getValueSlow(rows, l);
} }
int dataType = rows.getColumnType(0); int dataType = rows.getColumnType(0);
if (dataType == Value.NULL) { if (dataType == Value.NULL) {
return ValueBoolean.get(false);
}
l = l.convertTo(dataType);
if (rows.containsDistinct(new Value[] { l })) {
return ValueBoolean.get(true);
}
if (rows.containsDistinct(new Value[] { ValueNull.INSTANCE })) {
return ValueNull.INSTANCE;
}
return ValueBoolean.get(false); return ValueBoolean.get(false);
} }
l = l.convertTo(dataType);
if (rows.containsDistinct(new Value[] { l })) {
return ValueBoolean.get(true);
}
if (rows.containsDistinct(new Value[] { ValueNull.INSTANCE })) {
return ValueNull.INSTANCE;
}
return ValueBoolean.get(false);
} }
private Value getValueSlow(LocalResult rows, Value l) { private Value getValueSlow(LocalResult rows, Value l) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论