From 57d15d62f15e8b17eddf0a5e6c4beee8e78c07b1 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Tue, 3 Jun 2014 10:52:36 +0200 Subject: [PATCH] Add a test case for MySQL's: Bug #18167356: EXPLAIN W/ EXISTS(SELECT* UNION SELECT*) WHERE ONE OF SELECT* IS DISTINCT FAILS. the bugfix itself was not merged - MariaDB doesn't have this bug. --- mysql-test/r/union.result | 13 +++++++++++-- mysql-test/t/union.test | 12 ++++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index a3ad63c035a..6d99cad30f0 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -1876,8 +1876,8 @@ SELECT(SELECT 1 AS a FROM dual ORDER BY a DESC LIMIT 1) AS dev; dev 1 # -# LP bug#1010729: Unexpected syntax error from UNION -# (bug #54382) with single-table join nest +# lp:1010729: Unexpected syntax error from UNION +# (bug #54382) with single-table join nest # CREATE TABLE t1 (a int); CREATE TABLE t2 (b int); @@ -1892,3 +1892,12 @@ UNION SELECT t1.pk FROM t1 LEFT JOIN (t2) ON (t1.pk = t2.fk); pk DROP TABLE t1,t2; +create table t1 (a int); +insert t1 values (1),(2),(3),(1); +explain select 1 from dual where exists (select max(a) from t1 group by a union select a+2 from t1); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used +2 SUBQUERY t1 ALL NULL NULL NULL NULL 4 Using temporary; Using filesort +3 UNION t1 ALL NULL NULL NULL NULL 4 +NULL UNION RESULT ALL NULL NULL NULL NULL NULL +drop table t1; diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index a53427f7fc6..877509a9fc0 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -1274,8 +1274,8 @@ SELECT(SELECT 1 AS a LIMIT 1) AS dev; SELECT(SELECT 1 AS a FROM dual ORDER BY a DESC LIMIT 1) AS dev; --echo # ---echo # LP bug#1010729: Unexpected syntax error from UNION ---echo # (bug #54382) with single-table join nest +--echo # lp:1010729: Unexpected syntax error from UNION +--echo # (bug #54382) with single-table join nest --echo # CREATE TABLE t1 (a int); CREATE TABLE t2 (b int); @@ -1292,3 +1292,11 @@ SELECT t1.pk FROM t1 LEFT JOIN (t2) ON (t1.pk = t2.fk); DROP TABLE t1,t2; +# +# Bug #18167356: EXPLAIN W/ EXISTS(SELECT* UNION SELECT*) +# WHERE ONE OF SELECT* IS DISTINCT FAILS. +# +create table t1 (a int); +insert t1 values (1),(2),(3),(1); +explain select 1 from dual where exists (select max(a) from t1 group by a union select a+2 from t1); +drop table t1;