summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2017-07-18 14:48:25 +0200
committerSergei Golubchik <serg@mariadb.org>2017-07-18 14:59:34 +0200
commit7c9d00e0bb1977e474dff28c2ce93f27599bbc10 (patch)
tree3e06d02eabb872519c97fbf8ab79927f6bbd00e4
parent9b3360ea4417ed653d5c7eed29f4ef7e80618e43 (diff)
downloadmariadb-git-7c9d00e0bb1977e474dff28c2ce93f27599bbc10.tar.gz
Bug #24595639: INCORRECT BEHAVIOR IN QUERY WITH UNION AND GROUP BY
test case
-rw-r--r--mysql-test/r/union.result18
-rw-r--r--mysql-test/t/union.test15
2 files changed, 33 insertions, 0 deletions
diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result
index 5a6cd8907e9..fe2339db471 100644
--- a/mysql-test/r/union.result
+++ b/mysql-test/r/union.result
@@ -1978,3 +1978,21 @@ d
2016-06-04 00:00:00
drop table t1;
End of 5.0 tests
+create table t1 (a int, b int);
+insert into t1 values (1,1),(2,2),(3,3);
+create table t2 (c varchar(30), d varchar(30));
+insert into t1 values ('1','1'),('2','2'),('4','4');
+create table t3 (e int, f int);
+insert into t3 values (1,1),(2,2),(31,31),(32,32);
+select e,f, (e , f) in (select e,b from t1 union select c,d from t2) as sub from t3;
+e f sub
+1 1 1
+2 2 1
+31 31 0
+32 32 0
+select avg(f), (e , f) in (select e,b from t1 union select c,d from t2) as sub from t3 group by sub;
+avg(f) sub
+31.5000 0
+1.5000 1
+drop table t1,t2,t3;
+End of 5.5 tests
diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test
index f4dc6a5d449..4a3c19b49ab 100644
--- a/mysql-test/t/union.test
+++ b/mysql-test/t/union.test
@@ -1370,3 +1370,18 @@ order by d;
drop table t1;
--echo End of 5.0 tests
+
+#
+# Bug #24595639: INCORRECT BEHAVIOR IN QUERY WITH UNION AND GROUP BY
+#
+create table t1 (a int, b int);
+insert into t1 values (1,1),(2,2),(3,3);
+create table t2 (c varchar(30), d varchar(30));
+insert into t1 values ('1','1'),('2','2'),('4','4');
+create table t3 (e int, f int);
+insert into t3 values (1,1),(2,2),(31,31),(32,32);
+select e,f, (e , f) in (select e,b from t1 union select c,d from t2) as sub from t3;
+select avg(f), (e , f) in (select e,b from t1 union select c,d from t2) as sub from t3 group by sub;
+drop table t1,t2,t3;
+
+--echo End of 5.5 tests