提交 c808b054 authored 作者: Thomas Mueller's avatar Thomas Mueller

EXPLAIN SELECT didn't include the sample size if one was set.

上级 1af923c9
...@@ -956,8 +956,9 @@ public class Select extends Query { ...@@ -956,8 +956,9 @@ public class Select extends Query {
buff.append("DISTINCT "); buff.append("DISTINCT ");
} }
for (int i = 0; i < visibleColumnCount; i++) { for (int i = 0; i < visibleColumnCount; i++) {
buff.appendExceptFirst(", "); buff.appendExceptFirst(",");
buff.append(exprList[i].getSQL()); buff.append("\n");
buff.append(StringUtils.indent(exprList[i].getSQL(), 4, false));
} }
buff.append("\nFROM "); buff.append("\nFROM ");
TableFilter filter = topTableFilter; TableFilter filter = topTableFilter;
...@@ -1025,6 +1026,9 @@ public class Select extends Query { ...@@ -1025,6 +1026,9 @@ public class Select extends Query {
buff.append(" OFFSET ").append(StringUtils.unEnclose(offsetExpr.getSQL())); buff.append(" OFFSET ").append(StringUtils.unEnclose(offsetExpr.getSQL()));
} }
} }
if (sampleSize != 0) {
buff.append("\nSAMPLE_SIZE ").append(sampleSize);
}
if (isForUpdate) { if (isForUpdate) {
buff.append("\nFOR UPDATE"); buff.append("\nFOR UPDATE");
} }
......
...@@ -338,16 +338,16 @@ public class SelectUnion extends Query { ...@@ -338,16 +338,16 @@ public class SelectUnion extends Query {
buff.append('(').append(left.getPlanSQL()).append(')'); buff.append('(').append(left.getPlanSQL()).append(')');
switch (unionType) { switch (unionType) {
case UNION_ALL: case UNION_ALL:
buff.append(" UNION ALL "); buff.append("\nUNION ALL\n");
break; break;
case UNION: case UNION:
buff.append(" UNION "); buff.append("\nUNION\n");
break; break;
case INTERSECT: case INTERSECT:
buff.append(" INTERSECT "); buff.append("\nINTERSECT\n");
break; break;
case EXCEPT: case EXCEPT:
buff.append(" EXCEPT "); buff.append("\nEXCEPT\n");
break; break;
default: default:
DbException.throwInternalError("type=" + unionType); DbException.throwInternalError("type=" + unionType);
...@@ -355,16 +355,19 @@ public class SelectUnion extends Query { ...@@ -355,16 +355,19 @@ public class SelectUnion extends Query {
buff.append('(').append(right.getPlanSQL()).append(')'); buff.append('(').append(right.getPlanSQL()).append(')');
Expression[] exprList = expressions.toArray(new Expression[expressions.size()]); Expression[] exprList = expressions.toArray(new Expression[expressions.size()]);
if (sort != null) { if (sort != null) {
buff.append(" ORDER BY ").append(sort.getSQL(exprList, exprList.length)); buff.append("\nORDER BY ").append(sort.getSQL(exprList, exprList.length));
} }
if (limitExpr != null) { if (limitExpr != null) {
buff.append(" LIMIT ").append(StringUtils.unEnclose(limitExpr.getSQL())); buff.append("\nLIMIT ").append(StringUtils.unEnclose(limitExpr.getSQL()));
if (offsetExpr != null) { if (offsetExpr != null) {
buff.append(" OFFSET ").append(StringUtils.unEnclose(offsetExpr.getSQL())); buff.append("\nOFFSET ").append(StringUtils.unEnclose(offsetExpr.getSQL()));
} }
} }
if (sampleSize != 0) {
buff.append("\nSAMPLE_SIZE ").append(sampleSize);
}
if (isForUpdate) { if (isForUpdate) {
buff.append(" FOR UPDATE"); buff.append("\nFOR UPDATE");
} }
return buff.toString(); return buff.toString();
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论