Commit 974c29b9 authored by timour@mysql.com's avatar timour@mysql.com

WL#1972 "Evaluate HAVING before SELECT select-list"

- post-review fix regarding Item_fields
- added test for the changed name resolution
parent 660e1236
...@@ -245,6 +245,13 @@ col1 ...@@ -245,6 +245,13 @@ col1
10 10
10 10
10 10
select sum(col1) from t1
group by col_t1
having (select col_t1 from t2 where col_t1 = col_t2 order by col_t2 limit 1);
sum(col1)
40
20
30
select t1.col1 from t1 select t1.col1 from t1
where t1.col2 in where t1.col2 in
(select t2.col2 from t2 (select t2.col2 from t2
......
...@@ -211,6 +211,11 @@ where t1.col2 in ...@@ -211,6 +211,11 @@ where t1.col2 in
(select t2.col2 from t2 (select t2.col2 from t2
group by t2.col1, t2.col2 having col_t1 <= 10); group by t2.col1, t2.col2 having col_t1 <= 10);
# Item_field must be resolved in the same way as Item_ref
select sum(col1) from t1
group by col_t1
having (select col_t1 from t2 where col_t1 = col_t2 order by col_t2 limit 1);
# nested queries with HAVING, inner having column resolved in outer FROM clause # nested queries with HAVING, inner having column resolved in outer FROM clause
# the outer having column is not referenced in GROUP BY which results in an error # the outer having column is not referenced in GROUP BY which results in an error
--error 1054 --error 1054
...@@ -256,7 +261,6 @@ group by col_t1 ...@@ -256,7 +261,6 @@ group by col_t1
having col_t1 in (select sum(t2.col1) from t2 having col_t1 in (select sum(t2.col1) from t2
group by t2.col2, t2.col1 having t2.col1 = col_t1); group by t2.col2, t2.col1 having t2.col1 = col_t1);
# #
# queries with joins and ambiguous column names # queries with joins and ambiguous column names
# #
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment