| 1 |
Check that ndb_join_pushdown variable exists and is enabled |
| 2 |
##### |
| 3 |
# Create test table and data |
| 4 |
create table t1 ( |
| 5 |
a int not null, |
| 6 |
b int not null, |
| 7 |
c int not null, |
| 8 |
d int not null, |
| 9 |
primary key (`a`,`b`) |
| 10 |
) engine=ndbcluster; |
| 11 |
insert into t1 values |
| 12 |
(1,1,1,1), (2,2,2,2), (3,3,3,3), (4,4,4,4), |
| 13 |
(1,2,5,1), (1,3,1,2), (1,4,2,3), |
| 14 |
(2,1,3,4), (2,3,4,5), (2,4,5,1), |
| 15 |
(3,1,1,2), (3,2,2,3), (3,4,3,4), |
| 16 |
(4,1,4,5), (4,2,5,1), (4,3,1,2); |
| 17 |
#### |
| 18 |
# Check the basic pushed query |
| 19 |
select * from t1 |
| 20 |
join t1 as t2 on t2.a = t1.b and t2.b = t1.c; |
| 21 |
|
| 22 |
#### |
| 23 |
# Check that operation is not pushed as HASH_JOIN'ed tables are in |
| 24 |
# different 'Query_scope' branches in the AccessPath |
| 25 |
select straight_join count(*) |
| 26 |
from t1 as x1 |
| 27 |
join t1 as x2 on x1.d > x2.a + 1000 |
| 28 |
join t1 as x3 on x1.c=x3.a and x1.d=x3.b; |
| 29 |
Expected push message found in EXPLAIN; |
| 30 |
|
| 31 |
#### |
| 32 |
# Check that operation is not pushed as HASH_JOIN'ed tables are in |
| 33 |
# different 'Query_scope' branches in the AccessPath. The other table |
| 34 |
# operations in the query are pushed though |
| 35 |
select * |
| 36 |
from t1 as x1 |
| 37 |
join t1 as x2 on x1.a=1 and x1.c=x2.a and x1.d=x2.b |
| 38 |
join t1 as x3 |
| 39 |
join t1 as x4 where x4.a=x3.c and x4.b=x1.d; |
| 40 |
Expected push message found in EXPLAIN; |
| 41 |
|
| 42 |
drop table t1; |
| 43 |
create table t1 ( |
| 44 |
a int primary key, |
| 45 |
b int, |
| 46 |
c int, |
| 47 |
index(b,c) |
| 48 |
) engine = ndb; |
| 49 |
insert into t1 values (1,null, 2); |
| 50 |
insert into t1 values (2,1, null); |
| 51 |
insert into t1 values (3,2,2); |
| 52 |
insert into t1 values (4,null, 2); |
| 53 |
insert into t1 values (5,1, null); |
| 54 |
insert into t1 values (6,2,2); |
| 55 |
#### |
| 56 |
# The query contains a 'dynamic range'("Range checked for each |
| 57 |
# record..") and access type can not be choosen at prepare time |
| 58 |
# Make sure t2 is not pushed. |
| 59 |
select * |
| 60 |
from t1 |
| 61 |
join t1 as t2 on (t2.b = t1.b or t2.b = t1.a) |
| 62 |
join t1 as t3 on t3.a = t2.a |
| 63 |
join t1 as t4 on t4.a = t3.b /* index scan disguised as JT_ALL */; |
| 64 |
Expected push message found in EXPLAIN; |
| 65 |
|
| 66 |
drop table t1; |