use of com.alibaba.druid.stat.TableStat in project druid by alibaba.
the class PGSchemaStatVisitor method visit.
@Override
public boolean visit(PGInsertStatement x) {
setAliasMap();
if (x.getWith() != null) {
x.getWith().accept(this);
}
x.putAttribute("_original_use_mode", getMode());
setMode(x, Mode.Insert);
String originalTable = getCurrentTable();
if (x.getTableName() instanceof SQLName) {
String ident = ((SQLName) x.getTableName()).toString();
setCurrentTable(ident);
x.putAttribute("_old_local_", originalTable);
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());
accept(x.getQuery());
return false;
}
use of com.alibaba.druid.stat.TableStat in project druid by alibaba.
the class PGSchemaStatVisitor method visit.
@Override
public boolean visit(PGUpdateStatement x) {
Map<String, String> oldAliasMap = getAliasMap();
setAliasMap();
if (x.getWith() != null) {
x.getWith().accept(this);
}
String ident = x.getTableName().toString();
setCurrentTable(ident);
TableStat stat = getTableStat(ident);
stat.incrementUpdateCount();
accept(x.getFrom());
Map<String, String> aliasMap = getAliasMap();
aliasMap.put(ident, ident);
accept(x.getItems());
accept(x.getWhere());
setAliasMap(oldAliasMap);
return false;
}
use of com.alibaba.druid.stat.TableStat in project druid by alibaba.
the class SchemaStatVisitor method visit.
@Override
public boolean visit(SQLAlterTableDropIndex x) {
SQLAlterTableStatement stmt = (SQLAlterTableStatement) x.getParent();
String tableName = stmt.getName().toString();
TableStat tableStat = this.getTableStat(tableName);
tableStat.incrementDropIndexCount();
return false;
}
use of com.alibaba.druid.stat.TableStat in project druid by alibaba.
the class SchemaStatVisitor method visit.
@Override
public boolean visit(SQLDropIndexStatement x) {
setMode(x, Mode.DropIndex);
SQLExprTableSource table = x.getTableName();
if (table != null) {
SQLName name = (SQLName) table.getExpr();
String ident = name.toString();
setCurrentTable(ident);
TableStat stat = getTableStat(ident);
stat.incrementDropIndexCount();
Map<String, String> aliasMap = getAliasMap();
putAliasMap(aliasMap, ident, ident);
}
return false;
}
use of com.alibaba.druid.stat.TableStat in project druid by alibaba.
the class SchemaStatVisitor method visit.
@Override
public boolean visit(SQLMergeStatement x) {
setAliasMap();
String originalTable = getCurrentTable();
setMode(x.getUsing(), Mode.Select);
x.getUsing().accept(this);
setMode(x, Mode.Merge);
String ident = x.getInto().toString();
setCurrentTable(x, ident);
x.putAttribute("_old_local_", originalTable);
TableStat stat = getTableStat(ident);
stat.incrementMergeCount();
Map<String, String> aliasMap = getAliasMap();
if (aliasMap != null) {
if (x.getAlias() != null) {
putAliasMap(aliasMap, x.getAlias(), ident);
}
putAliasMap(aliasMap, ident, ident);
}
x.getOn().accept(this);
if (x.getUpdateClause() != null) {
x.getUpdateClause().accept(this);
}
if (x.getInsertClause() != null) {
x.getInsertClause().accept(this);
}
return false;
}
Aggregations