We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
我继承StatFilter将sql做了采样分析,采样的时候将sql进行格式化只会再次参数化处理,结果生产遇到问题 然后发现SQLASTOutputVisitor在拼sql的时候针对Reader等类型只拼了前半截单引号,没有后半截单引号就return了。
https://github.com/alibaba/druid/blob/master/src/main/java/com/alibaba/druid/sql/visitor/SQLASTOutputVisitor.java#L2310
我的代码如下:
private static List<Object> getSqlParamObjetList(StatementProxy statement) { List<Object> parameters = null; int parametersSize = statement.getParametersSize(); if (parametersSize > 0) { parameters = new ArrayList<>(parametersSize); for (int i = 0; i < parametersSize; ++i) { JdbcParameter jdbcParam = statement.getParameter(i); Object param = jdbcParam != null ? jdbcParam.getValue() : null; if (param instanceof String) { String str = (String) param; if (str.length() > 300) {// 超长文本做截取 param = str.subSequence(0, 300) + "........."; } } //以下是为了兼容druid SQLASTOutputVisitor的bug,返回指定字符串 if (param instanceof InputStream) { param = ("< InputStream >"); } if (param instanceof Reader) { param = ("< Reader >"); } if (param instanceof Blob) { param = ("< Blob >"); } if (param instanceof NClob) { param = ("< NClob >"); } if (param instanceof Clob) { param = ("< Clob >"); } parameters.add(param); } } return parameters; } private void trySamplingSql(String method, StatementProxy statement, String sql) { String dbType = statement.getConnectionProxy().getDirectDataSource().getDbType(); List<Object> parameters = getSqlParamObjetList(statement); String formattedSql = SQLUtils.format(sql, dbType, parameters); String mergedSql = null; try { //parameters里有Reader等类型就会出错了。 mergedSql = ParameterizedOutputVisitorUtils.parameterize(formattedSql, "mysql"); } catch (Exception e) { if (LOG.isWarnEnabled()) { String msg = "doAsyncSqlSampling|buterr|" + (formattedSql); LOG.warn(msg, e); } return; } //以mergedSql为基准每调采样10次。 }
The text was updated successfully, but these errors were encountered:
你这个是什么版本?
Sorry, something went wrong.
bug fixed for #3085
7a38344
问题已修复,请用新版本 https://github.com/alibaba/druid/releases/tag/1.1.14
👍
No branches or pull requests
我继承StatFilter将sql做了采样分析,采样的时候将sql进行格式化只会再次参数化处理,结果生产遇到问题
然后发现SQLASTOutputVisitor在拼sql的时候针对Reader等类型只拼了前半截单引号,没有后半截单引号就return了。
https://github.com/alibaba/druid/blob/master/src/main/java/com/alibaba/druid/sql/visitor/SQLASTOutputVisitor.java#L2310
我的代码如下:
The text was updated successfully, but these errors were encountered: