提交 9ad1ffae authored 作者: S.Vladykin's avatar S.Vladykin

Switched to use linked list like approach + allow to get info from upper levels

上级 bd37e682
......@@ -5,7 +5,6 @@
*/
package org.h2.engine;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
......@@ -110,7 +109,7 @@ public class Session extends SessionWithState {
private final int queryCacheSize;
private SmallLRUCache<String, Command> queryCache;
private long modificationMetaID = -1;
private ArrayDeque<SubQueryInfo> subQueryInfoStack = new ArrayDeque<SubQueryInfo>();
private SubQueryInfo subQueryInfo;
private int parsingView;
/**
......@@ -145,18 +144,12 @@ public class Session extends SessionWithState {
this.currentSchemaName = Constants.SCHEMA_MAIN;
}
public void pushSubQueryInfo(SubQueryInfo subQueryInfo) {
assert subQueryInfo != null;
subQueryInfoStack.addLast(subQueryInfo);
}
public void popSubQueryInfo(SubQueryInfo subQueryInfo) {
SubQueryInfo popped = subQueryInfoStack.pollLast();
assert popped == subQueryInfo;
public void setSubQueryInfo(SubQueryInfo subQueryInfo) {
this.subQueryInfo = subQueryInfo;
}
public SubQueryInfo getSubQueryInfo() {
return subQueryInfoStack.peekLast();
return subQueryInfo;
}
public void setParsingView(boolean parsingView) {
......
......@@ -198,12 +198,14 @@ public class ViewIndex extends BaseIndex implements SpatialIndex {
private static Query prepareSubQuery(String sql, Session session, int[] masks,
TableFilter[] filters, int filter, SortOrder sortOrder, boolean preliminary) {
Prepared p;
SubQueryInfo info = new SubQueryInfo(masks, filters, filter, sortOrder, preliminary);
session.pushSubQueryInfo(info);
SubQueryInfo upper = session.getSubQueryInfo();
SubQueryInfo info = new SubQueryInfo(upper,
masks, filters, filter, sortOrder, preliminary);
session.setSubQueryInfo(info);
try {
p = session.prepare(sql, true);
} finally {
session.popSubQueryInfo(info);
session.setSubQueryInfo(upper);
}
return (Query) p;
}
......
......@@ -20,8 +20,10 @@ public class SubQueryInfo {
private int filter;
private SortOrder sortOrder;
private boolean preliminary;
private SubQueryInfo upper;
/**
* @param upper upper level sub-query if any
* @param masks index conditions masks
* @param filters table filters
* @param filter current filter
......@@ -29,8 +31,9 @@ public class SubQueryInfo {
* @param preliminary if this is a preliminary query optimization
* without global conditions
*/
public SubQueryInfo(int[] masks, TableFilter[] filters, int filter,
public SubQueryInfo(SubQueryInfo upper, int[] masks, TableFilter[] filters, int filter,
SortOrder sortOrder, boolean preliminary) {
this.upper = upper;
this.masks = masks;
this.filters = filters;
this.filter = filter;
......@@ -38,6 +41,10 @@ public class SubQueryInfo {
this.preliminary = preliminary;
}
public SubQueryInfo getUpper() {
return upper;
}
public int[] getMasks() {
return masks;
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论