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

Nested UNION/INTERSECT queries with brackets could produce the wrong result if…

Nested UNION/INTERSECT queries with brackets could produce the wrong result if used within a subquery.
上级 3a086f29
......@@ -18,7 +18,9 @@ Change Log
<h1>Change Log</h1>
<h2>Next Version (unreleased)</h2>
<ul><li>Comparing an column against a constant expression with a higher precision or length
<ul><li>Nested UNION/INTERSECT queries with brackets could produce the wrong result if used within a subquery. Example:
select count(*) from (select 1 union (select 2 intersect select 2)) x;
</li><li>Comparing an column against a constant expression with a higher precision or length
than the column could give wrong results (the expression was truncated before comparing).
</li><li>Improved PostgreSQL compatibility (support SHOW DEFAULT_TRANSACTION_ISOLATION).
</li><li>Documentation: the javadocs for Csv.write and read used the wrong default charset.
......
......@@ -297,24 +297,24 @@ public class SelectUnion extends Query {
public String getPlanSQL() {
StringBuilder buff = new StringBuilder();
buff.append('(').append(StringUtils.unEnclose(left.getPlanSQL())).append(')');
buff.append('(').append(left.getPlanSQL()).append(')');
switch (unionType) {
case UNION_ALL:
buff.append("UNION ALL ");
buff.append(" UNION ALL ");
break;
case UNION:
buff.append("UNION ");
buff.append(" UNION ");
break;
case INTERSECT:
buff.append("INTERSECT ");
buff.append(" INTERSECT ");
break;
case EXCEPT:
buff.append("EXCEPT ");
buff.append(" EXCEPT ");
break;
default:
Message.throwInternalError("type=" + unionType);
}
buff.append('(').append(StringUtils.unEnclose(right.getPlanSQL())).append(')');
buff.append('(').append(right.getPlanSQL()).append(')');
Expression[] exprList = expressions.toArray(new Expression[expressions.size()]);
if (sort != null) {
buff.append(" ORDER BY ").append(sort.getSQL(exprList, exprList.length));
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论