diff options
Diffstat (limited to 'mysql-test/r/subselect.result')
-rw-r--r-- | mysql-test/r/subselect.result | 269 |
1 files changed, 268 insertions, 1 deletions
diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 87f76b5a9ad..593c606a3e9 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -908,6 +908,131 @@ id select_type table type possible_keys key key_len ref rows filtered Extra Warnings: Note 1003 select `test`.`t1`.`a` AS `a`,<in_optimizer>(`test`.`t1`.`a`,<exists>(select 1 from `test`.`t2` join `test`.`t3` where ((`test`.`t3`.`a` = `test`.`t2`.`a`) and ((<cache>(`test`.`t1`.`a`) = `test`.`t2`.`a`) or isnull(`test`.`t2`.`a`))) having <is_not_null_test>(`test`.`t2`.`a`))) AS `t1.a in (select t2.a from t2,t3 where t3.a=t2.a)` from `test`.`t1` drop table t1,t2,t3; +# check correct NULL Processing for normal IN/ALL/ANY +# and 2 ways of max/min optimization +create table t1 (a int); +insert into t1 values (1), (100), (NULL), (1000); +create table t2 (a int not null); +# subselect returns empty set (for NULL and non-NULL left part) +select a, a in (select * from t2) from t1; +a a in (select * from t2) +1 0 +100 0 +NULL 0 +1000 0 +select a, a > any (select * from t2) from t1; +a a > any (select * from t2) +1 0 +100 0 +NULL 0 +1000 0 +select a, a > all (select * from t2) from t1; +a a > all (select * from t2) +1 1 +100 1 +NULL 1 +1000 1 +select a from t1 where a in (select * from t2); +a +select a from t1 where a > any (select * from t2); +a +select a from t1 where a > all (select * from t2); +a +1 +100 +NULL +1000 +select a from t1 where a in (select * from t2 group by a); +a +select a from t1 where a > any (select * from t2 group by a); +a +select a from t1 where a > all (select * from t2 group by a); +a +1 +100 +NULL +1000 +insert into t2 values (1),(200); +# sebselect returns non-empty set without NULLs +select a, a in (select * from t2) from t1; +a a in (select * from t2) +1 1 +100 0 +NULL NULL +1000 0 +select a, a > any (select * from t2) from t1; +a a > any (select * from t2) +1 0 +100 1 +NULL NULL +1000 1 +select a, a > all (select * from t2) from t1; +a a > all (select * from t2) +1 0 +100 0 +NULL NULL +1000 1 +select a from t1 where a in (select * from t2); +a +1 +select a from t1 where a > any (select * from t2); +a +100 +1000 +select a from t1 where a > all (select * from t2); +a +1000 +select a from t1 where a in (select * from t2 group by a); +a +1 +select a from t1 where a > any (select * from t2 group by a); +a +100 +1000 +select a from t1 where a > all (select * from t2 group by a); +a +1000 +drop table t2; +create table t2 (a int); +insert into t2 values (1),(NULL),(200); +# sebselect returns non-empty set with NULLs +select a, a in (select * from t2) from t1; +a a in (select * from t2) +1 1 +100 NULL +NULL NULL +1000 NULL +select a, a > any (select * from t2) from t1; +a a > any (select * from t2) +1 NULL +100 1 +NULL NULL +1000 1 +select a, a > all (select * from t2) from t1; +a a > all (select * from t2) +1 0 +100 0 +NULL NULL +1000 NULL +select a from t1 where a in (select * from t2); +a +1 +select a from t1 where a > any (select * from t2); +a +100 +1000 +select a from t1 where a > all (select * from t2); +a +select a from t1 where a in (select * from t2 group by a); +a +1 +select a from t1 where a > any (select * from t2 group by a); +a +100 +1000 +select a from t1 where a > all (select * from t2 group by a); +a +drop table t1, t2; create table t1 (a float); select 10.5 IN (SELECT * from t1 LIMIT 1); ERROR 42000: This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery' @@ -1483,7 +1608,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra Warnings: Note 1003 select `test`.`t1`.`s1` AS `s1`,(not(<in_optimizer>(`test`.`t1`.`s1`,<exists>(<index_lookup>(<cache>(`test`.`t1`.`s1`) in t2 on s1 checking NULL where (`test`.`t2`.`s1` < 'a2') having trigcond(<is_not_null_test>(`test`.`t2`.`s1`))))))) AS `s1 NOT IN (SELECT s1 FROM t2 WHERE s1 < 'a2')` from `test`.`t1` drop table t1,t2; -create table t2 (a int, b int); +create table t2 (a int, b int not null); create table t3 (a int); insert into t3 values (6),(7),(3); select * from t3 where a >= all (select b from t2); @@ -4779,3 +4904,145 @@ SELECT 1 as foo FROM t1 WHERE a < SOME ); foo DROP TABLE t1; +CREATE TABLE t1 (a int(11), b varchar(1)); +INSERT INTO t1 VALUES (2,NULL),(5,'d'),(7,'g'); +SELECT a FROM t1 WHERE b < ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +SELECT a FROM t1 WHERE b < ANY ( SELECT b FROM t1 ); +a +5 +SELECT a FROM t1 WHERE b > ANY ( SELECT b FROM t1 GROUP BY b ); +a +7 +SELECT a FROM t1 WHERE b > ANY ( SELECT b FROM t1 ); +a +7 +SELECT a FROM t1 WHERE b <= ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b <= ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b >= ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b >= ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b = ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b = ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b <> ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b <> ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b < ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b < ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b > ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b > ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b <= ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b <= ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b >= ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b >= ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b = ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b = ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b <> ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b <> ALL ( SELECT b FROM t1 GROUP BY b ); +a +delete from t1; +INSERT INTO t1 VALUES (2,NULL),(5,'d'),(7,'g'); +SELECT a FROM t1 WHERE b < ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +SELECT a FROM t1 WHERE b < ANY ( SELECT b FROM t1 ); +a +5 +SELECT a FROM t1 WHERE b > ANY ( SELECT b FROM t1 GROUP BY b ); +a +7 +SELECT a FROM t1 WHERE b > ANY ( SELECT b FROM t1 ); +a +7 +SELECT a FROM t1 WHERE b <= ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b <= ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b >= ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b >= ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b = ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b = ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b <> ANY ( SELECT b FROM t1 ); +a +5 +7 +SELECT a FROM t1 WHERE b <> ANY ( SELECT b FROM t1 GROUP BY b ); +a +5 +7 +SELECT a FROM t1 WHERE b < ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b < ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b > ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b > ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b <= ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b <= ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b >= ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b >= ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b = ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b = ALL ( SELECT b FROM t1 GROUP BY b ); +a +SELECT a FROM t1 WHERE b <> ALL ( SELECT b FROM t1 ); +a +SELECT a FROM t1 WHERE b <> ALL ( SELECT b FROM t1 GROUP BY b ); +a +drop table t1; +End of 5.2 tests |