mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
bug fixed for mysql parser
This commit is contained in:
@@ -47,11 +47,16 @@ public enum SQLBinaryOperator {
|
||||
LessThanOrEqual("<=", 110),
|
||||
LessThanOrEqualOrGreaterThan("<=>",110),
|
||||
LessThanOrGreater("<>", 110),
|
||||
Like("LIKE", 110),
|
||||
|
||||
Like("LIKE", 110),
|
||||
NotLike("NOT LIKE", 110),
|
||||
|
||||
RLike("RLIKE", 110),
|
||||
NotRLike("NOT RLIKE", 110),
|
||||
|
||||
NotEqual("!=", 110),
|
||||
NotLessThan("!<", 110),
|
||||
NotGreaterThan("!>", 110),
|
||||
NotLike("NOT LIKE", 110),
|
||||
IsNot("IS NOT", 110),
|
||||
Escape("ESCAPE", 110),
|
||||
RegExp("REGEXP", 110),
|
||||
|
||||
@@ -52,7 +52,16 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
}
|
||||
|
||||
public SQLExpr relationalRest(SQLExpr expr) throws ParserException {
|
||||
if (lexer.token() == Token.IDENTIFIER && "REGEXP".equalsIgnoreCase(lexer.stringVal())) {
|
||||
if (identifierEquals("REGEXP")) {
|
||||
lexer.nextToken();
|
||||
SQLExpr rightExp = equality();
|
||||
|
||||
rightExp = relationalRest(rightExp);
|
||||
|
||||
return new SQLBinaryOpExpr(expr, SQLBinaryOperator.RegExp, rightExp);
|
||||
}
|
||||
|
||||
if (identifierEquals("RLIKE")) {
|
||||
lexer.nextToken();
|
||||
SQLExpr rightExp = equality();
|
||||
|
||||
@@ -78,7 +87,7 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
}
|
||||
|
||||
public SQLExpr notRationalRest(SQLExpr expr) {
|
||||
if (lexer.token() == Token.IDENTIFIER && "REGEXP".equalsIgnoreCase(lexer.stringVal())) {
|
||||
if (identifierEquals("REGEXP")) {
|
||||
lexer.nextToken();
|
||||
SQLExpr rightExp = primary();
|
||||
|
||||
@@ -86,6 +95,15 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
|
||||
return new SQLBinaryOpExpr(expr, SQLBinaryOperator.NotRegExp, rightExp);
|
||||
}
|
||||
|
||||
if (identifierEquals("RLIKE")) {
|
||||
lexer.nextToken();
|
||||
SQLExpr rightExp = primary();
|
||||
|
||||
rightExp = relationalRest(rightExp);
|
||||
|
||||
return new SQLBinaryOpExpr(expr, SQLBinaryOperator.NotRLike, rightExp);
|
||||
}
|
||||
|
||||
return super.notRationalRest(expr);
|
||||
}
|
||||
|
||||
+2
@@ -149,6 +149,8 @@ public class OracleSchemaStatVisitor extends SchemaStatVisitor implements Oracle
|
||||
public OracleSchemaStatVisitor(){
|
||||
this.variants.put("DUAL", null);
|
||||
this.variants.put("NOTFOUND", null);
|
||||
this.variants.put("TRUE", null);
|
||||
this.variants.put("FALSE", null);
|
||||
}
|
||||
|
||||
protected Column getColumn(SQLExpr expr) {
|
||||
|
||||
@@ -217,6 +217,7 @@ public class SQLExprParser extends SQLParser {
|
||||
case SCHEMA:
|
||||
case AT:
|
||||
case COLUMN:
|
||||
case IF:
|
||||
sqlExpr = new SQLIdentifierExpr(lexer.stringVal());
|
||||
lexer.nextToken();
|
||||
break;
|
||||
|
||||
@@ -14,6 +14,7 @@ import com.alibaba.druid.sql.ast.SQLOrderBy;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLAggregateExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLAllColumnExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLBinaryOpExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLCurrentOfCursorExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLInListExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLInSubQueryExpr;
|
||||
@@ -867,4 +868,8 @@ public class SchemaStatVisitor extends SQLASTVisitorAdapter {
|
||||
public boolean visit(SQLCommentStatement x) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean visit(SQLCurrentOfCursorExpr x) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user