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
@@ -16,7 +16,6 @@
package com.alibaba.druid.sql.ast;
public interface SQLExpr extends SQLObject, Cloneable {
SQLExpr clone();
SQLExpr clone();
SQLDataType computeDataType();
}
@@ -21,37 +21,24 @@ import java.util.Map;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
public interface SQLObject {
void accept(SQLASTVisitor visitor);
SQLObject clone();
void accept(SQLASTVisitor visitor);
SQLObject getParent();
void setParent(SQLObject parent);
SQLObject getParent();
void setParent(SQLObject parent);
Map<String, Object> getAttributes();
Object getAttribute(String name);
void putAttribute(String name, Object value);
Object getAttribute(String name);
void putAttribute(String name, Object value);
Map<String, Object> getAttributesDirect();
void addBeforeComment(String comment);
void addBeforeComment(List<String> comments);
List<String> getBeforeCommentsDirect();
void addAfterComment(String comment);
void addAfterComment(List<String> comments);
List<String> getAfterCommentsDirect();
boolean hasBeforeComment();
boolean hasAfterComment();
void output(StringBuffer buf);
void output(StringBuffer buf);
SQLObject clone();
void addBeforeComment(String comment);
void addBeforeComment(List<String> comments);
List<String> getBeforeCommentsDirect();
void addAfterComment(String comment);
void addAfterComment(List<String> comments);
List<String> getAfterCommentsDirect();
boolean hasBeforeComment();
boolean hasAfterComment();
}
@@ -16,11 +16,8 @@
package com.alibaba.druid.sql.ast;
public interface SQLStatement extends SQLObject {
String getDbType();
boolean isAfterSemi();
void setAfterSemi(boolean afterSemi);
String getDbType();
boolean isAfterSemi();
void setAfterSemi(boolean afterSemi);
SQLStatement clone();
}
@@ -21,11 +21,8 @@ import com.alibaba.druid.sql.visitor.SQLASTVisitor;
import java.util.List;
public abstract class SQLStatementImpl extends SQLObjectImpl implements SQLStatement {
protected String dbType;
private boolean afterSemi;
protected String dbType;
protected boolean afterSemi;
protected List<SQLCommentHint> headHints;
public SQLStatementImpl(){
@@ -18,12 +18,9 @@ package com.alibaba.druid.sql.ast;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
public class SQLSubPartition extends SQLObjectImpl {
protected SQLName name;
protected SQLPartitionValue values;
private SQLName tableSpace;
protected SQLName tableSpace;
public SQLName getName() {
return name;
@@ -22,11 +22,9 @@ import com.alibaba.druid.sql.ast.statement.SQLAssignItem;
public abstract class SQLSubPartitionBy extends SQLObjectImpl {
protected SQLExpr subPartitionsCount;
protected boolean linear;
protected List<SQLAssignItem> options = new ArrayList<SQLAssignItem>();
protected SQLExpr subPartitionsCount;
protected boolean linear;
protected List<SQLAssignItem> options = new ArrayList<SQLAssignItem>();
protected List<SQLSubPartition> subPartitionTemplate = new ArrayList<SQLSubPartition>();
public SQLExpr getSubPartitionsCount() {
@@ -22,7 +22,7 @@ import java.util.List;
import com.alibaba.druid.sql.SQLUtils;
import com.alibaba.druid.sql.ast.*;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
import com.alibaba.druid.util.FnvConstants;
import com.alibaba.druid.util.FnvHash.Constants;
import com.alibaba.druid.util.FnvHash;
public class SQLAggregateExpr extends SQLExprImpl implements Serializable, SQLReplaceable {
@@ -220,8 +220,8 @@ public class SQLAggregateExpr extends SQLExprImpl implements Serializable, SQLRe
public SQLDataType computeDataType() {
long hash = methodNameHashCod64();
if (hash == FnvConstants.COUNT
|| hash == FnvConstants.ROW_NUMBER) {
if (hash == FnvHash.Constants.COUNT
|| hash == FnvHash.Constants.ROW_NUMBER) {
return SQLIntegerExpr.DEFAULT_DATA_TYPE;
}
@@ -232,8 +232,8 @@ public class SQLAggregateExpr extends SQLExprImpl implements Serializable, SQLRe
}
}
if (hash == FnvConstants.WM_CONAT
|| hash == FnvConstants.GROUP_CONCAT) {
if (hash == FnvHash.Constants.WM_CONAT
|| hash == FnvHash.Constants.GROUP_CONCAT) {
return SQLCharExpr.DEFAULT_DATA_TYPE;
}
@@ -109,6 +109,14 @@ public class SQLIdentifierExpr extends SQLExprImpl implements SQLName {
return x;
}
public SQLIdentifierExpr simplify() {
String normalized = SQLUtils.normalize(name);
if (normalized != name) {
return new SQLIdentifierExpr(name, hashCode64);
}
return this;
}
public String normalizedName() {
return SQLUtils.normalize(name);
}
@@ -18,6 +18,7 @@ package com.alibaba.druid.sql.ast.expr;
import com.alibaba.druid.sql.ast.SQLDataType;
import com.alibaba.druid.sql.ast.SQLDataTypeImpl;
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
import com.alibaba.druid.util.Utils;
import java.io.IOException;
import java.math.BigDecimal;
@@ -80,13 +81,12 @@ public class SQLNumberExpr extends SQLNumericLiteralExpr implements SQLValuableE
@Override
public int hashCode() {
if (chars != null && number == null) {
this.number = new BigDecimal(chars);
Number number = getNumber();
if (number == null) {
return 0;
}
final int prime = 31;
int result = 1;
result = prime * result + ((number == null) ? 0 : number.hashCode());
return result;
return number.hashCode();
}
@Override
@@ -104,19 +104,9 @@ public class SQLNumberExpr extends SQLNumericLiteralExpr implements SQLValuableE
if (getClass() != obj.getClass()) {
return false;
}
SQLNumberExpr other = (SQLNumberExpr) obj;
if (other.chars != null && other.number == null) {
other.number = new BigDecimal(other.chars);
}
if (number == null) {
if (other.number != null) {
return false;
}
} else if (!number.equals(other.number)) {
return false;
}
return true;
SQLNumberExpr other = (SQLNumberExpr) obj;
return Utils.equals(getNumber(), other.getNumber());
}
public SQLNumberExpr clone() {
@@ -94,6 +94,14 @@ public class SQLColumnDefinition extends SQLObjectImpl implements SQLTableElemen
return name;
}
public long nameHashCode64() {
if (name == null) {
return 0;
}
return name.hashCode64();
}
public String getNameAsString() {
if (name == null) {
return null;
@@ -379,8 +387,10 @@ public class SQLColumnDefinition extends SQLObjectImpl implements SQLTableElemen
if (this.name instanceof SQLIdentifierExpr) {
SQLIdentifierExpr identExpr = (SQLIdentifierExpr) this.name;
String columnName = identExpr.getName();
columnName = SQLUtils.normalize(columnName, dbType);
this.setName(columnName);
String normalized = SQLUtils.normalize(columnName, dbType);
if (normalized != columnName) {
this.setName(normalized);
}
}
}
@@ -110,8 +110,11 @@ public abstract class SQLConstraintImpl extends SQLObjectImpl implements SQLCons
if (this.name instanceof SQLIdentifierExpr) {
SQLIdentifierExpr identExpr = (SQLIdentifierExpr) this.name;
String columnName = identExpr.getName();
columnName = SQLUtils.normalize(columnName, dbType);
this.setName(columnName);
String normalized = SQLUtils.normalize(columnName, dbType);
if (columnName != normalized) {
this.setName(normalized);
}
}
}
}
@@ -573,15 +573,21 @@ public class SQLCreateTableStatement extends SQLStatementImpl implements SQLDDLS
if (name instanceof SQLPropertyExpr) {
String tableName = ((SQLPropertyExpr) name).getName();
tableName = SQLUtils.normalize(tableName);
setName(tableName);
name = getName();
String normalized = SQLUtils.normalize(tableName, dbType);
if (tableName != normalized) {
this.setName(normalized);
name = getName();
}
}
if (name instanceof SQLIdentifierExpr) {
SQLIdentifierExpr identExpr = (SQLIdentifierExpr) name;
String tableName = identExpr.getName();
tableName = SQLUtils.normalize(tableName, dbType);
setName(tableName);
String normalized = SQLUtils.normalize(tableName, dbType);
if (normalized != tableName) {
setName(normalized);
}
}
for (SQLTableElement element : this.tableElementList) {
@@ -97,8 +97,10 @@ public class SQLUnique extends SQLConstraintImpl implements SQLUniqueConstraint,
if (column instanceof SQLIdentifierExpr) {
SQLIdentifierExpr identExpr = (SQLIdentifierExpr) column;
String columnName = identExpr.getName();
columnName = SQLUtils.normalize(columnName, dbType);
item.setExpr(new SQLIdentifierExpr(columnName));
String normalized = SQLUtils.normalize(columnName, dbType);
if (normalized != columnName) {
item.setExpr(new SQLIdentifierExpr(columnName));
}
}
}
}
@@ -16,6 +16,7 @@
package com.alibaba.druid.sql.ast.statement;
import com.alibaba.druid.sql.ast.SQLExpr;
import com.alibaba.druid.sql.ast.SQLName;
import com.alibaba.druid.sql.ast.SQLObjectImpl;
import com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr;
import com.alibaba.druid.sql.ast.expr.SQLPropertyExpr;
@@ -70,4 +71,12 @@ public class SQLUpdateSetItem extends SQLObjectImpl {
}
return false;
}
public boolean columnMatch(long columnHash) {
if (this.column instanceof SQLName) {
return ((SQLName) this.column).nameHashCode64() == columnHash;
}
return false;
}
}
@@ -24,7 +24,6 @@ import com.alibaba.druid.sql.parser.SQLExprParser;
import com.alibaba.druid.sql.parser.SQLParserFeature;
import com.alibaba.druid.sql.parser.Token;
import com.alibaba.druid.util.FnvHash;
import com.alibaba.druid.util.FnvConstants;
import java.util.Arrays;
@@ -62,16 +61,16 @@ public class DB2ExprParser extends SQLExprParser {
}
public SQLExpr primaryRest(SQLExpr expr) {
if (lexer.identifierEquals(FnvConstants.VALUE)) {
if (lexer.identifierEquals(FnvHash.Constants.VALUE)) {
if (expr instanceof SQLIdentifierExpr) {
SQLIdentifierExpr identExpr = (SQLIdentifierExpr) expr;
if (identExpr.hashCode64() == FnvConstants.NEXT) {
if (identExpr.hashCode64() == FnvHash.Constants.NEXT) {
lexer.nextToken();
accept(Token.FOR);
SQLName seqName = this.name();
SQLSequenceExpr seqExpr = new SQLSequenceExpr(seqName, SQLSequenceExpr.Function.NextVal);
return seqExpr;
} else if (identExpr.hashCode64() == FnvConstants.PREVIOUS) {
} else if (identExpr.hashCode64() == FnvHash.Constants.PREVIOUS) {
lexer.nextToken();
accept(Token.FOR);
SQLName seqName = this.name();
@@ -79,19 +78,19 @@ public class DB2ExprParser extends SQLExprParser {
return seqExpr;
}
}
} else if (lexer.identifierEquals(FnvConstants.DATE)) {
} else if (lexer.identifierEquals(FnvHash.Constants.DATE)) {
if (expr instanceof SQLIdentifierExpr) {
SQLIdentifierExpr identExpr = (SQLIdentifierExpr) expr;
if (identExpr.hashCode64() == FnvConstants.CURRENT) {
if (identExpr.hashCode64() == FnvHash.Constants.CURRENT) {
lexer.nextToken();
expr = new SQLIdentifierExpr("CURRENT DATE");
}
}
} else if (lexer.identifierEquals(FnvConstants.TIMESTAMP)) {
} else if (lexer.identifierEquals(FnvHash.Constants.TIMESTAMP)) {
if (expr instanceof SQLIdentifierExpr) {
SQLIdentifierExpr identExpr = (SQLIdentifierExpr) expr;
if (identExpr.hashCode64() == FnvConstants.CURRENT) {
if (identExpr.hashCode64() == FnvHash.Constants.CURRENT) {
lexer.nextToken();
expr = new SQLIdentifierExpr("CURRENT DATE");
@@ -51,7 +51,6 @@ import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlOutFileExpr;
import com.alibaba.druid.sql.dialect.mysql.ast.expr.MySqlUserName;
import com.alibaba.druid.sql.parser.*;
import com.alibaba.druid.util.FnvHash;
import com.alibaba.druid.util.FnvConstants;
import com.alibaba.druid.util.JdbcConstants;
import java.util.Arrays;
@@ -102,7 +101,7 @@ public class MySqlExprParser extends SQLExprParser {
public SQLExpr primary() {
final Token tok = lexer.token();
if (lexer.identifierEquals(FnvConstants.OUTFILE)) {
if (lexer.identifierEquals(FnvHash.Constants.OUTFILE)) {
lexer.nextToken();
SQLExpr file = primary();
SQLExpr expr = new MySqlOutFileExpr(file);
@@ -175,7 +174,7 @@ public class MySqlExprParser extends SQLExprParser {
MySqlCharExpr mysqlCharExpr = new MySqlCharExpr(charValue);
mysqlCharExpr.setCharset(identExpr.getName());
if (lexer.identifierEquals(FnvConstants.COLLATE)) {
if (lexer.identifierEquals(FnvHash.Constants.COLLATE)) {
lexer.nextToken();
String collate = lexer.stringVal();
@@ -210,7 +209,7 @@ public class MySqlExprParser extends SQLExprParser {
return primaryRest(expr);
}
} else if (lexer.identifierEquals(FnvConstants.COLLATE)) {
} else if (lexer.identifierEquals(FnvHash.Constants.COLLATE)) {
lexer.nextToken();
if (lexer.token() == Token.EQ) {
@@ -232,7 +231,7 @@ public class MySqlExprParser extends SQLExprParser {
return primaryRest(expr);
} else if (expr instanceof SQLVariantRefExpr) {
if (lexer.identifierEquals(FnvConstants.COLLATE)) {
if (lexer.identifierEquals(FnvHash.Constants.COLLATE)) {
lexer.nextToken();
if (lexer.token() != Token.IDENTIFIER
@@ -341,7 +340,7 @@ public class MySqlExprParser extends SQLExprParser {
if (lexer.token() == Token.IN) {
lexer.nextToken();
if (lexer.identifierEquals(FnvConstants.NATURAL)) {
if (lexer.identifierEquals(FnvHash.Constants.NATURAL)) {
lexer.nextToken();
acceptIdentifier("LANGUAGE");
acceptIdentifier("MODE");
@@ -353,7 +352,7 @@ public class MySqlExprParser extends SQLExprParser {
} else {
matchAgainstExpr.setSearchModifier(SearchModifier.IN_NATURAL_LANGUAGE_MODE);
}
} else if (lexer.identifierEquals(FnvConstants.BOOLEAN)) {
} else if (lexer.identifierEquals(FnvHash.Constants.BOOLEAN)) {
lexer.nextToken();
acceptIdentifier("MODE");
matchAgainstExpr.setSearchModifier(SearchModifier.IN_BOOLEAN_MODE);
@@ -435,12 +434,12 @@ public class MySqlExprParser extends SQLExprParser {
SQLExpr expr = this.expr();
column.setOnUpdate(expr);
}
if (lexer.identifierEquals(FnvConstants.CHARSET)) {
if (lexer.identifierEquals(FnvHash.Constants.CHARSET)) {
lexer.nextToken();
MySqlCharExpr charSetCollateExpr=new MySqlCharExpr();
charSetCollateExpr.setCharset(lexer.stringVal());
lexer.nextToken();
if (lexer.identifierEquals(FnvConstants.COLLATE)) {
if (lexer.identifierEquals(FnvHash.Constants.COLLATE)) {
lexer.nextToken();
charSetCollateExpr.setCollate(lexer.stringVal());
lexer.nextToken();
@@ -448,14 +447,14 @@ public class MySqlExprParser extends SQLExprParser {
column.setCharsetExpr(charSetCollateExpr);
return parseColumnRest(column);
}
if (lexer.identifierEquals(FnvConstants.AUTO_INCREMENT)) {
if (lexer.identifierEquals(FnvHash.Constants.AUTO_INCREMENT)) {
lexer.nextToken();
column.setAutoIncrement(true);
return parseColumnRest(column);
}
if (lexer.identifierEquals(FnvConstants.PRECISION)
&& column.getDataType().nameHashCode64() ==FnvConstants.DOUBLE) {
if (lexer.identifierEquals(FnvHash.Constants.PRECISION)
&& column.getDataType().nameHashCode64() ==FnvHash.Constants.DOUBLE) {
lexer.nextToken();
}
@@ -463,7 +462,7 @@ public class MySqlExprParser extends SQLExprParser {
throw new ParserException("syntax error " + lexer.info());
}
if (lexer.identifierEquals(FnvConstants.STORAGE)) {
if (lexer.identifierEquals(FnvHash.Constants.STORAGE)) {
lexer.nextToken();
SQLExpr expr = expr();
column.setStorage(expr);
@@ -477,12 +476,12 @@ public class MySqlExprParser extends SQLExprParser {
accept(Token.RPAREN);
}
if (lexer.identifierEquals(FnvConstants.STORED)) {
if (lexer.identifierEquals(FnvHash.Constants.STORED)) {
lexer.nextToken();
column.setSorted(true);
}
if (lexer.identifierEquals(FnvConstants.VIRTUAL)) {
if (lexer.identifierEquals(FnvHash.Constants.VIRTUAL)) {
lexer.nextToken();
column.setVirtual(true);
}
@@ -495,12 +494,12 @@ public class MySqlExprParser extends SQLExprParser {
protected SQLDataType parseDataTypeRest(SQLDataType dataType) {
super.parseDataTypeRest(dataType);
if (lexer.identifierEquals(FnvConstants.UNSIGNED)) {
if (lexer.identifierEquals(FnvHash.Constants.UNSIGNED)) {
lexer.nextToken();
dataType.getAttributes().put("UNSIGNED", true);
}
if (lexer.identifierEquals(FnvConstants.ZEROFILL)) {
if (lexer.identifierEquals(FnvHash.Constants.ZEROFILL)) {
lexer.nextToken();
dataType.getAttributes().put("ZEROFILL", true);
}
@@ -520,11 +519,11 @@ public class MySqlExprParser extends SQLExprParser {
ident = identExpr.getName();
identHash = identExpr.hashCode64();
if (identHash == FnvConstants.GLOBAL) {
if (identHash == FnvHash.Constants.GLOBAL) {
ident = lexer.stringVal();
lexer.nextToken();
var = new SQLVariantRefExpr(ident, true);
} else if (identHash == FnvConstants.SESSION) {
} else if (identHash == FnvHash.Constants.SESSION) {
ident = lexer.stringVal();
lexer.nextToken();
var = new SQLVariantRefExpr(ident, false);
@@ -533,7 +532,7 @@ public class MySqlExprParser extends SQLExprParser {
}
}
if (identHash == FnvConstants.NAMES) {
if (identHash == FnvHash.Constants.NAMES) {
String charset = lexer.stringVal();
SQLExpr varExpr = null;
@@ -552,7 +551,7 @@ public class MySqlExprParser extends SQLExprParser {
accept(Token.LITERAL_CHARS);
}
if (lexer.identifierEquals(FnvConstants.COLLATE)) {
if (lexer.identifierEquals(FnvHash.Constants.COLLATE)) {
MySqlCharExpr charsetExpr = new MySqlCharExpr(charset);
lexer.nextToken();
@@ -574,7 +573,7 @@ public class MySqlExprParser extends SQLExprParser {
item.setTarget(var);
return item;
} else if (identHash == FnvConstants.CHARACTER) {
} else if (identHash == FnvHash.Constants.CHARACTER) {
var = new SQLIdentifierExpr("CHARACTER SET");
accept(Token.SET);
if (lexer.token() == Token.EQ) {
@@ -623,7 +622,7 @@ public class MySqlExprParser extends SQLExprParser {
MySqlPrimaryKey primaryKey = new MySqlPrimaryKey();
if (lexer.identifierEquals(FnvConstants.USING)) {
if (lexer.identifierEquals(FnvHash.Constants.USING)) {
lexer.nextToken();
primaryKey.setIndexType(lexer.stringVal());
lexer.nextToken();
@@ -667,7 +666,7 @@ public class MySqlExprParser extends SQLExprParser {
}
//5.5语法 USING BTREE 放在index 名字后
if (lexer.identifierEquals(FnvConstants.USING)) {
if (lexer.identifierEquals(FnvHash.Constants.USING)) {
lexer.nextToken();
unique.setIndexType(lexer.stringVal());
lexer.nextToken();
@@ -692,7 +691,7 @@ public class MySqlExprParser extends SQLExprParser {
}
accept(Token.RPAREN);
if (lexer.identifierEquals(FnvConstants.USING)) {
if (lexer.identifierEquals(FnvHash.Constants.USING)) {
lexer.nextToken();
unique.setIndexType(lexer.stringVal());
lexer.nextToken();
@@ -724,12 +723,12 @@ public class MySqlExprParser extends SQLExprParser {
this.names(fk.getReferencedColumns());
accept(Token.RPAREN);
if (lexer.identifierEquals(FnvConstants.MATCH)) {
if (lexer.identifierEquals(FnvHash.Constants.MATCH)) {
if (lexer.identifierEquals("FULL")) {
fk.setReferenceMatch(Match.FULL);
} else if (lexer.identifierEquals(FnvConstants.PARTIAL)) {
} else if (lexer.identifierEquals(FnvHash.Constants.PARTIAL)) {
fk.setReferenceMatch(Match.PARTIAL);
} else if (lexer.identifierEquals(FnvConstants.SIMPLE)) {
} else if (lexer.identifierEquals(FnvHash.Constants.SIMPLE)) {
fk.setReferenceMatch(Match.SIMPLE);
}
}
@@ -757,19 +756,19 @@ public class MySqlExprParser extends SQLExprParser {
protected Option parseReferenceOption() {
Option option;
if (lexer.token() == Token.RESTRICT || lexer.identifierEquals(FnvConstants.RESTRICT)) {
if (lexer.token() == Token.RESTRICT || lexer.identifierEquals(FnvHash.Constants.RESTRICT)) {
option = Option.RESTRICT;
lexer.nextToken();
} else if (lexer.identifierEquals(FnvConstants.CASCADE)) {
} else if (lexer.identifierEquals(FnvHash.Constants.CASCADE)) {
option = Option.CASCADE;
lexer.nextToken();
} else if (lexer.token() == Token.SET) {
lexer.nextToken();
accept(Token.NULL);
option = Option.SET_NULL;
} else if (lexer.token() == Token.ON || lexer.identifierEquals(FnvConstants.ON)) {
} else if (lexer.token() == Token.ON || lexer.identifierEquals(FnvHash.Constants.ON)) {
lexer.nextToken();
if (lexer.identifierEquals(FnvConstants.ACTION)) {
if (lexer.identifierEquals(FnvHash.Constants.ACTION)) {
option = Option.NO_ACTION;
lexer.nextToken();
} else {
@@ -789,7 +788,7 @@ public class MySqlExprParser extends SQLExprParser {
SQLOrderBy orderBy = this.parseOrderBy();
aggregateExpr.putAttribute("ORDER BY", orderBy);
}
if (lexer.identifierEquals(FnvConstants.SEPARATOR)) {
if (lexer.identifierEquals(FnvHash.Constants.SEPARATOR)) {
lexer.nextToken();
SQLExpr seperator = this.primary();
@@ -830,7 +829,7 @@ public class MySqlExprParser extends SQLExprParser {
for (;;) {
boolean storage = false;
if (lexer.identifierEquals(FnvConstants.DATA)) {
if (lexer.identifierEquals(FnvHash.Constants.DATA)) {
lexer.nextToken();
acceptIdentifier("DIRECTORY");
if (lexer.token() == Token.EQ) {
@@ -851,22 +850,22 @@ public class MySqlExprParser extends SQLExprParser {
lexer.nextToken();
}
partitionDef.setIndexDirectory(this.expr());
} else if (lexer.identifierEquals(FnvConstants.MAX_ROWS)) {
} else if (lexer.identifierEquals(FnvHash.Constants.MAX_ROWS)) {
lexer.nextToken();
if (lexer.token() == Token.EQ) {
lexer.nextToken();
}
SQLExpr maxRows = this.primary();
partitionDef.setMaxRows(maxRows);
} else if (lexer.identifierEquals(FnvConstants.MIN_ROWS)) {
} else if (lexer.identifierEquals(FnvHash.Constants.MIN_ROWS)) {
lexer.nextToken();
if (lexer.token() == Token.EQ) {
lexer.nextToken();
}
SQLExpr minRows = this.primary();
partitionDef.setMaxRows(minRows);
} else if (lexer.identifierEquals(FnvConstants.ENGINE) || //
(storage = (lexer.token() == Token.STORAGE || lexer.identifierEquals(FnvConstants.STORAGE)))) {
} else if (lexer.identifierEquals(FnvHash.Constants.ENGINE) || //
(storage = (lexer.token() == Token.STORAGE || lexer.identifierEquals(FnvHash.Constants.STORAGE)))) {
if (storage) {
lexer.nextToken();
}
@@ -35,7 +35,7 @@ import com.alibaba.druid.sql.parser.ParserException;
import com.alibaba.druid.sql.parser.SQLExprParser;
import com.alibaba.druid.sql.parser.SQLSelectParser;
import com.alibaba.druid.sql.parser.Token;
import com.alibaba.druid.util.FnvConstants;
import com.alibaba.druid.util.FnvHash;
import java.util.List;
@@ -104,7 +104,7 @@ public class MySqlSelectParser extends SQLSelectParser {
if (token == (Token.DISTINCT)) {
queryBlock.setDistionOption(SQLSetQuantifier.DISTINCT);
lexer.nextToken();
} else if (lexer.identifierEquals(FnvConstants.DISTINCTROW)) {
} else if (lexer.identifierEquals(FnvHash.Constants.DISTINCTROW)) {
queryBlock.setDistionOption(SQLSetQuantifier.DISTINCTROW);
lexer.nextToken();
} else if (token == (Token.ALL)) {
@@ -112,42 +112,42 @@ public class MySqlSelectParser extends SQLSelectParser {
lexer.nextToken();
}
if (lexer.identifierEquals(FnvConstants.HIGH_PRIORITY)) {
if (lexer.identifierEquals(FnvHash.Constants.HIGH_PRIORITY)) {
queryBlock.setHignPriority(true);
lexer.nextToken();
}
if (lexer.identifierEquals(FnvConstants.STRAIGHT_JOIN)) {
if (lexer.identifierEquals(FnvHash.Constants.STRAIGHT_JOIN)) {
queryBlock.setStraightJoin(true);
lexer.nextToken();
}
if (lexer.identifierEquals(FnvConstants.SQL_SMALL_RESULT)) {
if (lexer.identifierEquals(FnvHash.Constants.SQL_SMALL_RESULT)) {
queryBlock.setSmallResult(true);
lexer.nextToken();
}
if (lexer.identifierEquals(FnvConstants.SQL_BIG_RESULT)) {
if (lexer.identifierEquals(FnvHash.Constants.SQL_BIG_RESULT)) {
queryBlock.setBigResult(true);
lexer.nextToken();
}
if (lexer.identifierEquals(FnvConstants.SQL_BUFFER_RESULT)) {
if (lexer.identifierEquals(FnvHash.Constants.SQL_BUFFER_RESULT)) {
queryBlock.setBufferResult(true);
lexer.nextToken();
}
if (lexer.identifierEquals(FnvConstants.SQL_CACHE)) {
if (lexer.identifierEquals(FnvHash.Constants.SQL_CACHE)) {
queryBlock.setCache(true);
lexer.nextToken();
}
if (lexer.identifierEquals(FnvConstants.SQL_NO_CACHE)) {
if (lexer.identifierEquals(FnvHash.Constants.SQL_NO_CACHE)) {
queryBlock.setCache(false);
lexer.nextToken();
}
if (lexer.identifierEquals(FnvConstants.SQL_CALC_FOUND_ROWS)) {
if (lexer.identifierEquals(FnvHash.Constants.SQL_CALC_FOUND_ROWS)) {
queryBlock.setCalcFoundRows(true);
lexer.nextToken();
}
@@ -184,10 +184,10 @@ public class MySqlSelectParser extends SQLSelectParser {
queryBlock.setForUpdate(true);
if (lexer.identifierEquals(FnvConstants.NO_WAIT) || lexer.identifierEquals(FnvConstants.NOWAIT)) {
if (lexer.identifierEquals(FnvHash.Constants.NO_WAIT) || lexer.identifierEquals(FnvHash.Constants.NOWAIT)) {
lexer.nextToken();
queryBlock.setNoWait(true);
} else if (lexer.identifierEquals(FnvConstants.WAIT)) {
} else if (lexer.identifierEquals(FnvHash.Constants.WAIT)) {
lexer.nextToken();
SQLExpr waitTime = this.exprParser.primary();
queryBlock.setWaitTime(waitTime);
@@ -259,32 +259,32 @@ public class MySqlSelectParser extends SQLSelectParser {
lexer.nextToken();
if (lexer.identifierEquals(FnvConstants.LOW_PRIORITY)) {
if (lexer.identifierEquals(FnvHash.Constants.LOW_PRIORITY)) {
lexer.nextToken();
update.setLowPriority(true);
}
if (lexer.identifierEquals(FnvConstants.IGNORE)) {
if (lexer.identifierEquals(FnvHash.Constants.IGNORE)) {
lexer.nextToken();
update.setIgnore(true);
}
if (lexer.identifierEquals(FnvConstants.COMMIT_ON_SUCCESS)) {
if (lexer.identifierEquals(FnvHash.Constants.COMMIT_ON_SUCCESS)) {
lexer.nextToken();
update.setCommitOnSuccess(true);
}
if (lexer.identifierEquals(FnvConstants.ROLLBACK_ON_FAIL)) {
if (lexer.identifierEquals(FnvHash.Constants.ROLLBACK_ON_FAIL)) {
lexer.nextToken();
update.setRollBackOnFail(true);
}
if (lexer.identifierEquals(FnvConstants.QUEUE_ON_PK)) {
if (lexer.identifierEquals(FnvHash.Constants.QUEUE_ON_PK)) {
lexer.nextToken();
update.setQueryOnPk(true);
}
if (lexer.identifierEquals(FnvConstants.TARGET_AFFECT_ROW)) {
if (lexer.identifierEquals(FnvHash.Constants.TARGET_AFFECT_ROW)) {
lexer.nextToken();
SQLExpr targetAffectRow = this.exprParser.expr();
update.setTargetAffectRow(targetAffectRow);
@@ -422,7 +422,7 @@ public class MySqlSelectParser extends SQLSelectParser {
}
protected SQLTableSource parseTableSourceRest(SQLTableSource tableSource) {
if (lexer.identifierEquals(FnvConstants.USING)) {
if (lexer.identifierEquals(FnvHash.Constants.USING)) {
return tableSource;
}
@@ -433,14 +433,14 @@ public class MySqlSelectParser extends SQLSelectParser {
tableSource.getHints().add(hint);
}
if (lexer.identifierEquals(FnvConstants.IGNORE)) {
if (lexer.identifierEquals(FnvHash.Constants.IGNORE)) {
lexer.nextToken();
MySqlIgnoreIndexHint hint = new MySqlIgnoreIndexHint();
parseIndexHint(hint);
tableSource.getHints().add(hint);
}
if (lexer.identifierEquals(FnvConstants.FORCE)) {
if (lexer.identifierEquals(FnvHash.Constants.FORCE)) {
lexer.nextToken();
MySqlForceIndexHint hint = new MySqlForceIndexHint();
parseIndexHint(hint);
@@ -45,7 +45,7 @@ import com.alibaba.druid.sql.dialect.mysql.ast.clause.MySqlSelectIntoStatement;
import com.alibaba.druid.sql.dialect.mysql.ast.statement.*;
import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlLockTableStatement.LockType;
import com.alibaba.druid.sql.parser.*;
import com.alibaba.druid.util.FnvConstants;
import com.alibaba.druid.util.FnvHash;
import com.alibaba.druid.util.JdbcConstants;
import java.util.ArrayList;
@@ -181,7 +181,7 @@ public class MySqlStatementParser extends SQLStatementParser {
throw new ParserException("syntax error. " + lexer.info());
}
if (lexer.identifierEquals(FnvConstants.USING)) {
if (lexer.identifierEquals(FnvHash.Constants.USING)) {
lexer.nextToken();
SQLTableSource tableSource = createSQLSelectParser().parseTableSource();
@@ -340,13 +340,13 @@ public class MySqlStatementParser extends SQLStatementParser {
}
private void parseCreateIndexUsing(SQLCreateIndexStatement stmt) {
if (lexer.identifierEquals(FnvConstants.USING)) {
if (lexer.identifierEquals(FnvHash.Constants.USING)) {
lexer.nextToken();
if (lexer.identifierEquals(FnvConstants.BTREE)) {
if (lexer.identifierEquals(FnvHash.Constants.BTREE)) {
stmt.setUsing("BTREE");
lexer.nextToken();
} else if (lexer.identifierEquals(FnvConstants.HASH)) {
} else if (lexer.identifierEquals(FnvHash.Constants.HASH)) {
stmt.setUsing("HASH");
lexer.nextToken();
} else {
@@ -962,7 +962,7 @@ public class MySqlStatementParser extends SQLStatementParser {
accept(Token.STAR);
accept(Token.RPAREN);
if (lexer.identifierEquals(FnvConstants.ERRORS)) {
if (lexer.identifierEquals(FnvHash.Constants.ERRORS)) {
lexer.nextToken();
MySqlShowErrorsStatement stmt = new MySqlShowErrorsStatement();
@@ -979,7 +979,7 @@ public class MySqlStatementParser extends SQLStatementParser {
}
}
if (lexer.identifierEquals(FnvConstants.ERRORS)) {
if (lexer.identifierEquals(FnvHash.Constants.ERRORS)) {
lexer.nextToken();
MySqlShowErrorsStatement stmt = new MySqlShowErrorsStatement();
@@ -3321,7 +3321,7 @@ public class MySqlStatementParser extends SQLStatementParser {
stmt.setDbType(dbType);
if (lexer.token() != Token.PROCEDURE) {
if (lexer.identifierEquals(FnvConstants.DEFINER)) {
if (lexer.identifierEquals(FnvHash.Constants.DEFINER)) {
lexer.nextToken();
accept(Token.EQ);
SQLName definer = this.exprParser.name();
@@ -3347,19 +3347,19 @@ public class MySqlStatementParser extends SQLStatementParser {
}
for (;;) {
if (lexer.identifierEquals(FnvConstants.DETERMINISTIC)) {
if (lexer.identifierEquals(FnvHash.Constants.DETERMINISTIC)) {
lexer.nextToken();
stmt.setDeterministic(true);
continue;
}
if (lexer.identifierEquals(FnvConstants.CONTAINS)) {
if (lexer.identifierEquals(FnvHash.Constants.CONTAINS)) {
lexer.nextToken();
acceptIdentifier("SQL");
stmt.setContainsSql(true);
continue;
}
if (lexer.identifierEquals(FnvConstants.SQL)) {
if (lexer.identifierEquals(FnvHash.Constants.SQL)) {
lexer.nextToken();
acceptIdentifier("SECURITY");
SQLName authid = this.exprParser.name();
@@ -52,7 +52,7 @@ import com.alibaba.druid.sql.dialect.oracle.ast.stmt.OracleUnique;
import com.alibaba.druid.sql.dialect.oracle.ast.stmt.OracleUsingIndexClause;
import com.alibaba.druid.sql.parser.*;
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 OracleExprParser extends SQLExprParser {
@@ -140,12 +140,12 @@ public class OracleExprParser extends SQLExprParser {
}
protected boolean isCharType(long hash) {
return hash == FnvConstants.CHAR
|| hash == FnvConstants.NCHAR
|| hash == FnvConstants.VARCHAR
|| hash == FnvConstants.VARCHAR2
|| hash == FnvConstants.NVARCHAR
|| hash == FnvConstants.NVARCHAR2
return hash == FnvHash.Constants.CHAR
|| hash == FnvHash.Constants.NCHAR
|| hash == FnvHash.Constants.VARCHAR
|| hash == FnvHash.Constants.VARCHAR2
|| hash == FnvHash.Constants.NVARCHAR
|| hash == FnvHash.Constants.NVARCHAR2
;
}
@@ -201,10 +201,10 @@ public class OracleExprParser extends SQLExprParser {
if (lexer.token() == Token.EXCEPTION) {
typeName = "EXCEPTION";
lexer.nextToken();
} else if (lexer.identifierEquals(FnvConstants.LONG)) {
} else if (lexer.identifierEquals(FnvHash.Constants.LONG)) {
lexer.nextToken();
if (lexer.identifierEquals(FnvConstants.RAW)) {
if (lexer.identifierEquals(FnvHash.Constants.RAW)) {
lexer.nextToken();
typeName = "LONG RAW";
} else {
@@ -600,11 +600,16 @@ public class OracleSelectParser extends SQLSelectParser {
public SQLTableSource parseTableSourcePrimary() {
if (lexer.token() == (Token.LPAREN)) {
lexer.nextToken();
OracleSelectSubqueryTableSource tableSource;
if (lexer.token() == Token.SELECT || lexer.token() == Token.WITH) {
tableSource = new OracleSelectSubqueryTableSource(select());
} else if (lexer.token() == (Token.LPAREN)) {
tableSource = new OracleSelectSubqueryTableSource(select());
} else if (lexer.token() == Token.IDENTIFIER) {
SQLTableSource identTable = parseTableSource();
accept(Token.RPAREN);
return identTable;
} else {
throw new ParserException("TODO :" + lexer.info());
}
@@ -26,7 +26,6 @@ import com.alibaba.druid.sql.ast.SQLObject;
import com.alibaba.druid.sql.ast.SQLStatement;
import com.alibaba.druid.sql.ast.expr.SQLCharExpr;
import com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr;
import com.alibaba.druid.sql.ast.expr.SQLMethodInvokeExpr;
import com.alibaba.druid.sql.ast.expr.SQLPropertyExpr;
import com.alibaba.druid.sql.ast.statement.*;
import com.alibaba.druid.sql.ast.statement.SQLMergeStatement.MergeInsertClause;
@@ -62,10 +61,8 @@ import com.alibaba.druid.sql.visitor.SchemaStatVisitor;
import com.alibaba.druid.stat.TableStat;
import com.alibaba.druid.stat.TableStat.Column;
import com.alibaba.druid.stat.TableStat.Mode;
import com.alibaba.druid.stat.TableStat.Relationship;
import com.alibaba.druid.util.FnvConstants;
import com.alibaba.druid.util.FnvHash;
import com.alibaba.druid.util.JdbcConstants;
import com.alibaba.druid.util.JdbcUtils;
public class OracleSchemaStatVisitor extends SchemaStatVisitor implements OracleASTVisitor {
@@ -90,7 +87,7 @@ public class OracleSchemaStatVisitor extends SchemaStatVisitor implements Oracle
TableStat stat = getTableStat(x);
if (expr instanceof SQLName) {
if (((SQLName) expr).nameHashCode64() == FnvConstants.DUAL) {
if (((SQLName) expr).nameHashCode64() == FnvHash.Constants.DUAL) {
return false;
}
@@ -27,7 +27,8 @@ import com.alibaba.druid.sql.ast.statement.SQLSelectStatement;
import com.alibaba.druid.sql.ast.statement.SQLSubqueryTableSource;
import com.alibaba.druid.sql.ast.statement.SQLTableSource;
import com.alibaba.druid.sql.dialect.oracle.ast.stmt.OracleSelectQueryBlock;
import com.alibaba.druid.util.FnvConstants;
import com.alibaba.druid.util.FnvHash;
import com.alibaba.druid.util.FnvHash.Constants;
public class OracleToMySqlOutputVisitor extends OracleOutputVisitor {
@@ -153,7 +154,7 @@ public class OracleToMySqlOutputVisitor extends OracleOutputVisitor {
static boolean isRowNumber(SQLExpr expr) {
if (expr instanceof SQLIdentifierExpr) {
return ((SQLIdentifierExpr) expr)
.hashCode64() == FnvConstants.ROWNUM;
.hashCode64() == FnvHash.Constants.ROWNUM;
}
return false;
@@ -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
@@ -37,7 +37,7 @@ import com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerInsertStatement
import com.alibaba.druid.sql.dialect.sqlserver.ast.stmt.SQLServerUpdateStatement;
import com.alibaba.druid.sql.dialect.sqlserver.visitor.SQLServerASTVisitorAdapter;
import com.alibaba.druid.sql.visitor.SQLASTVisitorAdapter;
import com.alibaba.druid.util.FnvConstants;
import com.alibaba.druid.util.FnvHash;
import com.alibaba.druid.util.PGUtils;
import java.util.ArrayList;
@@ -1488,7 +1488,7 @@ class SchemaResolveVisitorFactory {
long hash = x.nameHashCode64();
SQLTableSource tableSource = null;
if ((hash == FnvConstants.LEVEL || hash == FnvConstants.CONNECT_BY_ISCYCLE)
if ((hash == FnvHash.Constants.LEVEL || hash == FnvHash.Constants.CONNECT_BY_ISCYCLE)
&& ctx.object instanceof SQLSelectQueryBlock) {
SQLSelectQueryBlock queryBlock = (SQLSelectQueryBlock) ctx.object;
if (queryBlock.getStartWith() != null
@@ -43,7 +43,6 @@ import com.alibaba.druid.stat.TableStat.Condition;
import com.alibaba.druid.stat.TableStat.Mode;
import com.alibaba.druid.stat.TableStat.Relationship;
import com.alibaba.druid.util.FnvHash;
import com.alibaba.druid.util.FnvConstants;
import com.alibaba.druid.util.JdbcConstants;
import com.alibaba.druid.util.StringUtils;
@@ -1169,9 +1168,9 @@ public class SchemaStatVisitor extends SQLASTVisitorAdapter {
return false;
}
if ((hash == FnvConstants.LEVEL
|| hash == FnvConstants.CONNECT_BY_ISCYCLE
|| hash == FnvConstants.ROWNUM)
if ((hash == FnvHash.Constants.LEVEL
|| hash == FnvHash.Constants.CONNECT_BY_ISCYCLE
|| hash == FnvHash.Constants.ROWNUM)
&& x.getResolvedColumn() == null
&& tableSource == null) {
return false;
@@ -1471,7 +1470,7 @@ public class SchemaStatVisitor extends SQLASTVisitorAdapter {
if (expr instanceof SQLIdentifierExpr) {
SQLIdentifierExpr identifierExpr = (SQLIdentifierExpr) expr;
if (identifierExpr.nameHashCode64() == FnvConstants.DUAL) {
if (identifierExpr.nameHashCode64() == FnvHash.Constants.DUAL) {
return null;
}