improved sql parser.

This commit is contained in:
wenshao
2017-08-31 11:20:04 +08:00
parent ce2daf6b9a
commit 947059f715
36 changed files with 1291 additions and 670 deletions
@@ -49,7 +49,7 @@ import com.alibaba.druid.util.StringUtils;
*/
public class Lexer {
protected int features = 0; //SQLParserFeature.of(SQLParserFeature.EnableSQLBinaryOpExprGroup);
protected int features = 0; //SQLParserFeature.of(SQLParserFeature.EnableSQLBinaryOpExprGroup);
protected final String text;
protected int pos;
protected int mark;
@@ -61,41 +61,36 @@ public class Lexer {
protected Token token;
protected Keywords keywods = Keywords.DEFAULT_KEYWORDS;
protected Keywords keywods = Keywords.DEFAULT_KEYWORDS;
protected String stringVal;
protected long hash_lower; // fnv1a_64
protected long hash;
protected long hash;
protected int commentCount = 0;
protected int commentCount = 0;
protected List<String> comments = new ArrayList<String>(2);
protected List<String> comments = new ArrayList<String>(2);
protected boolean skipComment = true;
protected boolean skipComment = true;
private SavePoint savePoint = null;
private SavePoint savePoint = null;
/*
* anti sql injection
*/
private boolean allowComment = true;
private int varIndex = -1;
protected CommentHandler commentHandler;
protected boolean endOfComment = false;
protected boolean keepComments = false;
protected int line = 0;
protected int lines = 0;
protected String dbType;
protected boolean hasSpecial = false;
private int startPos;
private int posLine;
private int posColumn;
@@ -45,7 +45,7 @@ import com.alibaba.druid.sql.ast.statement.SQLSelectOrderByItem;
import com.alibaba.druid.sql.ast.statement.SQLUnique;
import com.alibaba.druid.sql.ast.statement.SQLUpdateSetItem;
import com.alibaba.druid.util.FnvHash;
import com.alibaba.druid.util.FnvConstants;
import com.alibaba.druid.util.FnvHash.Constants;
import com.alibaba.druid.util.JdbcConstants;
public class SQLExprParser extends SQLParser {
@@ -237,7 +237,7 @@ public class SQLExprParser extends SQLParser {
SQLExpr rightExp = bitXor();
expr = new SQLBinaryOpExpr(expr, SQLBinaryOperator.DIV, rightExp, getDbType());
expr = multiplicativeRest(expr);
} else if (lexer.identifierEquals(FnvConstants.MOD)) {
} else if (lexer.identifierEquals(FnvHash.Constants.MOD)) {
lexer.nextToken();
SQLExpr rightExp = primary();
@@ -788,7 +788,7 @@ public class SQLExprParser extends SQLParser {
if (token == Token.OF) {
if (expr instanceof SQLIdentifierExpr) {
long hashCode64 = ((SQLIdentifierExpr) expr).hashCode64();
if (hashCode64 == FnvConstants.CURRENT) {
if (hashCode64 == FnvHash.Constants.CURRENT) {
lexer.nextToken();
SQLName cursorName = this.name();
return new SQLCurrentOfCursorExpr(cursorName);
@@ -797,17 +797,17 @@ public class SQLExprParser extends SQLParser {
} else if (token == Token.FOR) {
if (expr instanceof SQLIdentifierExpr) {
SQLIdentifierExpr idenExpr = (SQLIdentifierExpr) expr;
if (idenExpr.hashCode64() == FnvConstants.NEXTVAL) {
if (idenExpr.hashCode64() == FnvHash.Constants.NEXTVAL) {
lexer.nextToken();
SQLName seqName = this.name();
SQLSequenceExpr seqExpr = new SQLSequenceExpr(seqName, SQLSequenceExpr.Function.NextVal);
return seqExpr;
} else if (idenExpr.hashCode64() == FnvConstants.CURRVAL) {
} else if (idenExpr.hashCode64() == FnvHash.Constants.CURRVAL) {
lexer.nextToken();
SQLName seqName = this.name();
SQLSequenceExpr seqExpr = new SQLSequenceExpr(seqName, SQLSequenceExpr.Function.CurrVal);
return seqExpr;
} else if (idenExpr.hashCode64() == FnvConstants.PREVVAL) {
} else if (idenExpr.hashCode64() == FnvHash.Constants.PREVVAL) {
lexer.nextToken();
SQLName seqName = this.name();
SQLSequenceExpr seqExpr = new SQLSequenceExpr(seqName, SQLSequenceExpr.Function.PrevVal);
@@ -826,7 +826,7 @@ public class SQLExprParser extends SQLParser {
expr = dotRest(expr);
return primaryRest(expr);
} else if (lexer.identifierEquals(FnvConstants.SETS) //
} else if (lexer.identifierEquals(FnvHash.Constants.SETS) //
&& expr.getClass() == SQLIdentifierExpr.class //
&& "GROUPING".equalsIgnoreCase(((SQLIdentifierExpr) expr).getName())) {
SQLGroupingSetExpr groupingSets = new SQLGroupingSetExpr();
@@ -907,24 +907,24 @@ public class SQLExprParser extends SQLParser {
methodName = identifierExpr.getName();
hash_lower = identifierExpr.nameHashCode64();
if (hash_lower == FnvConstants.TRIM) {
if (lexer.identifierEquals(FnvConstants.LEADING)) {
if (hash_lower == FnvHash.Constants.TRIM) {
if (lexer.identifierEquals(FnvHash.Constants.LEADING)) {
trimOption = lexer.stringVal();
lexer.nextToken();
} else if (lexer.identifierEquals(FnvConstants.BOTH)) {
} else if (lexer.identifierEquals(FnvHash.Constants.BOTH)) {
trimOption = lexer.stringVal();
lexer.nextToken();
} else if (lexer.identifierEquals(FnvConstants.TRAILING)) {
} else if (lexer.identifierEquals(FnvHash.Constants.TRAILING)) {
trimOption = lexer.stringVal();
lexer.nextToken();
}
} else if (hash_lower == FnvConstants.MATCH
} else if (hash_lower == FnvHash.Constants.MATCH
&& JdbcConstants.MYSQL.equals(dbType)) {
return parseMatch();
} else if (hash_lower == FnvConstants.EXTRACT
} else if (hash_lower == FnvHash.Constants.EXTRACT
&& JdbcConstants.MYSQL.equals(dbType)) {
return parseExtract();
} else if (hash_lower == FnvConstants.POSITION
} else if (hash_lower == FnvHash.Constants.POSITION
&& JdbcConstants.MYSQL.equals(dbType)) {
return parsePosition();
}
@@ -977,7 +977,7 @@ public class SQLExprParser extends SQLParser {
}
}
if (lexer.token == Token.USING || lexer.identifierEquals(FnvConstants.USING)) {
if (lexer.token == Token.USING || lexer.identifierEquals(FnvHash.Constants.USING)) {
lexer.nextToken();
SQLExpr using = this.primary();
methodInvokeExpr.setUsing(using);
@@ -1252,7 +1252,7 @@ public class SQLExprParser extends SQLParser {
} else if (lexer.token == Token.DISTINCT) {
aggregateExpr = new SQLAggregateExpr(methodName, SQLAggregateOption.DISTINCT);
lexer.nextToken();
} else if (lexer.identifierEquals(FnvConstants.DEDUPLICATION)) { // just for nut
} else if (lexer.identifierEquals(FnvHash.Constants.DEDUPLICATION)) { // just for nut
aggregateExpr = new SQLAggregateExpr(methodName, SQLAggregateOption.DEDUPLICATION);
lexer.nextToken();
} else {
@@ -1300,10 +1300,10 @@ public class SQLExprParser extends SQLParser {
}
SQLOver.WindowingType windowingType = null;
if (lexer.identifierEquals(FnvConstants.ROWS)) {
if (lexer.identifierEquals(FnvHash.Constants.ROWS)) {
windowingType = SQLOver.WindowingType.ROWS;
} else if (lexer.identifierEquals(FnvConstants.RANGE)) {
} else if (lexer.identifierEquals(FnvHash.Constants.RANGE)) {
windowingType = SQLOver.WindowingType.RANGE;
}
@@ -1316,10 +1316,10 @@ public class SQLExprParser extends SQLParser {
SQLIntegerExpr rowsBegin = (SQLIntegerExpr) this.primary();
over.setWindowingBetweenBegin(rowsBegin);
if (lexer.identifierEquals(FnvConstants.PRECEDING)) {
if (lexer.identifierEquals(FnvHash.Constants.PRECEDING)) {
over.setWindowingBetweenBeginPreceding(true);
lexer.nextToken();
} else if (lexer.identifierEquals(FnvConstants.FOLLOWING)) {
} else if (lexer.identifierEquals(FnvHash.Constants.FOLLOWING)) {
over.setWindowingBetweenBeginFollowing(true);
lexer.nextToken();
}
@@ -1329,25 +1329,25 @@ public class SQLExprParser extends SQLParser {
SQLIntegerExpr betweenEnd = (SQLIntegerExpr) this.primary();
over.setWindowingBetweenEnd(betweenEnd);
if (lexer.identifierEquals(FnvConstants.PRECEDING)) {
if (lexer.identifierEquals(FnvHash.Constants.PRECEDING)) {
over.setWindowingBetweenEndPreceding(true);
lexer.nextToken();
} else if (lexer.identifierEquals(FnvConstants.FOLLOWING)) {
} else if (lexer.identifierEquals(FnvHash.Constants.FOLLOWING)) {
over.setWindowingBetweenEndFollowing(true);
lexer.nextToken();
}
} else {
if (lexer.identifierEquals(FnvConstants.CURRENT)) {
if (lexer.identifierEquals(FnvHash.Constants.CURRENT)) {
lexer.nextToken();
acceptIdentifier("ROW");
over.setWindowing(new SQLIdentifierExpr("CURRENT ROW"));
} else if (lexer.identifierEquals(FnvConstants.UNBOUNDED)) {
} else if (lexer.identifierEquals(FnvHash.Constants.UNBOUNDED)) {
lexer.nextToken();
over.setWindowing(new SQLIdentifierExpr("UNBOUNDED"));
if (lexer.identifierEquals(FnvConstants.PRECEDING)) {
if (lexer.identifierEquals(FnvHash.Constants.PRECEDING)) {
over.setWindowingPreceding(true);
lexer.nextToken();
} else if (lexer.identifierEquals("FOLLOWING")) {
@@ -1358,10 +1358,10 @@ public class SQLExprParser extends SQLParser {
SQLIntegerExpr rowsExpr = (SQLIntegerExpr) this.primary();
over.setWindowing(rowsExpr);
if (lexer.identifierEquals(FnvConstants.PRECEDING)) {
if (lexer.identifierEquals(FnvHash.Constants.PRECEDING)) {
over.setWindowingPreceding(true);
lexer.nextToken();
} else if (lexer.identifierEquals(FnvConstants.FOLLOWING)) {
} else if (lexer.identifierEquals(FnvHash.Constants.FOLLOWING)) {
over.setWindowingFollowing(true);
lexer.nextToken();
}
@@ -1383,7 +1383,7 @@ public class SQLExprParser extends SQLParser {
lexer.nextToken();
if (lexer.identifierEquals(FnvConstants.SIBLINGS)) {
if (lexer.identifierEquals(FnvHash.Constants.SIBLINGS)) {
lexer.nextToken();
orderBy.setSibings(true);
}
@@ -1423,12 +1423,12 @@ public class SQLExprParser extends SQLParser {
item.setType(SQLOrderingSpecification.DESC);
}
if (lexer.identifierEquals(FnvConstants.NULLS)) {
if (lexer.identifierEquals(FnvHash.Constants.NULLS)) {
lexer.nextToken();
if (lexer.identifierEquals(FnvConstants.FIRST)) {
if (lexer.identifierEquals(FnvHash.Constants.FIRST)) {
lexer.nextToken();
item.setNullsOrderType(SQLSelectOrderByItem.NullsOrderType.NullsFirst);
} else if (lexer.identifierEquals(FnvConstants.LAST)) {
} else if (lexer.identifierEquals(FnvHash.Constants.LAST)) {
lexer.nextToken();
item.setNullsOrderType(SQLSelectOrderByItem.NullsOrderType.NullsLast);
} else {
@@ -1842,7 +1842,7 @@ public class SQLExprParser extends SQLParser {
rightExp = primary();
expr = new SQLBinaryOpExpr(expr, SQLBinaryOperator.Escape, rightExp, getDbType());
}
} else if (lexer.identifierEquals(FnvConstants.RLIKE)) {
} else if (lexer.identifierEquals(FnvHash.Constants.RLIKE)) {
lexer.nextToken();
rightExp = equality();
@@ -1900,7 +1900,7 @@ public class SQLExprParser extends SQLParser {
expr = new SQLBinaryOpExpr(expr, op, rightExp, dbType);
} else if (token == Token.IN) {
expr = inRest(expr);
} else if (lexer.identifierEquals(FnvConstants.REGEXP)) {
} else if (lexer.identifierEquals(FnvHash.Constants.REGEXP)) {
lexer.nextToken();
rightExp = equality();
@@ -1909,7 +1909,7 @@ public class SQLExprParser extends SQLParser {
return new SQLBinaryOpExpr(expr, SQLBinaryOperator.RegExp, rightExp, JdbcConstants.MYSQL);
} else if (JdbcConstants.POSTGRESQL.equals(lexer.dbType)) {
if (lexer.identifierEquals(FnvConstants.SIMILAR)) {
if (lexer.identifierEquals(FnvHash.Constants.SIMILAR)) {
lexer.nextToken();
accept(Token.TO);
@@ -2010,7 +2010,7 @@ public class SQLExprParser extends SQLParser {
expr = new SQLBetweenExpr(expr, true, beginExpr, endExpr);
return expr;
} else if (lexer.identifierEquals(FnvConstants.RLIKE)) {
} else if (lexer.identifierEquals(FnvHash.Constants.RLIKE)) {
lexer.nextToken();
SQLExpr rightExp = primary();
@@ -2024,7 +2024,7 @@ public class SQLExprParser extends SQLParser {
rightExp = relationalRest(rightExp);
return new SQLBinaryOpExpr(expr, SQLBinaryOperator.NotILike, rightExp, getDbType());
} else if (lexer.identifierEquals(FnvConstants.REGEXP)) {
} else if (lexer.identifierEquals(FnvHash.Constants.REGEXP)) {
lexer.nextToken();
SQLExpr rightExp = primary();
@@ -2102,14 +2102,14 @@ public class SQLExprParser extends SQLParser {
accept(Token.RPAREN);
}
if (lexer.identifierEquals(FnvConstants.PRECISION)
&& dataType.nameHashCode64() == FnvConstants.DOUBLE) {
if (lexer.identifierEquals(FnvHash.Constants.PRECISION)
&& dataType.nameHashCode64() == FnvHash.Constants.DOUBLE) {
lexer.nextToken();
dataType.setName("DOUBLE PRECISION");
}
if (FnvConstants.TIMESTAMP == dataType.nameHashCode64()) {
if (lexer.identifierEquals(FnvConstants.WITHOUT)) {
if (FnvHash.Constants.TIMESTAMP == dataType.nameHashCode64()) {
if (lexer.identifierEquals(FnvHash.Constants.WITHOUT)) {
lexer.nextToken();
acceptIdentifier("TIME");
acceptIdentifier("ZONE");
@@ -2132,14 +2132,14 @@ public class SQLExprParser extends SQLParser {
protected boolean isCharType(long hash) {
return hash == FnvConstants.CHAR
|| hash == FnvConstants.VARCHAR
|| hash == FnvConstants.NCHAR
|| hash == FnvConstants.NVARCHAR
|| hash == FnvConstants.TINYTEXT
|| hash == FnvConstants.TEXT
|| hash == FnvConstants.MEDIUMTEXT
|| hash == FnvConstants.LONGTEXT
return hash == FnvHash.Constants.CHAR
|| hash == FnvHash.Constants.VARCHAR
|| hash == FnvHash.Constants.NCHAR
|| hash == FnvHash.Constants.NVARCHAR
|| hash == FnvHash.Constants.TINYTEXT
|| hash == FnvHash.Constants.TEXT
|| hash == FnvHash.Constants.MEDIUMTEXT
|| hash == FnvHash.Constants.LONGTEXT
;
}
@@ -2149,7 +2149,7 @@ public class SQLExprParser extends SQLParser {
lexer.nextToken();
}
if (lexer.identifierEquals(FnvConstants.CHARACTER)) {
if (lexer.identifierEquals(FnvHash.Constants.CHARACTER)) {
lexer.nextToken();
accept(Token.SET);
@@ -2166,7 +2166,7 @@ public class SQLExprParser extends SQLParser {
lexer.nextToken();
}
if (lexer.identifierEquals(FnvConstants.COLLATE)) {
if (lexer.identifierEquals(FnvHash.Constants.COLLATE)) {
lexer.nextToken();
if (lexer.token != Token.IDENTIFIER) {
@@ -2347,16 +2347,16 @@ public class SQLExprParser extends SQLParser {
} else if (lexer.token == Token.ENABLE) {
lexer.nextToken();
check.setEnable(true);
} else if (lexer.identifierEquals(FnvConstants.VALIDATE)) {
} else if (lexer.identifierEquals(FnvHash.Constants.VALIDATE)) {
lexer.nextToken();
check.setValidate(Boolean.TRUE);
} else if (lexer.identifierEquals(FnvConstants.NOVALIDATE)) {
} else if (lexer.identifierEquals(FnvHash.Constants.NOVALIDATE)) {
lexer.nextToken();
check.setValidate(Boolean.FALSE);
} else if (lexer.identifierEquals(FnvConstants.RELY)) {
} else if (lexer.identifierEquals(FnvHash.Constants.RELY)) {
lexer.nextToken();
check.setRely(Boolean.TRUE);
} else if (lexer.identifierEquals(FnvConstants.NORELY)) {
} else if (lexer.identifierEquals(FnvHash.Constants.NORELY)) {
lexer.nextToken();
check.setRely(Boolean.FALSE);
}
@@ -2389,16 +2389,16 @@ public class SQLExprParser extends SQLParser {
} else if (lexer.token == Token.ENABLE) {
lexer.nextToken();
unique.setEnable(true);
} else if (lexer.identifierEquals(FnvConstants.VALIDATE)) {
} else if (lexer.identifierEquals(FnvHash.Constants.VALIDATE)) {
lexer.nextToken();
unique.setValidate(Boolean.TRUE);
} else if (lexer.identifierEquals(FnvConstants.NOVALIDATE)) {
} else if (lexer.identifierEquals(FnvHash.Constants.NOVALIDATE)) {
lexer.nextToken();
unique.setValidate(Boolean.FALSE);
} else if (lexer.identifierEquals(FnvConstants.RELY)) {
} else if (lexer.identifierEquals(FnvHash.Constants.RELY)) {
lexer.nextToken();
unique.setRely(Boolean.TRUE);
} else if (lexer.identifierEquals(FnvConstants.NORELY)) {
} else if (lexer.identifierEquals(FnvHash.Constants.NORELY)) {
lexer.nextToken();
unique.setRely(Boolean.FALSE);
}
@@ -2417,7 +2417,7 @@ public class SQLExprParser extends SQLParser {
item.setTarget(var);
if (lexer.token == Token.COLONEQ) {
lexer.nextToken();
} else if (lexer.token == Token.TRUE || lexer.identifierEquals(FnvConstants.TRUE)) {
} else if (lexer.token == Token.TRUE || lexer.identifierEquals(FnvHash.Constants.TRUE)) {
lexer.nextToken();
item.setValue(new SQLBooleanExpr(true));
return item;
@@ -2531,7 +2531,7 @@ public class SQLExprParser extends SQLParser {
if (lexer.token == Token.ON) {
lexer.nextToken();
accept(Token.DELETE);
if (lexer.identifierEquals(FnvConstants.CASCADE)) {
if (lexer.identifierEquals(FnvHash.Constants.CASCADE)) {
lexer.nextToken();
fk.setOnDeleteCascade(true);
} else {
@@ -2557,11 +2557,11 @@ public class SQLExprParser extends SQLParser {
long hash_lower = lexer.hash_lower();
lexer.nextTokenComma();
if (hash_lower == FnvConstants.CONNECT_BY_ROOT) {
if (hash_lower == FnvHash.Constants.CONNECT_BY_ROOT) {
connectByRoot = true;
expr = new SQLIdentifierExpr(lexer.stringVal());
lexer.nextToken();
} else if (FnvConstants.DATE == hash_lower
} else if (FnvHash.Constants.DATE == hash_lower
&& lexer.token == Token.LITERAL_CHARS
&& (JdbcConstants.ORACLE.equals(getDbType())
|| JdbcConstants.POSTGRESQL.equals(getDbType()))) {
@@ -2594,7 +2594,7 @@ public class SQLExprParser extends SQLParser {
return new SQLSelectItem(expr, as, connectByRoot);
}
if (token == Token.IDENTIFIER && hash_lower != FnvConstants.CURRENT) {
if (token == Token.IDENTIFIER && hash_lower != FnvHash.Constants.CURRENT) {
String as = lexer.stringVal();
lexer.nextTokenComma();
return new SQLSelectItem(expr, as, connectByRoot);
@@ -2638,7 +2638,7 @@ public class SQLExprParser extends SQLParser {
SQLGroupingSetExpr expr = new SQLGroupingSetExpr();
if (lexer.token == Token.SET || lexer.identifierEquals(FnvConstants.SET)) {
if (lexer.token == Token.SET || lexer.identifierEquals(FnvHash.Constants.SET)) {
lexer.nextToken();
} else {
return new SQLIdentifierExpr(tmp);
@@ -2668,13 +2668,13 @@ public class SQLExprParser extends SQLParser {
accept(Token.LPAREN);
this.exprList(values.getItems(), values);
accept(Token.RPAREN);
} else if (lexer.identifierEquals(FnvConstants.LESS)) {
} else if (lexer.identifierEquals(FnvHash.Constants.LESS)) {
lexer.nextToken();
acceptIdentifier("THAN");
values = new SQLPartitionValue(SQLPartitionValue.Operator.LessThan);
if (lexer.identifierEquals(FnvConstants.MAXVALUE)) {
if (lexer.identifierEquals(FnvHash.Constants.MAXVALUE)) {
SQLIdentifierExpr maxValue = new SQLIdentifierExpr(lexer.stringVal());
lexer.nextToken();
maxValue.setParent(values);
@@ -2713,7 +2713,7 @@ public class SQLExprParser extends SQLParser {
limit.setOffset(temp);
lexer.nextToken();
limit.setRowCount(this.expr());
} else if (lexer.identifierEquals(FnvConstants.OFFSET)) {
} else if (lexer.identifierEquals(FnvHash.Constants.OFFSET)) {
limit.setRowCount(temp);
lexer.nextToken();
limit.setOffset(this.expr());
@@ -20,7 +20,7 @@ import java.util.List;
import com.alibaba.druid.sql.ast.*;
import com.alibaba.druid.sql.ast.statement.*;
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlOrderingExpr;
import com.alibaba.druid.util.FnvConstants;
import com.alibaba.druid.util.FnvHash;
import com.alibaba.druid.util.JdbcConstants;
public class SQLSelectParser extends SQLParser {
@@ -42,7 +42,7 @@ public class SQLSelectParser extends SQLParser {
public SQLSelect select() {
SQLSelect select = new SQLSelect();
if (lexer.token() == Token.WITH) {
if (lexer.token == Token.WITH) {
SQLWithSubqueryClause with = this.parseWith();
select.setWithSubQuery(with);
}
@@ -176,13 +176,13 @@ public class SQLSelectParser extends SQLParser {
}
if (JdbcConstants.INFORMIX.equals(dbType)) {
if (lexer.identifierEquals(FnvConstants.SKIP)) {
if (lexer.identifierEquals(FnvHash.Constants.SKIP)) {
lexer.nextToken();
SQLExpr offset = this.exprParser.primary();
queryBlock.setOffset(offset);
}
if (lexer.identifierEquals(FnvConstants.FIRST)) {
if (lexer.identifierEquals(FnvHash.Constants.FIRST)) {
lexer.nextToken();
SQLExpr first = this.exprParser.primary();
queryBlock.setFirst(first);
@@ -219,7 +219,7 @@ public class SQLSelectParser extends SQLParser {
SQLWithSubqueryClause withQueryClause = new SQLWithSubqueryClause();
if (lexer.token == Token.RECURSIVE || lexer.identifierEquals(FnvConstants.RECURSIVE)) {
if (lexer.token == Token.RECURSIVE || lexer.identifierEquals(FnvHash.Constants.RECURSIVE)) {
lexer.nextToken();
withQueryClause.setRecursive(true);
}
@@ -262,7 +262,7 @@ public class SQLSelectParser extends SQLParser {
SQLWithSubqueryClause withQueryClause = new SQLWithSubqueryClause();
if (lexer.token == Token.RECURSIVE || lexer.identifierEquals(FnvConstants.RECURSIVE)) {
if (lexer.token == Token.RECURSIVE || lexer.identifierEquals(FnvHash.Constants.RECURSIVE)) {
lexer.nextToken();
withQueryClause.setRecursive(true);
}
@@ -337,12 +337,12 @@ public class SQLSelectParser extends SQLParser {
accept(Token.BY);
SQLSelectGroupByClause groupBy = new SQLSelectGroupByClause();
if (lexer.identifierEquals(FnvConstants.ROLLUP)) {
if (lexer.identifierEquals(FnvHash.Constants.ROLLUP)) {
lexer.nextToken();
accept(Token.LPAREN);
groupBy.setWithRollUp(true);
}
if (lexer.identifierEquals(FnvConstants.CUBE)) {
if (lexer.identifierEquals(FnvHash.Constants.CUBE)) {
lexer.nextToken();
accept(Token.LPAREN);
groupBy.setWithCube(true);
@@ -374,7 +374,7 @@ public class SQLSelectParser extends SQLParser {
if (lexer.token == Token.WITH) {
lexer.nextToken();
if (lexer.identifierEquals(FnvConstants.CUBE)) {
if (lexer.identifierEquals(FnvHash.Constants.CUBE)) {
lexer.nextToken();
groupBy.setWithCube(true);
} else {
@@ -524,8 +524,8 @@ public class SQLSelectParser extends SQLParser {
protected SQLTableSource parseTableSourceRest(SQLTableSource tableSource) {
if ((tableSource.getAlias() == null) || (tableSource.getAlias().length() == 0)) {
if (lexer.token != Token.LEFT && lexer.token != Token.RIGHT && lexer.token != Token.FULL
&& (!lexer.identifierEquals(FnvConstants.STRAIGHT_JOIN))
&& (!lexer.identifierEquals(FnvConstants.CROSS))
&& (!lexer.identifierEquals(FnvHash.Constants.STRAIGHT_JOIN))
&& (!lexer.identifierEquals(FnvHash.Constants.CROSS))
&& lexer.token != Token.OUTER) {
String alias = tableAlias();
if (alias != null) {
@@ -537,7 +537,7 @@ public class SQLSelectParser extends SQLParser {
SQLJoinTableSource.JoinType joinType = null;
boolean natural = lexer.identifierEquals(FnvConstants.NATURAL) && JdbcConstants.MYSQL.equals(dbType);
boolean natural = lexer.identifierEquals(FnvHash.Constants.NATURAL) && JdbcConstants.MYSQL.equals(dbType);
if (natural) {
lexer.nextToken();
}
@@ -545,10 +545,10 @@ public class SQLSelectParser extends SQLParser {
if (lexer.token == Token.LEFT) {
lexer.nextToken();
if (lexer.identifierEquals(FnvConstants.SEMI)) {
if (lexer.identifierEquals(FnvHash.Constants.SEMI)) {
lexer.nextToken();
joinType = SQLJoinTableSource.JoinType.LEFT_SEMI_JOIN;
} else if (lexer.identifierEquals(FnvConstants.ANTI)) {
} else if (lexer.identifierEquals(FnvHash.Constants.ANTI)) {
lexer.nextToken();
joinType = SQLJoinTableSource.JoinType.LEFT_ANTI_JOIN;
} else if (lexer.token == Token.OUTER) {
@@ -584,21 +584,21 @@ public class SQLSelectParser extends SQLParser {
} else if (lexer.token == Token.COMMA) {
lexer.nextToken();
joinType = SQLJoinTableSource.JoinType.COMMA;
} else if (lexer.identifierEquals(FnvConstants.STRAIGHT_JOIN)) {
} else if (lexer.identifierEquals(FnvHash.Constants.STRAIGHT_JOIN)) {
lexer.nextToken();
joinType = SQLJoinTableSource.JoinType.STRAIGHT_JOIN;
} else if (lexer.identifierEquals(FnvConstants.CROSS)) {
} else if (lexer.identifierEquals(FnvHash.Constants.CROSS)) {
lexer.nextToken();
if (lexer.token == Token.JOIN) {
lexer.nextToken();
joinType = SQLJoinTableSource.JoinType.CROSS_JOIN;
} else if (lexer.identifierEquals(FnvConstants.APPLY)) {
} else if (lexer.identifierEquals(FnvHash.Constants.APPLY)) {
lexer.nextToken();
joinType = SQLJoinTableSource.JoinType.CROSS_APPLY;
}
} else if (lexer.token == Token.OUTER) {
lexer.nextToken();
if (lexer.identifierEquals(FnvConstants.APPLY)) {
if (lexer.identifierEquals(FnvHash.Constants.APPLY)) {
lexer.nextToken();
joinType = SQLJoinTableSource.JoinType.OUTER_APPLY;
}
@@ -622,7 +622,7 @@ public class SQLSelectParser extends SQLParser {
}
if (lexer.token == Token.USING
||lexer.identifierEquals(FnvConstants.USING))
||lexer.identifierEquals(FnvHash.Constants.USING))
{
Lexer.SavePoint savePoint = lexer.mark();
lexer.nextToken();
@@ -664,7 +664,7 @@ public class SQLSelectParser extends SQLParser {
join.setRight(rightTableSource);
if (!natural) {
if (tableSource.aliasHashCode64() == FnvConstants.NATURAL && JdbcConstants.MYSQL.equals(dbType)) {
if (tableSource.aliasHashCode64() == FnvHash.Constants.NATURAL && JdbcConstants.MYSQL.equals(dbType)) {
tableSource.setAlias(null);
natural = true;
}
@@ -675,7 +675,7 @@ public class SQLSelectParser extends SQLParser {
lexer.nextToken();
join.setCondition(expr());
} else if (lexer.token == Token.USING
|| lexer.identifierEquals(FnvConstants.USING)) {
|| lexer.identifierEquals(FnvHash.Constants.USING)) {
Lexer.SavePoint savePoint = lexer.mark();
lexer.nextToken();
if (lexer.token == Token.LPAREN) {
@@ -717,11 +717,11 @@ public class SQLSelectParser extends SQLParser {
return;
}
if (lexer.identifierEquals(FnvConstants.OFFSET) || lexer.token == Token.OFFSET) {
if (lexer.identifierEquals(FnvHash.Constants.OFFSET) || lexer.token == Token.OFFSET) {
lexer.nextToken();
SQLExpr offset = this.exprParser.primary();
queryBlock.setOffset(offset);
if (lexer.identifierEquals(FnvConstants.ROW) || lexer.identifierEquals(FnvConstants.ROWS)) {
if (lexer.identifierEquals(FnvHash.Constants.ROW) || lexer.identifierEquals(FnvHash.Constants.ROWS)) {
lexer.nextToken();
}
}
@@ -729,14 +729,14 @@ public class SQLSelectParser extends SQLParser {
if (lexer.token == Token.FETCH) {
lexer.nextToken();
if (lexer.token == Token.FIRST
|| lexer.identifierEquals(FnvConstants.NEXT)) {
|| lexer.identifierEquals(FnvHash.Constants.NEXT)) {
lexer.nextToken();
} else {
acceptIdentifier("FIRST");
}
SQLExpr first = this.exprParser.primary();
queryBlock.setFirst(first);
if (lexer.identifierEquals(FnvConstants.ROW) || lexer.identifierEquals(FnvConstants.ROWS)) {
if (lexer.identifierEquals(FnvHash.Constants.ROW) || lexer.identifierEquals(FnvHash.Constants.ROWS)) {
lexer.nextToken();
}
@@ -749,16 +749,16 @@ public class SQLSelectParser extends SQLParser {
}
protected void parseHierachical(SQLSelectQueryBlock queryBlock) {
if (lexer.token == Token.CONNECT || lexer.identifierEquals(FnvConstants.CONNECT)) {
if (lexer.token == Token.CONNECT || lexer.identifierEquals(FnvHash.Constants.CONNECT)) {
lexer.nextToken();
accept(Token.BY);
if (lexer.token == Token.PRIOR || lexer.identifierEquals(FnvConstants.PRIOR)) {
if (lexer.token == Token.PRIOR || lexer.identifierEquals(FnvHash.Constants.PRIOR)) {
lexer.nextToken();
queryBlock.setPrior(true);
}
if (lexer.identifierEquals(FnvConstants.NOCYCLE)) {
if (lexer.identifierEquals(FnvHash.Constants.NOCYCLE)) {
queryBlock.setNoCycle(true);
lexer.nextToken();
@@ -770,27 +770,27 @@ public class SQLSelectParser extends SQLParser {
queryBlock.setConnectBy(this.exprParser.expr());
}
if (lexer.token == Token.START || lexer.identifierEquals(FnvConstants.START)) {
if (lexer.token == Token.START || lexer.identifierEquals(FnvHash.Constants.START)) {
lexer.nextToken();
accept(Token.WITH);
queryBlock.setStartWith(this.exprParser.expr());
}
if (lexer.token == Token.CONNECT || lexer.identifierEquals(FnvConstants.CONNECT)) {
if (lexer.token == Token.CONNECT || lexer.identifierEquals(FnvHash.Constants.CONNECT)) {
lexer.nextToken();
accept(Token.BY);
if (lexer.token == Token.PRIOR || lexer.identifierEquals(FnvConstants.PRIOR)) {
if (lexer.token == Token.PRIOR || lexer.identifierEquals(FnvHash.Constants.PRIOR)) {
lexer.nextToken();
queryBlock.setPrior(true);
}
if (lexer.identifierEquals(FnvConstants.NOCYCLE)) {
if (lexer.identifierEquals(FnvHash.Constants.NOCYCLE)) {
queryBlock.setNoCycle(true);
lexer.nextToken();
if (lexer.token == Token.PRIOR || lexer.identifierEquals(FnvConstants.PRIOR)) {
if (lexer.token == Token.PRIOR || lexer.identifierEquals(FnvHash.Constants.PRIOR)) {
lexer.nextToken();
queryBlock.setPrior(true);
}
File diff suppressed because it is too large Load Diff