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

Forbid empty WHEN [NOT] MATCHED THEN

上级 40f3269b
......@@ -1207,12 +1207,14 @@ public class Parser {
private void parseWhenMatched(MergeUsing command) {
read("THEN");
int startMatched = lastParseIndex;
boolean ok = false;
if (readIf("UPDATE")) {
Update updateCommand = new Update(session);
TableFilter filter = command.getTargetTableFilter();
updateCommand.setTableFilter(filter);
parseUpdateSetClause(updateCommand, filter, startMatched);
command.setUpdateCommand(updateCommand);
ok = true;
}
startMatched = lastParseIndex;
if (readIf("DELETE")) {
......@@ -1221,6 +1223,10 @@ public class Parser {
deleteCommand.setTableFilter(filter);
parseDeleteGivenTable(deleteCommand, null, startMatched);
command.setDeleteCommand(deleteCommand);
ok = true;
}
if (!ok) {
throw getSyntaxError();
}
}
......@@ -1233,6 +1239,8 @@ public class Parser {
insertCommand.setTable(command.getTargetTable());
parseInsertGivenTable(insertCommand, command.getTargetTable());
command.setInsertCommand(insertCommand);
} else {
throw getSyntaxError();
}
}
......
......@@ -158,10 +158,20 @@ MERGE INTO TEST USING DUAL ON (ID = 1)
WHEN;
> exception SYNTAX_ERROR_2
MERGE INTO TEST USING DUAL ON (ID = 1)
WHEN MATCHED THEN UPDATE SET VALUE = 1
WHEN NOT MATCHED THEN;
> exception SYNTAX_ERROR_2
MERGE INTO TEST USING DUAL ON (ID = 1)
WHEN NOT MATCHED THEN INSERT (ID, VALUE) VALUES (1, 1)
WHEN;
> exception SYNTAX_ERROR_2
MERGE INTO TEST USING DUAL ON (ID = 1)
WHEN NOT MATCHED THEN INSERT (ID, VALUE) VALUES (1, 1)
WHEN MATCHED THEN;
> exception SYNTAX_ERROR_2
DROP TABLE TEST;
> ok
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论