mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved sql parser.
This commit is contained in:
@@ -361,6 +361,12 @@ public class SQLStatementParser extends SQLParser {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (identifierEquals("RETURN")) {
|
||||
SQLStatement stmt = parseReturn();
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
|
||||
// throw new ParserException("syntax error, " + lexer.token() + " "
|
||||
// + lexer.stringVal() + ", pos "
|
||||
// + lexer.pos());
|
||||
@@ -368,6 +374,24 @@ public class SQLStatementParser extends SQLParser {
|
||||
}
|
||||
}
|
||||
|
||||
public SQLStatement parseReturn() {
|
||||
if (lexer.token() == Token.RETURN
|
||||
|| identifierEquals("RETURN")) {
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
SQLReturnStatement stmt = new SQLReturnStatement();
|
||||
if (lexer.token() != Token.SEMI) {
|
||||
SQLExpr expr = this.exprParser.expr();
|
||||
stmt.setExpr(expr);
|
||||
}
|
||||
|
||||
accept(Token.SEMI);
|
||||
stmt.setAfterSemi(true);
|
||||
|
||||
return stmt;
|
||||
}
|
||||
|
||||
public SQLStatement parseUpsert() {
|
||||
SQLInsertStatement insertStatement = new SQLInsertStatement();
|
||||
|
||||
@@ -1539,7 +1563,7 @@ public class SQLStatementParser extends SQLParser {
|
||||
accept(Token.LPAREN);
|
||||
SQLInsertStatement.ValuesClause values = new SQLInsertStatement.ValuesClause();
|
||||
this.exprParser.exprList(values.getValues(), values);
|
||||
insertStatement.getValuesList().add(values);
|
||||
insertStatement.addValueCause(values);
|
||||
accept(Token.RPAREN);
|
||||
|
||||
if (lexer.token() == Token.COMMA) {
|
||||
|
||||
Reference in New Issue
Block a user