98 lines
		
	
	
		
			3.0 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			98 lines
		
	
	
		
			3.0 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| --disable_query_log
 | |
| set @@session.explicit_defaults_for_timestamp=off;
 | |
| --enable_query_log
 | |
| # owner: yuchen.wyc
 | |
| # owner group: SQL1
 | |
| # Test of functions except
 | |
| 
 | |
| --disable_warnings
 | |
| drop table if exists t1,t2,t3,t4;
 | |
| --enable_warnings
 | |
| 
 | |
| 
 | |
| create table t1(c1 int primary key, c2 int);
 | |
| create table t2(c1 int primary key, c2 int);
 | |
| create table t3(c1 int, c2 int primary key);
 | |
| create table t4(c1 int primary key, c2 int);
 | |
| 
 | |
| insert into t1 values(1,1),(2,2),(3,3),(4,4),(5,5);
 | |
| insert into t2 values(0,0),(2,2),(4,4),(6,6);
 | |
| insert into t3 values(1,1),(3,3),(5,5),(7,7);
 | |
| insert into t4 values(1,0),(2,0),(3,1),(4,1);
 | |
| 
 | |
| #all same
 | |
| select * from t1 except select * from t1;
 | |
| --error 1064
 | |
| select * from t1 except all select * from t1;
 | |
| #partial same 
 | |
| select * from t1 except select * from t2;
 | |
| --error 1064
 | |
| select * from t1 except all select * from t2;
 | |
| 
 | |
| #different schema
 | |
| select * from t1 except select * from t3;
 | |
| --error 1064
 | |
| select * from t1 except all select * from t3;
 | |
| 
 | |
| #constant
 | |
| select * from t1 except select 1,1 from t1;
 | |
| --error 1064
 | |
| select * from t1 except all select 1,1 from t1;
 | |
| 
 | |
| #has no same
 | |
| select * from t2 except select * from t3;
 | |
| --error 1064
 | |
| select * from t2 except all select * from t3;
 | |
| 
 | |
| #empty input
 | |
| (select * from t2) except (select * from t2 where false);
 | |
| --error 1064
 | |
| (select * from t2) except all (select * from t2 where false);
 | |
| (select * from t2 where false) except (select * from t2);
 | |
| (select * from t2 where false) except (select * from t2 where false);
 | |
| 
 | |
| #distinct
 | |
| select c2  from t4 except select 1 from t4;
 | |
| --error 1064
 | |
| select c2  from t4 except all select 1 from t4;
 | |
| select c2  from t4 except select 0 from t4;
 | |
| select c2  from t4 except select c2  from t4;
 | |
| select c2  from t4 except select distinct c2  from t4;
 | |
| select distinct c2  from t4 except select distinct c2  from t4;
 | |
| --error 1064
 | |
| select distinct c2  from t4 except all select distinct c2  from t4;
 | |
| select distinct c2  from t4 except select c2  from t4;
 | |
| --error 1064
 | |
| select distinct c2  from t4 except all select c2  from t4;
 | |
| 
 | |
| select 0 from t4 except select c2 from t4;
 | |
| select 1 from t4 except select 0 from t4;
 | |
| --error 1064
 | |
| select 1 from t4 except all select 0 from t4;
 | |
| 
 | |
| 
 | |
| # nest
 | |
| (select * from t4 except (select * from t4 where c1=1) )except (select * from t4 where c1=2);
 | |
| select * from t4 except (select * from t4 where c1=1) except (select * from t4 where c1=3);
 | |
| select * from t4 except select 1,0 from t4 except select 3,1 from t4;
 | |
| (select * from t4 where false) except (select * from t4 where false) except select * from t4;
 | |
| 
 | |
| select * from t4 except ((select * from t4 where c1=1) except (select * from t4 where c1=2));
 | |
| select * from t4 except ((select * from t4 where c1=1) union (select * from t4 where c1=2));
 | |
| --disable_warnings
 | |
| drop table if exists t5,t6;
 | |
| --enable_warnings
 | |
| create table t5(c1 int primary key, c2 int);
 | |
| create table t6(c1 int primary key, c2 int);
 | |
| 
 | |
| insert into t5 values(1,1),(2,2),(3,3),(4,4),(5,5),(6,2),(7,3),(8,6);
 | |
| insert into t6 values(0,0),(2,2),(4,4),(6,6);
 | |
| select c2 from t5 except select c2 from t6;
 | |
| --error 1064
 | |
| select c2 from t5 except  all select c2 from t6;
 | |
| 
 | |
| 
 | |
| drop table t1,t2,t3,t4,t5,t6;
 | |
| 
 | |
| 
 | 
