提交 48b45dd4 authored 作者: Sergi Vladykin's avatar Sergi Vladykin

Call Query.setNeverLazy only in Parser

上级 189dc5fe
...@@ -224,7 +224,6 @@ public class Parser { ...@@ -224,7 +224,6 @@ public class Parser {
private ArrayList<Parameter> indexedParameterList; private ArrayList<Parameter> indexedParameterList;
private int orderInFrom; private int orderInFrom;
private ArrayList<Parameter> suppliedParameterList; private ArrayList<Parameter> suppliedParameterList;
private boolean hasRecursive;
public Parser(Session session) { public Parser(Session session) {
this.database = session.getDatabase(); this.database = session.getDatabase();
...@@ -301,9 +300,6 @@ public class Parser { ...@@ -301,9 +300,6 @@ public class Parser {
} }
p.setPrepareAlways(recompileAlways); p.setPrepareAlways(recompileAlways);
p.setParameterList(parameters); p.setParameterList(parameters);
if (hasRecursive && p.isQuery() && p instanceof Query) {
((Query) p).setNeverLazy(true);
}
return p; return p;
} }
...@@ -1719,7 +1715,9 @@ public class Parser { ...@@ -1719,7 +1715,9 @@ public class Parser {
} }
} }
if (isToken("SELECT") || isToken("FROM") || isToken("(") || isToken("WITH")) { if (isToken("SELECT") || isToken("FROM") || isToken("(") || isToken("WITH")) {
command.setCommand(parseSelect()); Query query = parseSelect();
query.setNeverLazy(true);
command.setCommand(query);
} else if (readIf("DELETE")) { } else if (readIf("DELETE")) {
command.setCommand(parseDelete()); command.setCommand(parseDelete());
} else if (readIf("UPDATE")) { } else if (readIf("UPDATE")) {
...@@ -1928,7 +1926,10 @@ public class Parser { ...@@ -1928,7 +1926,10 @@ public class Parser {
return command; return command;
} }
if (readIf("WITH")) { if (readIf("WITH")) {
return parseWith(); Query query = parseWith();
// recursive can not be lazy
query.setNeverLazy(true);
return query;
} }
Select select = parseSelectSimple(); Select select = parseSelectSimple();
return select; return select;
...@@ -2239,6 +2240,7 @@ public class Parser { ...@@ -2239,6 +2240,7 @@ public class Parser {
} else { } else {
if (isSelect()) { if (isSelect()) {
Query query = parseSelect(); Query query = parseSelect();
query.setNeverLazy(true);
r = new ConditionInSelect(database, r, query, false, r = new ConditionInSelect(database, r, query, false,
Comparison.EQUAL); Comparison.EQUAL);
} else { } else {
...@@ -4837,7 +4839,6 @@ public class Parser { ...@@ -4837,7 +4839,6 @@ public class Parser {
} }
private Query parseWith() { private Query parseWith() {
hasRecursive = true;
readIf("RECURSIVE"); readIf("RECURSIVE");
String tempViewName = readIdentifierWithSchema(); String tempViewName = readIdentifierWithSchema();
Schema schema = getSchema(); Schema schema = getSchema();
......
...@@ -38,9 +38,6 @@ public class Explain extends Prepared { ...@@ -38,9 +38,6 @@ public class Explain extends Prepared {
public void setCommand(Prepared command) { public void setCommand(Prepared command) {
this.command = command; this.command = command;
if (command instanceof Query) {
((Query) command).setNeverLazy(true);
}
} }
public Prepared getCommand() { public Prepared getCommand() {
......
...@@ -60,14 +60,13 @@ public abstract class Query extends Prepared { ...@@ -60,14 +60,13 @@ public abstract class Query extends Prepared {
*/ */
protected boolean randomAccessResult; protected boolean randomAccessResult;
protected boolean neverLazy;
private boolean noCache; private boolean noCache;
private int lastLimit; private int lastLimit;
private long lastEvaluated; private long lastEvaluated;
private ResultInterface lastResult; private ResultInterface lastResult;
private Value[] lastParameters; private Value[] lastParameters;
private boolean cacheableChecked; private boolean cacheableChecked;
private boolean neverLazy;
Query(Session session) { Query(Session session) {
super(session); super(session);
...@@ -77,6 +76,10 @@ public abstract class Query extends Prepared { ...@@ -77,6 +76,10 @@ public abstract class Query extends Prepared {
this.neverLazy = b; this.neverLazy = b;
} }
public boolean isNeverLazy() {
return neverLazy;
}
/** /**
* Check if this is a UNION query. * Check if this is a UNION query.
* *
......
...@@ -38,7 +38,6 @@ public class ConditionInSelect extends Condition { ...@@ -38,7 +38,6 @@ public class ConditionInSelect extends Condition {
this.query = query; this.query = query;
this.all = all; this.all = all;
this.compareType = compareType; this.compareType = compareType;
query.setNeverLazy(true);
} }
@Override @Override
......
...@@ -192,7 +192,7 @@ public class ViewIndex extends BaseIndex implements SpatialIndex { ...@@ -192,7 +192,7 @@ public class ViewIndex extends BaseIndex implements SpatialIndex {
parser.setRightsChecked(true); parser.setRightsChecked(true);
parser.setSuppliedParameterList(originalParameters); parser.setSuppliedParameterList(originalParameters);
query = (Query) parser.prepare(querySQL); query = (Query) parser.prepare(querySQL);
query.setNeverLazy(true); assert query.isNeverLazy();
} }
if (!query.isUnion()) { if (!query.isUnion()) {
throw DbException.get(ErrorCode.SYNTAX_ERROR_2, throw DbException.get(ErrorCode.SYNTAX_ERROR_2,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论