Do not flatten aggregate subqueries that contain min() or max() functions

so that if the min()/max() are discarded by the outer query, they still
function and cause non-aggregate expression to be evaluated on the minimal
or maximal row.

FossilOrigin-Name: 0bdf1a086b3946722f4d4b328e25917f61c14713
This commit is contained in:
drh
2014-09-15 14:46:02 +00:00
parent 6092d2bcfe
commit 9588ad95c1
8 changed files with 75 additions and 40 deletions
+7 -1
View File
@@ -156,8 +156,14 @@ do_test aggnested-3.2 {
(SELECT value1 as xyz, max(x1) AS pqr
FROM t1
GROUP BY id1);
SELECT
(SELECT sum(value2<>xyz) FROM t2)
FROM
(SELECT value1 as xyz, max(x1) AS pqr
FROM t1
GROUP BY id1);
}
} {0}
} {1 0}
do_test aggnested-3.3 {
db eval {
DROP TABLE IF EXISTS t1;