improve sql wall

This commit is contained in:
kiki
2013-09-10 14:19:56 +08:00
parent b8556813f2
commit afca1fe18f
10 changed files with 217 additions and 161 deletions
@@ -15,6 +15,7 @@
*/
package com.alibaba.druid.sql.dialect.mysql.visitor;
import java.security.AccessControlException;
import java.util.List;
import java.util.Properties;
@@ -46,7 +47,10 @@ public class MySqlParameterizedOutputVisitor extends MySqlOutputVisitor implemen
public MySqlParameterizedOutputVisitor(Appendable appender){
super(appender);
configFromPropety(System.getProperties());
try {
configFromPropety(System.getProperties());
} catch (AccessControlException e) {
}
}
public void configFromPropety(Properties properties) {
@@ -87,7 +91,7 @@ public class MySqlParameterizedOutputVisitor extends MySqlOutputVisitor implemen
SQLObject parent = x.getParent();
computeSharding = parent instanceof SQLExprTableSource || parent instanceof SQLPropertyExpr;
}
if (computeSharding) {
int pos = name.lastIndexOf('_');
if (pos != -1 && pos != name.length() - 1) {
@@ -94,7 +94,6 @@ import com.alibaba.druid.util.JdbcUtils;
import com.alibaba.druid.util.Utils;
import com.alibaba.druid.wall.spi.WallVisitorUtils;
import com.alibaba.druid.wall.spi.WallVisitorUtils.WallConditionContext;
import com.alibaba.druid.wall.spi.WallVisitorUtils.WallSelectQueryContext;
public class SQLEvalVisitorUtils {
@@ -872,17 +871,14 @@ public class SQLEvalVisitorUtils {
if (x.getOperator() == SQLBinaryOperator.Like) {
if (isAlwayTrueLikePattern(x.getRight())) {
final WallSelectQueryContext wallSelectQueryContext = WallVisitorUtils.getWallSelectQueryContext();
if (wallSelectQueryContext != null) {
wallSelectQueryContext.setTrueLike(Boolean.TRUE);
}
x.putAttribute(WallVisitorUtils.HAS_TRUE_LIKE, Boolean.TRUE);
x.putAttribute(EVAL_VALUE, Boolean.TRUE);
return false;
}
}
if (x.getOperator() == SQLBinaryOperator.NotLike) {
if (isAlwayTrueLikePattern(x)) {
if (isAlwayTrueLikePattern(x.getRight())) {
x.putAttribute(EVAL_VALUE, Boolean.FALSE);
return false;
}
@@ -1063,7 +1059,7 @@ public class SQLEvalVisitorUtils {
if (x instanceof SQLCharExpr) {
String text = ((SQLCharExpr) x).getText();
if (text.length() >= 0) {
if (text.length() > 0) {
for (char ch : text.toCharArray()) {
if (ch != '%') {
return false;