Debian Codegraph @

mysql-test/suite/ndbcluster/pushed_join.test

raw
1 --source include/have_ndb.inc
2
3 #
4 # Test integration of pushed joins in ha_ndbcluster
5 # i.e the functionality where the mysqld calls ha_make_pushed_join()
6 # providing an Abstract_query_plan(aka. AQP) for the handler to examine
7 # in order to determine if some parts of the queries can be executed by
8 # the storage engine natively.
9 #
10
11 echo Check that ndb_join_pushdown variable exists and is enabled;
12 if (!`select @@ndb_join_pushdown`)
13 {
14 die Need ndb_join_pushdown enabled by default;
15 }
16
17 --echo #####
18 --echo # Create test table and data
19 create table t1 (
20 a int not null,
21 b int not null,
22 c int not null,
23 d int not null,
24 primary key (`a`,`b`)
25 ) engine=ndbcluster;
26
27 insert into t1 values
28 (1,1,1,1), (2,2,2,2), (3,3,3,3), (4,4,4,4),
29 (1,2,5,1), (1,3,1,2), (1,4,2,3),
30 (2,1,3,4), (2,3,4,5), (2,4,5,1),
31 (3,1,1,2), (3,2,2,3), (3,4,3,4),
32 (4,1,4,5), (4,2,5,1), (4,3,1,2);
33
34 --echo ####
35 --echo # Check the basic pushed query
36 let $push_query =
37 select * from t1
38 join t1 as t2 on t2.a = t1.b and t2.b = t1.c;
39 let $push_expected = 1;
40 --source pushed_join.inc
41
42 --echo ####
43 --echo # Check that operation is not pushed as HASH_JOIN'ed tables are in
44 --echo # different 'Query_scope' branches in the AccessPath
45 let $push_query =
46 select straight_join count(*)
47 from t1 as x1
48 join t1 as x2 on x1.d > x2.a + 1000
49 join t1 as x3 on x1.c=x3.a and x1.d=x3.b;
50 let $push_expected = 0;
51 let $push_message = "is in a hash-bucket-branch which can't be referred";
52 --source pushed_join.inc
53
54 --echo ####
55 --echo # Check that operation is not pushed as HASH_JOIN'ed tables are in
56 --echo # different 'Query_scope' branches in the AccessPath. The other table
57 --echo # operations in the query are pushed though
58 let $push_query =
59 select *
60 from t1 as x1
61 join t1 as x2 on x1.a=1 and x1.c=x2.a and x1.d=x2.b
62 join t1 as x3
63 join t1 as x4 where x4.a=x3.c and x4.b=x1.d;
64 let $push_expected = 1;
65 let $push_message = "is in a hash-bucket-branch which can't be referred";
66 --source pushed_join.inc
67
68 drop table t1;
69
70 create table t1 (
71 a int primary key,
72 b int,
73 c int,
74 index(b,c)
75 ) engine = ndb;
76
77 insert into t1 values (1,null, 2);
78 insert into t1 values (2,1, null);
79 insert into t1 values (3,2,2);
80 insert into t1 values (4,null, 2);
81 insert into t1 values (5,1, null);
82 insert into t1 values (6,2,2);
83
84 --echo ####
85 --echo # The query contains a 'dynamic range'("Range checked for each
86 --echo # record..") and access type can not be choosen at prepare time
87 --echo # Make sure t2 is not pushed.
88 let $push_query =
89 select *
90 from t1
91 join t1 as t2 on (t2.b = t1.b or t2.b = t1.a)
92 join t1 as t3 on t3.a = t2.a
93 join t1 as t4 on t4.a = t3.b /* index scan disguised as JT_ALL */;
94 let $push_expected = 1;
95 let $push_message =
96 "Table 't2' is not pushable: Access type was not chosen at 'prepare' time";
97 --source pushed_join.inc
98
99 drop table t1;
100