Debian Codegraph @

mysql-test/suite/innodb_gis/t/rt_precise.test

raw
1 #*****************************************************************
2 # This was a Myisam testcase, converted to InnoDB
3 # Since Innodb does not support the spatial key, hence converted
4 # Orginal name of the testcase : gis_rt_precise.test
5 #*****************************************************************
6 --source include/have_innodb.inc
7 -- source include/have_geometry.inc
8 SET default_storage_engine=InnoDB;
9
10 #
11 # test of rtree (using with spatial data)
12 #
13 --disable_warnings
14 DROP TABLE IF EXISTS t1;
15 --enable_warnings
16
17 CREATE TABLE t1 (
18 fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
19 g GEOMETRY NOT NULL,
20 KEY gis_key(g(5))
21 ) ENGINE=InnoDB;
22
23 SHOW CREATE TABLE t1;
24
25 --disable_query_log
26 let $1=150;
27 let $2=150;
28 while ($1)
29 {
30 eval INSERT INTO t1 (g) VALUES (ST_GeomFromText('LineString($1 $1, $2 $2)'));
31 dec $1;
32 inc $2;
33 }
34 --enable_query_log
35
36 SELECT count(*) FROM t1;
37
38 ANALYZE TABLE t1;
39
40 --replace_column 9 #
41 EXPLAIN SELECT fid, ST_AsText(g) FROM t1 WHERE ST_Within(g, ST_GeomFromText('Polygon((140 140,160 140,160 160,140 140))'));
42 SELECT fid, ST_AsText(g) FROM t1 WHERE ST_Within(g, ST_GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))')) ORDER BY fid;
43
44 DROP TABLE t1;
45
46 CREATE TABLE t1 (
47 fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
48 g GEOMETRY NOT NULL
49 ) ENGINE=InnoDB;
50
51 --disable_query_log
52 let $1=10;
53 while ($1)
54 {
55 let $2=10;
56 while ($2)
57 {
58 eval INSERT INTO t1 (g) VALUES (LineString(Point($1 * 10 - 9, $2 * 10 - 9), Point($1 * 10, $2 * 10)));
59 dec $2;
60 }
61 dec $1;
62 }
63 --enable_query_log
64
65 #--error 1464
66 ALTER TABLE t1 ADD SPATIAL KEY(g);
67 SHOW CREATE TABLE t1;
68 SELECT count(*) FROM t1;
69 SELECT fid, ST_AsText(g) FROM t1 WHERE ST_Within(g,
70 ST_GeomFromText('Polygon((40 40,60 40,60 60,40 40))')) ORDER BY fid;
71
72 DROP TABLE t1;
73
74 --echo End of 5.5 tests.