diff options
Diffstat (limited to 'mysql-test/main/except_all.test')
-rw-r--r-- | mysql-test/main/except_all.test | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/mysql-test/main/except_all.test b/mysql-test/main/except_all.test new file mode 100644 index 00000000..f873b220 --- /dev/null +++ b/mysql-test/main/except_all.test @@ -0,0 +1,99 @@ +create table t1 (a int, b int) engine=MyISAM; +create table t2 (c int, d int) engine=MyISAM; +insert into t1 values (1,1),(2,2),(3,3),(2,2),(4,4),(4,4),(4,4); +insert into t2 values (1,1),(1,1),(1,1),(2,2),(3,3),(3,3),(5,5); + +select * from t1 except select * from t2; +select * from t1 except all select * from t2; +select * from t1 except all select c+1,d+1 from t2; +(select * from t1) except all (select * from t2); +select * from ((select * from t1) except all (select * from t2)) a; +select * from ((select a from t1) except all (select c from t2)) a; +select * from t1 except all select * from t1 union all select * from t1 union all select * from t1 except select * from t2; + +select * from t1 except all select * from t1 union all select * from t1 union all select * from t1 except all select * from t2; + +select * from (select * from t1 except all select * from t2) q1 except all select * from (select * from t1 except all select * from t2) q2; + +EXPLAIN select * from t1 except all select * from t2; +EXPLAIN format=json select * from t1 except all select * from t2; +EXPLAIN extended (select * from t1) except all (select * from t2); +EXPLAIN extended select * from ((select * from t1) except all (select * from t2)) a; + +--source include/analyze-format.inc +ANALYZE format=json select * from ((select a,b from t1) except all (select c,d from t2)) a; +--source include/analyze-format.inc +ANALYZE format=json select * from ((select a from t1) except all (select c from t2)) a; +select * from ((select a from t1) except all (select c from t2)) a; + +prepare stmt from "(select a,b from t1) except all (select c,d from t2)"; +execute stmt; +execute stmt; + +prepare stmt from "select * from ((select a,b from t1) except all (select c,d from t2)) a"; +execute stmt; +execute stmt; + +drop tables t1,t2; + +create table t1 (a int, b int) engine=MyISAM; +create table t2 (c int, d int) engine=MyISAM; +create table t3 (e int, f int) engine=MyISAM; +create table t4 (g int, h int) engine=MyISAM; +insert into t1 values (1,1),(2,2),(2,2); +insert into t2 values (2,2),(3,3); +insert into t3 values (4,4),(5,5),(4,4); +insert into t4 values (4,4),(7,7),(4,4); + +(select a,b,e,f from t1,t3) except all (select c,d,g,h from t2,t4); +select * from ((select a,b,e,f from t1,t3) except all (select c,d,g,h from t2,t4)) t; +(select * from t1,t3) except all (select * from t2,t4); +(select a,b,e from t1,t3) except all (select c,d,g from t2,t4); + +EXPLAIN (select a,b,e,f from t1,t3) except all (select c,d,g,h from t2,t4); +EXPLAIN select * from ((select a,b,e,f from t1,t3) except all (select c,d,g,h from t2,t4)) t; +EXPLAIN extended select * from ((select a,b,e,f from t1,t3) except all (select c,d,g,h from t2,t4)) t; +EXPLAIN format=json select * from ((select a,b,e,f from t1,t3) except all (select c,d,g,h from t2,t4)) t; + +--source include/analyze-format.inc +ANALYZE format=json (select a,b,e,f from t1,t3) except all (select c,d,g,h from t2,t4); +--source include/analyze-format.inc +ANALYZE format=json select * from ((select a,b,e,f from t1,t3) except all (select c,d,g,h from t2,t4)) t; + +prepare stmt from "(select a,b,e,f from t1,t3) except all (select c,d,g,h from t2,t4)"; +execute stmt; +execute stmt; + +prepare stmt from "select * from ((select a,b,e,f from t1,t3) except all (select c,d,g,h from t2,t4)) a"; +execute stmt; +execute stmt; + +drop tables t1,t2,t3,t4; + +select 1 as a from dual except all select 1 from dual; +(select 1 from dual) except all (select 1 from dual); +--error ER_PARSE_ERROR +(select 1 from dual into @v) except all (select 1 from dual); +--error ER_PARSE_ERROR +select 1 from dual ORDER BY 1 except all select 1 from dual; +select 1 as a from dual union all select 1 from dual; + +create table t1 (a int, b blob, a1 int, b1 blob) engine=MyISAM; +create table t2 (c int, d blob, c1 int, d1 blob) engine=MyISAM; +insert into t1 values (1,"ddd", 1, "sdfrrwwww"),(2, "fgh", 2, "dffggtt"),(2, "fgh", 2, "dffggtt"); +insert into t2 values (2, "fgh", 2, "dffggtt"),(3, "ffggddd", 3, "dfgg"); + + +(select a,b,b1 from t1) except all (select c,d,d1 from t2); +# make sure that blob is used +create table t3 (select a,b,b1 from t1) except all (select c,d,d1 from t2); +show create table t3; + +drop tables t1,t2,t3; + +CREATE TABLE t (i INT); +INSERT INTO t VALUES (1),(2); + +SELECT * FROM t WHERE i != ANY ( SELECT 3 EXCEPT ALL SELECT 3 ); + +drop table t;
\ No newline at end of file |