improve WallFilter

This commit is contained in:
wenshao
2013-04-01 11:04:38 +08:00
parent 8b6672debf
commit 7a49a6ce35
14 changed files with 102 additions and 54 deletions
@@ -19,8 +19,8 @@ import static com.alibaba.druid.sql.parser.CharTypes.isFirstIdentifierChar;
import static com.alibaba.druid.sql.parser.CharTypes.isIdentifierChar;
import static com.alibaba.druid.sql.parser.CharTypes.isWhitespace;
import static com.alibaba.druid.sql.parser.LayoutCharacters.EOI;
import static com.alibaba.druid.sql.parser.Token.COLONEQ;
import static com.alibaba.druid.sql.parser.Token.COLONCOLON;
import static com.alibaba.druid.sql.parser.Token.COLONEQ;
import static com.alibaba.druid.sql.parser.Token.COMMA;
import static com.alibaba.druid.sql.parser.Token.EOF;
import static com.alibaba.druid.sql.parser.Token.ERROR;
@@ -389,7 +389,7 @@ public class Lexer {
token = Token.SEMI;
return;
case '`':
throw new SQLParseException("TODO"); // TODO
throw new ParserException("TODO"); // TODO
case '@':
scanVariable();
return;
@@ -557,7 +557,7 @@ public class Lexer {
token = Token.TILDE;
break;
default:
throw new SQLParseException("TODO");
throw new ParserException("TODO");
}
}
@@ -641,7 +641,7 @@ public class Lexer {
public void scanVariable() {
if (ch != '@' && ch != ':' && ch != '#' && ch != '$') {
throw new SQLParseException("illegal variable");
throw new ParserException("illegal variable");
}
mark = pos;
@@ -672,7 +672,7 @@ public class Lexer {
if (mybatisFlag) {
if (ch != '}') {
throw new SQLParseException("syntax error");
throw new ParserException("syntax error");
}
++pos;
bufPos++;
@@ -754,7 +754,7 @@ public class Lexer {
final boolean firstFlag = isFirstIdentifierChar(first);
if (!firstFlag) {
throw new SQLParseException("illegal identifier");
throw new ParserException("illegal identifier");
}
mark = pos;
@@ -706,12 +706,12 @@ public class SQLExprParser extends SQLParser {
exprList(aggregateExpr.getArguments());
accept(Token.RPAREN);
if (lexer.token() == Token.OVER) {
lexer.nextToken();
SQLOver over = new SQLOver();
accept(Token.LPAREN);
if (identifierEquals("PARTITION")) {
lexer.nextToken();
accept(Token.BY);
@@ -725,13 +725,12 @@ public class SQLExprParser extends SQLParser {
}
}
over.setOrderBy(parseOrderBy());
// if (over.getOrderBy() != null) {
// //TODO window
// }
accept(Token.RPAREN);
aggregateExpr.setOver(over);
@@ -1133,16 +1132,16 @@ public class SQLExprParser extends SQLParser {
SQLName typeExpr = name();
String typeName = typeExpr.toString();
if (isCharType(typeName)) {
SQLCharactorDataType charType = new SQLCharactorDataType(typeName);
if (lexer.token() == Token.LPAREN) {
lexer.nextToken();
charType.getArguments().add(this.expr());
accept(Token.RPAREN);
}
return parseCharTypeRest(charType);
}
@@ -1205,8 +1204,8 @@ public class SQLExprParser extends SQLParser {
if (lexer.token() == token) {
lexer.nextToken();
} else {
throw new SQLParseException("syntax error, expect " + token + ", actual " + lexer.token() + " "
+ lexer.stringVal());
throw new ParserException("syntax error, expect " + token + ", actual " + lexer.token() + " "
+ lexer.stringVal());
}
}
@@ -1237,19 +1236,19 @@ public class SQLExprParser extends SQLParser {
column.setDefaultExpr(new SQLNullExpr());
return parseColumnRest(column);
}
if (lexer.token == Token.PRIMARY) {
lexer.nextToken();
accept(Token.KEY);
column.getConstaints().add(new SQLColumnPrimaryKey());
return parseColumnRest(column);
return parseColumnRest(column);
}
if (lexer.token == Token.UNION) {
lexer.nextToken();
accept(Token.KEY);
column.getConstaints().add(new SQLColumnPrimaryKey());
return parseColumnRest(column);
return parseColumnRest(column);
}
return column;
@@ -20,6 +20,7 @@ import com.alibaba.druid.DruidRuntimeException;
/**
* @author wenshao<szujobs@hotmail.com>
*/
@Deprecated
public class SQLParseException extends DruidRuntimeException {
private static final long serialVersionUID = 1L;
@@ -41,7 +41,7 @@ public class SQLParser {
lexer.nextToken();
} else {
setErrorEndPos(lexer.pos());
throw new SQLParseException("syntax error, expect " + text + ", actual " + lexer.token());
throw new ParserException("syntax error, expect " + text + ", actual " + lexer.token());
}
}
@@ -124,14 +124,14 @@ public class SQLParser {
lexer.nextToken();
} else {
setErrorEndPos(lexer.pos());
throw new SQLParseException("syntax error, expect " + token + ", actual " + lexer.token() + " "
throw new ParserException("syntax error, expect " + token + ", actual " + lexer.token() + " "
+ lexer.stringVal() + ", pos " + this.lexer.pos());
}
}
public void match(Token token) {
if (lexer.token() != token) {
throw new SQLParseException("syntax error, expect " + token + ", actual " + lexer.token() + " "
throw new ParserException("syntax error, expect " + token + ", actual " + lexer.token() + " "
+ lexer.stringVal());
}
}
@@ -416,7 +416,7 @@ public class SQLSelectParser extends SQLParser {
lexer.nextToken();
} else {
setErrorEndPos(lexer.pos());
throw new SQLParseException("syntax error, expect " + ident + ", actual " + lexer.token());
throw new ParserException("syntax error, expect " + ident + ", actual " + lexer.token());
}
}