improved oracle ddl support

This commit is contained in:
高铁
2020-11-26 18:01:15 +08:00
parent efd2819a3a
commit 1fa599c340
4 changed files with 123 additions and 1 deletions
@@ -34,6 +34,7 @@ import com.alibaba.druid.util.FnvHash;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.List;
public class OracleExprParser extends SQLExprParser {
@@ -121,6 +122,7 @@ public class OracleExprParser extends SQLExprParser {
protected boolean isCharType(long hash) {
return hash == FnvHash.Constants.CHAR
|| hash == FnvHash.Constants.CHARACTER
|| hash == FnvHash.Constants.NCHAR
|| hash == FnvHash.Constants.VARCHAR
|| hash == FnvHash.Constants.VARCHAR2
@@ -221,8 +223,43 @@ public class OracleExprParser extends SQLExprParser {
return timestamp;
}
if ("national".equalsIgnoreCase(typeName)
&& isCharType(lexer.hash_lower())) {
typeName += ' ' + lexer.stringVal();
lexer.nextToken();
if (lexer.identifierEquals("VARYING")) {
typeName += ' ' + lexer.stringVal();
lexer.nextToken();
}
SQLCharacterDataType charType = new SQLCharacterDataType(typeName);
if (lexer.token() == Token.LPAREN) {
lexer.nextToken();
SQLExpr arg = this.expr();
arg.setParent(charType);
charType.addArgument(arg);
accept(Token.RPAREN);
}
charType = (SQLCharacterDataType) parseCharTypeRest(charType);
if (lexer.token() == Token.HINT) {
List<SQLCommentHint> hints = this.parseHints();
charType.setHints(hints);
}
return charType;
}
if (isCharType(typeName)) {
if (lexer.identifierEquals("VARYING")) {
typeName += ' ' + lexer.stringVal();
lexer.nextToken();
}
SQLCharacterDataType charType = new SQLCharacterDataType(typeName);
if (lexer.token() == Token.LPAREN) {
@@ -261,7 +298,6 @@ public class OracleExprParser extends SQLExprParser {
}
}
SQLDataTypeImpl dataType = new SQLDataTypeImpl(typeName);
dataType.setDbType(dbType);
return parseDataTypeRest(dataType);