提交 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);
"
"Commands (DML)","DELETE","
DELETE [ TOP term ] FROM tableName deleteSearchCondition
DELETE [ TOP term ] FROM tableName [ WHERE expression ] [ LIMIT term ]
","
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).
......@@ -2275,14 +2275,6 @@ SELECT CAST(0 AS DOUBLE)
SELECT -1.4e-10
"
"Other Grammar","Delete search condition","
[ WHERE expression ] [ LIMIT term ]
","
Search condition for DELETE statement.
","
WHERE ID = 2
"
"Other Grammar","Digit","
0-9
","
......@@ -2383,7 +2375,7 @@ WHEN MATCHED THEN DELETE
WHEN MATCHED [ AND expression ] THEN
UPDATE SET setClauseList
| DELETE
| {UPDATE SET setClauseList [ WHERE expression ] DELETE deleteSearchCondition}
| {UPDATE SET setClauseList [ WHERE expression ] DELETE [ WHERE expression ]}
","
WHEN MATCHED clause for MERGE USING command.
......
......@@ -1197,20 +1197,15 @@ public class Parser {
}
TableFilter filter = readSimpleTableFilter(0, null);
command.setTableFilter(filter);
parseDeleteGivenTable(command, limit, start);
return command;
}
private void parseDeleteGivenTable(Delete command, Expression limit, int start) {
if (readIf(WHERE)) {
Expression condition = readExpression();
command.setCondition(condition);
command.setCondition(readExpression());
}
if (readIf(LIMIT) && limit == null) {
if (limit == null && readIf(LIMIT)) {
limit = readTerm().optimize(session);
}
command.setLimit(limit);
setSQL(command, "DELETE", start);
return command;
}
private IndexColumn[] parseIndexColumnList() {
......@@ -1519,14 +1514,16 @@ public class Parser {
TableFilter filter = command.getTargetTableFilter();
updateCommand.setTableFilter(filter);
parseUpdateSetClause(updateCommand, filter, startMatched);
}
startMatched = lastParseIndex;
}
Delete deleteCommand = null;
if (readIf("DELETE")) {
deleteCommand = new Delete(session);
TableFilter filter = command.getTargetTableFilter();
deleteCommand.setTableFilter(filter);
parseDeleteGivenTable(deleteCommand, null, startMatched);
deleteCommand.setTableFilter(command.getTargetTableFilter());
if (readIf(WHERE)) {
deleteCommand.setCondition(readExpression());
}
setSQL(deleteCommand, "DELETE", startMatched);
}
if (updateCommand != null || deleteCommand != null) {
MergeUsing.WhenMatched when = new MergeUsing.WhenMatched(command);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论