提交 aa822ca6 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Do not create temporary Merge for MergeUsing

上级 03cde6d9
...@@ -1397,18 +1397,17 @@ public class Parser { ...@@ -1397,18 +1397,17 @@ public class Parser {
private Prepared parseMerge() { private Prepared parseMerge() {
Merge command = new Merge(session);
currentPrepared = command;
int start = lastParseIndex; int start = lastParseIndex;
read("INTO"); read("INTO");
List<String> excludeIdentifiers = Arrays.asList("USING", "KEY", "VALUES"); List<String> excludeIdentifiers = Arrays.asList("USING", "KEY", "VALUES");
TableFilter targetTableFilter = readSimpleTableFilter(0, excludeIdentifiers); TableFilter targetTableFilter = readSimpleTableFilter(0, excludeIdentifiers);
command.setTargetTableFilter(targetTableFilter);
Table table = command.getTargetTable();
if (readIf("USING")) { if (readIf("USING")) {
return parseMergeUsing(command, start); return parseMergeUsing(targetTableFilter, start);
} }
Merge command = new Merge(session);
currentPrepared = command;
command.setTargetTableFilter(targetTableFilter);
Table table = command.getTargetTable();
if (readIf(OPEN_PAREN)) { if (readIf(OPEN_PAREN)) {
if (isSelect()) { if (isSelect()) {
command.setQuery(parseSelect()); command.setQuery(parseSelect());
...@@ -1434,8 +1433,8 @@ public class Parser { ...@@ -1434,8 +1433,8 @@ public class Parser {
return command; return command;
} }
private MergeUsing parseMergeUsing(Merge oldCommand, int start) { private MergeUsing parseMergeUsing(TableFilter targetTableFilter, int start) {
MergeUsing command = new MergeUsing(oldCommand); MergeUsing command = new MergeUsing(session, targetTableFilter);
currentPrepared = command; currentPrepared = command;
if (readIf(OPEN_PAREN)) { if (readIf(OPEN_PAREN)) {
......
...@@ -15,6 +15,7 @@ import org.h2.api.Trigger; ...@@ -15,6 +15,7 @@ import org.h2.api.Trigger;
import org.h2.command.CommandInterface; import org.h2.command.CommandInterface;
import org.h2.command.Prepared; import org.h2.command.Prepared;
import org.h2.engine.Right; import org.h2.engine.Right;
import org.h2.engine.Session;
import org.h2.expression.ConditionAndOr; import org.h2.expression.ConditionAndOr;
import org.h2.expression.Expression; import org.h2.expression.Expression;
import org.h2.expression.ExpressionColumn; import org.h2.expression.ExpressionColumn;
...@@ -32,7 +33,7 @@ import org.h2.value.Value; ...@@ -32,7 +33,7 @@ import org.h2.value.Value;
/** /**
* This class represents the statement syntax * This class represents the statement syntax
* MERGE table alias USING... * MERGE INTO table alias USING...
* *
* It does not replace the existing MERGE INTO... KEYS... form. * It does not replace the existing MERGE INTO... KEYS... form.
* *
...@@ -119,12 +120,10 @@ public class MergeUsing extends Prepared { ...@@ -119,12 +120,10 @@ public class MergeUsing extends Prepared {
private int sourceQueryRowNumber; private int sourceQueryRowNumber;
public MergeUsing(Merge merge) { public MergeUsing(Session session, TableFilter targetTableFilter) {
super(merge.getSession()); super(session);
this.targetTable = targetTableFilter.getTable();
// bring across only the already parsed data from Merge... this.targetTableFilter = targetTableFilter;
this.targetTable = merge.getTargetTable();
this.targetTableFilter = merge.getTargetTableFilter();
} }
@Override @Override
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论