mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved SchemaStatVisitor.
This commit is contained in:
+30
-1
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user