提交 6c842956 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Pass Session instead of Parser to Command()

上级 d5478abd
...@@ -46,8 +46,8 @@ public abstract class Command implements CommandInterface { ...@@ -46,8 +46,8 @@ public abstract class Command implements CommandInterface {
private boolean canReuse; private boolean canReuse;
Command(Parser parser, String sql) { Command(Session session, String sql) {
this.session = parser.getSession(); this.session = session;
this.sql = sql; this.sql = sql;
trace = session.getDatabase().getTrace(Trace.COMMAND); trace = session.getDatabase().getTrace(Trace.COMMAND);
} }
......
...@@ -9,6 +9,7 @@ import java.util.ArrayList; ...@@ -9,6 +9,7 @@ import java.util.ArrayList;
import org.h2.api.DatabaseEventListener; import org.h2.api.DatabaseEventListener;
import org.h2.command.dml.Explain; import org.h2.command.dml.Explain;
import org.h2.command.dml.Query; import org.h2.command.dml.Query;
import org.h2.engine.Session;
import org.h2.expression.Parameter; import org.h2.expression.Parameter;
import org.h2.expression.ParameterInterface; import org.h2.expression.ParameterInterface;
import org.h2.result.ResultInterface; import org.h2.result.ResultInterface;
...@@ -26,8 +27,8 @@ public class CommandContainer extends Command { ...@@ -26,8 +27,8 @@ public class CommandContainer extends Command {
private boolean readOnlyKnown; private boolean readOnlyKnown;
private boolean readOnly; private boolean readOnly;
CommandContainer(Parser parser, String sql, Prepared prepared) { CommandContainer(Session session, String sql, Prepared prepared) {
super(parser, sql); super(session, sql);
prepared.setCommand(this); prepared.setCommand(this);
this.prepared = prepared; this.prepared = prepared;
} }
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
package org.h2.command; package org.h2.command;
import java.util.ArrayList; import java.util.ArrayList;
import org.h2.engine.Session;
import org.h2.expression.ParameterInterface; import org.h2.expression.ParameterInterface;
import org.h2.result.ResultInterface; import org.h2.result.ResultInterface;
...@@ -17,8 +19,8 @@ class CommandList extends Command { ...@@ -17,8 +19,8 @@ class CommandList extends Command {
private final Command command; private final Command command;
private final String remaining; private final String remaining;
CommandList(Parser parser, String sql, Command c, String remaining) { CommandList(Session session, String sql, Command c, String remaining) {
super(parser, sql); super(session, sql);
this.command = c; this.command = c;
this.remaining = remaining; this.remaining = remaining;
} }
......
...@@ -285,11 +285,11 @@ public class Parser { ...@@ -285,11 +285,11 @@ public class Parser {
throw getSyntaxError(); throw getSyntaxError();
} }
p.prepare(); p.prepare();
Command c = new CommandContainer(this, sql, p); Command c = new CommandContainer(session, sql, p);
if (hasMore) { if (hasMore) {
String remaining = originalSQL.substring(parseIndex); String remaining = originalSQL.substring(parseIndex);
if (!StringUtils.isWhitespaceOrEmpty(remaining)) { if (!StringUtils.isWhitespaceOrEmpty(remaining)) {
c = new CommandList(this, sql, c, remaining); c = new CommandList(session, sql, c, remaining);
} }
} }
return c; return c;
...@@ -3877,10 +3877,6 @@ public class Parser { ...@@ -3877,10 +3877,6 @@ public class Parser {
currentTokenType = VALUE; currentTokenType = VALUE;
} }
public Session getSession() {
return session;
}
private void initialize(String sql) { private void initialize(String sql) {
if (sql == null) { if (sql == null) {
sql = ""; sql = "";
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论