mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
refactor sql parser.
This commit is contained in:
@@ -26,7 +26,7 @@ public class SQLOver extends SQLObjectImpl {
|
||||
protected SQLOrderBy orderBy;
|
||||
|
||||
// for db2
|
||||
protected SQLExpr of;
|
||||
protected SQLName of;
|
||||
|
||||
protected SQLExpr windowing;
|
||||
protected WindowingType windowingType = WindowingType.ROWS;
|
||||
@@ -71,11 +71,11 @@ public class SQLOver extends SQLObjectImpl {
|
||||
this.orderBy = orderBy;
|
||||
}
|
||||
|
||||
public SQLExpr getOf() {
|
||||
public SQLName getOf() {
|
||||
return of;
|
||||
}
|
||||
|
||||
public void setOf(SQLExpr of) {
|
||||
public void setOf(SQLName of) {
|
||||
if (of != null) {
|
||||
of.setParent(this);
|
||||
}
|
||||
|
||||
@@ -133,7 +133,9 @@ public class SQLAggregateExpr extends SQLExprImpl implements Serializable, SQLRe
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
if (visitor.visit(this)) {
|
||||
acceptChild(visitor, this.arguments);
|
||||
acceptChild(visitor, this.keep);
|
||||
acceptChild(visitor, this.over);
|
||||
acceptChild(visitor, this.withinGroup);
|
||||
}
|
||||
|
||||
visitor.endVisit(this);
|
||||
|
||||
@@ -22,12 +22,12 @@ import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
import com.alibaba.druid.util.FnvHash;
|
||||
|
||||
public class SQLIdentifierExpr extends SQLExprImpl implements SQLName {
|
||||
protected String name;
|
||||
private transient String lowerName;
|
||||
private transient long hashCode64;
|
||||
protected String name;
|
||||
private String lowerName;
|
||||
private long hashCode64;
|
||||
|
||||
private transient SQLObject resolvedColumn;
|
||||
private transient SQLObject resolvedOwnerObject;
|
||||
private SQLObject resolvedColumn;
|
||||
private SQLObject resolvedOwnerObject;
|
||||
|
||||
public SQLIdentifierExpr(){
|
||||
|
||||
@@ -125,6 +125,10 @@ public class SQLIdentifierExpr extends SQLExprImpl implements SQLName {
|
||||
return null;
|
||||
}
|
||||
|
||||
public SQLObject getResolvedColumnObject() {
|
||||
return resolvedColumn;
|
||||
}
|
||||
|
||||
public void setResolvedColumn(SQLColumnDefinition resolvedColumn) {
|
||||
this.resolvedColumn = resolvedColumn;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class SQLPropertyExpr extends SQLExprImpl implements SQLName {
|
||||
private transient long hashCode64;
|
||||
|
||||
private transient SQLColumnDefinition resolvedColumn;
|
||||
private transient SQLObject resolvedTableSource;
|
||||
private transient SQLObject resolvedOwnerObject;
|
||||
|
||||
public SQLPropertyExpr(String owner, String name){
|
||||
this(new SQLIdentifierExpr(owner), name);
|
||||
@@ -119,7 +119,7 @@ public class SQLPropertyExpr extends SQLExprImpl implements SQLName {
|
||||
} else if (owner == null){
|
||||
hash = FnvHash.BASIC;
|
||||
} else {
|
||||
hash = FnvHash.fnv_64_lower(owner.toString());
|
||||
hash = FnvHash.fnv1a_64_lower(owner.toString());
|
||||
|
||||
hash ^= '.';
|
||||
hash *= FnvHash.PRIME;
|
||||
@@ -170,7 +170,7 @@ public class SQLPropertyExpr extends SQLExprImpl implements SQLName {
|
||||
|
||||
x.hashCode64 = hashCode64;
|
||||
x.resolvedColumn = resolvedColumn;
|
||||
x.resolvedTableSource = resolvedTableSource;
|
||||
x.resolvedOwnerObject = resolvedOwnerObject;
|
||||
|
||||
return x;
|
||||
}
|
||||
@@ -214,41 +214,45 @@ public class SQLPropertyExpr extends SQLExprImpl implements SQLName {
|
||||
}
|
||||
|
||||
public SQLTableSource getResolvedTableSource() {
|
||||
if (resolvedTableSource instanceof SQLTableSource) {
|
||||
return (SQLTableSource) resolvedTableSource;
|
||||
if (resolvedOwnerObject instanceof SQLTableSource) {
|
||||
return (SQLTableSource) resolvedOwnerObject;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setResolvedTableSource(SQLTableSource resolvedTableSource) {
|
||||
this.resolvedTableSource = resolvedTableSource;
|
||||
this.resolvedOwnerObject = resolvedTableSource;
|
||||
}
|
||||
|
||||
public void setResolvedProcedure(SQLCreateProcedureStatement stmt) {
|
||||
this.resolvedTableSource = stmt;
|
||||
this.resolvedOwnerObject = stmt;
|
||||
}
|
||||
|
||||
public void setResolvedOwnerObject(SQLObject resolvedOwnerObject) {
|
||||
this.resolvedTableSource = resolvedOwnerObject;
|
||||
this.resolvedOwnerObject = resolvedOwnerObject;
|
||||
}
|
||||
|
||||
public SQLCreateProcedureStatement getResolvedProcudure() {
|
||||
if (this.resolvedTableSource instanceof SQLCreateProcedureStatement) {
|
||||
return (SQLCreateProcedureStatement) this.resolvedTableSource;
|
||||
if (this.resolvedOwnerObject instanceof SQLCreateProcedureStatement) {
|
||||
return (SQLCreateProcedureStatement) this.resolvedOwnerObject;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public SQLObject getResolvedOwnerObject() {
|
||||
return resolvedOwnerObject;
|
||||
}
|
||||
|
||||
public SQLDataType computeDataType() {
|
||||
if (resolvedColumn != null) {
|
||||
return resolvedColumn.getDataType();
|
||||
}
|
||||
|
||||
if (resolvedTableSource != null
|
||||
&& resolvedTableSource instanceof SQLSubqueryTableSource) {
|
||||
SQLSelect select = ((SQLSubqueryTableSource) resolvedTableSource).getSelect();
|
||||
if (resolvedOwnerObject != null
|
||||
&& resolvedOwnerObject instanceof SQLSubqueryTableSource) {
|
||||
SQLSelect select = ((SQLSubqueryTableSource) resolvedOwnerObject).getSelect();
|
||||
SQLSelectQueryBlock queryBlock = select.getFirstQueryBlock();
|
||||
if (queryBlock == null) {
|
||||
return null;
|
||||
|
||||
@@ -32,7 +32,6 @@ public class SQLExprTableSource extends SQLTableSourceImpl {
|
||||
|
||||
protected SQLExpr expr;
|
||||
private List<SQLName> partitions;
|
||||
|
||||
private SchemaObject schemaObject;
|
||||
|
||||
public SQLExprTableSource(){
|
||||
|
||||
@@ -50,7 +50,10 @@ public class SQLSelectQueryBlock extends SQLObjectImpl implements SQLSelectQuery
|
||||
protected SQLLimit limit;
|
||||
|
||||
// for oracle
|
||||
protected List<SQLExpr> forUpdateOf;
|
||||
protected List<SQLExpr> forUpdateOf;
|
||||
|
||||
protected List<SQLExpr> distributeBy;
|
||||
protected List<SQLSelectOrderByItem> sortBy;
|
||||
|
||||
public SQLSelectQueryBlock(){
|
||||
|
||||
@@ -308,6 +311,14 @@ public class SQLSelectQueryBlock extends SQLObjectImpl implements SQLSelectQuery
|
||||
this.noCycle = noCycle;
|
||||
}
|
||||
|
||||
public List<SQLExpr> getDistributeBy() {
|
||||
return distributeBy;
|
||||
}
|
||||
|
||||
public List<SQLSelectOrderByItem> getSortBy() {
|
||||
return sortBy;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
if (visitor.visit(this)) {
|
||||
@@ -500,7 +511,7 @@ public class SQLSelectQueryBlock extends SQLObjectImpl implements SQLSelectQuery
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean selectItemHashAllColumn() {
|
||||
public boolean selectItemHasAllColumn() {
|
||||
for (SQLSelectItem item : this.selectList) {
|
||||
SQLExpr expr = item.getExpr();
|
||||
|
||||
@@ -512,7 +523,7 @@ public class SQLSelectQueryBlock extends SQLObjectImpl implements SQLSelectQuery
|
||||
SQLSelect subSelect = ((SQLSubqueryTableSource) from).select;
|
||||
SQLSelectQueryBlock queryBlock = subSelect.getQueryBlock();
|
||||
if (queryBlock != null) {
|
||||
return queryBlock.selectItemHashAllColumn();
|
||||
return queryBlock.selectItemHasAllColumn();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -522,6 +533,23 @@ public class SQLSelectQueryBlock extends SQLObjectImpl implements SQLSelectQuery
|
||||
return false;
|
||||
}
|
||||
|
||||
public SQLSelectItem findAllColumnSelectItem() {
|
||||
SQLSelectItem allColumnItem = null;
|
||||
for (SQLSelectItem item : this.selectList) {
|
||||
SQLExpr expr = item.getExpr();
|
||||
|
||||
boolean allColumn = expr instanceof SQLAllColumnExpr
|
||||
|| (expr instanceof SQLPropertyExpr && ((SQLPropertyExpr) expr).getName().equals("*"));
|
||||
|
||||
if (allColumnItem != null) {
|
||||
return null; // duplicateAllColumn
|
||||
}
|
||||
allColumnItem = item;
|
||||
}
|
||||
|
||||
return allColumnItem;
|
||||
}
|
||||
|
||||
public SQLColumnDefinition findColumn(String columnName) {
|
||||
if (from == null) {
|
||||
return null;
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.alibaba.druid.sql.ast.*;
|
||||
import com.alibaba.druid.sql.visitor.SQLASTVisitor;
|
||||
|
||||
public class SQLUpdateStatement extends SQLStatementImpl implements SQLReplaceable {
|
||||
protected SQLWithSubqueryClause with; // for pg
|
||||
|
||||
protected final List<SQLUpdateSetItem> items = new ArrayList<SQLUpdateSetItem>();
|
||||
protected SQLExpr where;
|
||||
@@ -161,4 +162,15 @@ public class SQLUpdateStatement extends SQLStatementImpl implements SQLReplaceab
|
||||
}
|
||||
this.orderBy = orderBy;
|
||||
}
|
||||
|
||||
public SQLWithSubqueryClause getWith() {
|
||||
return with;
|
||||
}
|
||||
|
||||
public void setWith(SQLWithSubqueryClause with) {
|
||||
if (with != null) {
|
||||
with.setParent(this);
|
||||
}
|
||||
this.with = with;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,6 +132,15 @@ public class SQLWithSubqueryClause extends SQLObjectImpl {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
if (subQuery != null) {
|
||||
SQLSelectQueryBlock queryBlock = subQuery.getFirstQueryBlock();
|
||||
if (queryBlock != null) {
|
||||
if (queryBlock.findSelectItem(columnNameHash) != null) {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,10 +36,10 @@ public class DB2ExprParser extends SQLExprParser {
|
||||
static {
|
||||
String[] strings = { "AVG", "COUNT", "MAX", "MIN", "STDDEV", "SUM", "ROW_NUMBER",
|
||||
"ROWNUMBER" };
|
||||
AGGREGATE_FUNCTIONS_CODES = FnvHash.fnv_64_lower(strings, true);
|
||||
AGGREGATE_FUNCTIONS_CODES = FnvHash.fnv1a_64_lower(strings, true);
|
||||
AGGREGATE_FUNCTIONS = new String[AGGREGATE_FUNCTIONS_CODES.length];
|
||||
for (String str : strings) {
|
||||
long hash = FnvHash.fnv_64_lower(str);
|
||||
long hash = FnvHash.fnv1a_64_lower(str);
|
||||
int index = Arrays.binarySearch(AGGREGATE_FUNCTIONS_CODES, hash);
|
||||
AGGREGATE_FUNCTIONS[index] = str;
|
||||
}
|
||||
|
||||
@@ -63,10 +63,10 @@ public class MySqlExprParser extends SQLExprParser {
|
||||
|
||||
static {
|
||||
String[] strings = { "AVG", "COUNT", "GROUP_CONCAT", "MAX", "MIN", "STDDEV", "SUM" };
|
||||
AGGREGATE_FUNCTIONS_CODES = FnvHash.fnv_64_lower(strings, true);
|
||||
AGGREGATE_FUNCTIONS_CODES = FnvHash.fnv1a_64_lower(strings, true);
|
||||
AGGREGATE_FUNCTIONS = new String[AGGREGATE_FUNCTIONS_CODES.length];
|
||||
for (String str : strings) {
|
||||
long hash = FnvHash.fnv_64_lower(str);
|
||||
long hash = FnvHash.fnv1a_64_lower(str);
|
||||
int index = Arrays.binarySearch(AGGREGATE_FUNCTIONS_CODES, hash);
|
||||
AGGREGATE_FUNCTIONS[index] = str;
|
||||
}
|
||||
|
||||
+9
-52
@@ -69,9 +69,6 @@ public class MySqlSchemaStatVisitor extends SchemaStatVisitor implements MySqlAS
|
||||
repository.resolve(x);
|
||||
}
|
||||
|
||||
setAliasMap();
|
||||
getAliasMap().put("DUAL", null);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -87,8 +84,6 @@ public class MySqlSchemaStatVisitor extends SchemaStatVisitor implements MySqlAS
|
||||
repository.resolve(x);
|
||||
}
|
||||
|
||||
setAliasMap();
|
||||
|
||||
setMode(x, Mode.Delete);
|
||||
|
||||
accept(x.getFrom());
|
||||
@@ -96,10 +91,7 @@ public class MySqlSchemaStatVisitor extends SchemaStatVisitor implements MySqlAS
|
||||
x.getTableSource().accept(this);
|
||||
|
||||
if (x.getTableSource() instanceof SQLExprTableSource) {
|
||||
SQLName tableName = (SQLName) ((SQLExprTableSource) x.getTableSource()).getExpr();
|
||||
String ident = tableName.toString();
|
||||
|
||||
TableStat stat = this.getTableStat(ident);
|
||||
TableStat stat = this.getTableStat(x.getExprTableSource());
|
||||
stat.incrementDeleteCount();
|
||||
}
|
||||
|
||||
@@ -112,7 +104,6 @@ public class MySqlSchemaStatVisitor extends SchemaStatVisitor implements MySqlAS
|
||||
}
|
||||
|
||||
public void endVisit(MySqlDeleteStatement x) {
|
||||
setAliasMap(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -129,27 +120,10 @@ public class MySqlSchemaStatVisitor extends SchemaStatVisitor implements MySqlAS
|
||||
|
||||
setMode(x, Mode.Insert);
|
||||
|
||||
setAliasMap();
|
||||
TableStat stat = getTableStat(x.getTableSource());
|
||||
|
||||
SQLName tableName = x.getTableName();
|
||||
|
||||
String ident = null;
|
||||
if (tableName instanceof SQLIdentifierExpr) {
|
||||
ident = ((SQLIdentifierExpr) tableName).getName();
|
||||
} else if (tableName instanceof SQLPropertyExpr) {
|
||||
SQLPropertyExpr propertyExpr = (SQLPropertyExpr) tableName;
|
||||
if (propertyExpr.getOwner() instanceof SQLIdentifierExpr) {
|
||||
ident = propertyExpr.toString();
|
||||
}
|
||||
}
|
||||
|
||||
if (ident != null) {
|
||||
TableStat stat = getTableStat(ident);
|
||||
if (stat != null) {
|
||||
stat.incrementInsertCount();
|
||||
|
||||
Map<String, String> aliasMap = getAliasMap();
|
||||
putAliasMap(aliasMap, x.getAlias(), ident);
|
||||
putAliasMap(aliasMap, ident, ident);
|
||||
}
|
||||
|
||||
accept(x.getColumns());
|
||||
@@ -299,26 +273,12 @@ public class MySqlSchemaStatVisitor extends SchemaStatVisitor implements MySqlAS
|
||||
|
||||
setMode(x, Mode.Replace);
|
||||
|
||||
setAliasMap();
|
||||
|
||||
SQLName tableName = x.getTableName();
|
||||
|
||||
String ident = null;
|
||||
if (tableName instanceof SQLIdentifierExpr) {
|
||||
ident = ((SQLIdentifierExpr) tableName).getName();
|
||||
} else if (tableName instanceof SQLPropertyExpr) {
|
||||
SQLPropertyExpr propertyExpr = (SQLPropertyExpr) tableName;
|
||||
if (propertyExpr.getOwner() instanceof SQLIdentifierExpr) {
|
||||
ident = propertyExpr.toString();
|
||||
}
|
||||
}
|
||||
TableStat stat = getTableStat(tableName);
|
||||
|
||||
if (ident != null) {
|
||||
TableStat stat = getTableStat(ident);
|
||||
if (stat != null) {
|
||||
stat.incrementInsertCount();
|
||||
|
||||
Map<String, String> aliasMap = getAliasMap();
|
||||
putAliasMap(aliasMap, ident, ident);
|
||||
}
|
||||
|
||||
accept(x.getColumns());
|
||||
@@ -480,7 +440,7 @@ public class MySqlSchemaStatVisitor extends SchemaStatVisitor implements MySqlAS
|
||||
SQLName tableName = x.getTableName();
|
||||
if (tableName != null) {
|
||||
String table = tableName.toString();
|
||||
getTableStat(table);
|
||||
getTableStat(tableName);
|
||||
|
||||
SQLName columnName = x.getColumnName();
|
||||
if (columnName != null) {
|
||||
@@ -1217,12 +1177,7 @@ public class MySqlSchemaStatVisitor extends SchemaStatVisitor implements MySqlAS
|
||||
|
||||
@Override
|
||||
public boolean visit(MySqlDeclareStatement x) {
|
||||
for (SQLDeclareItem item : x.getVarList()) {
|
||||
SQLName var = (SQLName) item.getName();
|
||||
this.variants.put(var.toString(), var);
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1355,4 +1310,6 @@ public class MySqlSchemaStatVisitor extends SchemaStatVisitor implements MySqlAS
|
||||
public void endVisit(MySqlFlushStatement x) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -35,11 +35,9 @@ public class OdpsSelectQueryBlock extends SQLSelectQueryBlock {
|
||||
|
||||
protected List<SQLHint> hints;
|
||||
|
||||
protected List<SQLExpr> distributeBy = new ArrayList<SQLExpr>();
|
||||
protected List<SQLSelectOrderByItem> sortBy = new ArrayList<SQLSelectOrderByItem>(2);
|
||||
|
||||
public OdpsSelectQueryBlock(){
|
||||
|
||||
distributeBy = new ArrayList<SQLExpr>();
|
||||
sortBy = new ArrayList<SQLSelectOrderByItem>(2);
|
||||
}
|
||||
|
||||
public SQLOrderBy getOrderBy() {
|
||||
@@ -50,13 +48,7 @@ public class OdpsSelectQueryBlock extends SQLSelectQueryBlock {
|
||||
this.orderBy = orderBy;
|
||||
}
|
||||
|
||||
public List<SQLExpr> getDistributeBy() {
|
||||
return distributeBy;
|
||||
}
|
||||
|
||||
public List<SQLSelectOrderByItem> getSortBy() {
|
||||
return sortBy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
||||
@@ -46,10 +46,10 @@ public class OdpsExprParser extends SQLExprParser {
|
||||
"ROW_NUMBER",
|
||||
"WM_CONCAT"//
|
||||
};
|
||||
AGGREGATE_FUNCTIONS_CODES = FnvHash.fnv_64_lower(strings, true);
|
||||
AGGREGATE_FUNCTIONS_CODES = FnvHash.fnv1a_64_lower(strings, true);
|
||||
AGGREGATE_FUNCTIONS = new String[AGGREGATE_FUNCTIONS_CODES.length];
|
||||
for (String str : strings) {
|
||||
long hash = FnvHash.fnv_64_lower(str);
|
||||
long hash = FnvHash.fnv1a_64_lower(str);
|
||||
int index = Arrays.binarySearch(AGGREGATE_FUNCTIONS_CODES, hash);
|
||||
AGGREGATE_FUNCTIONS[index] = str;
|
||||
}
|
||||
|
||||
+1
-12
@@ -64,20 +64,14 @@ public class OdpsSchemaStatVisitor extends SchemaStatVisitor implements OdpsASTV
|
||||
public boolean visit(OdpsInsert x) {
|
||||
setMode(x, TableStat.Mode.Insert);
|
||||
|
||||
setAliasMap();
|
||||
|
||||
SQLExprTableSource tableSource = x.getTableSource();
|
||||
SQLExpr tableName = tableSource.getExpr();
|
||||
|
||||
if (tableName instanceof SQLName) {
|
||||
String ident = ((SQLName) tableName).toString();
|
||||
|
||||
TableStat stat = getTableStat(ident);
|
||||
TableStat stat = getTableStat(tableName);
|
||||
stat.incrementInsertCount();
|
||||
|
||||
Map<String, String> aliasMap = getAliasMap();
|
||||
putAliasMap(aliasMap, tableSource.getAlias(), ident);
|
||||
putAliasMap(aliasMap, ident, ident);
|
||||
}
|
||||
|
||||
for (SQLAssignItem partition : x.getPartitions()) {
|
||||
@@ -289,11 +283,6 @@ public class OdpsSchemaStatVisitor extends SchemaStatVisitor implements OdpsASTV
|
||||
|
||||
@Override
|
||||
public boolean visit(OdpsValuesTableSource x) {
|
||||
Map<String, String> aliasMap = getAliasMap();
|
||||
if (aliasMap != null && x.getAlias() != null) {
|
||||
putAliasMap(aliasMap, x.getAlias(), null);
|
||||
addSubQuery(x.getAlias(), x);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ public class OracleDbLinkExpr extends SQLExprImpl implements SQLName, OracleExpr
|
||||
} else if (expr == null){
|
||||
hash = FnvHash.BASIC;
|
||||
} else {
|
||||
hash = FnvHash.fnv_64_lower(expr.toString());
|
||||
hash = FnvHash.fnv1a_64_lower(expr.toString());
|
||||
|
||||
hash ^= '.';
|
||||
hash *= FnvHash.PRIME;
|
||||
|
||||
@@ -111,10 +111,10 @@ public class OracleExprParser extends SQLExprParser {
|
||||
"VARIANCE", //
|
||||
"WM_CONCAT"
|
||||
};
|
||||
AGGREGATE_FUNCTIONS_CODES = FnvHash.fnv_64_lower(strings, true);
|
||||
AGGREGATE_FUNCTIONS_CODES = FnvHash.fnv1a_64_lower(strings, true);
|
||||
AGGREGATE_FUNCTIONS = new String[AGGREGATE_FUNCTIONS_CODES.length];
|
||||
for (String str : strings) {
|
||||
long hash = FnvHash.fnv_64_lower(str);
|
||||
long hash = FnvHash.fnv1a_64_lower(str);
|
||||
int index = Arrays.binarySearch(AGGREGATE_FUNCTIONS_CODES, hash);
|
||||
AGGREGATE_FUNCTIONS[index] = str;
|
||||
}
|
||||
|
||||
+39
-109
@@ -63,6 +63,7 @@ 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.JdbcConstants;
|
||||
import com.alibaba.druid.util.JdbcUtils;
|
||||
|
||||
@@ -74,10 +75,6 @@ public class OracleSchemaStatVisitor extends SchemaStatVisitor implements Oracle
|
||||
|
||||
public OracleSchemaStatVisitor(List<Object> parameters){
|
||||
super(JdbcConstants.ORACLE, parameters);
|
||||
this.variants.put("DUAL", null);
|
||||
this.variants.put("NOTFOUND", null);
|
||||
this.variants.put("TRUE", null);
|
||||
this.variants.put("FALSE", null);
|
||||
}
|
||||
|
||||
protected Column getColumn(SQLExpr expr) {
|
||||
@@ -90,42 +87,25 @@ public class OracleSchemaStatVisitor extends SchemaStatVisitor implements Oracle
|
||||
|
||||
public boolean visit(OracleSelectTableReference x) {
|
||||
SQLExpr expr = x.getExpr();
|
||||
|
||||
if (expr instanceof SQLMethodInvokeExpr) {
|
||||
SQLMethodInvokeExpr methodInvoke = (SQLMethodInvokeExpr) expr;
|
||||
if ("TABLE".equalsIgnoreCase(methodInvoke.getMethodName()) && methodInvoke.getParameters().size() == 1) {
|
||||
expr = methodInvoke.getParameters().get(0);
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, String> aliasMap = getAliasMap();
|
||||
TableStat stat = getTableStat(x);
|
||||
|
||||
if (expr instanceof SQLName) {
|
||||
String ident;
|
||||
if (((SQLName) expr).nameHashCode64() == FnvConstants.DUAL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (expr instanceof SQLPropertyExpr) {
|
||||
String owner = ((SQLPropertyExpr) expr).getOwner().toString();
|
||||
String name = ((SQLPropertyExpr) expr).getName();
|
||||
|
||||
if (aliasMap.containsKey(owner)) {
|
||||
owner = aliasMap.get(owner);
|
||||
SQLPropertyExpr propertyExpr = (SQLPropertyExpr) expr;
|
||||
if (isSubQueryOrParamOrVariant(propertyExpr)) {
|
||||
return false;
|
||||
}
|
||||
} else if (expr instanceof SQLIdentifierExpr) {
|
||||
SQLIdentifierExpr identifierExpr = (SQLIdentifierExpr) expr;
|
||||
if (isSubQueryOrParamOrVariant(identifierExpr)) {
|
||||
return false;
|
||||
}
|
||||
ident = owner + "." + name;
|
||||
} else {
|
||||
ident = expr.toString();
|
||||
}
|
||||
|
||||
if (containsSubQuery(ident)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ("DUAL".equalsIgnoreCase(ident)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
x.putAttribute(ATTR_TABLE, ident);
|
||||
|
||||
TableStat stat = getTableStat(ident);
|
||||
|
||||
Mode mode = getMode();
|
||||
switch (mode) {
|
||||
case Delete:
|
||||
@@ -147,23 +127,15 @@ public class OracleSchemaStatVisitor extends SchemaStatVisitor implements Oracle
|
||||
break;
|
||||
}
|
||||
|
||||
putAliasMap(aliasMap, x.getAlias(), ident);
|
||||
putAliasMap(aliasMap, ident, ident);
|
||||
return false;
|
||||
}
|
||||
|
||||
accept(x.getExpr());
|
||||
// accept(x.getExpr());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void endVisit(SQLSelect x) {
|
||||
if (x.getQuery() != null) {
|
||||
String table = (String) x.getQuery().getAttribute(ATTR_TABLE);
|
||||
if (table != null) {
|
||||
x.putAttribute(ATTR_TABLE, table);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean visit(OracleUpdateStatement x) {
|
||||
@@ -172,7 +144,6 @@ public class OracleSchemaStatVisitor extends SchemaStatVisitor implements Oracle
|
||||
repository.resolve(x);
|
||||
}
|
||||
|
||||
setAliasMap();
|
||||
setMode(x, Mode.Update);
|
||||
|
||||
SQLTableSource tableSource = x.getTableSource();
|
||||
@@ -187,10 +158,6 @@ public class OracleSchemaStatVisitor extends SchemaStatVisitor implements Oracle
|
||||
|
||||
TableStat stat = getTableStat(ident);
|
||||
stat.incrementUpdateCount();
|
||||
|
||||
Map<String, String> aliasMap = getAliasMap();
|
||||
aliasMap.put(ident, ident);
|
||||
aliasMap.put(tableSource.getAlias(), ident);
|
||||
} else {
|
||||
tableSource.accept(this);
|
||||
}
|
||||
@@ -220,9 +187,7 @@ public class OracleSchemaStatVisitor extends SchemaStatVisitor implements Oracle
|
||||
}
|
||||
}
|
||||
|
||||
visit((SQLSelectQueryBlock) x);
|
||||
|
||||
return true;
|
||||
return visit((SQLSelectQueryBlock) x);
|
||||
}
|
||||
|
||||
public void endVisit(OracleSelectQueryBlock x) {
|
||||
@@ -366,29 +331,29 @@ public class OracleSchemaStatVisitor extends SchemaStatVisitor implements Oracle
|
||||
@Override
|
||||
public boolean visit(OracleSelectJoin x) {
|
||||
super.visit(x);
|
||||
|
||||
for (SQLExpr item : x.getUsing()) {
|
||||
if (item instanceof SQLIdentifierExpr) {
|
||||
String columnName = ((SQLIdentifierExpr) item).getName();
|
||||
String leftTable = (String) x.getLeft().getAttribute(ATTR_TABLE);
|
||||
String rightTable = (String) x.getRight().getAttribute(ATTR_TABLE);
|
||||
if (leftTable != null && rightTable != null) {
|
||||
Relationship relationship = new Relationship();
|
||||
relationship.setLeft(new Column(leftTable, columnName));
|
||||
relationship.setRight(new Column(rightTable, columnName));
|
||||
relationship.setOperator("USING");
|
||||
relationships.add(relationship);
|
||||
}
|
||||
|
||||
if (leftTable != null) {
|
||||
addColumn(leftTable, columnName);
|
||||
}
|
||||
|
||||
if (rightTable != null) {
|
||||
addColumn(rightTable, columnName);
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
// for (SQLExpr item : x.getUsing()) {
|
||||
// if (item instanceof SQLIdentifierExpr) {
|
||||
// String columnName = ((SQLIdentifierExpr) item).getName();
|
||||
// String leftTable = (String) x.getLeft().getAttribute(ATTR_TABLE);
|
||||
// String rightTable = (String) x.getRight().getAttribute(ATTR_TABLE);
|
||||
// if (leftTable != null && rightTable != null) {
|
||||
// Relationship relationship = new Relationship();
|
||||
// relationship.setLeft(new Column(leftTable, columnName));
|
||||
// relationship.setRight(new Column(rightTable, columnName));
|
||||
// relationship.setOperator("USING");
|
||||
// relationships.add(relationship);
|
||||
// }
|
||||
//
|
||||
// if (leftTable != null) {
|
||||
// addColumn(leftTable, columnName);
|
||||
// }
|
||||
//
|
||||
// if (rightTable != null) {
|
||||
// addColumn(rightTable, columnName);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -422,18 +387,6 @@ public class OracleSchemaStatVisitor extends SchemaStatVisitor implements Oracle
|
||||
accept(x.getSelect());
|
||||
accept(x.getPivot());
|
||||
accept(x.getFlashback());
|
||||
|
||||
String table = (String) x.getSelect().getAttribute(ATTR_TABLE);
|
||||
if (x.getAlias() != null) {
|
||||
if (table != null) {
|
||||
this.aliasMap.put(x.getAlias(), table);
|
||||
}
|
||||
addSubQuery(x.getAlias(), x.getSelect());
|
||||
}
|
||||
|
||||
if (table != null) {
|
||||
x.putAttribute(ATTR_TABLE, table);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -471,15 +424,6 @@ public class OracleSchemaStatVisitor extends SchemaStatVisitor implements Oracle
|
||||
|
||||
@Override
|
||||
public boolean visit(OracleWithSubqueryEntry x) {
|
||||
Map<String, String> aliasMap = getAliasMap();
|
||||
if (aliasMap != null) {
|
||||
String alias = x.getAlias();
|
||||
|
||||
if (alias != null) {
|
||||
putAliasMap(aliasMap, alias, null);
|
||||
addSubQuery(alias, x.getSubQuery());
|
||||
}
|
||||
}
|
||||
x.getSubQuery().accept(this);
|
||||
return false;
|
||||
}
|
||||
@@ -701,14 +645,6 @@ public class OracleSchemaStatVisitor extends SchemaStatVisitor implements Oracle
|
||||
|
||||
TableStat stat = getTableStat(ident);
|
||||
stat.incrementInsertCount();
|
||||
|
||||
Map<String, String> aliasMap = getAliasMap();
|
||||
if (aliasMap != null) {
|
||||
if (x.getAlias() != null) {
|
||||
putAliasMap(aliasMap, x.getAlias(), ident);
|
||||
}
|
||||
putAliasMap(aliasMap, ident, ident);
|
||||
}
|
||||
}
|
||||
|
||||
accept(x.getColumns());
|
||||
@@ -734,8 +670,6 @@ public class OracleSchemaStatVisitor extends SchemaStatVisitor implements Oracle
|
||||
x.putAttribute("_original_use_mode", getMode());
|
||||
setMode(x, Mode.Insert);
|
||||
|
||||
setAliasMap();
|
||||
|
||||
accept(x.getSubQuery());
|
||||
accept(x.getEntries());
|
||||
|
||||
@@ -1008,12 +942,8 @@ public class OracleSchemaStatVisitor extends SchemaStatVisitor implements Oracle
|
||||
|
||||
@Override
|
||||
public boolean visit(OracleForStatement x) {
|
||||
SQLName index = x.getIndex();
|
||||
this.getVariants().put(index.toString(), x);
|
||||
|
||||
x.getRange().accept(this);
|
||||
accept(x.getStatements());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
-10
@@ -25,8 +25,6 @@ public class PGUpdateStatement extends SQLUpdateStatement implements PGSQLStatem
|
||||
|
||||
private boolean only = false;
|
||||
|
||||
private SQLWithSubqueryClause with;
|
||||
|
||||
public PGUpdateStatement(){
|
||||
super (JdbcConstants.POSTGRESQL);
|
||||
}
|
||||
@@ -39,14 +37,6 @@ public class PGUpdateStatement extends SQLUpdateStatement implements PGSQLStatem
|
||||
this.only = only;
|
||||
}
|
||||
|
||||
public SQLWithSubqueryClause getWith() {
|
||||
return with;
|
||||
}
|
||||
|
||||
public void setWith(SQLWithSubqueryClause with) {
|
||||
this.with = with;
|
||||
}
|
||||
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
accept0((PGASTVisitor) visitor);
|
||||
}
|
||||
|
||||
@@ -54,10 +54,10 @@ public class PGExprParser extends SQLExprParser {
|
||||
|
||||
static {
|
||||
String[] strings = { "AVG", "COUNT", "MAX", "MIN", "STDDEV", "SUM", "ROW_NUMBER" };
|
||||
AGGREGATE_FUNCTIONS_CODES = FnvHash.fnv_64_lower(strings, true);
|
||||
AGGREGATE_FUNCTIONS_CODES = FnvHash.fnv1a_64_lower(strings, true);
|
||||
AGGREGATE_FUNCTIONS = new String[AGGREGATE_FUNCTIONS_CODES.length];
|
||||
for (String str : strings) {
|
||||
long hash = FnvHash.fnv_64_lower(str);
|
||||
long hash = FnvHash.fnv1a_64_lower(str);
|
||||
int index = Arrays.binarySearch(AGGREGATE_FUNCTIONS_CODES, hash);
|
||||
AGGREGATE_FUNCTIONS[index] = str;
|
||||
}
|
||||
|
||||
+1
-24
@@ -101,8 +101,6 @@ public class PGSchemaStatVisitor extends SchemaStatVisitor implements PGASTVisit
|
||||
x.getWith().accept(this);
|
||||
}
|
||||
|
||||
setAliasMap();
|
||||
|
||||
SQLTableSource using = x.getUsing();
|
||||
if (using != null) {
|
||||
using.accept(this);
|
||||
@@ -111,9 +109,7 @@ public class PGSchemaStatVisitor extends SchemaStatVisitor implements PGASTVisit
|
||||
x.putAttribute("_original_use_mode", getMode());
|
||||
setMode(x, Mode.Delete);
|
||||
|
||||
String ident = ((SQLIdentifierExpr) x.getTableName()).getName();
|
||||
|
||||
TableStat stat = getTableStat(ident, x.getAlias());
|
||||
TableStat stat = getTableStat(x.getTableName());
|
||||
stat.incrementDeleteCount();
|
||||
|
||||
accept(x.getWhere());
|
||||
@@ -133,8 +129,6 @@ public class PGSchemaStatVisitor extends SchemaStatVisitor implements PGASTVisit
|
||||
repository.resolve(x);
|
||||
}
|
||||
|
||||
setAliasMap();
|
||||
|
||||
if (x.getWith() != null) {
|
||||
x.getWith().accept(this);
|
||||
}
|
||||
@@ -149,14 +143,6 @@ public class PGSchemaStatVisitor extends SchemaStatVisitor implements PGASTVisit
|
||||
|
||||
TableStat stat = getTableStat(ident);
|
||||
stat.incrementInsertCount();
|
||||
|
||||
Map<String, String> aliasMap = getAliasMap();
|
||||
if (aliasMap != null) {
|
||||
if (x.getAlias() != null) {
|
||||
aliasMap.put(x.getAlias(), ident);
|
||||
}
|
||||
aliasMap.put(ident, ident);
|
||||
}
|
||||
}
|
||||
|
||||
accept(x.getColumns());
|
||||
@@ -191,10 +177,6 @@ public class PGSchemaStatVisitor extends SchemaStatVisitor implements PGASTVisit
|
||||
repository.resolve(x);
|
||||
}
|
||||
|
||||
Map<String, String> oldAliasMap = getAliasMap();
|
||||
|
||||
setAliasMap();
|
||||
|
||||
if (x.getWith() != null) {
|
||||
x.getWith().accept(this);
|
||||
}
|
||||
@@ -206,14 +188,9 @@ public class PGSchemaStatVisitor extends SchemaStatVisitor implements PGASTVisit
|
||||
|
||||
accept(x.getFrom());
|
||||
|
||||
Map<String, String> aliasMap = getAliasMap();
|
||||
aliasMap.put(ident, ident);
|
||||
|
||||
accept(x.getItems());
|
||||
accept(x.getWhere());
|
||||
|
||||
setAliasMap(oldAliasMap);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -44,10 +44,10 @@ public class SQLServerExprParser extends SQLExprParser {
|
||||
|
||||
static {
|
||||
String[] strings = { "AVG", "COUNT", "MAX", "MIN", "ROW_NUMBER", "STDDEV", "SUM" };
|
||||
AGGREGATE_FUNCTIONS_CODES = FnvHash.fnv_64_lower(strings, true);
|
||||
AGGREGATE_FUNCTIONS_CODES = FnvHash.fnv1a_64_lower(strings, true);
|
||||
AGGREGATE_FUNCTIONS = new String[AGGREGATE_FUNCTIONS_CODES.length];
|
||||
for (String str : strings) {
|
||||
long hash = FnvHash.fnv_64_lower(str);
|
||||
long hash = FnvHash.fnv1a_64_lower(str);
|
||||
int index = Arrays.binarySearch(AGGREGATE_FUNCTIONS_CODES, hash);
|
||||
AGGREGATE_FUNCTIONS[index] = str;
|
||||
}
|
||||
|
||||
-5
@@ -84,16 +84,11 @@ public class SQLServerSchemaStatVisitor extends SchemaStatVisitor implements SQL
|
||||
|
||||
@Override
|
||||
public boolean visit(SQLServerUpdateStatement x) {
|
||||
setAliasMap();
|
||||
|
||||
String ident = x.getTableName().toString();
|
||||
|
||||
TableStat stat = getTableStat(ident);
|
||||
stat.incrementUpdateCount();
|
||||
|
||||
Map<String, String> aliasMap = getAliasMap();
|
||||
aliasMap.put(ident, ident);
|
||||
|
||||
accept(x.getItems());
|
||||
accept(x.getFrom());
|
||||
accept(x.getWhere());
|
||||
|
||||
@@ -1529,7 +1529,7 @@ public class Lexer {
|
||||
if (stringVal == null) {
|
||||
stringVal = subString(mark, bufPos);
|
||||
}
|
||||
this.hash_lower = FnvHash.fnv_64_lower(stringVal);
|
||||
this.hash_lower = FnvHash.fnv1a_64_lower(stringVal);
|
||||
}
|
||||
return this.hash_lower == hash_lower;
|
||||
}
|
||||
@@ -1539,7 +1539,7 @@ public class Lexer {
|
||||
if (stringVal == null) {
|
||||
stringVal = subString(mark, bufPos);
|
||||
}
|
||||
this.hash_lower = FnvHash.fnv_64_lower(stringVal);
|
||||
this.hash_lower = FnvHash.fnv1a_64_lower(stringVal);
|
||||
}
|
||||
return hash_lower;
|
||||
}
|
||||
|
||||
@@ -56,10 +56,10 @@ public class SQLExprParser extends SQLParser {
|
||||
|
||||
static {
|
||||
String[] strings = { "AVG", "COUNT", "MAX", "MIN", "STDDEV", "SUM" };
|
||||
AGGREGATE_FUNCTIONS_CODES = FnvHash.fnv_64_lower(strings, true);
|
||||
AGGREGATE_FUNCTIONS_CODES = FnvHash.fnv1a_64_lower(strings, true);
|
||||
AGGREGATE_FUNCTIONS = new String[AGGREGATE_FUNCTIONS_CODES.length];
|
||||
for (String str : strings) {
|
||||
long hash = FnvHash.fnv_64_lower(str);
|
||||
long hash = FnvHash.fnv1a_64_lower(str);
|
||||
int index = Arrays.binarySearch(AGGREGATE_FUNCTIONS_CODES, hash);
|
||||
AGGREGATE_FUNCTIONS[index] = str;
|
||||
}
|
||||
@@ -896,7 +896,6 @@ public class SQLExprParser extends SQLParser {
|
||||
}
|
||||
|
||||
String methodName = null;
|
||||
boolean isAggregate = false;
|
||||
String aggMethodName = null;
|
||||
SQLMethodInvokeExpr methodInvokeExpr;
|
||||
SQLExpr owner = null;
|
||||
@@ -933,7 +932,7 @@ public class SQLExprParser extends SQLParser {
|
||||
} else if (expr instanceof SQLPropertyExpr) {
|
||||
methodName = expr.toString();
|
||||
aggMethodName = SQLUtils.normalize(methodName);
|
||||
hash_lower = FnvHash.fnv_64_lower(aggMethodName);
|
||||
hash_lower = FnvHash.fnv1a_64_lower(aggMethodName);
|
||||
aggMethodName = getAggreateFunction(hash_lower);
|
||||
|
||||
owner = ((SQLPropertyExpr) expr).getOwner();
|
||||
@@ -1229,7 +1228,7 @@ public class SQLExprParser extends SQLParser {
|
||||
}
|
||||
|
||||
public boolean isAggreateFunction(String word) {
|
||||
long hash_lower = FnvHash.fnv_64_lower(word);
|
||||
long hash_lower = FnvHash.fnv1a_64_lower(word);
|
||||
return isAggreateFunction(hash_lower);
|
||||
}
|
||||
|
||||
@@ -1296,7 +1295,7 @@ public class SQLExprParser extends SQLParser {
|
||||
|
||||
if (lexer.token == Token.OF) {
|
||||
lexer.nextToken();
|
||||
SQLExpr of = this.expr();
|
||||
SQLName of = this.name();
|
||||
over.setOf(of);
|
||||
}
|
||||
|
||||
|
||||
@@ -203,6 +203,11 @@ class SchemaResolveVisitorFactory {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean visit(SQLOver x) {
|
||||
resolve(this, x);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(Option option) {
|
||||
return (options & option.mask) != 0;
|
||||
@@ -346,6 +351,11 @@ class SchemaResolveVisitorFactory {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean visit(SQLOver x) {
|
||||
resolve(this, x);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(Option option) {
|
||||
return (options & option.mask) != 0;
|
||||
@@ -397,12 +407,28 @@ class SchemaResolveVisitorFactory {
|
||||
public boolean visit(OracleForStatement x) {
|
||||
Context ctx = createContext(x);
|
||||
|
||||
SQLExpr index = x.getIndex();
|
||||
SQLName index = x.getIndex();
|
||||
SQLExpr range = x.getRange();
|
||||
|
||||
if (index != null) {
|
||||
SQLDeclareItem declareItem = new SQLDeclareItem(index, null);
|
||||
declareItem.setParent(x);
|
||||
|
||||
if (index instanceof SQLIdentifierExpr) {
|
||||
((SQLIdentifierExpr) index).setResolvedDeclareItem(declareItem);
|
||||
}
|
||||
declareItem.setResolvedObject(range);
|
||||
ctx.declare(declareItem);
|
||||
if (range instanceof SQLQueryExpr) {
|
||||
SQLSelect select = ((SQLQueryExpr) range).getSubQuery();
|
||||
SQLSubqueryTableSource tableSource = new SQLSubqueryTableSource(select);
|
||||
declareItem.setResolvedObject(tableSource);
|
||||
}
|
||||
|
||||
index.accept(this);
|
||||
}
|
||||
|
||||
SQLExpr range = x.getRange();
|
||||
|
||||
if (range != null) {
|
||||
range.accept(this);
|
||||
}
|
||||
@@ -583,6 +609,11 @@ class SchemaResolveVisitorFactory {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean visit(SQLOver x) {
|
||||
resolve(this, x);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(Option option) {
|
||||
return (options & option.mask) != 0;
|
||||
@@ -751,6 +782,11 @@ class SchemaResolveVisitorFactory {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean visit(SQLOver x) {
|
||||
resolve(this, x);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(Option option) {
|
||||
return (options & option.mask) != 0;
|
||||
@@ -930,6 +966,11 @@ class SchemaResolveVisitorFactory {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean visit(SQLOver x) {
|
||||
resolve(this, x);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(Option option) {
|
||||
return (options & option.mask) != 0;
|
||||
@@ -1081,6 +1122,11 @@ class SchemaResolveVisitorFactory {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean visit(SQLOver x) {
|
||||
resolve(this, x);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(Option option) {
|
||||
return (options & option.mask) != 0;
|
||||
@@ -1217,6 +1263,11 @@ class SchemaResolveVisitorFactory {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean visit(SQLOver x) {
|
||||
resolve(this, x);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled(Option option) {
|
||||
return (options & option.mask) != 0;
|
||||
@@ -1297,6 +1348,11 @@ class SchemaResolveVisitorFactory {
|
||||
static void resolve(SchemaResolveVisitor visitor, SQLUpdateStatement x) {
|
||||
SchemaResolveVisitor.Context ctx = visitor.createContext(x);
|
||||
|
||||
SQLWithSubqueryClause with = x.getWith();
|
||||
if (with != null) {
|
||||
with.accept(visitor);
|
||||
}
|
||||
|
||||
SQLTableSource table = x.getTableSource();
|
||||
SQLTableSource from = x.getFrom();
|
||||
|
||||
@@ -1453,7 +1509,7 @@ class SchemaResolveVisitorFactory {
|
||||
&& right instanceof SQLExprTableSource) {
|
||||
SQLSelect leftSelect = ((SQLSubqueryTableSource) left).getSelect();
|
||||
if (leftSelect.getQuery() instanceof SQLSelectQueryBlock) {
|
||||
boolean hasAllColumn = ((SQLSelectQueryBlock) leftSelect.getQuery()).selectItemHashAllColumn();
|
||||
boolean hasAllColumn = ((SQLSelectQueryBlock) leftSelect.getQuery()).selectItemHasAllColumn();
|
||||
if (!hasAllColumn) {
|
||||
tableSource = right;
|
||||
}
|
||||
@@ -1462,7 +1518,7 @@ class SchemaResolveVisitorFactory {
|
||||
&& left instanceof SQLExprTableSource) {
|
||||
SQLSelect rightSelect = ((SQLSubqueryTableSource) right).getSelect();
|
||||
if (rightSelect.getQuery() instanceof SQLSelectQueryBlock) {
|
||||
boolean hasAllColumn = ((SQLSelectQueryBlock) rightSelect.getQuery()).selectItemHashAllColumn();
|
||||
boolean hasAllColumn = ((SQLSelectQueryBlock) rightSelect.getQuery()).selectItemHasAllColumn();
|
||||
if (!hasAllColumn) {
|
||||
tableSource = left;
|
||||
}
|
||||
@@ -1629,8 +1685,10 @@ class SchemaResolveVisitorFactory {
|
||||
SQLDeclareItem declareItem = parentCtx.findDeclare(owner_hash);
|
||||
if (declareItem != null) {
|
||||
SQLObject resolvedObject = declareItem.getResolvedObject();
|
||||
if (resolvedObject instanceof SQLCreateProcedureStatement) {
|
||||
x.setResolvedProcedure((SQLCreateProcedureStatement) resolvedObject);
|
||||
if (resolvedObject instanceof SQLCreateProcedureStatement
|
||||
|| resolvedObject instanceof SQLCreateFunctionStatement
|
||||
|| resolvedObject instanceof SQLTableSource) {
|
||||
x.setResolvedOwnerObject(resolvedObject);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1661,7 +1719,7 @@ class SchemaResolveVisitorFactory {
|
||||
}
|
||||
}
|
||||
|
||||
for (SchemaResolveVisitor.Context parentCtx = ctx.parent;
|
||||
for (SchemaResolveVisitor.Context parentCtx = ctx;
|
||||
parentCtx != null;
|
||||
parentCtx = parentCtx.parent) {
|
||||
|
||||
@@ -1675,6 +1733,9 @@ class SchemaResolveVisitorFactory {
|
||||
} else if (parentCtx.object instanceof SQLInsertStatement) {
|
||||
SQLInsertStatement insertStmt = (SQLInsertStatement) parentCtx.object;
|
||||
with = insertStmt.getWith();
|
||||
} else if (parentCtx.object instanceof SQLUpdateStatement) {
|
||||
SQLUpdateStatement updateStmt = (SQLUpdateStatement) parentCtx.object;
|
||||
with = updateStmt.getWith();
|
||||
}
|
||||
|
||||
if (with != null) {
|
||||
@@ -2082,17 +2143,20 @@ class SchemaResolveVisitorFactory {
|
||||
}
|
||||
|
||||
static void resolve(SchemaResolveVisitor visitor, SQLCreateFunctionStatement x) {
|
||||
SchemaResolveVisitor.Context ctx = visitor.createContext(x);
|
||||
|
||||
{
|
||||
SQLDeclareItem declareItem = new SQLDeclareItem(x.getName().clone(), null);
|
||||
declareItem.setResolvedObject(x);
|
||||
|
||||
SchemaResolveVisitor.Context parentCtx = visitor.getContext();
|
||||
if (parentCtx != null) {
|
||||
SQLDeclareItem declareItem = new SQLDeclareItem(x.getName().clone(), null);
|
||||
declareItem.setResolvedObject(x);
|
||||
parentCtx.declare(declareItem);
|
||||
} else {
|
||||
ctx.declare(declareItem);
|
||||
}
|
||||
}
|
||||
|
||||
SchemaResolveVisitor.Context ctx = visitor.createContext(x);
|
||||
|
||||
for (SQLParameter parameter : x.getParameters()) {
|
||||
parameter.accept(visitor);
|
||||
}
|
||||
@@ -2105,17 +2169,21 @@ class SchemaResolveVisitorFactory {
|
||||
visitor.popContext();
|
||||
}
|
||||
static void resolve(SchemaResolveVisitor visitor, SQLCreateProcedureStatement x) {
|
||||
SchemaResolveVisitor.Context ctx = visitor.createContext(x);
|
||||
|
||||
{
|
||||
SQLDeclareItem declareItem = new SQLDeclareItem(x.getName().clone(), null);
|
||||
declareItem.setResolvedObject(x);
|
||||
|
||||
|
||||
SchemaResolveVisitor.Context parentCtx = visitor.getContext();
|
||||
if (parentCtx != null) {
|
||||
SQLDeclareItem declareItem = new SQLDeclareItem(x.getName().clone(), null);
|
||||
declareItem.setResolvedObject(x);
|
||||
parentCtx.declare(declareItem);
|
||||
} else {
|
||||
ctx.declare(declareItem);
|
||||
}
|
||||
}
|
||||
|
||||
SchemaResolveVisitor.Context ctx = visitor.createContext(x);
|
||||
|
||||
for (SQLParameter parameter : x.getParameters()) {
|
||||
parameter.accept(visitor);
|
||||
}
|
||||
@@ -2212,6 +2280,23 @@ class SchemaResolveVisitorFactory {
|
||||
}
|
||||
}
|
||||
|
||||
static void resolve(SchemaResolveVisitor visitor, SQLOver x) {
|
||||
SQLName of = x.getOf();
|
||||
SQLOrderBy orderBy = x.getOrderBy();
|
||||
List<SQLExpr> partitionBy = x.getPartitionBy();
|
||||
|
||||
|
||||
if (of == null // skip if of is not null
|
||||
&& orderBy != null) {
|
||||
orderBy.accept(visitor);
|
||||
}
|
||||
|
||||
if (partitionBy != null) {
|
||||
for (SQLExpr expr : partitionBy) {
|
||||
expr.accept(visitor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean checkParameter(SchemaResolveVisitor visitor, SQLIdentifierExpr x) {
|
||||
if (x.getResolvedParameter() != null) {
|
||||
@@ -2245,6 +2330,24 @@ class SchemaResolveVisitorFactory {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (parentCtx.object instanceof SQLSelect) {
|
||||
SQLSelect select = (SQLSelect) parentCtx.object;
|
||||
SQLWithSubqueryClause with = select.getWithSubQuery();
|
||||
if (with != null) {
|
||||
SQLWithSubqueryClause.Entry entry = with.findEntry(hash);
|
||||
if (entry != null) {
|
||||
x.setResolvedTableSource(entry);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SQLDeclareItem declareItem = parentCtx.findDeclare(hash);
|
||||
if (declareItem != null) {
|
||||
x.setResolvedDeclareItem(declareItem);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -436,7 +436,7 @@ public class TableStat {
|
||||
SQLExpr owner = SQLUtils.toSQLExpr(table, dbType);
|
||||
hashCode64 = new SQLPropertyExpr(owner, name).hashCode64();
|
||||
} else {
|
||||
hashCode64 = FnvHash.fnv_64_lower(table, name);
|
||||
hashCode64 = FnvHash.hashCode64(table, name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,148 +15,146 @@
|
||||
*/
|
||||
package com.alibaba.druid.util;
|
||||
|
||||
import static com.alibaba.druid.util.FnvHash.fnv_64_lower;
|
||||
|
||||
public interface FnvConstants {
|
||||
long HIGH_PRIORITY = fnv_64_lower("HIGH_PRIORITY");
|
||||
long DISTINCTROW = fnv_64_lower("DISTINCTROW");
|
||||
long STRAIGHT_JOIN = fnv_64_lower("STRAIGHT_JOIN");
|
||||
long SQL_SMALL_RESULT = fnv_64_lower("SQL_SMALL_RESULT");
|
||||
long SQL_BIG_RESULT = fnv_64_lower("SQL_BIG_RESULT");
|
||||
long SQL_BUFFER_RESULT = fnv_64_lower("SQL_BUFFER_RESULT");
|
||||
long SQL_CACHE = fnv_64_lower("SQL_CACHE");
|
||||
long SQL_NO_CACHE = fnv_64_lower("SQL_NO_CACHE");
|
||||
long SQL_CALC_FOUND_ROWS = fnv_64_lower("SQL_CALC_FOUND_ROWS");
|
||||
long OUTFILE = fnv_64_lower("OUTFILE");
|
||||
long SETS = fnv_64_lower("SETS");
|
||||
long REGEXP = fnv_64_lower("REGEXP");
|
||||
long RLIKE = fnv_64_lower("RLIKE");
|
||||
long USING = fnv_64_lower("USING");
|
||||
long IGNORE = fnv_64_lower("IGNORE");
|
||||
long FORCE = fnv_64_lower("FORCE");
|
||||
long CROSS = fnv_64_lower("CROSS");
|
||||
long NATURAL = fnv_64_lower("NATURAL");
|
||||
long APPLY = fnv_64_lower("APPLY");
|
||||
long CONNECT = fnv_64_lower("CONNECT");
|
||||
long START = fnv_64_lower("START");
|
||||
long BTREE = fnv_64_lower("BTREE");
|
||||
long HASH = fnv_64_lower("HASH");
|
||||
long NO_WAIT = fnv_64_lower("NO_WAIT");
|
||||
long WAIT = fnv_64_lower("WAIT");
|
||||
long NOWAIT = fnv_64_lower("NOWAIT");
|
||||
long ERRORS = fnv_64_lower("ERRORS");
|
||||
long VALUE = fnv_64_lower("VALUE");
|
||||
long NEXT = fnv_64_lower("NEXT");
|
||||
long NEXTVAL = fnv_64_lower("NEXTVAL");
|
||||
long CURRVAL = fnv_64_lower("CURRVAL");
|
||||
long PREVVAL = fnv_64_lower("PREVVAL");
|
||||
long PREVIOUS = fnv_64_lower("PREVIOUS");
|
||||
long LOW_PRIORITY = fnv_64_lower("LOW_PRIORITY");
|
||||
long COMMIT_ON_SUCCESS = fnv_64_lower("COMMIT_ON_SUCCESS");
|
||||
long ROLLBACK_ON_FAIL = fnv_64_lower("ROLLBACK_ON_FAIL");
|
||||
long QUEUE_ON_PK = fnv_64_lower("QUEUE_ON_PK");
|
||||
long TARGET_AFFECT_ROW = fnv_64_lower("TARGET_AFFECT_ROW");
|
||||
long COLLATE = fnv_64_lower("COLLATE");
|
||||
long BOOLEAN = fnv_64_lower("BOOLEAN");
|
||||
long CHARSET = fnv_64_lower("CHARSET");
|
||||
long SEMI = fnv_64_lower("SEMI");
|
||||
long ANTI = fnv_64_lower("ANTI");
|
||||
long PRIOR = fnv_64_lower("PRIOR");
|
||||
long NOCYCLE = fnv_64_lower("NOCYCLE");
|
||||
long CONNECT_BY_ROOT = fnv_64_lower("CONNECT_BY_ROOT");
|
||||
long DATE = fnv_64_lower("DATE");
|
||||
long TIMESTAMP = fnv_64_lower("TIMESTAMP");
|
||||
long CURRENT = fnv_64_lower("CURRENT");
|
||||
long COUNT = fnv_64_lower("COUNT");
|
||||
long ROW_NUMBER = fnv_64_lower("ROW_NUMBER");
|
||||
long WM_CONAT = fnv_64_lower("WM_CONAT");
|
||||
long AVG = fnv_64_lower("AVG");
|
||||
long MAX = fnv_64_lower("MAX");
|
||||
long MIN = fnv_64_lower("MIN");
|
||||
long STDDEV = fnv_64_lower("STDDEV");
|
||||
long SUM = fnv_64_lower("SUM");
|
||||
long GROUP_CONCAT = fnv_64_lower("GROUP_CONCAT");
|
||||
long DEDUPLICATION = fnv_64_lower("DEDUPLICATION");
|
||||
long CONVERT = fnv_64_lower("CONVERT");
|
||||
long CHAR = fnv_64_lower("CHAR");
|
||||
long VARCHAR = fnv_64_lower("VARCHAR");
|
||||
long VARCHAR2 = fnv_64_lower("VARCHAR2");
|
||||
long NCHAR = fnv_64_lower("NCHAR");
|
||||
long NVARCHAR = fnv_64_lower("NVARCHAR");
|
||||
long NVARCHAR2 = fnv_64_lower("NVARCHAR2");
|
||||
long TINYTEXT = fnv_64_lower("TINYTEXT");
|
||||
long TEXT = fnv_64_lower("TEXT");
|
||||
long MEDIUMTEXT = fnv_64_lower("MEDIUMTEXT");
|
||||
long LONGTEXT = fnv_64_lower("LONGTEXT");
|
||||
long TRIM = fnv_64_lower("TRIM");
|
||||
long LEADING = fnv_64_lower("LEADING");
|
||||
long BOTH = fnv_64_lower("BOTH");
|
||||
long TRAILING = fnv_64_lower("TRAILING");
|
||||
long MOD = fnv_64_lower("MOD");
|
||||
long MATCH = fnv_64_lower("MATCH");
|
||||
long EXTRACT = fnv_64_lower("EXTRACT");
|
||||
long POSITION = fnv_64_lower("POSITION");
|
||||
long DUAL = fnv_64_lower("DUAL");
|
||||
long LEVEL = fnv_64_lower("LEVEL");
|
||||
long CONNECT_BY_ISCYCLE = fnv_64_lower("CONNECT_BY_ISCYCLE");
|
||||
long CURRENT_TIMESTAMP = fnv_64_lower("CURRENT_TIMESTAMP");
|
||||
long FALSE = fnv_64_lower("FALSE");
|
||||
long TRUE = fnv_64_lower("TRUE");
|
||||
long SET = fnv_64_lower("SET");
|
||||
long LESS = fnv_64_lower("LESS");
|
||||
long MAXVALUE = fnv_64_lower("MAXVALUE");
|
||||
long OFFSET = fnv_64_lower("OFFSET");
|
||||
long RAW = fnv_64_lower("RAW");
|
||||
long LONG = fnv_64_lower("LONG");
|
||||
long ROWNUM = fnv_64_lower("ROWNUM");
|
||||
long PRECISION = fnv_64_lower("PRECISION");
|
||||
long DOUBLE = fnv_64_lower("DOUBLE");
|
||||
long WITHOUT = fnv_64_lower("WITHOUT");
|
||||
long HIGH_PRIORITY = FnvHash.fnv1a_64_lower("HIGH_PRIORITY");
|
||||
long DISTINCTROW = FnvHash.fnv1a_64_lower("DISTINCTROW");
|
||||
long STRAIGHT_JOIN = FnvHash.fnv1a_64_lower("STRAIGHT_JOIN");
|
||||
long SQL_SMALL_RESULT = FnvHash.fnv1a_64_lower("SQL_SMALL_RESULT");
|
||||
long SQL_BIG_RESULT = FnvHash.fnv1a_64_lower("SQL_BIG_RESULT");
|
||||
long SQL_BUFFER_RESULT = FnvHash.fnv1a_64_lower("SQL_BUFFER_RESULT");
|
||||
long SQL_CACHE = FnvHash.fnv1a_64_lower("SQL_CACHE");
|
||||
long SQL_NO_CACHE = FnvHash.fnv1a_64_lower("SQL_NO_CACHE");
|
||||
long SQL_CALC_FOUND_ROWS = FnvHash.fnv1a_64_lower("SQL_CALC_FOUND_ROWS");
|
||||
long OUTFILE = FnvHash.fnv1a_64_lower("OUTFILE");
|
||||
long SETS = FnvHash.fnv1a_64_lower("SETS");
|
||||
long REGEXP = FnvHash.fnv1a_64_lower("REGEXP");
|
||||
long RLIKE = FnvHash.fnv1a_64_lower("RLIKE");
|
||||
long USING = FnvHash.fnv1a_64_lower("USING");
|
||||
long IGNORE = FnvHash.fnv1a_64_lower("IGNORE");
|
||||
long FORCE = FnvHash.fnv1a_64_lower("FORCE");
|
||||
long CROSS = FnvHash.fnv1a_64_lower("CROSS");
|
||||
long NATURAL = FnvHash.fnv1a_64_lower("NATURAL");
|
||||
long APPLY = FnvHash.fnv1a_64_lower("APPLY");
|
||||
long CONNECT = FnvHash.fnv1a_64_lower("CONNECT");
|
||||
long START = FnvHash.fnv1a_64_lower("START");
|
||||
long BTREE = FnvHash.fnv1a_64_lower("BTREE");
|
||||
long HASH = FnvHash.fnv1a_64_lower("HASH");
|
||||
long NO_WAIT = FnvHash.fnv1a_64_lower("NO_WAIT");
|
||||
long WAIT = FnvHash.fnv1a_64_lower("WAIT");
|
||||
long NOWAIT = FnvHash.fnv1a_64_lower("NOWAIT");
|
||||
long ERRORS = FnvHash.fnv1a_64_lower("ERRORS");
|
||||
long VALUE = FnvHash.fnv1a_64_lower("VALUE");
|
||||
long NEXT = FnvHash.fnv1a_64_lower("NEXT");
|
||||
long NEXTVAL = FnvHash.fnv1a_64_lower("NEXTVAL");
|
||||
long CURRVAL = FnvHash.fnv1a_64_lower("CURRVAL");
|
||||
long PREVVAL = FnvHash.fnv1a_64_lower("PREVVAL");
|
||||
long PREVIOUS = FnvHash.fnv1a_64_lower("PREVIOUS");
|
||||
long LOW_PRIORITY = FnvHash.fnv1a_64_lower("LOW_PRIORITY");
|
||||
long COMMIT_ON_SUCCESS = FnvHash.fnv1a_64_lower("COMMIT_ON_SUCCESS");
|
||||
long ROLLBACK_ON_FAIL = FnvHash.fnv1a_64_lower("ROLLBACK_ON_FAIL");
|
||||
long QUEUE_ON_PK = FnvHash.fnv1a_64_lower("QUEUE_ON_PK");
|
||||
long TARGET_AFFECT_ROW = FnvHash.fnv1a_64_lower("TARGET_AFFECT_ROW");
|
||||
long COLLATE = FnvHash.fnv1a_64_lower("COLLATE");
|
||||
long BOOLEAN = FnvHash.fnv1a_64_lower("BOOLEAN");
|
||||
long CHARSET = FnvHash.fnv1a_64_lower("CHARSET");
|
||||
long SEMI = FnvHash.fnv1a_64_lower("SEMI");
|
||||
long ANTI = FnvHash.fnv1a_64_lower("ANTI");
|
||||
long PRIOR = FnvHash.fnv1a_64_lower("PRIOR");
|
||||
long NOCYCLE = FnvHash.fnv1a_64_lower("NOCYCLE");
|
||||
long CONNECT_BY_ROOT = FnvHash.fnv1a_64_lower("CONNECT_BY_ROOT");
|
||||
long DATE = FnvHash.fnv1a_64_lower("DATE");
|
||||
long TIMESTAMP = FnvHash.fnv1a_64_lower("TIMESTAMP");
|
||||
long CURRENT = FnvHash.fnv1a_64_lower("CURRENT");
|
||||
long COUNT = FnvHash.fnv1a_64_lower("COUNT");
|
||||
long ROW_NUMBER = FnvHash.fnv1a_64_lower("ROW_NUMBER");
|
||||
long WM_CONAT = FnvHash.fnv1a_64_lower("WM_CONAT");
|
||||
long AVG = FnvHash.fnv1a_64_lower("AVG");
|
||||
long MAX = FnvHash.fnv1a_64_lower("MAX");
|
||||
long MIN = FnvHash.fnv1a_64_lower("MIN");
|
||||
long STDDEV = FnvHash.fnv1a_64_lower("STDDEV");
|
||||
long SUM = FnvHash.fnv1a_64_lower("SUM");
|
||||
long GROUP_CONCAT = FnvHash.fnv1a_64_lower("GROUP_CONCAT");
|
||||
long DEDUPLICATION = FnvHash.fnv1a_64_lower("DEDUPLICATION");
|
||||
long CONVERT = FnvHash.fnv1a_64_lower("CONVERT");
|
||||
long CHAR = FnvHash.fnv1a_64_lower("CHAR");
|
||||
long VARCHAR = FnvHash.fnv1a_64_lower("VARCHAR");
|
||||
long VARCHAR2 = FnvHash.fnv1a_64_lower("VARCHAR2");
|
||||
long NCHAR = FnvHash.fnv1a_64_lower("NCHAR");
|
||||
long NVARCHAR = FnvHash.fnv1a_64_lower("NVARCHAR");
|
||||
long NVARCHAR2 = FnvHash.fnv1a_64_lower("NVARCHAR2");
|
||||
long TINYTEXT = FnvHash.fnv1a_64_lower("TINYTEXT");
|
||||
long TEXT = FnvHash.fnv1a_64_lower("TEXT");
|
||||
long MEDIUMTEXT = FnvHash.fnv1a_64_lower("MEDIUMTEXT");
|
||||
long LONGTEXT = FnvHash.fnv1a_64_lower("LONGTEXT");
|
||||
long TRIM = FnvHash.fnv1a_64_lower("TRIM");
|
||||
long LEADING = FnvHash.fnv1a_64_lower("LEADING");
|
||||
long BOTH = FnvHash.fnv1a_64_lower("BOTH");
|
||||
long TRAILING = FnvHash.fnv1a_64_lower("TRAILING");
|
||||
long MOD = FnvHash.fnv1a_64_lower("MOD");
|
||||
long MATCH = FnvHash.fnv1a_64_lower("MATCH");
|
||||
long EXTRACT = FnvHash.fnv1a_64_lower("EXTRACT");
|
||||
long POSITION = FnvHash.fnv1a_64_lower("POSITION");
|
||||
long DUAL = FnvHash.fnv1a_64_lower("DUAL");
|
||||
long LEVEL = FnvHash.fnv1a_64_lower("LEVEL");
|
||||
long CONNECT_BY_ISCYCLE = FnvHash.fnv1a_64_lower("CONNECT_BY_ISCYCLE");
|
||||
long CURRENT_TIMESTAMP = FnvHash.fnv1a_64_lower("CURRENT_TIMESTAMP");
|
||||
long FALSE = FnvHash.fnv1a_64_lower("FALSE");
|
||||
long TRUE = FnvHash.fnv1a_64_lower("TRUE");
|
||||
long SET = FnvHash.fnv1a_64_lower("SET");
|
||||
long LESS = FnvHash.fnv1a_64_lower("LESS");
|
||||
long MAXVALUE = FnvHash.fnv1a_64_lower("MAXVALUE");
|
||||
long OFFSET = FnvHash.fnv1a_64_lower("OFFSET");
|
||||
long RAW = FnvHash.fnv1a_64_lower("RAW");
|
||||
long LONG = FnvHash.fnv1a_64_lower("LONG");
|
||||
long ROWNUM = FnvHash.fnv1a_64_lower("ROWNUM");
|
||||
long PRECISION = FnvHash.fnv1a_64_lower("PRECISION");
|
||||
long DOUBLE = FnvHash.fnv1a_64_lower("DOUBLE");
|
||||
long WITHOUT = FnvHash.fnv1a_64_lower("WITHOUT");
|
||||
|
||||
long DEFINER = fnv_64_lower("DEFINER");
|
||||
long DETERMINISTIC = fnv_64_lower("DETERMINISTIC");
|
||||
long CONTAINS = fnv_64_lower("CONTAINS");
|
||||
long SQL = fnv_64_lower("SQL");
|
||||
long CALL = fnv_64_lower("CALL");
|
||||
long CHARACTER = fnv_64_lower("CHARACTER");
|
||||
long DEFINER = FnvHash.fnv1a_64_lower("DEFINER");
|
||||
long DETERMINISTIC = FnvHash.fnv1a_64_lower("DETERMINISTIC");
|
||||
long CONTAINS = FnvHash.fnv1a_64_lower("CONTAINS");
|
||||
long SQL = FnvHash.fnv1a_64_lower("SQL");
|
||||
long CALL = FnvHash.fnv1a_64_lower("CALL");
|
||||
long CHARACTER = FnvHash.fnv1a_64_lower("CHARACTER");
|
||||
|
||||
long VALIDATE = fnv_64_lower("VALIDATE");
|
||||
long NOVALIDATE = fnv_64_lower("NOVALIDATE");
|
||||
long SIMILAR = fnv_64_lower("SIMILAR");
|
||||
long CASCADE = fnv_64_lower("CASCADE");
|
||||
long RELY = fnv_64_lower("RELY");
|
||||
long NORELY = fnv_64_lower("NORELY");
|
||||
long ROW = fnv_64_lower("ROW");
|
||||
long ROWS = fnv_64_lower("ROWS");
|
||||
long RANGE = fnv_64_lower("RANGE");
|
||||
long PRECEDING = fnv_64_lower("PRECEDING");
|
||||
long FOLLOWING = fnv_64_lower("FOLLOWING");
|
||||
long UNBOUNDED = fnv_64_lower("UNBOUNDED");
|
||||
long SIBLINGS = fnv_64_lower("SIBLINGS");
|
||||
long NULLS = fnv_64_lower("NULLS");
|
||||
long FIRST = fnv_64_lower("FIRST");
|
||||
long LAST = fnv_64_lower("LAST");
|
||||
long AUTO_INCREMENT = fnv_64_lower("AUTO_INCREMENT");
|
||||
long STORAGE = fnv_64_lower("STORAGE");
|
||||
long STORED = fnv_64_lower("STORED");
|
||||
long VIRTUAL = fnv_64_lower("VIRTUAL");
|
||||
long UNSIGNED = fnv_64_lower("UNSIGNED");
|
||||
long ZEROFILL = fnv_64_lower("ZEROFILL");
|
||||
long GLOBAL = fnv_64_lower("GLOBAL");
|
||||
long SESSION = fnv_64_lower("SESSION");
|
||||
long NAMES = fnv_64_lower("NAMES");
|
||||
long PARTIAL = fnv_64_lower("PARTIAL");
|
||||
long SIMPLE = fnv_64_lower("SIMPLE");
|
||||
long RESTRICT = fnv_64_lower("RESTRICT");
|
||||
long ON = fnv_64_lower("ON");
|
||||
long ACTION = fnv_64_lower("ACTION");
|
||||
long SEPARATOR = fnv_64_lower("SEPARATOR");
|
||||
long DATA = fnv_64_lower("DATA");
|
||||
long MAX_ROWS = fnv_64_lower("MAX_ROWS");
|
||||
long MIN_ROWS = fnv_64_lower("MIN_ROWS");
|
||||
long ENGINE = fnv_64_lower("ENGINE");
|
||||
long SKIP = fnv_64_lower("SKIP");
|
||||
long RECURSIVE = fnv_64_lower("RECURSIVE");
|
||||
long ROLLUP = fnv_64_lower("ROLLUP");
|
||||
long CUBE = fnv_64_lower("CUBE");
|
||||
long VALIDATE = FnvHash.fnv1a_64_lower("VALIDATE");
|
||||
long NOVALIDATE = FnvHash.fnv1a_64_lower("NOVALIDATE");
|
||||
long SIMILAR = FnvHash.fnv1a_64_lower("SIMILAR");
|
||||
long CASCADE = FnvHash.fnv1a_64_lower("CASCADE");
|
||||
long RELY = FnvHash.fnv1a_64_lower("RELY");
|
||||
long NORELY = FnvHash.fnv1a_64_lower("NORELY");
|
||||
long ROW = FnvHash.fnv1a_64_lower("ROW");
|
||||
long ROWS = FnvHash.fnv1a_64_lower("ROWS");
|
||||
long RANGE = FnvHash.fnv1a_64_lower("RANGE");
|
||||
long PRECEDING = FnvHash.fnv1a_64_lower("PRECEDING");
|
||||
long FOLLOWING = FnvHash.fnv1a_64_lower("FOLLOWING");
|
||||
long UNBOUNDED = FnvHash.fnv1a_64_lower("UNBOUNDED");
|
||||
long SIBLINGS = FnvHash.fnv1a_64_lower("SIBLINGS");
|
||||
long NULLS = FnvHash.fnv1a_64_lower("NULLS");
|
||||
long FIRST = FnvHash.fnv1a_64_lower("FIRST");
|
||||
long LAST = FnvHash.fnv1a_64_lower("LAST");
|
||||
long AUTO_INCREMENT = FnvHash.fnv1a_64_lower("AUTO_INCREMENT");
|
||||
long STORAGE = FnvHash.fnv1a_64_lower("STORAGE");
|
||||
long STORED = FnvHash.fnv1a_64_lower("STORED");
|
||||
long VIRTUAL = FnvHash.fnv1a_64_lower("VIRTUAL");
|
||||
long UNSIGNED = FnvHash.fnv1a_64_lower("UNSIGNED");
|
||||
long ZEROFILL = FnvHash.fnv1a_64_lower("ZEROFILL");
|
||||
long GLOBAL = FnvHash.fnv1a_64_lower("GLOBAL");
|
||||
long SESSION = FnvHash.fnv1a_64_lower("SESSION");
|
||||
long NAMES = FnvHash.fnv1a_64_lower("NAMES");
|
||||
long PARTIAL = FnvHash.fnv1a_64_lower("PARTIAL");
|
||||
long SIMPLE = FnvHash.fnv1a_64_lower("SIMPLE");
|
||||
long RESTRICT = FnvHash.fnv1a_64_lower("RESTRICT");
|
||||
long ON = FnvHash.fnv1a_64_lower("ON");
|
||||
long ACTION = FnvHash.fnv1a_64_lower("ACTION");
|
||||
long SEPARATOR = FnvHash.fnv1a_64_lower("SEPARATOR");
|
||||
long DATA = FnvHash.fnv1a_64_lower("DATA");
|
||||
long MAX_ROWS = FnvHash.fnv1a_64_lower("MAX_ROWS");
|
||||
long MIN_ROWS = FnvHash.fnv1a_64_lower("MIN_ROWS");
|
||||
long ENGINE = FnvHash.fnv1a_64_lower("ENGINE");
|
||||
long SKIP = FnvHash.fnv1a_64_lower("SKIP");
|
||||
long RECURSIVE = FnvHash.fnv1a_64_lower("RECURSIVE");
|
||||
long ROLLUP = FnvHash.fnv1a_64_lower("ROLLUP");
|
||||
long CUBE = FnvHash.fnv1a_64_lower("CUBE");
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public final class FnvHash {
|
||||
public final static long BASIC = 0xcbf29ce484222325L;
|
||||
public final static long PRIME = 0x100000001b3L;
|
||||
|
||||
public static long fnv_64(String input) {
|
||||
public static long fnv1a_64(String input) {
|
||||
if (input == null) {
|
||||
return 0;
|
||||
}
|
||||
@@ -68,7 +68,7 @@ public final class FnvHash {
|
||||
}
|
||||
}
|
||||
|
||||
public static long fnv_64_lower(String key) {
|
||||
public static long fnv1a_64_lower(String key) {
|
||||
long hashCode = BASIC;
|
||||
for (int i = 0; i < key.length(); ++i) {
|
||||
char ch = key.charAt(i);
|
||||
@@ -156,10 +156,10 @@ public final class FnvHash {
|
||||
return hashCode;
|
||||
}
|
||||
|
||||
public static long[] fnv_64_lower(String[] strings, boolean sort) {
|
||||
public static long[] fnv1a_64_lower(String[] strings, boolean sort) {
|
||||
long[] hashCodes = new long[strings.length];
|
||||
for (int i = 0; i < strings.length; i++) {
|
||||
hashCodes[i] = fnv_64_lower(strings[i]);
|
||||
hashCodes[i] = fnv1a_64_lower(strings[i]);
|
||||
}
|
||||
if (sort) {
|
||||
Arrays.sort(hashCodes);
|
||||
@@ -167,7 +167,13 @@ public final class FnvHash {
|
||||
return hashCodes;
|
||||
}
|
||||
|
||||
public static long fnv_64_lower(String owner, String name) {
|
||||
/**
|
||||
* normalized & lower & fnv1a_64_hash
|
||||
* @param owner
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
public static long hashCode64(String owner, String name) {
|
||||
long hashCode = BASIC;
|
||||
|
||||
if (owner != null) {
|
||||
|
||||
@@ -407,11 +407,11 @@ public class Utils {
|
||||
}
|
||||
|
||||
public static long fnv_64(String input) {
|
||||
return FnvHash.fnv_64(input);
|
||||
return FnvHash.fnv1a_64(input);
|
||||
}
|
||||
|
||||
public static long fnv_64_lower(String key) {
|
||||
return FnvHash.fnv_64_lower(key);
|
||||
return FnvHash.fnv1a_64_lower(key);
|
||||
}
|
||||
|
||||
public static long fnv_32_lower(String key) {
|
||||
|
||||
Reference in New Issue
Block a user