improved postgresql sql parser support. support SIMILAR TO Operator. issue #1391

This commit is contained in:
wenshao
2016-09-19 13:23:29 +08:00
parent eaeb1e3eac
commit 0a3fbb639b
4 changed files with 67 additions and 0 deletions
@@ -58,6 +58,7 @@ public enum SQLBinaryOperator {
ILike("ILIKE", 110),
NotILike("NOT ILIKE", 110),
AT_AT("@@", 110), // postgresql textsearch
SIMILAR_TO("SIMILAR TO", 110),
RLike("RLIKE", 110),
NotRLike("NOT RLIKE", 110),
@@ -226,6 +226,10 @@ public class Lexer {
return token;
}
public final String getDbType() {
return this.dbType;
}
public String info() {
return this.token + " " + this.stringVal();
}
@@ -1492,6 +1492,16 @@ public class SQLExprParser extends SQLParser {
}
} else if (lexer.token() == Token.IN) {
expr = inRest(expr);
} else if (JdbcConstants.POSTGRESQL.equals(lexer.dbType)
&& identifierEquals("SIMILAR")) {
lexer.nextToken();
accept(Token.TO);
rightExp = equality();
rightExp = relationalRest(rightExp);
expr = new SQLBinaryOpExpr(expr, SQLBinaryOperator.SIMILAR_TO, rightExp, getDbType());
}
return expr;