mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
enhance for schema stat
This commit is contained in:
@@ -57,14 +57,15 @@ import com.alibaba.druid.proxy.jdbc.StatementProxy;
|
||||
* @author wenshao<szujobs@hotmail.com>
|
||||
*/
|
||||
public abstract class FilterAdapter extends NotificationBroadcasterSupport implements Filter {
|
||||
protected DataSourceProxy dataSource;
|
||||
|
||||
@Override
|
||||
public void loadConfig(AbstractDruidFilterConfig DruidFilterConfig) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(DataSourceProxy newDataSource) {
|
||||
|
||||
public void init(DataSourceProxy dataSource) {
|
||||
this.dataSource = dataSource;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -33,6 +33,7 @@ import com.alibaba.druid.proxy.jdbc.ClobProxy;
|
||||
import com.alibaba.druid.proxy.jdbc.ConnectionProxy;
|
||||
import com.alibaba.druid.proxy.jdbc.PreparedStatementProxy;
|
||||
import com.alibaba.druid.proxy.jdbc.ResultSetProxy;
|
||||
import com.alibaba.druid.proxy.jdbc.ResultSetProxyImpl;
|
||||
import com.alibaba.druid.proxy.jdbc.StatementProxy;
|
||||
import com.alibaba.druid.util.JdbcUtils;
|
||||
|
||||
@@ -211,6 +212,26 @@ public class EncodingConvertFilter extends FilterAdapter {
|
||||
String text = JdbcUtils.read(reader);
|
||||
return new StringReader(decode(connection, text));
|
||||
}
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
public Object decodeObject(CallableStatementProxy stmt, Object object) throws SQLException {
|
||||
if (object instanceof String) {
|
||||
return decode(stmt.getConnectionProxy(), (String) object);
|
||||
}
|
||||
|
||||
if (object instanceof Reader) {
|
||||
Reader reader = (Reader) object;
|
||||
String text = JdbcUtils.read(reader);
|
||||
return new StringReader(decode(stmt.getConnectionProxy(), text));
|
||||
}
|
||||
|
||||
if (object instanceof ResultSet) {
|
||||
ResultSet resultSet = (ResultSet) object;
|
||||
return new ResultSetProxyImpl(stmt, resultSet, dataSource.createResultSetId(),
|
||||
stmt.getLastExecuteSql());
|
||||
}
|
||||
|
||||
return object;
|
||||
}
|
||||
@@ -594,21 +615,21 @@ public class EncodingConvertFilter extends FilterAdapter {
|
||||
public Object callableStatement_getObject(FilterChain chain, CallableStatementProxy statement, int parameterIndex)
|
||||
throws SQLException {
|
||||
Object value = chain.callableStatement_getObject(statement, parameterIndex);
|
||||
return decodeObject(statement.getConnectionProxy(), value);
|
||||
return decodeObject(statement, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object callableStatement_getObject(FilterChain chain, CallableStatementProxy statement, int parameterIndex,
|
||||
java.util.Map<String, Class<?>> map) throws SQLException {
|
||||
Object value = chain.callableStatement_getObject(statement, parameterIndex, map);
|
||||
return decodeObject(statement.getConnectionProxy(), value);
|
||||
return decodeObject(statement, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object callableStatement_getObject(FilterChain chain, CallableStatementProxy statement, String parameterName)
|
||||
throws SQLException {
|
||||
Object value = chain.callableStatement_getObject(statement, parameterName);
|
||||
return decodeObject(statement.getConnectionProxy(), value);
|
||||
return decodeObject(statement, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -616,7 +637,7 @@ public class EncodingConvertFilter extends FilterAdapter {
|
||||
String parameterName, java.util.Map<String, Class<?>> map)
|
||||
throws SQLException {
|
||||
Object value = chain.callableStatement_getObject(statement, parameterName, map);
|
||||
return decodeObject(statement.getConnectionProxy(), value);
|
||||
return decodeObject(statement, value);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,7 +39,11 @@ public class OracleOrderBy extends SQLOrderBy {
|
||||
}
|
||||
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
accept0((OracleASTVisitor) visitor);
|
||||
if (visitor instanceof OracleASTVisitor) {
|
||||
accept0((OracleASTVisitor) visitor);
|
||||
} else {
|
||||
super.accept0(visitor);
|
||||
}
|
||||
}
|
||||
|
||||
protected void accept0(OracleASTVisitor visitor) {
|
||||
|
||||
@@ -39,7 +39,11 @@ public class OracleOrderByItem extends SQLSelectOrderByItem {
|
||||
}
|
||||
|
||||
protected void accept0(SQLASTVisitor visitor) {
|
||||
accept0((OracleASTVisitor) visitor);
|
||||
if (visitor instanceof OracleASTVisitor) {
|
||||
accept0((OracleASTVisitor) visitor);
|
||||
} else {
|
||||
super.accept0(visitor);
|
||||
}
|
||||
}
|
||||
|
||||
protected void accept0(OracleASTVisitor visitor) {
|
||||
|
||||
+531
-511
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,8 @@
|
||||
package com.alibaba.druid.sql.visitor;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -39,11 +40,11 @@ import com.alibaba.druid.stat.TableStat.Mode;
|
||||
|
||||
public class SchemaStatVisitor extends SQLASTVisitorAdapter {
|
||||
|
||||
protected final HashMap<TableStat.Name, TableStat> tableStats = new HashMap<TableStat.Name, TableStat>();
|
||||
protected final Set<Column> columns = new HashSet<Column>();
|
||||
protected final Set<Condition> conditions = new HashSet<Condition>();
|
||||
protected final Set<Column> orderByColumns = new HashSet<Column>();
|
||||
protected final Set<Column> groupByColumns = new HashSet<Column>();
|
||||
protected final HashMap<TableStat.Name, TableStat> tableStats = new LinkedHashMap<TableStat.Name, TableStat>();
|
||||
protected final Set<Column> columns = new LinkedHashSet<Column>();
|
||||
protected final Set<Condition> conditions = new LinkedHashSet<Condition>();
|
||||
protected final Set<Column> orderByColumns = new LinkedHashSet<Column>();
|
||||
protected final Set<Column> groupByColumns = new LinkedHashSet<Column>();
|
||||
|
||||
protected final static ThreadLocal<Map<String, String>> aliasLocal = new ThreadLocal<Map<String, String>>();
|
||||
protected final static ThreadLocal<String> currentTableLocal = new ThreadLocal<String>();
|
||||
|
||||
Reference in New Issue
Block a user