1# WL#6745 InnoDB R-tree support
2# This test case will test R-tree split, mostly on duplciate records.
3
4# Not supported in embedded
5--source include/not_embedded.inc
6
7--source include/have_innodb.inc
8--source include/big_test.inc
9--source include/not_valgrind.inc
10--source include/have_debug.inc
11
12# Create table with R-tree index.
13create table t1 (c1 int, c2 geometry not null, spatial index (c2))engine=innodb;
14
15# Insert enough values to let R-tree split.
16insert into t1 values(1, Point(1,1));
17insert into t1 values(2, Point(2,2));
18insert into t1 values(3, Point(3,3));
19insert into t1 values(4, Point(4,4));
20insert into t1 values(5, Point(5,5));
21insert into t1 values(6, Point(6,6));
22insert into t1 values(7, Point(7,7));
23insert into t1 values(8, Point(8,8));
24insert into t1 values(9, Point(9,9));
25
26insert into t1 select * from t1;
27insert into t1 select * from t1;
28insert into t1 select * from t1;
29insert into t1 select * from t1;
30insert into t1 select * from t1;
31insert into t1 select * from t1;
32
33#Check second round spliting.
34SET SESSION debug="+d, rtr_page_need_second_split";
35insert into t1 select * from t1;
36SET SESSION debug="-d, rtr_page_need_second_split";
37
38delete from t1;
39
40insert into t1 values(1, Point(1,1));
41insert into t1 values(2, Point(2,2));
42insert into t1 values(3, Point(3,3));
43insert into t1 values(4, Point(4,4));
44insert into t1 values(5, Point(5,5));
45insert into t1 values(6, Point(6,6));
46insert into t1 values(7, Point(7,7));
47insert into t1 values(8, Point(8,8));
48insert into t1 values(9, Point(9,9));
49
50insert into t1 select * from t1;
51insert into t1 select * from t1;
52insert into t1 select * from t1;
53insert into t1 select * from t1;
54
55insert into t1 select * from t1;
56insert into t1 select * from t1;
57
58insert into t1 select * from t1;
59insert into t1 select * from t1;
60start transaction;
61insert into t1 select * from t1;
62rollback;
63check table t1;
64insert into t1 select * from t1;
65insert into t1 select * from t1;
66insert into t1 select * from t1;
67insert into t1 select * from t1;
68insert into t1 select * from t1;
69check table t1;
70
71select count(*) from t1;
72
73set @g1 = ST_GeomFromText('Polygon((0 0,0 100,100 100,100 0,0 0))');
74select count(*) from t1 where MBRWithin(t1.c2, @g1);
75
76set @g1 = ST_GeomFromText('Polygon((10 10,10 800,800 800,800 10,10 10))');
77select count(*) from t1 where MBRWithin(t1.c2, @g1);
78
79drop index c2 on t1;
80
81# Test create index with algorithm=inplace
82create spatial index idx2 on t1(c2);
83
84show create table t1;
85
86set @g1 = ST_GeomFromText('Polygon((0 0,0 100,100 100,100 0,0 0))');
87select count(*) from t1 where MBRWithin(t1.c2, @g1);
88
89# test read only case
90let $restart_parameters = restart: --innodb-read-only;
91--source include/restart_mysqld.inc
92set @g1 = ST_GeomFromText('Polygon((0 0,0 100,100 100,100 0,0 0))');
93select count(*) from t1 where MBRWithin(t1.c2, @g1);
94
95set @g1 = ST_GeomFromText('Polygon((2 2,2 800,800 800,800 2,2 2))');
96select count(*) from t1 where MBRWithin(t1.c2, @g1);
97
98let $restart_parameters = restart;
99--source include/restart_mysqld.inc
100
101# Clean up.
102drop table t1;
103
104--echo #
105--echo # Bug #29465567 INNODB: RTREE SPLIT ASSERTION FAILURE
106--echo #
107
108# Create table with R-tree index.
109create table t1 (c1 int, c2 geometry not null, spatial index (c2))engine=innodb;
110
111# Insert enough values to let R-tree split.
112insert into t1 values(1, Point(1,1));
113insert into t1 values(2, Point(2,2));
114insert into t1 values(3, Point(3,3));
115insert into t1 values(4, Point(4,4));
116insert into t1 values(5, Point(5,5));
117insert into t1 values(6, Point(6,6));
118insert into t1 values(7, Point(7,7));
119insert into t1 values(8, Point(8,8));
120insert into t1 values(9, Point(9,9));
121
122insert into t1 select * from t1;
123insert into t1 select * from t1;
124insert into t1 select * from t1;
125insert into t1 select * from t1;
126insert into t1 select * from t1;
127insert into t1 select * from t1;
128insert into t1 select * from t1;
129insert into t1 select * from t1;
130start transaction;
131insert into t1 select * from t1;
132rollback;
133check table t1;
134insert into t1 select * from t1;
135insert into t1 select * from t1;
136insert into t1 select * from t1;
137insert into t1 select * from t1;
138
139#Check first round spliting.
140SET SESSION debug="+d, rtr_page_need_first_split";
141insert into t1 select * from t1;
142SET SESSION debug="-d, rtr_page_need_first_split";
143
144# Clean up.
145drop table t1;
146