提交 112c2247 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Do not parse ORDER and LIMIT in UPDATE clause of MERGE USING

上级 7601a29e
...@@ -1116,11 +1116,11 @@ public class Parser { ...@@ -1116,11 +1116,11 @@ public class Parser {
int start = lastParseIndex; int start = lastParseIndex;
TableFilter filter = readSimpleTableFilter(0, null); TableFilter filter = readSimpleTableFilter(0, null);
command.setTableFilter(filter); command.setTableFilter(filter);
parseUpdateSetClause(command, filter, start); parseUpdateSetClause(command, filter, start, true);
return command; return command;
} }
private void parseUpdateSetClause(Update command, TableFilter filter, int start) { private void parseUpdateSetClause(Update command, TableFilter filter, int start, boolean allowExtensions) {
read("SET"); read("SET");
if (readIf(OPEN_PAREN)) { if (readIf(OPEN_PAREN)) {
ArrayList<Column> columns = Utils.newSmallArrayList(); ArrayList<Column> columns = Utils.newSmallArrayList();
...@@ -1154,15 +1154,17 @@ public class Parser { ...@@ -1154,15 +1154,17 @@ public class Parser {
Expression condition = readExpression(); Expression condition = readExpression();
command.setCondition(condition); command.setCondition(condition);
} }
if (readIf(ORDER)) { if (allowExtensions) {
// for MySQL compatibility if (readIf(ORDER)) {
// (this syntax is supported, but ignored) // for MySQL compatibility
read("BY"); // (this syntax is supported, but ignored)
parseSimpleOrderList(); read("BY");
} parseSimpleOrderList();
if (readIf(LIMIT)) { }
Expression limit = readTerm().optimize(session); if (readIf(LIMIT)) {
command.setLimit(limit); Expression limit = readTerm().optimize(session);
command.setLimit(limit);
}
} }
setSQL(command, "UPDATE", start); setSQL(command, "UPDATE", start);
} }
...@@ -1513,7 +1515,7 @@ public class Parser { ...@@ -1513,7 +1515,7 @@ public class Parser {
updateCommand = new Update(session); updateCommand = new Update(session);
TableFilter filter = command.getTargetTableFilter(); TableFilter filter = command.getTargetTableFilter();
updateCommand.setTableFilter(filter); updateCommand.setTableFilter(filter);
parseUpdateSetClause(updateCommand, filter, startMatched); parseUpdateSetClause(updateCommand, filter, startMatched, false);
startMatched = lastParseIndex; startMatched = lastParseIndex;
} }
Delete deleteCommand = null; Delete deleteCommand = null;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论