mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
bug fixed sql parser for db2. for issue #2332
This commit is contained in:
@@ -23,6 +23,7 @@ import com.alibaba.druid.sql.parser.SQLExprParser;
|
||||
import com.alibaba.druid.sql.parser.SQLParserFeature;
|
||||
import com.alibaba.druid.sql.parser.Token;
|
||||
import com.alibaba.druid.util.FnvHash;
|
||||
import com.alibaba.druid.util.JdbcConstants;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -46,6 +47,7 @@ public class DB2ExprParser extends SQLExprParser {
|
||||
public DB2ExprParser(String sql){
|
||||
this(new DB2Lexer(sql));
|
||||
this.lexer.nextToken();
|
||||
this.dbType = JdbcConstants.DB2;
|
||||
}
|
||||
|
||||
public DB2ExprParser(String sql, SQLParserFeature... features){
|
||||
@@ -57,6 +59,7 @@ public class DB2ExprParser extends SQLExprParser {
|
||||
super(lexer);
|
||||
this.aggregateFunctions = AGGREGATE_FUNCTIONS;
|
||||
this.aggregateFunctionHashCodes = AGGREGATE_FUNCTIONS_CODES;
|
||||
this.dbType = JdbcConstants.DB2;
|
||||
}
|
||||
|
||||
public SQLExpr primaryRest(SQLExpr expr) {
|
||||
@@ -116,6 +119,15 @@ public class DB2ExprParser extends SQLExprParser {
|
||||
expr = new SQLIdentifierExpr("CURRENT SCHEMA");
|
||||
}
|
||||
}
|
||||
} else if (lexer.identifierEquals(FnvHash.Constants.PATH)) {
|
||||
if (expr instanceof SQLIdentifierExpr) {
|
||||
SQLIdentifierExpr identExpr = (SQLIdentifierExpr) expr;
|
||||
if (identExpr.hashCode64() == FnvHash.Constants.CURRENT) {
|
||||
lexer.nextToken();
|
||||
|
||||
expr = new SQLIdentifierExpr("CURRENT PATH");
|
||||
}
|
||||
}
|
||||
} else if (lexer.identifierEquals(FnvHash.Constants.MONTHS)) {
|
||||
SQLIntervalExpr intervalExpr = new SQLIntervalExpr(expr, SQLIntervalUnit.MONTH);
|
||||
lexer.nextToken();
|
||||
|
||||
@@ -3679,7 +3679,7 @@ public class MySqlStatementParser extends SQLStatementParser {
|
||||
renameStmt.addItem(item);
|
||||
|
||||
return renameStmt;
|
||||
}
|
||||
}
|
||||
} else if (lexer.token() == Token.ORDER) {
|
||||
throw new ParserException("TODO " + lexer.info());
|
||||
} else if (lexer.identifierEquals("CONVERT")) {
|
||||
|
||||
Reference in New Issue
Block a user