1# WL#6745 InnoDB R-tree support
2# This test case will test R-tree multi level split.
3
4--source include/have_innodb.inc
5--source include/big_test.inc
6--source include/not_valgrind.inc
7--source include/have_debug.inc
8
9# Create table with R-tree index.
10create table t1 (c1 int, c2 geometry not null, spatial index (c2))engine=innodb;
11
12# Insert enough values to let R-tree split.
13delimiter |;
14create procedure insert_t1(IN total int)
15begin
16	declare i int default 1;
17	while (i <= total) DO
18		insert into t1 values
19		(i, Point(i, i)),
20		(i + 1, Point(i + 1, i + 1)),
21		(i + 2, Point(i + 2, i + 2)),
22		(i + 3, Point(i + 3, i + 3)),
23		(i + 4, Point(i + 4, i + 4)),
24		(i + 5, Point(i + 5, i + 5)),
25		(i + 6, Point(i + 6, i + 6)),
26		(i + 7, Point(i + 7, i + 7)),
27		(i + 8, Point(i + 8, i + 8)),
28		(i + 9, Point(i + 9, i + 9));
29		set i = i + 10;
30	end while;
31end|
32delimiter ;|
33
34# Test level 1 rtree.
35CALL insert_t1(5000);
36select count(*) from t1;
37
38# Check table.
39check table t1;
40
41# Test level 2 rtree.
42truncate table t1;
43CALL insert_t1(10000);
44select count(*) from t1;
45
46drop index c2 on t1;
47
48create spatial index idx on t1(c2);
49
50show create table t1;
51
52SET @save_dbug = @@SESSION.debug_dbug;
53SET debug_dbug='+d,row_merge_ins_spatial_fail';
54--error ER_GET_ERRNO
55create spatial index idx2 on t1(c2);
56SET @@SESSION.debug_dbug = @save_dbug;
57show create table t1;
58
59# Check table.
60check table t1;
61
62# Test level 3 rtree.
63truncate table t1;
64CALL insert_t1(100000);
65select count(*) from t1;
66
67# Check table.
68check table t1;
69
70truncate table t1;
71
72# Clean up.
73drop procedure insert_t1;
74drop table t1;
75