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

Do not create temporary Merge for MergeUsing

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