use of com.alibaba.druid.stat.TableStat in project Mycat-Server by MyCATApache.
the class MycatSchemaStatVisitor method visit.
@Override
public boolean visit(SQLAlterTableStatement x) {
String tableName = x.getName().toString();
TableStat stat = getTableStat(tableName, tableName);
stat.incrementAlterCount();
setCurrentTable(x, tableName);
for (SQLAlterTableItem item : x.getItems()) {
item.setParent(x);
item.accept(this);
}
return false;
}
use of com.alibaba.druid.stat.TableStat in project Mycat-Server by MyCATApache.
the class MycatSchemaStatVisitor method visit.
public boolean visit(SQLUpdateStatement x) {
setAliasMap();
setMode(x, Mode.Update);
SQLName identName = x.getTableName();
if (identName != null) {
String ident = identName.toString();
String alias = x.getTableSource().getAlias();
setCurrentTable(ident);
TableStat stat = getTableStat(ident);
stat.incrementUpdateCount();
Map<String, String> aliasMap = getAliasMap();
aliasMap.put(ident, ident);
if (alias != null) {
aliasMap.put(alias, ident);
}
} else {
x.getTableSource().accept(this);
}
accept(x.getItems());
accept(x.getWhere());
return false;
}
use of com.alibaba.druid.stat.TableStat in project Mycat-Server by MyCATApache.
the class MycatSchemaStatVisitor method visit.
// DUAL
public boolean visit(MySqlDeleteStatement x) {
setAliasMap();
setMode(x, Mode.Delete);
accept(x.getFrom());
accept(x.getUsing());
x.getTableSource().accept(this);
if (x.getTableSource() instanceof SQLExprTableSource) {
SQLName tableName = (SQLName) ((SQLExprTableSource) x.getTableSource()).getExpr();
String ident = tableName.toString();
setCurrentTable(x, ident);
TableStat stat = this.getTableStat(ident, ident);
stat.incrementDeleteCount();
}
accept(x.getWhere());
accept(x.getOrderBy());
accept(x.getLimit());
return false;
}
use of com.alibaba.druid.stat.TableStat in project Mycat-Server by MyCATApache.
the class DruidUpdateParser method getUpdateTableCount.
/**
* 获取更新的表数
* @author lian
* @date 2016年11月2日
* @return
*/
private int getUpdateTableCount() {
Map<Name, TableStat> tableMap = this.ctx.getVisitor().getTables();
int updateTableCount = 0;
for (Name _name : tableMap.keySet()) {
TableStat ts = tableMap.get(_name);
updateTableCount += ts.getUpdateCount();
}
return updateTableCount;
}
use of com.alibaba.druid.stat.TableStat in project druid by alibaba.
the class OracleSchemaStatVisitor method visit.
public boolean visit(OracleUpdateStatement x) {
setAliasMap();
setMode(x, Mode.Update);
SQLTableSource tableSource = x.getTableSource();
SQLExpr tableExpr = null;
if (tableSource instanceof SQLExprTableSource) {
tableExpr = ((SQLExprTableSource) tableSource).getExpr();
}
if (tableExpr instanceof SQLName) {
String ident = tableExpr.toString();
setCurrentTable(ident);
TableStat stat = getTableStat(ident);
stat.incrementUpdateCount();
Map<String, String> aliasMap = getAliasMap();
aliasMap.put(ident, ident);
aliasMap.put(tableSource.getAlias(), ident);
} else {
tableSource.accept(this);
}
accept(x.getItems());
accept(x.getWhere());
return false;
}
Aggregations