mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
mysql parser bug fixed
This commit is contained in:
@@ -52,12 +52,25 @@ public class SQLSelectParser extends SQLParser {
|
||||
|
||||
return select;
|
||||
}
|
||||
|
||||
protected SQLUnionQuery createSQLUnionQuery() {
|
||||
return new SQLUnionQuery();
|
||||
}
|
||||
|
||||
public SQLUnionQuery unionRest(SQLUnionQuery union) {
|
||||
if (lexer.token() == Token.ORDER) {
|
||||
SQLOrderBy orderBy = this.createExprParser().parseOrderBy();
|
||||
union.setOrderBy(orderBy);
|
||||
return unionRest(union);
|
||||
}
|
||||
return union;
|
||||
}
|
||||
|
||||
public SQLSelectQuery queryRest(SQLSelectQuery selectQuery) throws ParserException {
|
||||
if (lexer.token() == Token.UNION) {
|
||||
lexer.nextToken();
|
||||
|
||||
SQLUnionQuery union = new SQLUnionQuery();
|
||||
SQLUnionQuery union = createSQLUnionQuery();
|
||||
union.setLeft(selectQuery);
|
||||
|
||||
if (lexer.token() == Token.ALL) {
|
||||
@@ -68,7 +81,7 @@ public class SQLSelectParser extends SQLParser {
|
||||
SQLSelectQuery right = this.query();
|
||||
union.setRight(right);
|
||||
|
||||
return union;
|
||||
return unionRest(union);
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.INTERSECT) {
|
||||
|
||||
@@ -168,6 +168,18 @@ public class SQLStatementParser extends SQLParser {
|
||||
if (parseStatementListDialect(statementList)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.LPAREN) {
|
||||
char mark_ch = lexer.current();
|
||||
int mark_bp = lexer.bp();
|
||||
lexer.nextToken();
|
||||
if (lexer.token() == Token.SELECT) {
|
||||
lexer.reset(mark_bp, mark_ch, Token.LPAREN);
|
||||
SQLStatement stmt = parseSelect();
|
||||
statementList.add(stmt);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
throw new ParserException("TODO " + lexer.token() + " " + lexer.stringVal());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user