-
-
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 root cause: sub-select item is the left argument,not the right argument of item_func;
- Loading branch information
lujiashun
committed
Nov 15, 2022
1 parent
c0c9973
commit 2e10d61
Showing
3 changed files
with
255 additions
and
33 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