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:
@@ -1705,11 +1705,19 @@ public class SQLStatementParser extends SQLParser {
|
||||
if (lexer.token == Token.VALUES) {
|
||||
lexer.nextToken();
|
||||
for (;;) {
|
||||
accept(Token.LPAREN);
|
||||
SQLInsertStatement.ValuesClause values = new SQLInsertStatement.ValuesClause();
|
||||
this.exprParser.exprList(values.getValues(), values);
|
||||
insertStatement.addValueCause(values);
|
||||
accept(Token.RPAREN);
|
||||
if (lexer.token == Token.LPAREN) {
|
||||
lexer.nextToken();
|
||||
|
||||
SQLInsertStatement.ValuesClause values = new SQLInsertStatement.ValuesClause();
|
||||
this.exprParser.exprList(values.getValues(), values);
|
||||
insertStatement.addValueCause(values);
|
||||
accept(Token.RPAREN);
|
||||
} else { // oracle
|
||||
SQLInsertStatement.ValuesClause values = new SQLInsertStatement.ValuesClause();
|
||||
SQLExpr value = this.exprParser.expr();
|
||||
values.addValue(value);
|
||||
insertStatement.addValueCause(values);
|
||||
}
|
||||
|
||||
if (lexer.token == Token.COMMA) {
|
||||
lexer.nextToken();
|
||||
@@ -2051,15 +2059,17 @@ public class SQLStatementParser extends SQLParser {
|
||||
}
|
||||
|
||||
public SQLStatement parseCreateTrigger() {
|
||||
accept(Token.CREATE);
|
||||
|
||||
SQLCreateTriggerStatement stmt = new SQLCreateTriggerStatement(getDbType());
|
||||
|
||||
if (lexer.token == Token.OR) {
|
||||
if (lexer.token == Token.CREATE) {
|
||||
lexer.nextToken();
|
||||
accept(Token.REPLACE);
|
||||
|
||||
stmt.setOrReplace(true);
|
||||
if (lexer.token == Token.OR) {
|
||||
lexer.nextToken();
|
||||
accept(Token.REPLACE);
|
||||
|
||||
stmt.setOrReplace(true);
|
||||
}
|
||||
}
|
||||
|
||||
accept(Token.TRIGGER);
|
||||
@@ -2613,6 +2623,12 @@ public class SQLStatementParser extends SQLParser {
|
||||
accept(Token.OPEN);
|
||||
stmt.setCursorName(exprParser.name().getSimpleName());
|
||||
|
||||
if (lexer.token == Token.LPAREN) {
|
||||
lexer.nextToken();
|
||||
this.exprParser.names(stmt.getColumns(), stmt);
|
||||
accept(Token.RPAREN);
|
||||
}
|
||||
|
||||
if (lexer.token == Token.FOR) {
|
||||
lexer.nextToken();
|
||||
if (lexer.token == Token.SELECT) {
|
||||
|
||||
Reference in New Issue
Block a user