mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
bug fixed for mysql parser create function. for issue #2340
This commit is contained in:
+16
-12
@@ -318,6 +318,9 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
} else if (lexer.token() == Token.VIEW) {
|
||||
lexer.reset(markBp, markChar, Token.CREATE);
|
||||
return parseCreateView();
|
||||
} else if (lexer.token() == Token.FUNCTION) {
|
||||
lexer.reset(markBp, markChar, Token.CREATE);
|
||||
return parseCreateFunction();
|
||||
} else {
|
||||
lexer.reset(markBp, markChar, Token.CREATE);
|
||||
return parseCreateProcedure();
|
||||
@@ -4282,22 +4285,23 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
SQLCreateFunctionStatement stmt = new SQLCreateFunctionStatement();
|
||||
stmt.setDbType(dbType);
|
||||
|
||||
if (lexer.token() != Token.FUNCTION) {
|
||||
if (lexer.identifierEquals("DEFINER")) {
|
||||
if (lexer.token() == Token.CREATE) {
|
||||
lexer.nextToken();
|
||||
|
||||
if (lexer.token() == Token.OR) {
|
||||
lexer.nextToken();
|
||||
accept(Token.EQ);
|
||||
SQLName definer = this.exprParser.name();
|
||||
stmt.setDefiner(definer);
|
||||
} else {
|
||||
accept(Token.CREATE);
|
||||
if (lexer.token() == Token.OR) {
|
||||
lexer.nextToken();
|
||||
accept(Token.REPLACE);
|
||||
stmt.setOrReplace(true);
|
||||
}
|
||||
accept(Token.REPLACE);
|
||||
stmt.setOrReplace(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (lexer.identifierEquals(FnvHash.Constants.DEFINER)) {
|
||||
lexer.nextToken();
|
||||
accept(Token.EQ);
|
||||
SQLName definer = this.getExprParser().userName();
|
||||
stmt.setDefiner(definer);
|
||||
}
|
||||
|
||||
accept(Token.FUNCTION);
|
||||
|
||||
stmt.setName(this.exprParser.name());
|
||||
|
||||
@@ -2428,6 +2428,16 @@ public class SQLExprParser extends SQLParser {
|
||||
|
||||
accept(Token.SET);
|
||||
|
||||
if (lexer.token != Token.IDENTIFIER
|
||||
&& lexer.token != Token.LITERAL_CHARS
|
||||
&& lexer.token != Token.BINARY) {
|
||||
throw new ParserException(lexer.info());
|
||||
}
|
||||
charType.setCharSetName(lexer.stringVal());
|
||||
lexer.nextToken();
|
||||
} else if (lexer.identifierEquals(FnvHash.Constants.CHARSET)) {
|
||||
lexer.nextToken();
|
||||
|
||||
if (lexer.token != Token.IDENTIFIER
|
||||
&& lexer.token != Token.LITERAL_CHARS
|
||||
&& lexer.token != Token.BINARY) {
|
||||
|
||||
@@ -600,8 +600,10 @@ public class SQLStatementParser extends SQLParser {
|
||||
stmt.setExpr(expr);
|
||||
}
|
||||
|
||||
accept(Token.SEMI);
|
||||
stmt.setAfterSemi(true);
|
||||
if (lexer.token == Token.SEMI) {
|
||||
lexer.nextToken();
|
||||
stmt.setAfterSemi(true);
|
||||
}
|
||||
|
||||
return stmt;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user