mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
Merge pull request #547 from yakolee/master
bugfix & improve sql parser
This commit is contained in:
@@ -149,6 +149,8 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
|
||||
|
||||
public static ThreadLocal<Long> waitNanosLocal = new ThreadLocal<Long>();
|
||||
|
||||
private boolean logDiffrentThread = true;
|
||||
|
||||
public DruidDataSource(){
|
||||
this(false);
|
||||
}
|
||||
@@ -1128,7 +1130,7 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
|
||||
return;
|
||||
}
|
||||
|
||||
if (pooledConnection.getOwnerThread() != Thread.currentThread()) {
|
||||
if (logDiffrentThread && pooledConnection.getOwnerThread() != Thread.currentThread()) {
|
||||
LOG.warn("get/close not same thread");
|
||||
}
|
||||
|
||||
@@ -1569,7 +1571,9 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
|
||||
value.setTestWhileIdle(this.isTestWhileIdle());
|
||||
|
||||
value.setDefaultAutoCommit(this.isDefaultAutoCommit());
|
||||
value.setDefaultReadOnly(this.getDefaultReadOnly());
|
||||
if (getDefaultReadOnly() != null) {
|
||||
value.setDefaultReadOnly(this.getDefaultReadOnly());
|
||||
}
|
||||
value.setDefaultTransactionIsolation(this.getDefaultTransactionIsolation());
|
||||
|
||||
value.setLogicConnectErrorCount(connectErrorCount.getAndSet(0));
|
||||
@@ -2393,4 +2397,12 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
|
||||
|
||||
return super.unwrap(iface);
|
||||
}
|
||||
|
||||
public boolean isLogDiffrentThread() {
|
||||
return logDiffrentThread;
|
||||
}
|
||||
|
||||
public void setLogDiffrentThread(boolean logDiffrentThread) {
|
||||
this.logDiffrentThread = logDiffrentThread;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,7 +234,7 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
String chars = lexer.stringVal();
|
||||
concat.addParameter(new SQLCharExpr(chars));
|
||||
lexer.nextToken();
|
||||
} while (lexer.token() == Token.LITERAL_CHARS);
|
||||
} while (lexer.token() == Token.LITERAL_CHARS || lexer.token() == Token.LITERAL_ALIAS);
|
||||
expr = concat;
|
||||
}
|
||||
} else if (lexer.token() == Token.IDENTIFIER) {
|
||||
|
||||
@@ -105,6 +105,7 @@ public class MySqlLexer extends Lexer {
|
||||
|
||||
stringVal = subString(mark, bufPos);
|
||||
token = Token.LINE_COMMENT;
|
||||
hasComment = true;
|
||||
|
||||
if (commentHandler != null && commentHandler.handle(lastToken, stringVal)) {
|
||||
return;
|
||||
@@ -440,6 +441,7 @@ public class MySqlLexer extends Lexer {
|
||||
} else {
|
||||
stringVal = subString(mark, bufPos);
|
||||
token = Token.MULTI_LINE_COMMENT;
|
||||
hasComment = true;
|
||||
}
|
||||
|
||||
if (commentHandler != null && commentHandler.handle(lastToken, stringVal)) {
|
||||
@@ -481,6 +483,7 @@ public class MySqlLexer extends Lexer {
|
||||
|
||||
stringVal = subString(mark, bufPos + 1);
|
||||
token = Token.LINE_COMMENT;
|
||||
hasComment = true;
|
||||
|
||||
if (commentHandler != null && commentHandler.handle(lastToken, stringVal)) {
|
||||
return;
|
||||
|
||||
@@ -171,7 +171,7 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
return visit((MySqlSelectQueryBlock) select);
|
||||
}
|
||||
|
||||
return false;
|
||||
return super.visit(select);
|
||||
}
|
||||
|
||||
public boolean visit(MySqlSelectQueryBlock x) {
|
||||
@@ -383,13 +383,7 @@ public class MySqlOutputVisitor extends SQLASTOutputVisitor implements MySqlASTV
|
||||
if (x.getCharSetName() != null) {
|
||||
print(" CHARACTER SET ");
|
||||
print(x.getCharSetName());
|
||||
|
||||
if (x.getCollate() != null) {
|
||||
print(" COLLATE ");
|
||||
print(x.getCollate());
|
||||
}
|
||||
}
|
||||
|
||||
if (x.getCollate() != null) {
|
||||
print(" COLLATE ");
|
||||
print(x.getCollate());
|
||||
|
||||
+18
@@ -22,6 +22,7 @@ import java.util.Properties;
|
||||
import com.alibaba.druid.sql.ast.SQLObject;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLBinaryOpExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLCharExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLHexExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLInListExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLIntegerExpr;
|
||||
@@ -31,6 +32,7 @@ import com.alibaba.druid.sql.ast.expr.SQLNumberExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLPropertyExpr;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLExprTableSource;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLInsertStatement.ValuesClause;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlCharExpr;
|
||||
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlInsertStatement;
|
||||
import com.alibaba.druid.sql.visitor.ParameterizedOutputVisitorUtils;
|
||||
import com.alibaba.druid.sql.visitor.ParameterizedVisitor;
|
||||
@@ -179,6 +181,22 @@ public class MySqlParameterizedOutputVisitor extends MySqlOutputVisitor implemen
|
||||
|
||||
return ParameterizedOutputVisitorUtils.visit(this, x);
|
||||
}
|
||||
|
||||
public boolean visit(SQLHexExpr x) {
|
||||
if (!ParameterizedOutputVisitorUtils.checkParameterize(x)) {
|
||||
return super.visit(x);
|
||||
}
|
||||
|
||||
return ParameterizedOutputVisitorUtils.visit(this, x);
|
||||
}
|
||||
|
||||
public boolean visit(MySqlCharExpr x) {
|
||||
if (!ParameterizedOutputVisitorUtils.checkParameterize(x)) {
|
||||
return super.visit(x);
|
||||
}
|
||||
|
||||
return ParameterizedOutputVisitorUtils.visit(this, x);
|
||||
}
|
||||
|
||||
protected void printValuesList(MySqlInsertStatement x) {
|
||||
List<ValuesClause> valuesList = x.getValuesList();
|
||||
|
||||
@@ -92,6 +92,7 @@ public class OdpsLexer extends Lexer {
|
||||
} else {
|
||||
stringVal = subString(mark, bufPos);
|
||||
token = Token.MULTI_LINE_COMMENT;
|
||||
hasComment = true;
|
||||
}
|
||||
|
||||
if (token != Token.HINT && !isAllowComment()) {
|
||||
@@ -134,6 +135,7 @@ public class OdpsLexer extends Lexer {
|
||||
|
||||
stringVal = subString(mark + 1, bufPos);
|
||||
token = Token.LINE_COMMENT;
|
||||
hasComment = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,6 +230,7 @@ public class OracleLexer extends Lexer {
|
||||
} else {
|
||||
stringVal = subString(mark, bufPos);
|
||||
token = Token.MULTI_LINE_COMMENT;
|
||||
hasComment = true;
|
||||
}
|
||||
|
||||
if (token != Token.HINT && !isAllowComment()) {
|
||||
@@ -272,6 +273,7 @@ public class OracleLexer extends Lexer {
|
||||
|
||||
stringVal = subString(mark + 1, bufPos);
|
||||
token = Token.LINE_COMMENT;
|
||||
hasComment = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2205,6 +2205,7 @@ public class OracleOutputVisitor extends SQLASTOutputVisitor implements OracleAS
|
||||
item.setParent(x);
|
||||
item.accept(this);
|
||||
}
|
||||
print(";");
|
||||
|
||||
decrementIndent();
|
||||
return false;
|
||||
@@ -2226,6 +2227,7 @@ public class OracleOutputVisitor extends SQLASTOutputVisitor implements OracleAS
|
||||
item.setParent(x);
|
||||
item.accept(this);
|
||||
}
|
||||
print(";");
|
||||
|
||||
decrementIndent();
|
||||
return false;
|
||||
@@ -2256,6 +2258,7 @@ public class OracleOutputVisitor extends SQLASTOutputVisitor implements OracleAS
|
||||
println();
|
||||
}
|
||||
}
|
||||
print(";");
|
||||
decrementIndent();
|
||||
|
||||
for (ElseIf elseIf : x.getElseIfList()) {
|
||||
|
||||
@@ -100,6 +100,7 @@ public class SQLServerLexer extends Lexer {
|
||||
} else {
|
||||
stringVal = subString(mark, bufPos);
|
||||
token = Token.MULTI_LINE_COMMENT;
|
||||
hasComment = true;
|
||||
}
|
||||
|
||||
if (token != Token.HINT && !isAllowComment()) {
|
||||
@@ -142,6 +143,7 @@ public class SQLServerLexer extends Lexer {
|
||||
|
||||
stringVal = subString(mark + 1, bufPos);
|
||||
token = Token.LINE_COMMENT;
|
||||
hasComment = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
+9
@@ -22,6 +22,7 @@ import com.alibaba.druid.sql.ast.expr.SQLIntegerExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLNCharExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLNullExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLNumberExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLVariantRefExpr;
|
||||
import com.alibaba.druid.sql.visitor.ParameterizedOutputVisitorUtils;
|
||||
import com.alibaba.druid.sql.visitor.ParameterizedVisitor;
|
||||
|
||||
@@ -90,5 +91,13 @@ public class SQLServerParameterizedOutputVisitor extends SQLServerOutputVisitor
|
||||
|
||||
return ParameterizedOutputVisitorUtils.visit(this, x);
|
||||
}
|
||||
|
||||
public boolean visit(SQLVariantRefExpr x) {
|
||||
if (!ParameterizedOutputVisitorUtils.checkParameterize(x) || x.getName().equalsIgnoreCase("?")) {
|
||||
return super.visit(x);
|
||||
}
|
||||
|
||||
return ParameterizedOutputVisitorUtils.visit(this, x);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -69,6 +69,8 @@ public class Lexer {
|
||||
private int varIndex = -1;
|
||||
|
||||
protected CommentHandler commentHandler;
|
||||
|
||||
protected boolean hasComment = false;
|
||||
|
||||
public Lexer(String input){
|
||||
this(input, true);
|
||||
@@ -747,6 +749,7 @@ public class Lexer {
|
||||
|
||||
stringVal = subString(mark, bufPos);
|
||||
token = Token.MULTI_LINE_COMMENT;
|
||||
hasComment = true;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -777,6 +780,7 @@ public class Lexer {
|
||||
|
||||
stringVal = subString(mark + 1, bufPos);
|
||||
token = Token.LINE_COMMENT;
|
||||
hasComment = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1045,4 +1049,8 @@ public class Lexer {
|
||||
|
||||
boolean handle(Token lastToken, String comment);
|
||||
}
|
||||
|
||||
public boolean isHasComment() {
|
||||
return hasComment;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1360,29 +1360,19 @@ public class SQLExprParser extends SQLParser {
|
||||
}
|
||||
charType.setCharSetName(lexer.stringVal());
|
||||
lexer.nextToken();
|
||||
|
||||
if (lexer.token() == Token.IDENTIFIER) {
|
||||
if (lexer.stringVal().equalsIgnoreCase("COLLATE")) {
|
||||
lexer.nextToken();
|
||||
|
||||
if (lexer.token() != Token.IDENTIFIER) {
|
||||
throw new ParserException();
|
||||
}
|
||||
charType.setCollate(lexer.stringVal());
|
||||
lexer.nextToken();
|
||||
}
|
||||
}
|
||||
}else if(identifierEquals("COLLATE")){
|
||||
lexer.nextToken();
|
||||
|
||||
if (lexer.token() != Token.IDENTIFIER) {
|
||||
throw new ParserException();
|
||||
}
|
||||
|
||||
charType.setCollate(lexer.stringVal());
|
||||
lexer.nextToken();
|
||||
}
|
||||
|
||||
if (lexer.token() == Token.IDENTIFIER) {
|
||||
if (lexer.stringVal().equalsIgnoreCase("COLLATE")) {
|
||||
lexer.nextToken();
|
||||
|
||||
if (lexer.token() != Token.IDENTIFIER) {
|
||||
throw new ParserException();
|
||||
}
|
||||
charType.setCollate(lexer.stringVal());
|
||||
lexer.nextToken();
|
||||
}
|
||||
}
|
||||
return charType;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import com.alibaba.druid.sql.ast.SQLStatement;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLBinaryOpExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLBinaryOperator;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLCharExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLHexExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLInListExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLIntegerExpr;
|
||||
import com.alibaba.druid.sql.ast.expr.SQLLiteralExpr;
|
||||
@@ -55,13 +56,18 @@ public class ParameterizedOutputVisitorUtils {
|
||||
return sql;
|
||||
}
|
||||
|
||||
SQLStatement stmt = statementList.get(0);
|
||||
|
||||
StringBuilder out = new StringBuilder();
|
||||
ParameterizedVisitor visitor = createParameterizedOutputVisitor(out, dbType);
|
||||
stmt.accept(visitor);
|
||||
|
||||
if (visitor.getReplaceCount() == 0) {
|
||||
for (int i = 0; i < statementList.size(); i++) {
|
||||
if (i > 0) {
|
||||
out.append(";\n");
|
||||
}
|
||||
SQLStatement stmt = statementList.get(i);
|
||||
stmt.accept(visitor);
|
||||
}
|
||||
|
||||
if (visitor.getReplaceCount() == 0 && !parser.getLexer().isHasComment()) {
|
||||
return sql;
|
||||
}
|
||||
|
||||
@@ -190,6 +196,18 @@ public class ParameterizedOutputVisitorUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean visit(ParameterizedVisitor v, SQLVariantRefExpr x) {
|
||||
v.print('?');
|
||||
v.incrementReplaceCunt();
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean visit(ParameterizedVisitor v, SQLHexExpr x) {
|
||||
v.print('?');
|
||||
v.incrementReplaceCunt();
|
||||
return false;
|
||||
}
|
||||
|
||||
public static SQLBinaryOpExpr merge(ParameterizedVisitor v, SQLBinaryOpExpr x) {
|
||||
SQLExpr left = x.getLeft();
|
||||
SQLExpr right = x.getRight();
|
||||
@@ -198,8 +216,17 @@ public class ParameterizedOutputVisitorUtils {
|
||||
if (left instanceof SQLLiteralExpr && right instanceof SQLLiteralExpr) {
|
||||
if (x.getOperator() == SQLBinaryOperator.Equality //
|
||||
|| x.getOperator() == SQLBinaryOperator.NotEqual) {
|
||||
left.putAttribute(ATTR_PARAMS_SKIP, true);
|
||||
right.putAttribute(ATTR_PARAMS_SKIP, true);
|
||||
if((left instanceof SQLIntegerExpr) && (right instanceof SQLIntegerExpr) ) {
|
||||
if (((SQLIntegerExpr) left).getNumber().intValue() < 100) {
|
||||
left.putAttribute(ATTR_PARAMS_SKIP, true);
|
||||
}
|
||||
if (((SQLIntegerExpr) right).getNumber().intValue() < 100) {
|
||||
right.putAttribute(ATTR_PARAMS_SKIP, true);
|
||||
}
|
||||
} else {
|
||||
left.putAttribute(ATTR_PARAMS_SKIP, true);
|
||||
right.putAttribute(ATTR_PARAMS_SKIP, true);
|
||||
}
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
@@ -97,6 +97,7 @@ import com.alibaba.druid.sql.ast.statement.SQLCreateTableStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLCreateTriggerStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLCreateTriggerStatement.TriggerEvent;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLCreateTriggerStatement.TriggerType;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLCreateViewStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLDeleteStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLDropDatabaseStatement;
|
||||
import com.alibaba.druid.sql.ast.statement.SQLDropFunctionStatement;
|
||||
@@ -601,7 +602,9 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Printab
|
||||
decrementIndent();
|
||||
} else if (parent instanceof ValuesClause) {
|
||||
println();
|
||||
print("(");
|
||||
x.getSubQuery().accept(this);
|
||||
print(")");
|
||||
println();
|
||||
} else {
|
||||
print("(");
|
||||
@@ -1411,6 +1414,27 @@ public class SQLASTOutputVisitor extends SQLASTVisitorAdapter implements Printab
|
||||
x.getName().accept(this);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(SQLCreateViewStatement x) {
|
||||
print("CREATE ");
|
||||
if(x.isOrReplace()) {
|
||||
print("OR REPLACE ");
|
||||
}
|
||||
print("VIEW ");
|
||||
x.getName().accept(this);
|
||||
|
||||
if (x.getColumns().size() > 0) {
|
||||
print(" (");
|
||||
printAndAccept(x.getColumns(), ", ");
|
||||
print(")");
|
||||
}
|
||||
|
||||
print(" AS ");
|
||||
|
||||
x.getSubQuery().accept(this);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visit(SQLAlterTableDropIndex x) {
|
||||
|
||||
@@ -1278,6 +1278,49 @@ public class SQLEvalVisitorUtils {
|
||||
|
||||
return BigInteger.valueOf(((Number) val).longValue());
|
||||
}
|
||||
|
||||
public static Number castToNumber(String val) {
|
||||
if (val == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
return Byte.parseByte(val);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
|
||||
try {
|
||||
return Short.parseShort(val);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
|
||||
try {
|
||||
return Integer.parseInt(val);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
|
||||
try {
|
||||
return Long.parseLong(val);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
|
||||
try {
|
||||
return Float.parseFloat(val);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
|
||||
try {
|
||||
return Double.parseDouble(val);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
|
||||
try {
|
||||
return new BigInteger(val);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
|
||||
return new BigDecimal(val);
|
||||
}
|
||||
|
||||
public static Date castToDate(Object val) {
|
||||
if (val == null) {
|
||||
@@ -1383,6 +1426,14 @@ public class SQLEvalVisitorUtils {
|
||||
if (a == null || b == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (a instanceof String) {
|
||||
a = castToNumber((String) a);
|
||||
}
|
||||
|
||||
if (b instanceof String) {
|
||||
b = castToNumber((String) b);
|
||||
}
|
||||
|
||||
if (a instanceof BigDecimal || b instanceof BigDecimal) {
|
||||
BigDecimal decimalA = castToDecimal(a);
|
||||
@@ -1660,6 +1711,14 @@ public class SQLEvalVisitorUtils {
|
||||
if (a == EVAL_VALUE_NULL || b == EVAL_VALUE_NULL) {
|
||||
return EVAL_VALUE_NULL;
|
||||
}
|
||||
|
||||
if (a instanceof String && !(b instanceof String)) {
|
||||
a = castToNumber((String) a);
|
||||
}
|
||||
|
||||
if (b instanceof String && !(a instanceof String)) {
|
||||
b = castToNumber((String) b);
|
||||
}
|
||||
|
||||
if (a instanceof BigDecimal || b instanceof BigDecimal) {
|
||||
return castToDecimal(a).add(castToDecimal(b));
|
||||
@@ -1700,7 +1759,7 @@ public class SQLEvalVisitorUtils {
|
||||
return castToByte(a) + castToByte(b);
|
||||
}
|
||||
|
||||
if (a instanceof String || b instanceof String) {
|
||||
if (a instanceof String && b instanceof String) {
|
||||
return castToString(a) + castToString(b);
|
||||
}
|
||||
|
||||
@@ -1723,6 +1782,14 @@ public class SQLEvalVisitorUtils {
|
||||
if (a instanceof Date || b instanceof Date) {
|
||||
return SQLEvalVisitor.EVAL_ERROR;
|
||||
}
|
||||
|
||||
if (a instanceof String) {
|
||||
a = castToNumber((String) a);
|
||||
}
|
||||
|
||||
if (b instanceof String) {
|
||||
b = castToNumber((String) b);
|
||||
}
|
||||
|
||||
if (a instanceof BigDecimal || b instanceof BigDecimal) {
|
||||
return castToDecimal(a).subtract(castToDecimal(b));
|
||||
@@ -1763,10 +1830,6 @@ public class SQLEvalVisitorUtils {
|
||||
return castToByte(a) - castToByte(b);
|
||||
}
|
||||
|
||||
if (a instanceof String && b instanceof String) {
|
||||
return castToLong(a) - castToLong(b);
|
||||
}
|
||||
|
||||
// return SQLEvalVisitor.EVAL_ERROR;
|
||||
throw new IllegalArgumentException(a.getClass() + " and " + b.getClass() + " not supported.");
|
||||
}
|
||||
@@ -1776,6 +1839,14 @@ public class SQLEvalVisitorUtils {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (a instanceof String) {
|
||||
a = castToNumber((String) a);
|
||||
}
|
||||
|
||||
if (b instanceof String) {
|
||||
b = castToNumber((String) b);
|
||||
}
|
||||
|
||||
if (a instanceof BigDecimal || b instanceof BigDecimal) {
|
||||
return castToDecimal(a).multiply(castToDecimal(b));
|
||||
}
|
||||
@@ -1783,6 +1854,14 @@ public class SQLEvalVisitorUtils {
|
||||
if (a instanceof BigInteger || b instanceof BigInteger) {
|
||||
return castToBigInteger(a).multiply(castToBigInteger(b));
|
||||
}
|
||||
|
||||
if (a instanceof Double || b instanceof Double) {
|
||||
return castToDouble(a) * castToDouble(b);
|
||||
}
|
||||
|
||||
if (a instanceof Float || b instanceof Float) {
|
||||
return castToFloat(a) * castToFloat(b);
|
||||
}
|
||||
|
||||
if (a instanceof Long || b instanceof Long) {
|
||||
return castToLong(a) * castToLong(b);
|
||||
|
||||
Reference in New Issue
Block a user