1# WL#6745 InnoDB R-tree support
2# This test case will test R-tree split, mostly on duplicate 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--source include/have_sequence.inc
12let $restart_noprint=2;
13
14# Create table with R-tree index.
15create table t1 (c1 int, c2 geometry not null, spatial index (c2))engine=innodb;
16
17begin;
18# Insert enough values to let R-tree split.
19insert into t1 select @s:=1+(seq mod 9), point(@s, @s)
20from seq_1_to_576;
21
22#Check second round spliting.
23SET @saved_dbug = @@SESSION.debug_dbug;
24SET debug_dbug = '+d,rtr_page_need_second_split';
25insert into t1 select @s:=1+(seq mod 9), point(@s, @s)
26from seq_1_to_576;
27SET debug_dbug = @saved_dbug;
28rollback;
29
30insert into t1 select @s:=1+(seq mod 9), point(@s, @s)
31from seq_1_to_2304;
32begin;
33insert into t1 select @s:=1+(seq mod 9), point(@s, @s)
34from seq_1_to_2304;
35rollback;
36check table t1;
37insert into t1 select @s:=1+(seq mod 9), point(@s, @s)
38from seq_1_to_71424;
39check table t1;
40
41select count(*) from t1;
42
43set @g1 = ST_GeomFromText('Polygon((0 0,0 100,100 100,100 0,0 0))');
44select count(*) from t1 where MBRWithin(t1.c2, @g1);
45
46set @g1 = ST_GeomFromText('Polygon((10 10,10 800,800 800,800 10,10 10))');
47select count(*) from t1 where MBRWithin(t1.c2, @g1);
48
49drop index c2 on t1;
50
51# Test create index with algorithm=inplace
52--enable_info
53create spatial index idx2 on t1(c2);
54--disable_info
55
56show create table t1;
57
58# test read only case
59let $restart_parameters = --innodb-read-only;
60--source include/restart_mysqld.inc
61set @g1 = ST_GeomFromText('Polygon((0 0,0 100,100 100,100 0,0 0))');
62select count(*) from t1 where MBRWithin(t1.c2, @g1);
63set @g1 = ST_GeomFromText('Polygon((2 2,2 800,800 800,800 2,2 2))');
64select count(*) from t1 where MBRWithin(t1.c2, @g1);
65
66let $restart_parameters =;
67--source include/restart_mysqld.inc
68
69set @g1 = ST_GeomFromText('Polygon((0 0,0 100,100 100,100 0,0 0))');
70select count(*) from t1 where MBRWithin(t1.c2, @g1);
71set @g1 = ST_GeomFromText('Polygon((2 2,2 800,800 800,800 2,2 2))');
72select count(*) from t1 where MBRWithin(t1.c2, @g1);
73
74# Clean up.
75drop table t1;
76
77--echo #
78--echo # MDEV-27417 Spatial index tries to update
79--echo #	change buffer bookkeeping page
80--echo #
81CREATE TEMPORARY TABLE t1 (c POINT NOT NULL, SPATIAL(c)) ENGINE=InnoDB;
82INSERT INTO t1 SELECT PointFromText('POINT(0 0)') FROM seq_1_to_366;
83DROP TABLE t1;
84