提交 e3a0d5ee authored 作者: Thomas Mueller's avatar Thomas Mueller

Statements with a nested query and a condition that was always NULL threw an…

Statements with a nested query and a condition that was always NULL threw an IndexOutOfBoundsException.
上级 d5e0bdb4
......@@ -18,7 +18,9 @@ Change Log
<h1>Change Log</h1>
<h2>Next Version (unreleased)</h2>
<ul><li>Experimental feature to support very large transactions (except when using MVCC).
<ul><li>Statements with a nested query and a condition that was always NULL threw an
IndexOutOfBoundsException. Example: select * from (select null as x) where x=1
</li><li>Experimental feature to support very large transactions (except when using MVCC).
To enable, set the system property h2.largeTransactions to true.
If enabled, changes to tables without a primary key can be buffered to disk.
The plan is to enable this feature by default in version 1.3.x.
......
......@@ -154,12 +154,8 @@ public class ViewIndex extends BaseIndex {
for (int i = 0; originalParameters != null && i < originalParameters.size(); i++) {
Parameter orig = originalParameters.get(i);
int idx = orig.getIndex();
// the parameter may have been optimized away
if (idx < paramList.size()) {
Parameter param = paramList.get(idx);
Value value = orig.getValue(session);
param.setValue(value);
}
Value value = orig.getValue(session);
setParameter(paramList, idx, value);
}
int len;
if (first != null) {
......@@ -175,22 +171,32 @@ public class ViewIndex extends BaseIndex {
if (first != null) {
Value v = first.getValue(i);
if (v != null) {
Parameter param = paramList.get(idx++);
param.setValue(v);
int x = idx++;
setParameter(paramList, x, v);
}
}
// for equality, only one parameter is used (first == last)
if (last != null && indexMasks[i] != IndexCondition.EQUALITY) {
Value v = last.getValue(i);
if (v != null) {
Parameter param = paramList.get(idx++);
param.setValue(v);
int x = idx++;
setParameter(paramList, x, v);
}
}
}
ResultInterface result = query.query(0);
return new ViewCursor(table, result);
}
private void setParameter(ArrayList<Parameter> paramList, int x, Value v) {
if (x >= paramList.size()) {
// the parameter may be optimized away as in
// select * from (select null as x) where x=1;
return;
}
Parameter param = paramList.get(x);
param.setValue(v);
}
private Query getQuery(Session session, int[] masks) {
Query q = (Query) session.prepare(querySQL, true);
......
--- special grammar and test cases ---------------------------------------------------------------------------------------------
select * from (select null as x) where x=1;
> X
> -
> rows: 0
create table test(a int primary key, b int references(a));
> ok
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论