This commit is contained in:
温少
2012-03-15 15:47:32 +08:00
5 changed files with 26 additions and 9 deletions
@@ -470,7 +470,7 @@ public class StatFilter extends FilterEventAdapter implements StatFilterMBean {
String sql = resultSet.getSql();
if (sql != null) {
JdbcSqlStat sqlStat = getSqlCounter(sql);
JdbcSqlStat sqlStat = getSqlStat(sql);
if (sqlStat != null) {
sqlStat.addFetchRowCount(fetchCount);
}
@@ -657,7 +657,12 @@ public class StatFilter extends FilterEventAdapter implements StatFilterMBean {
return (JdbcSqlStat) statement.getAttributes().get(ATTR_SQL);
}
@Deprecated
public JdbcSqlStat getSqlCounter(String sql) {
return getSqlStat(sql);
}
public JdbcSqlStat getSqlStat(String sql) {
return dataSourceStat.getSqlStatMap().get(sql);
}
@@ -26,7 +26,7 @@ import com.alibaba.druid.sql.visitor.SQLASTVisitor;
public class SQLCreateTableStatement extends SQLStatementImpl {
protected Type type;
protected SQLName name;
protected SQLExprTableSource tableSource;
protected List<SQLTableElement> tableElementList = new ArrayList<SQLTableElement>();
@@ -35,11 +35,23 @@ public class SQLCreateTableStatement extends SQLStatementImpl {
}
public SQLName getName() {
return name;
if (tableSource == null) {
return null;
}
return (SQLName) tableSource.getExpr();
}
public void setName(SQLName name) {
this.name = name;
this.setTableSource(new SQLExprTableSource(name));
}
public SQLExprTableSource getTableSource() {
return tableSource;
}
public void setTableSource(SQLExprTableSource tableSource) {
this.tableSource = tableSource;
}
public Type getType() {
@@ -67,7 +79,7 @@ public class SQLCreateTableStatement extends SQLStatementImpl {
buf.append("LOCAL TEMPORARY ");
}
this.name.output(buf);
this.tableSource.output(buf);
buf.append(" ");
buf.append("(");
@@ -83,7 +95,7 @@ public class SQLCreateTableStatement extends SQLStatementImpl {
@Override
protected void accept0(SQLASTVisitor visitor) {
if (visitor.visit(this)) {
this.acceptChild(visitor, name);
this.acceptChild(visitor, tableSource);
this.acceptChild(visitor, tableElementList);
}
visitor.endVisit(this);
@@ -29,7 +29,7 @@ public class HiveCreateTableStatement extends SQLCreateTableStatement implements
@Override
public void accept0(HiveASTVisitor visitor) {
if (visitor.visit(this)) {
this.acceptChild(visitor, name);
this.acceptChild(visitor, tableSource);
this.acceptChild(visitor, tableElementList);
this.acceptChild(visitor, partitionedBy);
}
@@ -69,7 +69,7 @@ public class MySqlCreateTableStatement extends SQLCreateTableStatement {
buf.append("IF NOT EXISTS ");
}
this.name.output(buf);
this.tableSource.output(buf);
buf.append(" ");
buf.append("(");
for (int i = 0, size = tableElementList.size(); i < size; ++i) {
@@ -184,7 +184,7 @@ public class OracleCreateTableStatement extends SQLCreateTableStatement implemen
public void accept0(OracleASTVisitor visitor) {
if (visitor.visit(this)) {
this.acceptChild(visitor, name);
this.acceptChild(visitor, tableSource);
this.acceptChild(visitor, tableElementList);
this.acceptChild(visitor, tablespace);
this.acceptChild(visitor, select);