improved SchemaStatVisitor.

This commit is contained in:
wenshao
2016-10-08 17:59:31 +08:00
parent 9481c8d604
commit dc2d7bd2af
4 changed files with 97 additions and 2 deletions
@@ -365,8 +365,37 @@ public class MySqlSchemaStatVisitor extends SchemaStatVisitor implements MySqlAS
@Override
public boolean visit(MySqlReplaceStatement x) {
setMode(x, Mode.Replace);
return true;
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();
}
}
if (ident != null) {
setCurrentTable(x, ident);
TableStat stat = getTableStat(ident);
stat.incrementInsertCount();
Map<String, String> aliasMap = getAliasMap();
putAliasMap(aliasMap, ident, ident);
}
accept(x.getColumns());
accept(x.getValuesList());
accept(x.getQuery());
return false;
}
@Override
@@ -929,6 +929,10 @@ public class SchemaStatVisitor extends SQLASTVisitorAdapter {
return tableStats.containsKey(new TableStat.Name(tableName));
}
public boolean containsColumn(String tableName, String columnName) {
return columns.containsKey(new Column(tableName, columnName));
}
public Collection<Column> getColumns() {
return columns.values();
}
@@ -572,7 +572,8 @@ public class TableStat {
Alter(64), //
Drop(128), //
DropIndex(256), //
CreateIndex(512)//
CreateIndex(512), //
Replace(1024),
; //
public final int mark;