summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/r/subselect3.result16
-rw-r--r--mysql-test/t/subselect3.test17
-rw-r--r--sql/item.cc5
3 files changed, 37 insertions, 1 deletions
diff --git a/mysql-test/r/subselect3.result b/mysql-test/r/subselect3.result
index 07ff17c9df9..29143b9e504 100644
--- a/mysql-test/r/subselect3.result
+++ b/mysql-test/r/subselect3.result
@@ -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;
diff --git a/mysql-test/t/subselect3.test b/mysql-test/t/subselect3.test
index 23d78721dbe..ed8480ba464 100644
--- a/mysql-test/t/subselect3.test
+++ b/mysql-test/t/subselect3.test
@@ -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;
+
diff --git a/sql/item.cc b/sql/item.cc
index 0017b64ba0d..9a55eb25e2c 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -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);