Commit 14959243 authored by unknown's avatar unknown

Fixed bug #24420.

Objects of the classes Item_func_is_not_null_test and Item_func_trig_cond
must be transparent for the method Item::split_sum_func2 as these classes
are pure helpers. It means that the method Item::split_sum_func2 should
look at those objects as at pure wrappers.


mysql-test/r/subselect3.result:
  Added a test case for bug #24420.
mysql-test/t/subselect3.test:
  Added a test case for bug #24420.
parent 4f118f1d
......@@ -629,3 +629,19 @@ cc NULL NULL
aa 1 1
bb NULL NULL
drop table t1,t2;
create table t1 (a int, b int);
insert into t1 values (0,0), (2,2), (3,3);
create table t2 (a int, b int);
insert into t2 values (1,1), (3,3);
select a, b, (a,b) in (select a, min(b) from t2 group by a) Z from t1;
a b Z
0 0 0
2 2 0
3 3 1
insert into t2 values (NULL,4);
select a, b, (a,b) in (select a, min(b) from t2 group by a) Z from t1;
a b Z
0 0 0
2 2 0
3 3 1
drop table t1,t2;
......@@ -472,3 +472,20 @@ select oref, a, a in (select min(ie) from t1 where oref=t2.oref group by grp) Z
drop table t1,t2;
#
# BUG#24420: row-based IN suqueries with aggregation when the left operand
# of the subquery predicate may contain NULL values
#
create table t1 (a int, b int);
insert into t1 values (0,0), (2,2), (3,3);
create table t2 (a int, b int);
insert into t2 values (1,1), (3,3);
select a, b, (a,b) in (select a, min(b) from t2 group by a) Z from t1;
insert into t2 values (NULL,4);
select a, b, (a,b) in (select a, min(b) from t2 group by a) Z from t1;
drop table t1,t2;
......@@ -1242,7 +1242,10 @@ void Item::split_sum_func2(THD *thd, Item **ref_pointer_array,
if (type() == SUM_FUNC_ITEM && skip_registered &&
((Item_sum *) this)->ref_by)
return;
if (type() != SUM_FUNC_ITEM && with_sum_func)
if ((type() != SUM_FUNC_ITEM && with_sum_func) ||
(type() == FUNC_ITEM &&
(((Item_func *) this)->functype() == Item_func::ISNOTNULLTEST_FUNC ||
((Item_func *) this)->functype() == Item_func::TRIG_COND_FUNC)))
{
/* Will split complicated items and ignore simple ones */
split_sum_func(thd, ref_pointer_array, fields);
......
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