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:
@@ -47,6 +47,7 @@ public class HiveLexer extends Lexer {
|
||||
map.put("IF", Token.IF);
|
||||
map.put("TRUE", Token.TRUE);
|
||||
map.put("FALSE", Token.FALSE);
|
||||
map.put("RLIKE", Token.RLIKE);
|
||||
|
||||
DEFAULT_HIVE_KEYWORDS = new Keywords(map);
|
||||
}
|
||||
|
||||
@@ -61,6 +61,9 @@ public class MySqlLexer extends Lexer {
|
||||
map.put("UNDO", Token.UNDO);
|
||||
map.put("SQLSTATE", Token.SQLSTATE);
|
||||
map.put("CONDITION", Token.CONDITION);
|
||||
map.put("MOD", Token.MOD);
|
||||
map.put("CONTAINS", Token.CONTAINS);
|
||||
map.put("RLIKE", Token.RLIKE);
|
||||
|
||||
DEFAULT_MYSQL_KEYWORDS = new Keywords(map);
|
||||
}
|
||||
|
||||
@@ -3161,7 +3161,7 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
|
||||
SQLExpr sqlSecurity = this.exprParser.name();
|
||||
stmt.setSqlSecurity(sqlSecurity);
|
||||
} else if (lexer.identifierEquals(FnvHash.Constants.CONTAINS)) {
|
||||
} else if (lexer.identifierEquals(FnvHash.Constants.CONTAINS) || lexer.token() == Token.CONTAINS) {
|
||||
lexer.nextToken();
|
||||
acceptIdentifier("SQL");
|
||||
stmt.setContainsSql(true);
|
||||
@@ -3201,7 +3201,7 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
|
||||
SQLExpr sqlSecurity = this.exprParser.name();
|
||||
stmt.setSqlSecurity(sqlSecurity);
|
||||
} else if (lexer.identifierEquals(FnvHash.Constants.CONTAINS)) {
|
||||
} else if (lexer.identifierEquals(FnvHash.Constants.CONTAINS) || lexer.token() == Token.CONTAINS) {
|
||||
lexer.nextToken();
|
||||
acceptIdentifier("SQL");
|
||||
stmt.setContainsSql(true);
|
||||
@@ -4383,7 +4383,7 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
stmt.setDeterministic(true);
|
||||
continue;
|
||||
}
|
||||
if (lexer.identifierEquals(FnvHash.Constants.CONTAINS)) {
|
||||
if (lexer.identifierEquals(FnvHash.Constants.CONTAINS) || lexer.token() == Token.CONTAINS) {
|
||||
lexer.nextToken();
|
||||
acceptIdentifier("SQL");
|
||||
stmt.setContainsSql(true);
|
||||
|
||||
@@ -152,16 +152,16 @@ public class OdpsExprParser extends SQLExprParser {
|
||||
|
||||
return super.primaryRest(expr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public SQLExpr relationalRest(SQLExpr expr) {
|
||||
if (lexer.identifierEquals("REGEXP")) {
|
||||
lexer.nextToken();
|
||||
SQLExpr rightExp = equality();
|
||||
SQLExpr rightExp = bitOr();
|
||||
|
||||
rightExp = relationalRest(rightExp);
|
||||
|
||||
return new SQLBinaryOpExpr(expr, SQLBinaryOperator.RegExp, rightExp, JdbcConstants.MYSQL);
|
||||
return new SQLBinaryOpExpr(expr, SQLBinaryOperator.RegExp, rightExp, dbType);
|
||||
}
|
||||
|
||||
return super.relationalRest(expr);
|
||||
|
||||
@@ -47,6 +47,7 @@ public class OdpsLexer extends Lexer {
|
||||
map.put("DISTRIBUTE", Token.DISTRIBUTE);
|
||||
map.put("TRUE", Token.TRUE);
|
||||
map.put("FALSE", Token.FALSE);
|
||||
map.put("RLIKE", Token.RLIKE);
|
||||
|
||||
DEFAULT_ODPS_KEYWORDS = new Keywords(map);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user