-
-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(tianmu): fix query syntax (WHERE NOT IN ) is not supported. (#767)
[summary] 1 'sub_select' item is the left argument,not the right argument of 'item_func'; 2 5.7 use 'item_func_not' class to represent the meaning of the syntax "not", while 8.0 use a variable 'value_transform'; 3 porting new join code from 5.7 for this case; 3.1 solve throwing exception ”select * from t1 where val not in (select * from t2 where val2 >= 10);" 4 porting ChooseJoinAlgorithm from 5.7 for this case; 4.1 solve incorrect result set for some sql in the mtr(which one is forgotton...) 5 porting ResetToTemplate modification from 5.7 for this case; 5.1 solve incorrect result set "select * from t1 where val not in (select * from t2 where val2 > t1.val);"
- Loading branch information
1 parent
9a3ef6b
commit 2d82933
Showing
8 changed files
with
280 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
use test; | ||
create table t1(val int) ENGINE=tianmu; | ||
create table t2(val2 int) ENGINE=tianmu; | ||
insert into t1 values(0); | ||
insert into t1 values(1); | ||
insert into t1 values(10); | ||
insert into t1 values(11); | ||
insert into t1 values(20); | ||
insert into t1 values(21); | ||
insert into t1 values(42); | ||
insert into t1 values(43); | ||
insert into t2 values(0); | ||
insert into t2 values(1); | ||
insert into t2 values(10); | ||
insert into t2 values(11); | ||
insert into t2 values(20); | ||
insert into t2 values(21); | ||
insert into t2 values(42); | ||
insert into t2 values(43); | ||
select * from t1 where 42 not in (select * from t1 where val > 42); | ||
val | ||
0 | ||
1 | ||
10 | ||
11 | ||
20 | ||
21 | ||
42 | ||
43 | ||
select * from t1 where 42 not in (select * from t1 where val < 10); | ||
val | ||
0 | ||
1 | ||
10 | ||
11 | ||
20 | ||
21 | ||
42 | ||
43 | ||
select * from t1 where 42 not in (select * from t1 where val >= 42); | ||
val | ||
select * from t1 where 42 not in (select * from t1 where val <= 10); | ||
val | ||
0 | ||
1 | ||
10 | ||
11 | ||
20 | ||
21 | ||
42 | ||
43 | ||
insert into t2 values(10); | ||
select * from t1 where val not in (select * from t2 where val2 > 10); | ||
val | ||
0 | ||
1 | ||
10 | ||
select * from t1 where val not in (select * from t2 where val2 >= 10); | ||
val | ||
0 | ||
1 | ||
select * from t1 where val not in (select * from t2 where val2 < 10); | ||
val | ||
10 | ||
11 | ||
20 | ||
21 | ||
42 | ||
43 | ||
select * from t1 where val not in (select * from t2 where val2 <=10); | ||
val | ||
11 | ||
20 | ||
21 | ||
42 | ||
43 | ||
select * from t1 where val not in (select * from t2 where val2 > t1.val); | ||
val | ||
0 | ||
1 | ||
10 | ||
11 | ||
20 | ||
21 | ||
42 | ||
43 | ||
select * from t1 where val not in (select * from t2 where val2 >= t1.val); | ||
val | ||
select * from t1 where val not in (select * from t2 where val2 < t1.val); | ||
val | ||
0 | ||
1 | ||
10 | ||
11 | ||
20 | ||
21 | ||
42 | ||
43 | ||
select * from t1 where val not in (select * from t2 where val2 <= t1.val); | ||
val | ||
select * from t1 where val not in (select * from t2 where val2 > t1.val and val2 >t1.val +10); | ||
val | ||
0 | ||
1 | ||
10 | ||
11 | ||
20 | ||
21 | ||
42 | ||
43 | ||
select * from t1 where val not in (select * from t2 where val2 >= t1.val and val2 >= t1.val +10); | ||
val | ||
0 | ||
1 | ||
10 | ||
11 | ||
20 | ||
21 | ||
42 | ||
43 | ||
select * from t1 where val not in (select * from t2 where val2 < t1.val and val2 <t1.val +10); | ||
val | ||
0 | ||
1 | ||
10 | ||
11 | ||
20 | ||
21 | ||
42 | ||
43 | ||
select * from t1 where val not in (select * from t2 where val2 <= t1.val and val2 >= t1.val +10); | ||
val | ||
0 | ||
1 | ||
10 | ||
11 | ||
20 | ||
21 | ||
42 | ||
43 | ||
select * from t1 where val not in (select * from t2 where val2 > t1.val); | ||
val | ||
0 | ||
1 | ||
10 | ||
11 | ||
20 | ||
21 | ||
42 | ||
43 | ||
drop table t1; | ||
drop table t2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
--source include/have_tianmu.inc | ||
use test; | ||
create table t1(val int) ENGINE=tianmu; | ||
create table t2(val2 int) ENGINE=tianmu; | ||
|
||
insert into t1 values(0); | ||
insert into t1 values(1); | ||
insert into t1 values(10); | ||
insert into t1 values(11); | ||
insert into t1 values(20); | ||
insert into t1 values(21); | ||
insert into t1 values(42); | ||
insert into t1 values(43); | ||
insert into t2 values(0); | ||
insert into t2 values(1); | ||
insert into t2 values(10); | ||
insert into t2 values(11); | ||
insert into t2 values(20); | ||
insert into t2 values(21); | ||
insert into t2 values(42); | ||
insert into t2 values(43); | ||
|
||
#original case(just test not in) | ||
select * from t1 where 42 not in (select * from t1 where val > 42); | ||
select * from t1 where 42 not in (select * from t1 where val < 10); | ||
select * from t1 where 42 not in (select * from t1 where val >= 42); | ||
select * from t1 where 42 not in (select * from t1 where val <= 10); | ||
|
||
#independent subquery | ||
insert into t2 values(10); | ||
select * from t1 where val not in (select * from t2 where val2 > 10); | ||
select * from t1 where val not in (select * from t2 where val2 >= 10); | ||
select * from t1 where val not in (select * from t2 where val2 < 10); | ||
select * from t1 where val not in (select * from t2 where val2 <=10); | ||
|
||
#dependent subquery | ||
select * from t1 where val not in (select * from t2 where val2 > t1.val); | ||
select * from t1 where val not in (select * from t2 where val2 >= t1.val); | ||
select * from t1 where val not in (select * from t2 where val2 < t1.val); | ||
select * from t1 where val not in (select * from t2 where val2 <= t1.val); | ||
|
||
select * from t1 where val not in (select * from t2 where val2 > t1.val and val2 >t1.val +10); | ||
select * from t1 where val not in (select * from t2 where val2 >= t1.val and val2 >= t1.val +10); | ||
select * from t1 where val not in (select * from t2 where val2 < t1.val and val2 <t1.val +10); | ||
select * from t1 where val not in (select * from t2 where val2 <= t1.val and val2 >= t1.val +10); | ||
select * from t1 where val not in (select * from t2 where val2 > t1.val); | ||
|
||
drop table t1; | ||
drop table t2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.