提交 7601a29e authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Do not try to parse LIMIT in DELETE clause of MERGE USING

上级 e4ebb286
...@@ -82,7 +82,7 @@ UPDATE PERSON P SET NAME=(SELECT A.NAME FROM ADDRESS A WHERE A.ID=P.ID); ...@@ -82,7 +82,7 @@ UPDATE PERSON P SET NAME=(SELECT A.NAME FROM ADDRESS A WHERE A.ID=P.ID);
" "
"Commands (DML)","DELETE"," "Commands (DML)","DELETE","
DELETE [ TOP term ] FROM tableName deleteSearchCondition DELETE [ TOP term ] FROM tableName [ WHERE expression ] [ LIMIT term ]
"," ","
Deletes rows form a table. Deletes rows form a table.
If TOP or LIMIT is specified, at most the specified number of rows are deleted (no limit if null or smaller than zero). If TOP or LIMIT is specified, at most the specified number of rows are deleted (no limit if null or smaller than zero).
...@@ -2275,14 +2275,6 @@ SELECT CAST(0 AS DOUBLE) ...@@ -2275,14 +2275,6 @@ SELECT CAST(0 AS DOUBLE)
SELECT -1.4e-10 SELECT -1.4e-10
" "
"Other Grammar","Delete search condition","
[ WHERE expression ] [ LIMIT term ]
","
Search condition for DELETE statement.
","
WHERE ID = 2
"
"Other Grammar","Digit"," "Other Grammar","Digit","
0-9 0-9
"," ","
...@@ -2383,7 +2375,7 @@ WHEN MATCHED THEN DELETE ...@@ -2383,7 +2375,7 @@ WHEN MATCHED THEN DELETE
WHEN MATCHED [ AND expression ] THEN WHEN MATCHED [ AND expression ] THEN
UPDATE SET setClauseList UPDATE SET setClauseList
| DELETE | DELETE
| {UPDATE SET setClauseList [ WHERE expression ] DELETE deleteSearchCondition} | {UPDATE SET setClauseList [ WHERE expression ] DELETE [ WHERE expression ]}
"," ","
WHEN MATCHED clause for MERGE USING command. WHEN MATCHED clause for MERGE USING command.
......
...@@ -1197,20 +1197,15 @@ public class Parser { ...@@ -1197,20 +1197,15 @@ public class Parser {
} }
TableFilter filter = readSimpleTableFilter(0, null); TableFilter filter = readSimpleTableFilter(0, null);
command.setTableFilter(filter); command.setTableFilter(filter);
parseDeleteGivenTable(command, limit, start);
return command;
}
private void parseDeleteGivenTable(Delete command, Expression limit, int start) {
if (readIf(WHERE)) { if (readIf(WHERE)) {
Expression condition = readExpression(); command.setCondition(readExpression());
command.setCondition(condition);
} }
if (readIf(LIMIT) && limit == null) { if (limit == null && readIf(LIMIT)) {
limit = readTerm().optimize(session); limit = readTerm().optimize(session);
} }
command.setLimit(limit); command.setLimit(limit);
setSQL(command, "DELETE", start); setSQL(command, "DELETE", start);
return command;
} }
private IndexColumn[] parseIndexColumnList() { private IndexColumn[] parseIndexColumnList() {
...@@ -1519,14 +1514,16 @@ public class Parser { ...@@ -1519,14 +1514,16 @@ public class Parser {
TableFilter filter = command.getTargetTableFilter(); TableFilter filter = command.getTargetTableFilter();
updateCommand.setTableFilter(filter); updateCommand.setTableFilter(filter);
parseUpdateSetClause(updateCommand, filter, startMatched); parseUpdateSetClause(updateCommand, filter, startMatched);
startMatched = lastParseIndex;
} }
startMatched = lastParseIndex;
Delete deleteCommand = null; Delete deleteCommand = null;
if (readIf("DELETE")) { if (readIf("DELETE")) {
deleteCommand = new Delete(session); deleteCommand = new Delete(session);
TableFilter filter = command.getTargetTableFilter(); deleteCommand.setTableFilter(command.getTargetTableFilter());
deleteCommand.setTableFilter(filter); if (readIf(WHERE)) {
parseDeleteGivenTable(deleteCommand, null, startMatched); deleteCommand.setCondition(readExpression());
}
setSQL(deleteCommand, "DELETE", startMatched);
} }
if (updateCommand != null || deleteCommand != null) { if (updateCommand != null || deleteCommand != null) {
MergeUsing.WhenMatched when = new MergeUsing.WhenMatched(command); MergeUsing.WhenMatched when = new MergeUsing.WhenMatched(command);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论