File: pushed_join.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (100 lines) | stat: -rw-r--r-- 2,861 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
--source include/have_ndb.inc

#
# Test integration of pushed joins in ha_ndbcluster
# i.e the functionality where the mysqld calls ha_make_pushed_join()
# providing an Abstract_query_plan(aka. AQP) for the handler to examine
# in order to determine if some parts of the queries can be executed by
# the storage engine natively.
#

echo Check that ndb_join_pushdown variable exists and is enabled;
if (!`select @@ndb_join_pushdown`)
{
  die Need ndb_join_pushdown enabled by default;
}

--echo #####
--echo # Create test table and data
create table t1 (
  a int not null,
  b int not null,
  c int not null,
  d int not null,
  primary key (`a`,`b`)
) engine=ndbcluster;

insert into t1 values
(1,1,1,1), (2,2,2,2), (3,3,3,3), (4,4,4,4),
(1,2,5,1), (1,3,1,2), (1,4,2,3),
(2,1,3,4), (2,3,4,5), (2,4,5,1),
(3,1,1,2), (3,2,2,3), (3,4,3,4),
(4,1,4,5), (4,2,5,1), (4,3,1,2);

--echo ####
--echo # Check the basic pushed query
let $push_query =
  select * from t1
    join t1 as t2 on t2.a = t1.b and t2.b = t1.c;
let $push_expected = 1;
--source pushed_join.inc

--echo ####
--echo # Check that operation is not pushed as HASH_JOIN'ed tables are in
--echo # different 'Query_scope' branches in the AccessPath
let $push_query =
  select straight_join count(*)
    from t1 as x1
      join t1 as x2 on x1.d > x2.a + 1000
      join t1 as x3 on x1.c=x3.a and x1.d=x3.b;
let $push_expected = 0;
let $push_message = "is in a hash-bucket-branch which can't be referred";
--source pushed_join.inc

--echo ####
--echo # Check that operation is not pushed as HASH_JOIN'ed tables are in
--echo # different 'Query_scope' branches in the AccessPath. The other table
--echo # operations in the query are pushed though
let $push_query =
  select *
    from t1 as x1
      join t1 as x2 on x1.a=1 and x1.c=x2.a and x1.d=x2.b
      join t1 as x3
      join t1 as x4 where x4.a=x3.c and x4.b=x1.d;
let $push_expected = 1;
let $push_message = "is in a hash-bucket-branch which can't be referred";
--source pushed_join.inc

drop table t1;

create table t1 (
  a int primary key,
  b int,
  c int,
  index(b,c)
) engine = ndb;

insert into t1 values (1,null, 2);
insert into t1 values (2,1, null);
insert into t1 values (3,2,2);
insert into t1 values (4,null, 2);
insert into t1 values (5,1, null);
insert into t1 values (6,2,2);

--echo ####
--echo # The query contains a 'dynamic range'("Range checked for each
--echo # record..") and access type can not be choosen at prepare time
--echo # Make sure t2 is not pushed.
let $push_query =
  select *
    from t1
      join t1 as t2 on (t2.b = t1.b or t2.b = t1.a)
      join t1 as t3 on t3.a = t2.a
      join t1 as t4 on t4.a = t3.b /* index scan disguised as JT_ALL */;
let $push_expected = 1;
let $push_message =
  "Table 't2' is not pushable: Access type was not chosen at 'prepare' time";
--source pushed_join.inc

drop table t1;