Commit 42e3e574 authored by Jan Lindström's avatar Jan Lindström

MDEV-13626: Merge InnoDB test cases from MySQL 5.7

Add missing innodb_gis tests.
parent f7090df7
This source diff could not be displayed because it is too large. You can view the blob instead.
DROP TABLE IF EXISTS linestring;
CREATE TABLE linestring (pk INTEGER NOT NULL PRIMARY KEY, linestring_key
GEOMETRY NOT NULL, linestring_nokey GEOMETRY NOT NULL) ENGINE=InnoDB ;
INSERT INTO linestring (pk, linestring_key, linestring_nokey) VALUES (1,
ST_GeomFromText('POINT(10 10) '), ST_GeomFromText('POINT(10 10) '));
INSERT INTO linestring (pk, linestring_key, linestring_nokey) VALUES (2,
ST_GeomFromText('LINESTRING(10 10,20 20,30 30)'), ST_GeomFromText('LINESTRING(10
10,20 20,30 30)'));
INSERT INTO linestring (pk, linestring_key, linestring_nokey) VALUES (3,
ST_GeomFromText('POLYGON((0 0,5 5,10 10,15 15,0 0),(10 10,20 20,30 30,40 40,10
10))'), ST_GeomFromText('POLYGON((0 0,5 5,10 10,15 15,0 0),(10 10,20 20,30 30,40
40,10 10))'));
INSERT INTO linestring (pk, linestring_key, linestring_nokey) VALUES (4,
ST_GeomFromText('MULTIPOINT(0 0,5 5,10 10,20 20) '), ST_GeomFromText('MULTIPOINT(0
0,5 5,10 10,20 20) '));
INSERT INTO linestring (pk, linestring_key, linestring_nokey) VALUES (5,
ST_GeomFromText('MULTILINESTRING((1 1,2 2,3 3),(10 10,20 20,30 30))'),
ST_GeomFromText('MULTILINESTRING((1 1,2 2,3 3),(10 10,20 20,30 30))'));
INSERT INTO linestring (pk, linestring_key, linestring_nokey) VALUES (6,
ST_GeomFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73
9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))'),
ST_GeomFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73
9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))'));
INSERT INTO linestring (pk, linestring_key, linestring_nokey) VALUES (7,
ST_GeomFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))'),
ST_GeomFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))'));
CREATE INDEX linestring_index ON linestring(linestring_nokey(5));
ALTER TABLE linestring ADD KEY (linestring_key(5));
SELECT ST_AsText(linestring_nokey) FROM linestring FORCE KEY (
linestring_key ) WHERE ST_CONTAINS( ST_GeomFromText('POLYGON( ( 3923 2815 , 4246
2122 , 4028 2971 , 4017 3019 , 3923 2815 ) )') , linestring_key ) AND
ST_WITHIN( ST_GeomFromText('POLYGON( ( 4135 3009 , 4914 3087 , 4236 3194 , 4091
3036 , 4022 3004 , 4087 3004 , 3853 2825 , 3490 3118 , 3784 3141 , 4052 3072
, 4205 2787 , 4024 2951 , 4076 3036 , 4041 3053 , 3789 3401 , 4080 3100 ,
4169 2867 , 4056 3029 , 4715 3943 , 4052 3098 , 4035 3080 , 4013 3077 , 4218
2915 , 3789 2980 , 4058 3046 , 4042 3043 , 4135 3009 ) )') , linestring_nokey
) AND ST_CONTAINS( ST_GeomFromText('POLYGON( ( 4082 2842 , 3678 3647 , 3420 3068
, 4018 3030 , 4082 2842 ) )') , linestring_key ) OR ST_INTERSECTS(
ST_GeomFromText('MULTILINESTRING( ( 4147 2871 , 4072 3042 , 4081 3099 , 3796
3021 , 4007 3463 ) , ( 4042 2808 , 4109 2816 , 3730 3673 ) )') ,
linestring_key ) AND ST_Length( linestring_nokey ) > 1;
ERROR 22023: Invalid GIS data provided to function st_within.
DROP TABLE linestring;
SELECT ST_WITHIN( LINESTRINGFROMTEXT(' LINESTRING( 5 9 , 3 4 , 4 1 , 4
4 , 4 9 ) ') , ST_SYMDIFFERENCE( ST_UNION( ST_ENVELOPE( POLYGONFROMTEXT('
POLYGON( ( 3 2 , 0 6 , 2 3 , 8 0 , 4 6 , 7 2 , 3 2 ) ) ') ) ,
MULTIPOLYGONFROMTEXT('
MULTIPOLYGON( ( ( 0 0 , 7 1 , 6 8 , 0 0 ) ) , ( ( 9 9 , 4 0 , 4 7 , 9 9) ) )
') ) , ST_SYMDIFFERENCE( POLYGONFROMTEXT(' POLYGON( ( 9 9 , 6 5 , 2 3 , 9 9
) ) ') , MULTIPOLYGONFROMTEXT(' MULTIPOLYGON( ( ( 2 2 , 5 2 , 5 2 , 2 6 , 2
2 ) ) , ( ( 7 7 , 3 7 , 2 9 , 7 1 , 7 7 ) ) ) ') ) ) );
ERROR HY000: Geometry overlay calculation error: geometry data is invalid in function st_union.
CREATE DATABASE geotest;
use geotest;
CREATE TABLE tmp (id int unsigned NOT NULL PRIMARY KEY);
INSERT INTO tmp VALUES (0), (1), (2), (3), (4), (5), (6), (7), (8), (9);
INSERT INTO tmp SELECT 10+id FROM tmp;
INSERT INTO tmp SELECT 20+id FROM tmp;
INSERT INTO tmp SELECT 40+id FROM tmp;
INSERT INTO tmp SELECT 80+id FROM tmp;
CREATE TABLE t1 (id int unsigned NOT NULL auto_increment PRIMARY KEY,
location point, INDEX (location)) ENGINE=InnoDB;
INSERT INTO t1 (location) SELECT POINT(tmp1.id, tmp2.id) FROM tmp tmp1,
tmp tmp2 ORDER BY tmp1.id, tmp2.id;
EXPLAIN SELECT id, ST_AsText(location) FROM t1 WHERE location = POINT(1,
2);
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 NULL ref location location 28 const 1 100.00 Using where
Warnings:
Note 1003 /* select#1 */ select `geotest`.`t1`.`id` AS `id`,st_astext(`geotest`.`t1`.`location`) AS `ST_AsText(location)` from `geotest`.`t1` where (`geotest`.`t1`.`location` = <cache>(point(1,2)))
SELECT id, ST_AsText(location) FROM t1 WHERE location = POINT(1, 2);
id ST_AsText(location)
163 POINT(1 2)
DROP TABLE t1;
DROP TABLE tmp;
DROP DATABASE geotest;
SET default_storage_engine=InnoDB;
SET innodb_strict_mode=OFF;
SET SESSION debug="+d,row_print_geometry_data";
SHOW VARIABLES LIKE '%engine%';
Variable_name Value
default_storage_engine InnoDB
default_tmp_storage_engine InnoDB
disabled_storage_engines
internal_tmp_disk_storage_engine InnoDB
USE test;
DROP TABLE IF EXISTS t1, gis_point, gis_line, gis_polygon;
DROP TABLE IF EXISTS gis_multi_point, gis_multi_line, gis_multi_polygon;
DROP TABLE IF EXISTS gis_geometrycollection, gis_geometry;
DROP TABLE IF EXISTS tab,tab2,tab3,parent,emp2;
DROP PROCEDURE IF EXISTS geominout;
DROP PROCEDURE IF EXISTS geom_insert;
DROP TRIGGER IF EXISTS geom_trigger;
DROP PROCEDURE IF EXISTS geom_cursor;
CREATE TABLE gis_point (fid INTEGER NOT NULL PRIMARY KEY, g POINT) ENGINE=InnoDB;
CREATE TABLE gis_line (fid INTEGER NOT NULL PRIMARY KEY, g LINESTRING) ENGINE=InnoDB;
CREATE TABLE gis_polygon (fid INTEGER NOT NULL PRIMARY KEY, g POLYGON) ENGINE=InnoDB;
CREATE TABLE gis_multi_point (fid INTEGER NOT NULL PRIMARY KEY, g MULTIPOINT) ENGINE=InnoDB;
CREATE TABLE gis_multi_line (fid INTEGER NOT NULL PRIMARY KEY, g MULTILINESTRING) ENGINE=InnoDB;
CREATE TABLE gis_multi_polygon (fid INTEGER NOT NULL PRIMARY KEY, g MULTIPOLYGON) ENGINE=InnoDB;
CREATE TABLE gis_geometrycollection (fid INTEGER NOT NULL PRIMARY KEY, g GEOMETRYCOLLECTION) ENGINE=InnoDB;
CREATE TABLE gis_geometry (fid INTEGER NOT NULL PRIMARY KEY, g GEOMETRY) ENGINE=InnoDB;
SHOW FIELDS FROM gis_point;
Field Type Null Key Default Extra
fid int(11) NO PRI NULL
g point YES NULL
SHOW FIELDS FROM gis_line;
Field Type Null Key Default Extra
fid int(11) NO PRI NULL
g linestring YES NULL
SHOW FIELDS FROM gis_polygon;
Field Type Null Key Default Extra
fid int(11) NO PRI NULL
g polygon YES NULL
SHOW FIELDS FROM gis_multi_point;
Field Type Null Key Default Extra
fid int(11) NO PRI NULL
g multipoint YES NULL
SHOW FIELDS FROM gis_multi_line;
Field Type Null Key Default Extra
fid int(11) NO PRI NULL
g multilinestring YES NULL
SHOW FIELDS FROM gis_multi_polygon;
Field Type Null Key Default Extra
fid int(11) NO PRI NULL
g multipolygon YES NULL
SHOW FIELDS FROM gis_geometrycollection;
Field Type Null Key Default Extra
fid int(11) NO PRI NULL
g geometrycollection YES NULL
SHOW FIELDS FROM gis_geometry;
Field Type Null Key Default Extra
fid int(11) NO PRI NULL
g geometry YES NULL
#INSERT using all WKT & WKB functions
INSERT INTO gis_point VALUES
(101, ST_PointFromText('POINT(10 10)')),
(102, ST_PointFromText('POINT(20 10)')),
(103, ST_PointFromText('POINT(20 20)')),
(104, ST_PointFromWKB(ST_AsWKB(ST_PointFromText('POINT(10 20)'))));
INSERT INTO gis_line VALUES
(105, ST_LineFromText('LINESTRING(0 0,0 10,10 0)')),
(106, ST_LineStringFromText('LINESTRING(10 10,20 10,20 20,10 20,10 10)')),
(107, ST_LineStringFromWKB(ST_AsWKB(LineString(Point(10, 10), Point(40, 10)))));
INSERT INTO gis_polygon VALUES
(108, ST_PolygonFromText('POLYGON((10 10,20 10,20 20,10 20,10 10))')),
(109, ST_PolyFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))')),
(110, ST_PolyFromWKB(ST_AsWKB(Polygon(LineString(Point(0, 0), Point(30, 0), Point(30, 30), Point(0, 0))))));
INSERT INTO gis_multi_point VALUES
(111, ST_MultiPointFromText('MULTIPOINT(0 0,10 10,10 20,20 20)')),
(112, ST_MPointFromText('MULTIPOINT(1 1,11 11,11 21,21 21)')),
(113, ST_MPointFromWKB(ST_AsWKB(MultiPoint(Point(3, 6), Point(4, 10)))));
INSERT INTO gis_multi_line VALUES
(114, ST_MultiLineStringFromText('MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))')),
(115, ST_MLineFromText('MULTILINESTRING((10 48,10 21,10 0))')),
(116, ST_MLineFromWKB(ST_AsWKB(MultiLineString(LineString(Point(1, 2), Point(3, 5)), LineString(Point(2, 5), Point(5, 8), Point(21, 7))))));
INSERT INTO gis_multi_polygon VALUES
(117, ST_MultiPolygonFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),
((59 18,67 18,67 13,59 13,59 18)))')),
(118, ST_MPolyFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),
(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')),
(119, ST_MPolyFromWKB(ST_AsWKB(MultiPolygon(Polygon(LineString(Point(0, 3), Point(3, 3), Point(3, 0), Point(0, 3)))))));
INSERT INTO gis_geometrycollection VALUES
(120, ST_GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')),
(121, ST_GeometryCollectionFromText('GEOMETRYCOLLECTION(POINT(10 10), LINESTRING(10 10,20 20))')),
(122, ST_GeometryFromWKB(ST_AsWKB(GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9))))));
#check INSERT using SELECT query
INSERT into gis_geometry SELECT * FROM gis_point;
INSERT into gis_geometry SELECT * FROM gis_line;
INSERT into gis_geometry SELECT * FROM gis_polygon;
INSERT into gis_geometry SELECT * FROM gis_multi_point;
INSERT into gis_geometry SELECT * FROM gis_multi_line;
INSERT into gis_geometry SELECT * FROM gis_multi_polygon;
INSERT into gis_geometry SELECT * FROM gis_geometrycollection;
#check format coversion functions & spatial values
SELECT fid, ST_AsText(g) FROM gis_point;
fid ST_AsText(g)
101 POINT(10 10)
102 POINT(20 10)
103 POINT(20 20)
104 POINT(10 20)
SELECT fid, ST_AsText(g) FROM gis_line;
fid ST_AsText(g)
105 LINESTRING(0 0,0 10,10 0)
106 LINESTRING(10 10,20 10,20 20,10 20,10 10)
107 LINESTRING(10 10,40 10)
SELECT fid, ST_AsText(g) FROM gis_polygon;
fid ST_AsText(g)
108 POLYGON((10 10,20 10,20 20,10 20,10 10))
109 POLYGON((0 0,50 0,50 50,0 50,0 0),(10 10,20 10,20 20,10 20,10 10))
110 POLYGON((0 0,30 0,30 30,0 0))
SELECT fid, ST_AsText(g) FROM gis_multi_point;
fid ST_AsText(g)
111 MULTIPOINT((0 0),(10 10),(10 20),(20 20))
112 MULTIPOINT((1 1),(11 11),(11 21),(21 21))
113 MULTIPOINT((3 6),(4 10))
SELECT fid, ST_AsText(g) FROM gis_multi_line;
fid ST_AsText(g)
114 MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))
115 MULTILINESTRING((10 48,10 21,10 0))
116 MULTILINESTRING((1 2,3 5),(2 5,5 8,21 7))
SELECT fid, ST_AsText(g) FROM gis_multi_polygon;
fid ST_AsText(g)
117 MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))
118 MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))
119 MULTIPOLYGON(((0 3,3 3,3 0,0 3)))
SELECT fid, ST_AsText(g) FROM gis_geometrycollection;
fid ST_AsText(g)
120 GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(0 0,10 10))
121 GEOMETRYCOLLECTION(POINT(10 10),LINESTRING(10 10,20 20))
122 GEOMETRYCOLLECTION(POINT(44 6),LINESTRING(3 6,7 9))
SELECT fid, ST_AsText(g) FROM gis_geometry;
fid ST_AsText(g)
101 POINT(10 10)
102 POINT(20 10)
103 POINT(20 20)
104 POINT(10 20)
105 LINESTRING(0 0,0 10,10 0)
106 LINESTRING(10 10,20 10,20 20,10 20,10 10)
107 LINESTRING(10 10,40 10)
108 POLYGON((10 10,20 10,20 20,10 20,10 10))
109 POLYGON((0 0,50 0,50 50,0 50,0 0),(10 10,20 10,20 20,10 20,10 10))
110 POLYGON((0 0,30 0,30 30,0 0))
111 MULTIPOINT((0 0),(10 10),(10 20),(20 20))
112 MULTIPOINT((1 1),(11 11),(11 21),(21 21))
113 MULTIPOINT((3 6),(4 10))
114 MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))
115 MULTILINESTRING((10 48,10 21,10 0))
116 MULTILINESTRING((1 2,3 5),(2 5,5 8,21 7))
117 MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))
118 MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))
119 MULTIPOLYGON(((0 3,3 3,3 0,0 3)))
120 GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(0 0,10 10))
121 GEOMETRYCOLLECTION(POINT(10 10),LINESTRING(10 10,20 20))
122 GEOMETRYCOLLECTION(POINT(44 6),LINESTRING(3 6,7 9))
#2.1 check DDL functionality on GIS datatypes
CREATE TABLE tab(c1 POINT,c2 LINESTRING,c3 POLYGON,C4 MULTIPOINT,c5 MULTILINESTRING ,
c6 MULTIPOLYGON,c7 GEOMETRYCOLLECTION ,c8 GEOMETRY) ENGINE=InnoDB;
#check information schema for all the columns refer to 14, except POINT which is 15
SELECT sc.name, sc.pos, sc.mtype
FROM information_schema.innodb_sys_columns sc
INNER JOIN information_schema.innodb_sys_tables st
ON sc.TABLE_ID=st.TABLE_ID
WHERE st.NAME='test/tab'
ORDER BY sc.name;
name pos mtype
c1 0 14
c2 1 14
c3 2 14
C4 3 14
c5 4 14
c6 5 14
c7 6 14
c8 7 14
#check Perform convesrion before INSERT using WKT functions
SET @c1=ST_PointFromText('POINT(10 10)');
SET @c2=ST_LineFromText('LINESTRING(10 10,20 20,30 30)');
SET @c3=ST_PolyFromText('POLYGON((0 0,5 5,10 10,15 15,0 0),(10 10,20 20,30 30,40 40,10 10))');
SET @c4=ST_MPointFromText('MULTIPOINT(0 0,5 5,10 10,20 20)');
SET @c5=ST_MLineFromText('MULTILINESTRING((1 1,2 2,3 3),(10 10,20 20,30 30))');
SET @c6=ST_MPolyFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))');
SET @c7=ST_GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))');
SET @c8=ST_GeomCollFromText('GeometryCollection(Point(1 1),LineString(2 2, 3 3))');
#Insert the spatial values
INSERT INTO tab VALUES(@c1,@c2,@c3,@c4,@c5,@c6,@c7,@c8);
#check index on GIS datatypes
CREATE INDEX idx1 on tab(c2(5) DESC) USING BTREE;
CREATE INDEX idx3 on tab(c3(5) ASC) USING BTREE;
CREATE UNIQUE INDEX idx2 on tab(c8(5) ASC) ;
#check equality predicate on the index columns
EXPLAIN SELECT ST_ASText(c1),ST_AsText(c2),ST_AsText(c8) FROM tab
WHERE c2=ST_LineFromText('LINESTRING(10 10,20 20,30 30)');
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE tab NULL ref idx1 idx1 8 const # 100.00 Using where
Warnings:
Note 1003 /* select#1 */ select st_astext(`test`.`tab`.`c1`) AS `ST_ASText(c1)`,st_astext(`test`.`tab`.`c2`) AS `ST_AsText(c2)`,st_astext(`test`.`tab`.`c8`) AS `ST_AsText(c8)` from `test`.`tab` where (`test`.`tab`.`c2` = <cache>(st_geometryfromtext('LINESTRING(10 10,20 20,30 30)')))
#check index with WKB function
EXPLAIN SELECT ST_ASText(c1),ST_AsText(c2),ST_AsText(c8)
FROM tab WHERE c2=ST_LineStringFromWKB(ST_AsWKB(ST_LineFromText('LINESTRING(10 10,20 20,30 30)')));
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE tab NULL ref idx1 idx1 8 const # 100.00 Using where
Warnings:
Note 1003 /* select#1 */ select st_astext(`test`.`tab`.`c1`) AS `ST_ASText(c1)`,st_astext(`test`.`tab`.`c2`) AS `ST_AsText(c2)`,st_astext(`test`.`tab`.`c8`) AS `ST_AsText(c8)` from `test`.`tab` where (`test`.`tab`.`c2` = <cache>(st_geometryfromwkb(st_aswkb(st_geometryfromtext('LINESTRING(10 10,20 20,30 30)')))))
#check index with WKT function
EXPLAIN SELECT ST_ASText(c1),ST_AsText(c2),ST_AsText(c8) FROM tab
WHERE c3=ST_PolyFromText('POLYGON((0 0,5 5,10 10,15 15,0 0),(10 10,20 20,30 30,40 40,10 10))');
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE tab NULL ref idx3 idx3 8 const # 100.00 Using where
Warnings:
Note 1003 /* select#1 */ select st_astext(`test`.`tab`.`c1`) AS `ST_ASText(c1)`,st_astext(`test`.`tab`.`c2`) AS `ST_AsText(c2)`,st_astext(`test`.`tab`.`c8`) AS `ST_AsText(c8)` from `test`.`tab` where (`test`.`tab`.`c3` = <cache>(st_geometryfromtext('POLYGON((0 0,5 5,10 10,15 15,0 0),(10 10,20 20,30 30,40 40,10 10))')))
#check index with WKB function
EXPLAIN SELECT ST_ASText(c1),ST_AsText(c2),ST_AsText(c8)
FROM tab
WHERE c3=ST_PolyFromWKB(ST_AsWkB(ST_PolyFromText('POLYGON((0 0,5 5,10 10,15 15,0 0),(10 10,20 20,30 30,40 40,10 10))')));
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE tab NULL ref idx3 idx3 8 const # 100.00 Using where
Warnings:
Note 1003 /* select#1 */ select st_astext(`test`.`tab`.`c1`) AS `ST_ASText(c1)`,st_astext(`test`.`tab`.`c2`) AS `ST_AsText(c2)`,st_astext(`test`.`tab`.`c8`) AS `ST_AsText(c8)` from `test`.`tab` where (`test`.`tab`.`c3` = <cache>(st_geometryfromwkb(st_aswkb(st_geometryfromtext('POLYGON((0 0,5 5,10 10,15 15,0 0),(10 10,20 20,30 30,40 40,10 10))')))))
#check index with WKT function
EXPLAIN SELECT ST_ASText(c1),ST_AsText(c2),ST_AsText(c8) FROM tab
WHERE c8=ST_GeomCollFromText('GeometryCollection(Point(1 1),LineString(2 2, 3 3))');
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE tab NULL const idx2 idx2 8 const # 100.00 NULL
Warnings:
Note 1003 /* select#1 */ select st_astext('
#check index with WKB function
EXPLAIN SELECT ST_ASText(c1),ST_AsText(c2),ST_AsText(c8)
FROM tab
WHERE c8=ST_GeometryFromWKB(ST_AsWKB(ST_GeomCollFromText('GeometryCollection(Point(1 1),LineString(2 2, 3 3))')));
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE tab NULL const idx2 idx2 8 const # 100.00 NULL
Warnings:
Note 1003 /* select#1 */ select st_astext('
#check range predicate on the index columns
EXPLAIN SELECT ST_ASText(c1),ST_AsText(c2),ST_AsText(c8) FROM tab
WHERE c2>=ST_LineFromText('LINESTRING(10 10,20 20,30 30)');
ERROR HY000: Incorrect arguments to >=
EXPLAIN SELECT ST_ASText(c1),ST_AsText(c2),ST_AsText(c8) FROM tab
WHERE c3>=ST_PolyFromText('POLYGON((0 0,5 5,10 10,15 15,0 0),(10 10,20 20,30 30,40 40,10 10))');
ERROR HY000: Incorrect arguments to >=
EXPLAIN SELECT ST_ASText(c1),ST_AsText(c2),ST_AsText(c8) FROM tab
WHERE c8>=ST_GeomCollFromText('GeometryCollection(Point(1 1),LineString(2 2, 3 3))');
ERROR HY000: Incorrect arguments to >=
#check index with DELETE operation
EXPLAIN DELETE FROM tab
WHERE c8=ST_GeometryFromWKB(ST_AsWKB(ST_GeomCollFromText('GeometryCollection(Point(1 1),LineString(2 2, 3 3))')));
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 DELETE tab NULL range idx2 idx2 8 const # 100.00 Using where
#check the spatial values
SELECT ST_AsText(c1) FROM tab;
ST_AsText(c1)
POINT(10 10)
SELECT ST_AsText(c2) FROM tab;
ST_AsText(c2)
LINESTRING(10 10,20 20,30 30)
SELECT ST_AsText(c3) FROM tab;
ST_AsText(c3)
POLYGON((0 0,5 5,10 10,15 15,0 0),(10 10,20 20,30 30,40 40,10 10))
SELECT ST_AsText(c4) FROM tab;
ST_AsText(c4)
MULTIPOINT((0 0),(5 5),(10 10),(20 20))
SELECT ST_AsText(c5) FROM tab;
ST_AsText(c5)
MULTILINESTRING((1 1,2 2,3 3),(10 10,20 20,30 30))
SELECT ST_AsText(c6) FROM tab;
ST_AsText(c6)
MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))
SELECT ST_AsText(c7) FROM tab;
ST_AsText(c7)
GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(0 0,10 10))
SELECT ST_AsText(c8) From tab;
ST_AsText(c8)
GEOMETRYCOLLECTION(POINT(1 1),LINESTRING(2 2,3 3))
#check by modify the column type
ALTER TABLE tab MODIFY COLUMN c1 Geometry;
ALTER TABLE tab MODIFY COLUMN c2 Geometry;
ALTER TABLE tab MODIFY COLUMN c3 Geometry;
ALTER TABLE tab MODIFY COLUMN c4 Geometry;
ALTER TABLE tab MODIFY COLUMN c5 Geometry;
ALTER TABLE tab MODIFY COLUMN c6 Geometry;
ALTER TABLE tab MODIFY COLUMN c7 Geometry;
#check column datatypes
SHOW FIELDS FROM tab;
Field Type Null Key Default Extra
c1 geometry YES NULL
c2 geometry YES MUL NULL
c3 geometry YES MUL NULL
c4 geometry YES NULL
c5 geometry YES NULL
c6 geometry YES NULL
c7 geometry YES NULL
c8 geometry YES UNI NULL
#check the data after modify
SELECT ST_AsText(c1) FROM tab;
ST_AsText(c1)
POINT(10 10)
SELECT ST_AsText(c2) FROM tab;
ST_AsText(c2)
LINESTRING(10 10,20 20,30 30)
SELECT ST_AsText(c3) FROM tab;
ST_AsText(c3)
POLYGON((0 0,5 5,10 10,15 15,0 0),(10 10,20 20,30 30,40 40,10 10))
SELECT ST_AsText(c4) FROM tab;
ST_AsText(c4)
MULTIPOINT((0 0),(5 5),(10 10),(20 20))
SELECT ST_AsText(c5) FROM tab;
ST_AsText(c5)
MULTILINESTRING((1 1,2 2,3 3),(10 10,20 20,30 30))
SELECT ST_AsText(c6) FROM tab;
ST_AsText(c6)
MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))
SELECT ST_AsText(c7) FROM tab;
ST_AsText(c7)
GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(0 0,10 10))
SELECT ST_AsText(c8) From tab;
ST_AsText(c8)
GEOMETRYCOLLECTION(POINT(1 1),LINESTRING(2 2,3 3))
#check by modify the column type
ALTER TABLE tab MODIFY COLUMN c1 POINT;
ALTER TABLE tab MODIFY COLUMN c2 LINESTRING;
ALTER TABLE tab MODIFY COLUMN c3 POLYGON;
ALTER TABLE tab MODIFY COLUMN c4 MULTIPOINT;
ALTER TABLE tab MODIFY COLUMN c5 MULTILINESTRING;
ALTER TABLE tab MODIFY COLUMN c6 MULTIPOLYGON;
ALTER TABLE tab MODIFY COLUMN c7 GEOMETRYCOLLECTION;
#check column datatypes
SHOW FIELDS FROM tab;
Field Type Null Key Default Extra
c1 point YES NULL
c2 linestring YES MUL NULL
c3 polygon YES MUL NULL
c4 multipoint YES NULL
c5 multilinestring YES NULL
c6 multipolygon YES NULL
c7 geometrycollection YES NULL
c8 geometry YES UNI NULL
#check the data after modify
SELECT ST_AsText(c1) FROM tab;
ST_AsText(c1)
POINT(10 10)
SELECT ST_AsText(c2) FROM tab;
ST_AsText(c2)
LINESTRING(10 10,20 20,30 30)
SELECT ST_AsText(c3) FROM tab;
ST_AsText(c3)
POLYGON((0 0,5 5,10 10,15 15,0 0),(10 10,20 20,30 30,40 40,10 10))
SELECT ST_AsText(c4) FROM tab;
ST_AsText(c4)
MULTIPOINT((0 0),(5 5),(10 10),(20 20))
SELECT ST_AsText(c5) FROM tab;
ST_AsText(c5)
MULTILINESTRING((1 1,2 2,3 3),(10 10,20 20,30 30))
SELECT ST_AsText(c6) FROM tab;
ST_AsText(c6)
MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))
SELECT ST_AsText(c7) FROM tab;
ST_AsText(c7)
GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(0 0,10 10))
SELECT ST_AsText(c8) From tab;
ST_AsText(c8)
GEOMETRYCOLLECTION(POINT(1 1),LINESTRING(2 2,3 3))
#check change the column type
ALTER TABLE tab MODIFY COLUMN c1 BLOB;
#check column datatypes
SHOW CREATE TABLE tab;
Table Create Table
tab CREATE TABLE `tab` (
`c1` blob,
`c2` linestring DEFAULT NULL,
`c3` polygon DEFAULT NULL,
`c4` multipoint DEFAULT NULL,
`c5` multilinestring DEFAULT NULL,
`c6` multipolygon DEFAULT NULL,
`c7` geometrycollection DEFAULT NULL,
`c8` geometry DEFAULT NULL,
UNIQUE KEY `idx2` (`c8`(5)),
KEY `idx1` (`c2`(5)) USING BTREE,
KEY `idx3` (`c3`(5)) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=latin1
#check the data after modify
SELECT ST_AsText(c1) FROM tab;
ST_AsText(c1)
POINT(10 10)
#change the column name
ALTER TABLE tab CHANGE COLUMN c1 c0 GEOMETRY ;
#check column datatypes
SHOW FIELDS FROM tab;
Field Type Null Key Default Extra
c0 geometry YES NULL
c2 linestring YES MUL NULL
c3 polygon YES MUL NULL
c4 multipoint YES NULL
c5 multilinestring YES NULL
c6 multipolygon YES NULL
c7 geometrycollection YES NULL
c8 geometry YES UNI NULL
#add primary key
ALTER TABLE tab ADD PRIMARY KEY pk2(c8(5));
#check columns
SHOW FIELDS FROM tab;
Field Type Null Key Default Extra
c0 geometry YES NULL
c2 linestring YES MUL NULL
c3 polygon YES MUL NULL
c4 multipoint YES NULL
c5 multilinestring YES NULL
c6 multipolygon YES NULL
c7 geometrycollection YES NULL
c8 geometry NO PRI NULL
#drop key
ALTER TABLE tab DROP PRIMARY KEY;
#check columns
SHOW FIELDS FROM tab;
Field Type Null Key Default Extra
c0 geometry YES NULL
c2 linestring YES MUL NULL
c3 polygon YES MUL NULL
c4 multipoint YES NULL
c5 multilinestring YES NULL
c6 multipolygon YES NULL
c7 geometrycollection YES NULL
c8 geometry NO UNI NULL
#cleanup the table
TRUNCATE TABLE tab;
#check with procedures
#crate proc with INOUT params
CREATE PROCEDURE geom_insert(IN c1 POINT,IN c2 LINESTRING,IN c3 POLYGON,
IN c4 MULTIPOINT,IN c5 MULTILINESTRING, IN c6 MULTIPOLYGON,IN c7 GEOMETRYCOLLECTION,
IN c8 GEOMETRY)
BEGIN
INSERT INTO tab VALUES(@c1,@c2,@c3,@c4,@c5,@c6,@c7,@c8);
END |
#set the spatial values
SET @c1=ST_PointFromText('POINT(10 10)');
SET @c2=ST_LineFromText('LINESTRING(10 10,20 20,30 30)');
SET @c3=ST_PolyFromText('POLYGON((0 0,5 5,10 10,15 15,0 0),(10 10,20 20,30 30,40 40,10 10))');
SET @c4=ST_MPointFromText('MULTIPOINT(0 0,5 5,10 10,20 20)');
SET @c5=ST_MLineFromText('MULTILINESTRING((1 1,2 2,3 3),(10 10,20 20,30 30))');
SET @c6=ST_MPolyFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))');
SET @c7=ST_GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))');
SET @c8=ST_GeomCollFromText('GeometryCollection(Point(1 1),LineString(2 2, 3 3))');
#call the proc
CALL geom_insert(@c1,@c2,@c3,@c4,@c5,@c6,@c7,@c8);
#check the values ofter proc call
SELECT ST_AsText(c0) FROM tab;
ST_AsText(c0)
POINT(10 10)
SELECT ST_AsText(c2) FROM tab;
ST_AsText(c2)
LINESTRING(10 10,20 20,30 30)
SELECT ST_AsText(c3) FROM tab;
ST_AsText(c3)
POLYGON((0 0,5 5,10 10,15 15,0 0),(10 10,20 20,30 30,40 40,10 10))
SELECT ST_AsText(c4) FROM tab;
ST_AsText(c4)
MULTIPOINT((0 0),(5 5),(10 10),(20 20))
SELECT ST_AsText(c5) FROM tab;
ST_AsText(c5)
MULTILINESTRING((1 1,2 2,3 3),(10 10,20 20,30 30))
SELECT ST_AsText(c6) FROM tab;
ST_AsText(c6)
MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))
SELECT ST_AsText(c7) FROM tab;
ST_AsText(c7)
GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(0 0,10 10))
SELECT ST_AsText(c8) From tab;
ST_AsText(c8)
GEOMETRYCOLLECTION(POINT(1 1),LINESTRING(2 2,3 3))
#set the input spatial value
SET @c9=ST_GeomCollFromText('GeometryCollection(Point(1 1),LineString(2 2, 3 3))');
#crate a proc with INOUT params and pass a value.
CREATE PROCEDURE geominout(INOUT c9 GEOMETRY)
BEGIN
SELECT ST_AsText(@c9);
SET c9=ST_GeomCollFromText('GeometryCollection(Point(10 10),LineString(20 20, 30 30))');
END|
#call the proc and then change the spatial value of c8
CALL geominout(@c9);
ST_AsText(@c9)
GEOMETRYCOLLECTION(POINT(1 1),LINESTRING(2 2,3 3))
#now check the out spatial values should be changed to new values
SELECT ST_AsText(@c9);
ST_AsText(@c9)
GEOMETRYCOLLECTION(POINT(10 10),LINESTRING(20 20,30 30))
#delete the records
TRUNCATE TABLE tab;
#create another table same as tab
CREATE TABLE tab2 AS SELECT * FROM tab;
#check the table definition
SHOW CREATE TABLE tab2;
Table Create Table
tab2 CREATE TABLE `tab2` (
`c0` geometry DEFAULT NULL,
`c2` linestring DEFAULT NULL,
`c3` polygon DEFAULT NULL,
`c4` multipoint DEFAULT NULL,
`c5` multilinestring DEFAULT NULL,
`c6` multipolygon DEFAULT NULL,
`c7` geometrycollection DEFAULT NULL,
`c8` geometry NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
#create a tigger and populate the values into tab2
CREATE TRIGGER geom_trigger AFTER INSERT ON tab
FOR EACH ROW
BEGIN
INSERT INTO tab2 VALUES (@c1,@c2,@c3,@c4,@c5,@c6,@c7,@c8);
END|
#set the spatial values
SET @c1=ST_PointFromText('POINT(10 10)');
SET @c2=ST_LineFromText('LINESTRING(10 10,20 20,30 30)');
SET @c3=ST_PolyFromText('POLYGON((0 0,5 5,10 10,15 15,0 0),(10 10,20 20,30 30,40 40,10 10))');
SET @c4=ST_MPointFromText('MULTIPOINT(0 0,5 5,10 10,20 20)');
SET @c5=ST_MLineFromText('MULTILINESTRING((1 1,2 2,3 3),(10 10,20 20,30 30))');
SET @c6=ST_MPolyFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))');
SET @c7=ST_GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))');
SET @c8=ST_GeomCollFromText('GeometryCollection(Point(1 1),LineString(2 2, 3 3))');
#Insert the spatial values
INSERT INTO tab VALUES(@c1,@c2,@c3,@c4,@c5,@c6,@c7,@c8);
#check the values whether populated
SELECT ST_AsText(c0) FROM tab2;
ST_AsText(c0)
POINT(10 10)
SELECT ST_AsText(c2) FROM tab2;
ST_AsText(c2)
LINESTRING(10 10,20 20,30 30)
SELECT ST_AsText(c3) FROM tab2;
ST_AsText(c3)
POLYGON((0 0,5 5,10 10,15 15,0 0),(10 10,20 20,30 30,40 40,10 10))
SELECT ST_AsText(c4) FROM tab2;
ST_AsText(c4)
MULTIPOINT((0 0),(5 5),(10 10),(20 20))
SELECT ST_AsText(c5) FROM tab2;
ST_AsText(c5)
MULTILINESTRING((1 1,2 2,3 3),(10 10,20 20,30 30))
SELECT ST_AsText(c6) FROM tab2;
ST_AsText(c6)
MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))
SELECT ST_AsText(c7) FROM tab2;
ST_AsText(c7)
GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(0 0,10 10))
SELECT ST_AsText(c8) From tab2;
ST_AsText(c8)
GEOMETRYCOLLECTION(POINT(1 1),LINESTRING(2 2,3 3))
#check Cursor with Geometry
CREATE PROCEDURE geom_cursor()
BEGIN
DECLARE v GEOMETRY;
DECLARE c CURSOR FOR SELECT c8 FROM tab2;
OPEN c;
FETCH c INTO v;
CLOSE c;
SELECT ST_AsText(v);
END|
# the following line was commented due the Bug#16282246
# Once it is fixed, the comment will be removed.
# right now bug fixing date is unknown.
check self join
SELECT ST_AsText(a.c0),ST_AsText(a.c2),ST_AsText(a.c3)
FROM tab a,tab2 b WHERE a.c0=b.c0 AND a.c2=b.c2
AND a.c3=b.c3 AND a.c4=b.c4 AND a.c5=b.c5 AND a.c6=b.c6
AND a.c7=b.c7 AND a.c8=b.c8;
ST_AsText(a.c0) ST_AsText(a.c2) ST_AsText(a.c3)
POINT(10 10) LINESTRING(10 10,20 20,30 30) POLYGON((0 0,5 5,10 10,15 15,0 0),(10 10,20 20,30 30,40 40,10 10))
#check equi join
SELECT ST_AsText(a.c2),ST_AsText(b.c2) FROM tab a,tab2 b WHERE a.c2=b.c2;
ST_AsText(a.c2) ST_AsText(b.c2)
LINESTRING(10 10,20 20,30 30) LINESTRING(10 10,20 20,30 30)
#check DELETE stmt with Where clause and a constant predicate
DELETE FROM tab
Where c8=c8=ST_GeometryFromWKB(ST_AsWKB(ST_GeomCollFromText('GeometryCollection(Point(1 1),LineString(2 2, 3 3))')));
#check the data, should 0
SELECT COUNT(*) FROM tab;
COUNT(*)
1
#check UPDATE stmt with Where clause and a constant predicate
SET @c8=ST_GeomCollFromText('GeometryCollection(Point(10 10),LineString(20 20, 30 30))');
UPDATE tab2 SET c8=@c8
WHERE c2=ST_LineStringFromWKB(ST_AsWKB(ST_LineFromText('LINESTRING(10 10,20 20,30 30)')));
#check the column should be modified to LINESTRING(10 10,20 20,30 30)
SELECT ST_AsText(c8) From tab2;
ST_AsText(c8)
GEOMETRYCOLLECTION(POINT(10 10),LINESTRING(20 20,30 30))
#check GIS datatypes with aggregate functions
SELECT COUNT(ST_AsText(g)) FROM gis_point;
COUNT(ST_AsText(g))
4
SELECT COUNT(ST_AsText(g)) FROM gis_line;
COUNT(ST_AsText(g))
3
SELECT COUNT(ST_AsText(g)) FROM gis_polygon;
COUNT(ST_AsText(g))
3
SELECT COUNT(ST_AsText(g)) FROM gis_multi_point;
COUNT(ST_AsText(g))
3
SELECT COUNT(ST_AsText(g)) FROM gis_multi_line;
COUNT(ST_AsText(g))
3
SELECT COUNT(ST_AsText(g)) FROM gis_multi_polygon;
COUNT(ST_AsText(g))
3
SELECT COUNT(ST_AsText(g)) FROM gis_geometrycollection;
COUNT(ST_AsText(g))
3
SELECT COUNT(ST_AsText(g)) FROM gis_geometry;
COUNT(ST_AsText(g))
22
SELECT SUM(ST_AsText(g)) FROM gis_point;
SUM(ST_AsText(g))
0
SELECT SUM(ST_AsText(g)) FROM gis_line;
SUM(ST_AsText(g))
0
SELECT AVG(ST_AsText(g)) FROM gis_polygon;
AVG(ST_AsText(g))
0
#here it show some string value no meaning
SELECT MAX(ST_AsText(g)) FROM gis_multi_point;
MAX(ST_AsText(g))
MULTIPOINT((3 6),(4 10))
#here it show some string value no meaning
SELECT MIN(ST_AsText(g)) FROM gis_multi_line;
MIN(ST_AsText(g))
MULTILINESTRING((1 2,3 5),(2 5,5 8,21 7))
SELECT STD(ST_AsText(g)) FROM gis_multi_polygon;
STD(ST_AsText(g))
0
SELECT COUNT(ST_AsText(g)) FROM gis_geometrycollection;
COUNT(ST_AsText(g))
3
SELECT AVG(ST_AsText(g)) FROM gis_geometry;
AVG(ST_AsText(g))
0
#check Datatypes with compression tables
CREATE TABLE tab3(c1 POINT,c2 LINESTRING,c3 POLYGON,C4 MULTIPOINT,c5 MULTILINESTRING ,
c6 MULTIPOLYGON,c7 GEOMETRYCOLLECTION ,c8 GEOMETRY) ENGINE=InnoDB
KEY_BLOCK_SIZE=8 ROW_FORMAT=COMPRESSED;
#check file format
SHOW CREATE TABLE tab3;
Table Create Table
tab3 CREATE TABLE `tab3` (
`c1` point DEFAULT NULL,
`c2` linestring DEFAULT NULL,
`c3` polygon DEFAULT NULL,
`C4` multipoint DEFAULT NULL,
`c5` multilinestring DEFAULT NULL,
`c6` multipolygon DEFAULT NULL,
`c7` geometrycollection DEFAULT NULL,
`c8` geometry DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=COMPRESSED KEY_BLOCK_SIZE=8
ALTER TABLE tab3 KEY_BLOCK_SIZE=16 ROW_FORMAT=Dynamic;
#check file format
SHOW CREATE TABLE tab3;
Table Create Table
tab3 CREATE TABLE `tab3` (
`c1` point DEFAULT NULL,
`c2` linestring DEFAULT NULL,
`c3` polygon DEFAULT NULL,
`C4` multipoint DEFAULT NULL,
`c5` multilinestring DEFAULT NULL,
`c6` multipolygon DEFAULT NULL,
`c7` geometrycollection DEFAULT NULL,
`c8` geometry DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC KEY_BLOCK_SIZE=16
#check information schema for all the columns refer to 14, except POINT which is 15
SELECT sc.name, sc.pos, sc.mtype
FROM information_schema.innodb_sys_columns sc
INNER JOIN information_schema.innodb_sys_tables st
ON sc.TABLE_ID=st.TABLE_ID
WHERE st.NAME='test/tab3'
ORDER BY sc.name;
name pos mtype
c1 0 14
c2 1 14
c3 2 14
C4 3 14
c5 4 14
c6 5 14
c7 6 14
c8 7 14
#check Perform convesrion before INSERT using WKT functions
SET @c1=ST_PointFromText('POINT(10 10)');
SET @c2=ST_LineFromText('LINESTRING(10 10,20 20,30 30)');
SET @c3=ST_PolyFromText('POLYGON((0 0,5 5,10 10,15 15,0 0),(10 10,20 20,30 30,40 40,10 10))');
SET @c4=ST_MPointFromText('MULTIPOINT(0 0,5 5,10 10,20 20)');
SET @c5=ST_MLineFromText('MULTILINESTRING((1 1,2 2,3 3),(10 10,20 20,30 30))');
SET @c6=ST_MPolyFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))');
SET @c7=ST_GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))');
SET @c8=ST_GeomCollFromText('GeometryCollection(Point(1 1),LineString(2 2, 3 3))');
#Insert the spatial values
INSERT INTO tab3 VALUES(@c1,@c2,@c3,@c4,@c5,@c6,@c7,@c8);
#check index on GIS datatypes
CREATE INDEX idx1 on tab3(c2(5) DESC) USING BTREE;
CREATE INDEX idx3 on tab3(c3(5) ASC) USING BTREE;
CREATE UNIQUE INDEX idx2 on tab3(c8(5) ASC) ;
#check equality predicate on the index columns
EXPLAIN SELECT ST_ASText(c1),ST_AsText(c2),ST_AsText(c8) FROM tab3
WHERE c2=ST_LineFromText('LINESTRING(10 10,20 20,30 30)');
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE tab3 NULL ref idx1 idx1 8 const # 100.00 Using where
Warnings:
Note 1003 /* select#1 */ select st_astext(`test`.`tab3`.`c1`) AS `ST_ASText(c1)`,st_astext(`test`.`tab3`.`c2`) AS `ST_AsText(c2)`,st_astext(`test`.`tab3`.`c8`) AS `ST_AsText(c8)` from `test`.`tab3` where (`test`.`tab3`.`c2` = <cache>(st_geometryfromtext('LINESTRING(10 10,20 20,30 30)')))
#check index with WKB function
EXPLAIN SELECT ST_ASText(c1),ST_AsText(c2),ST_AsText(c8)
FROM tab3 WHERE c2=ST_LineStringFromWKB(ST_AsWKB(ST_LineFromText('LINESTRING(10 10,20 20,30 30)')));
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE tab3 NULL ref idx1 idx1 8 const # 100.00 Using where
Warnings:
Note 1003 /* select#1 */ select st_astext(`test`.`tab3`.`c1`) AS `ST_ASText(c1)`,st_astext(`test`.`tab3`.`c2`) AS `ST_AsText(c2)`,st_astext(`test`.`tab3`.`c8`) AS `ST_AsText(c8)` from `test`.`tab3` where (`test`.`tab3`.`c2` = <cache>(st_geometryfromwkb(st_aswkb(st_geometryfromtext('LINESTRING(10 10,20 20,30 30)')))))
#check index with WKT function
EXPLAIN SELECT ST_ASText(c1),ST_AsText(c2),ST_AsText(c8) FROM tab3
WHERE c3=ST_PolyFromText('POLYGON((0 0,5 5,10 10,15 15,0 0),(10 10,20 20,30 30,40 40,10 10))');
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE tab3 NULL ref idx3 idx3 8 const # 100.00 Using where
Warnings:
Note 1003 /* select#1 */ select st_astext(`test`.`tab3`.`c1`) AS `ST_ASText(c1)`,st_astext(`test`.`tab3`.`c2`) AS `ST_AsText(c2)`,st_astext(`test`.`tab3`.`c8`) AS `ST_AsText(c8)` from `test`.`tab3` where (`test`.`tab3`.`c3` = <cache>(st_geometryfromtext('POLYGON((0 0,5 5,10 10,15 15,0 0),(10 10,20 20,30 30,40 40,10 10))')))
#check index with WKB function
EXPLAIN SELECT ST_ASText(c1),ST_AsText(c2),ST_AsText(c8)
FROM tab3
WHERE c3=ST_PolyFromWKB(ST_AsWkB(ST_PolyFromText('POLYGON((0 0,5 5,10 10,15 15,0 0),(10 10,20 20,30 30,40 40,10 10))')));
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE tab3 NULL ref idx3 idx3 8 const # 100.00 Using where
Warnings:
Note 1003 /* select#1 */ select st_astext(`test`.`tab3`.`c1`) AS `ST_ASText(c1)`,st_astext(`test`.`tab3`.`c2`) AS `ST_AsText(c2)`,st_astext(`test`.`tab3`.`c8`) AS `ST_AsText(c8)` from `test`.`tab3` where (`test`.`tab3`.`c3` = <cache>(st_geometryfromwkb(st_aswkb(st_geometryfromtext('POLYGON((0 0,5 5,10 10,15 15,0 0),(10 10,20 20,30 30,40 40,10 10))')))))
#check index with WKT function
EXPLAIN SELECT ST_ASText(c1),ST_AsText(c2),ST_AsText(c8) FROM tab3
WHERE c8=ST_GeomCollFromText('GeometryCollection(Point(1 1),LineString(2 2, 3 3))');
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE tab3 NULL const idx2 idx2 8 const # 100.00 NULL
Warnings:
Note 1003 /* select#1 */ select st_astext('
#check index with WKB function
EXPLAIN SELECT ST_ASText(c1),ST_AsText(c2),ST_AsText(c8)
FROM tab3
WHERE c8=ST_GeometryFromWKB(ST_AsWKB(ST_GeomCollFromText('GeometryCollection(Point(1 1),LineString(2 2, 3 3))')));
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE tab3 NULL const idx2 idx2 8 const # 100.00 NULL
Warnings:
Note 1003 /* select#1 */ select st_astext('
#check range predicate on the index columns
EXPLAIN SELECT ST_ASText(c1),ST_AsText(c2),ST_AsText(c8) FROM tab3
WHERE c2>=ST_LineFromText('LINESTRING(10 10,20 20,30 30)');
ERROR HY000: Incorrect arguments to >=
EXPLAIN SELECT ST_ASText(c1),ST_AsText(c2),ST_AsText(c8) FROM tab3
WHERE c3>=ST_PolyFromText('POLYGON((0 0,5 5,10 10,15 15,0 0),(10 10,20 20,30 30,40 40,10 10))');
ERROR HY000: Incorrect arguments to >=
EXPLAIN SELECT ST_ASText(c1),ST_AsText(c2),ST_AsText(c8) FROM tab3
WHERE c8>=ST_GeomCollFromText('GeometryCollection(Point(1 1),LineString(2 2, 3 3))');
ERROR HY000: Incorrect arguments to >=
#check index with DELETE operation
EXPLAIN DELETE FROM tab3
WHERE c8=ST_GeometryFromWKB(ST_AsWKB(ST_GeomCollFromText('GeometryCollection(Point(1 1),LineString(2 2, 3 3))')));
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 DELETE tab3 NULL range idx2 idx2 8 const # 100.00 Using where
#check the spatial values
SELECT ST_AsText(c1) FROM tab3;
ST_AsText(c1)
POINT(10 10)
SELECT ST_AsText(c2) FROM tab3;
ST_AsText(c2)
LINESTRING(10 10,20 20,30 30)
SELECT ST_AsText(c3) FROM tab3;
ST_AsText(c3)
POLYGON((0 0,5 5,10 10,15 15,0 0),(10 10,20 20,30 30,40 40,10 10))
SELECT ST_AsText(c4) FROM tab3;
ST_AsText(c4)
MULTIPOINT((0 0),(5 5),(10 10),(20 20))
SELECT ST_AsText(c5) FROM tab3;
ST_AsText(c5)
MULTILINESTRING((1 1,2 2,3 3),(10 10,20 20,30 30))
SELECT ST_AsText(c6) FROM tab3;
ST_AsText(c6)
MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))
SELECT ST_AsText(c7) FROM tab3;
ST_AsText(c7)
GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(0 0,10 10))
SELECT ST_AsText(c8) From tab3;
ST_AsText(c8)
GEOMETRYCOLLECTION(POINT(1 1),LINESTRING(2 2,3 3))
#check with Row_format = Dynamic
ALTER TABLE tab3 ROW_FORMAT=Dynamic;
#check file format
SHOW CREATE TABLE tab3;
Table Create Table
tab3 CREATE TABLE `tab3` (
`c1` point DEFAULT NULL,
`c2` linestring DEFAULT NULL,
`c3` polygon DEFAULT NULL,
`C4` multipoint DEFAULT NULL,
`c5` multilinestring DEFAULT NULL,
`c6` multipolygon DEFAULT NULL,
`c7` geometrycollection DEFAULT NULL,
`c8` geometry DEFAULT NULL,
UNIQUE KEY `idx2` (`c8`(5)),
KEY `idx1` (`c2`(5)) USING BTREE,
KEY `idx3` (`c3`(5)) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=latin1 ROW_FORMAT=DYNAMIC KEY_BLOCK_SIZE=16
#check index with WKB function
EXPLAIN SELECT ST_ASText(c1),ST_AsText(c2),ST_AsText(c8)
FROM tab3 WHERE c2=ST_LineStringFromWKB(ST_AsWKB(ST_LineFromText('LINESTRING(10 10,20 20,30 30)')));
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE tab3 NULL ref idx1 idx1 8 const # 100.00 Using where
Warnings:
Note 1003 /* select#1 */ select st_astext(`test`.`tab3`.`c1`) AS `ST_ASText(c1)`,st_astext(`test`.`tab3`.`c2`) AS `ST_AsText(c2)`,st_astext(`test`.`tab3`.`c8`) AS `ST_AsText(c8)` from `test`.`tab3` where (`test`.`tab3`.`c2` = <cache>(st_geometryfromwkb(st_aswkb(st_geometryfromtext('LINESTRING(10 10,20 20,30 30)')))))
#check index with WKT function
EXPLAIN SELECT ST_ASText(c1),ST_AsText(c2),ST_AsText(c8) FROM tab3
WHERE c3=ST_PolyFromText('POLYGON((0 0,5 5,10 10,15 15,0 0),(10 10,20 20,30 30,40 40,10 10))');
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE tab3 NULL ref idx3 idx3 8 const # 100.00 Using where
Warnings:
Note 1003 /* select#1 */ select st_astext(`test`.`tab3`.`c1`) AS `ST_ASText(c1)`,st_astext(`test`.`tab3`.`c2`) AS `ST_AsText(c2)`,st_astext(`test`.`tab3`.`c8`) AS `ST_AsText(c8)` from `test`.`tab3` where (`test`.`tab3`.`c3` = <cache>(st_geometryfromtext('POLYGON((0 0,5 5,10 10,15 15,0 0),(10 10,20 20,30 30,40 40,10 10))')))
#check the Geometry property functions
SELECT fid, ST_Dimension(g) FROM gis_geometry;
fid ST_Dimension(g)
101 0
102 0
103 0
104 0
105 1
106 1
107 1
108 2
109 2
110 2
111 0
112 0
113 0
114 1
115 1
116 1
117 2
118 2
119 2
120 1
121 1
122 1
SELECT fid, ST_GeometryType(g) FROM gis_geometry;
fid ST_GeometryType(g)
101 POINT
102 POINT
103 POINT
104 POINT
105 LINESTRING
106 LINESTRING
107 LINESTRING
108 POLYGON
109 POLYGON
110 POLYGON
111 MULTIPOINT
112 MULTIPOINT
113 MULTIPOINT
114 MULTILINESTRING
115 MULTILINESTRING
116 MULTILINESTRING
117 MULTIPOLYGON
118 MULTIPOLYGON
119 MULTIPOLYGON
120 GEOMETRYCOLLECTION
121 GEOMETRYCOLLECTION
122 GEOMETRYCOLLECTION
SELECT fid, ST_IsEmpty(g) FROM gis_geometry;
fid ST_IsEmpty(g)
101 0
102 0
103 0
104 0
105 0
106 0
107 0
108 0
109 0
110 0
111 0
112 0
113 0
114 0
115 0
116 0
117 0
118 0
119 0
120 0
121 0
122 0
SELECT fid, ST_AsText(ST_Envelope(g)) FROM gis_geometry;
fid ST_AsText(ST_Envelope(g))
101 POINT(10 10)
102 POINT(20 10)
103 POINT(20 20)
104 POINT(10 20)
105 POLYGON((0 0,10 0,10 10,0 10,0 0))
106 POLYGON((10 10,20 10,20 20,10 20,10 10))
107 LINESTRING(10 10,40 10)
108 POLYGON((10 10,20 10,20 20,10 20,10 10))
109 POLYGON((0 0,50 0,50 50,0 50,0 0))
110 POLYGON((0 0,30 0,30 30,0 30,0 0))
111 POLYGON((0 0,20 0,20 20,0 20,0 0))
112 POLYGON((1 1,21 1,21 21,1 21,1 1))
113 POLYGON((3 6,4 6,4 10,3 10,3 6))
114 POLYGON((10 0,16 0,16 48,10 48,10 0))
115 LINESTRING(10 0,10 48)
116 POLYGON((1 2,21 2,21 8,1 8,1 2))
117 POLYGON((28 0,84 0,84 42,28 42,28 0))
118 POLYGON((28 0,84 0,84 42,28 42,28 0))
119 POLYGON((0 0,3 0,3 3,0 3,0 0))
120 POLYGON((0 0,10 0,10 10,0 10,0 0))
121 POLYGON((10 10,20 10,20 20,10 20,10 10))
122 POLYGON((3 6,44 6,44 9,3 9,3 6))
explain extended select ST_Dimension(g), ST_GeometryType(g), ST_IsEmpty(g), ST_AsText(ST_Envelope(g)) from gis_geometry;
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE gis_geometry NULL ALL NULL NULL NULL NULL # 100.00 NULL
Warnings:
Warning 1681 'EXTENDED' is deprecated and will be removed in a future release.
Note 1003 /* select#1 */ select st_dimension(`test`.`gis_geometry`.`g`) AS `ST_Dimension(g)`,st_geometrytype(`test`.`gis_geometry`.`g`) AS `ST_GeometryType(g)`,st_isempty(`test`.`gis_geometry`.`g`) AS `ST_IsEmpty(g)`,st_astext(st_envelope(`test`.`gis_geometry`.`g`)) AS `ST_AsText(ST_Envelope(g))` from `test`.`gis_geometry`
#check Geometry point functions
SELECT fid, ST_X(g) FROM gis_point;
fid ST_X(g)
101 10
102 20
103 20
104 10
SELECT fid, ST_Y(g) FROM gis_point;
fid ST_Y(g)
101 10
102 10
103 20
104 20
explain extended select ST_X(g),ST_Y(g) FROM gis_point;
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE gis_point NULL ALL NULL NULL NULL NULL # 100.00 NULL
Warnings:
Warning 1681 'EXTENDED' is deprecated and will be removed in a future release.
Note 1003 /* select#1 */ select st_x(`test`.`gis_point`.`g`) AS `ST_X(g)`,st_y(`test`.`gis_point`.`g`) AS `ST_Y(g)` from `test`.`gis_point`
SELECT fid, ST_AsText(ST_StartPoint(g)) FROM gis_line;
fid ST_AsText(ST_StartPoint(g))
105 POINT(0 0)
106 POINT(10 10)
107 POINT(10 10)
SELECT fid, ST_AsText(ST_EndPoint(g)) FROM gis_line;
fid ST_AsText(ST_EndPoint(g))
105 POINT(10 0)
106 POINT(10 10)
107 POINT(40 10)
SELECT fid, ST_Length(g) FROM gis_line;
fid ST_Length(g)
105 24.14213562373095
106 40
107 30
SELECT fid, ST_NumPoints(g) FROM gis_line;
fid ST_NumPoints(g)
105 3
106 5
107 2
SELECT fid, ST_AsText(ST_PointN(g, 2)) FROM gis_line;
fid ST_AsText(ST_PointN(g, 2))
105 POINT(0 10)
106 POINT(20 10)
107 POINT(40 10)
SELECT fid, ST_IsClosed(g) FROM gis_line;
fid ST_IsClosed(g)
105 0
106 1
107 0
explain extended select ST_AsText(ST_StartPoint(g)),ST_AsText(ST_EndPoint(g)),
ST_Length(g),ST_NumPoints(g),ST_AsText(ST_PointN(g, 2)),ST_IsClosed(g) FROM gis_line;
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE gis_line NULL ALL NULL NULL NULL NULL # 100.00 NULL
Warnings:
Warning 1681 'EXTENDED' is deprecated and will be removed in a future release.
Note 1003 /* select#1 */ select st_astext(st_startpoint(`test`.`gis_line`.`g`)) AS `ST_AsText(ST_StartPoint(g))`,st_astext(st_endpoint(`test`.`gis_line`.`g`)) AS `ST_AsText(ST_EndPoint(g))`,st_length(`test`.`gis_line`.`g`) AS `ST_Length(g)`,st_numpoints(`test`.`gis_line`.`g`) AS `ST_NumPoints(g)`,st_astext(st_pointn(`test`.`gis_line`.`g`,2)) AS `ST_AsText(ST_PointN(g, 2))`,st_isclosed(`test`.`gis_line`.`g`) AS `ST_IsClosed(g)` from `test`.`gis_line`
SELECT fid, ST_AsText(ST_Centroid(g)) FROM gis_polygon;
fid ST_AsText(ST_Centroid(g))
108 POINT(15 15)
109 POINT(25.416666666666668 25.416666666666668)
110 POINT(20 10)
SELECT fid, ST_Area(g) FROM gis_polygon;
fid ST_Area(g)
108 100
109 2400
110 450
SELECT fid, ST_AsText(ST_ExteriorRing(g)) FROM gis_polygon;
fid ST_AsText(ST_ExteriorRing(g))
108 LINESTRING(10 10,20 10,20 20,10 20,10 10)
109 LINESTRING(0 0,50 0,50 50,0 50,0 0)
110 LINESTRING(0 0,30 0,30 30,0 0)
SELECT fid, ST_NumInteriorRings(g) FROM gis_polygon;
fid ST_NumInteriorRings(g)
108 0
109 1
110 0
SELECT fid, ST_AsText(ST_InteriorRingN(g, 1)) FROM gis_polygon;
fid ST_AsText(ST_InteriorRingN(g, 1))
108 NULL
109 LINESTRING(10 10,20 10,20 20,10 20,10 10)
110 NULL
explain extended select ST_AsText(ST_Centroid(g)),ST_Area(g),ST_AsText(ST_ExteriorRing(g)),
ST_NumInteriorRings(g),ST_AsText(ST_InteriorRingN(g, 1)) FROM gis_polygon;
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE gis_polygon NULL ALL NULL NULL NULL NULL # 100.00 NULL
Warnings:
Warning 1681 'EXTENDED' is deprecated and will be removed in a future release.
Note 1003 /* select#1 */ select st_astext(st_centroid(`test`.`gis_polygon`.`g`)) AS `ST_AsText(ST_Centroid(g))`,st_area(`test`.`gis_polygon`.`g`) AS `ST_Area(g)`,st_astext(st_exteriorring(`test`.`gis_polygon`.`g`)) AS `ST_AsText(ST_ExteriorRing(g))`,st_numinteriorrings(`test`.`gis_polygon`.`g`) AS `ST_NumInteriorRings(g)`,st_astext(st_interiorringn(`test`.`gis_polygon`.`g`,1)) AS `ST_AsText(ST_InteriorRingN(g, 1))` from `test`.`gis_polygon`
SELECT fid, ST_IsClosed(g) FROM gis_multi_line;
fid ST_IsClosed(g)
114 0
115 0
116 0
SELECT fid, ST_AsText(ST_Centroid(g)) FROM gis_multi_polygon;
fid ST_AsText(ST_Centroid(g))
117 POINT(57.98031067576927 17.854754130800437)
118 POINT(57.98031067576927 17.854754130800437)
119 POINT(2 2)
SELECT fid, ST_Area(g) FROM gis_multi_polygon;
fid ST_Area(g)
117 1684.5
118 1684.5
119 4.5
SELECT fid, ST_NumGeometries(g) from gis_multi_point;
fid ST_NumGeometries(g)
111 4
112 4
113 2
SELECT fid, ST_NumGeometries(g) from gis_multi_line;
fid ST_NumGeometries(g)
114 2
115 1
116 2
SELECT fid, ST_NumGeometries(g) from gis_multi_polygon;
fid ST_NumGeometries(g)
117 2
118 2
119 1
SELECT fid, ST_NumGeometries(g) from gis_geometrycollection;
fid ST_NumGeometries(g)
120 2
121 2
122 2
explain extended SELECT fid, ST_NumGeometries(g) from gis_multi_point;
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE gis_multi_point NULL ALL NULL NULL NULL NULL # 100.00 NULL
Warnings:
Warning 1681 'EXTENDED' is deprecated and will be removed in a future release.
Note 1003 /* select#1 */ select `test`.`gis_multi_point`.`fid` AS `fid`,st_numgeometries(`test`.`gis_multi_point`.`g`) AS `ST_NumGeometries(g)` from `test`.`gis_multi_point`
SELECT fid, ST_AsText(ST_GeometryN(g, 2)) from gis_multi_point;
fid ST_AsText(ST_GeometryN(g, 2))
111 POINT(10 10)
112 POINT(11 11)
113 POINT(4 10)
SELECT fid, ST_AsText(ST_GeometryN(g, 2)) from gis_multi_line;
fid ST_AsText(ST_GeometryN(g, 2))
114 LINESTRING(16 0,16 23,16 48)
115 NULL
116 LINESTRING(2 5,5 8,21 7)
SELECT fid, ST_AsText(ST_GeometryN(g, 2)) from gis_multi_polygon;
fid ST_AsText(ST_GeometryN(g, 2))
117 POLYGON((59 18,67 18,67 13,59 13,59 18))
118 POLYGON((59 18,67 18,67 13,59 13,59 18))
119 NULL
SELECT fid, ST_AsText(ST_GeometryN(g, 2)) from gis_geometrycollection;
fid ST_AsText(ST_GeometryN(g, 2))
120 LINESTRING(0 0,10 10)
121 LINESTRING(10 10,20 20)
122 LINESTRING(3 6,7 9)
SELECT fid, ST_AsText(ST_GeometryN(g, 1)) from gis_geometrycollection;
fid ST_AsText(ST_GeometryN(g, 1))
120 POINT(0 0)
121 POINT(10 10)
122 POINT(44 6)
explain extended SELECT fid, ST_AsText(ST_GeometryN(g, 2)) from gis_multi_point;
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE gis_multi_point NULL ALL NULL NULL NULL NULL # 100.00 NULL
Warnings:
Warning 1681 'EXTENDED' is deprecated and will be removed in a future release.
Note 1003 /* select#1 */ select `test`.`gis_multi_point`.`fid` AS `fid`,st_astext(st_geometryn(`test`.`gis_multi_point`.`g`,2)) AS `ST_AsText(ST_GeometryN(g, 2))` from `test`.`gis_multi_point`
SELECT g1.fid as first, g2.fid as second,
MBRWithin(g1.g, g2.g) as w, MBRContains(g1.g, g2.g) as c, MBROverlaps(g1.g, g2.g) as o,
MBREquals(g1.g, g2.g) as e, MBRDisjoint(g1.g, g2.g) as d, ST_Touches(g1.g, g2.g) as t,
MBRIntersects(g1.g, g2.g) as i, ST_Crosses(g1.g, g2.g) as r
FROM gis_geometrycollection g1, gis_geometrycollection g2 ORDER BY first, second;
first second w c o e d t i r
120 120 1 1 0 1 0 0 1 0
120 121 0 0 0 0 0 1 1 0
120 122 0 0 1 0 0 0 1 0
121 120 0 0 0 0 0 1 1 0
121 121 1 1 0 1 0 0 1 0
121 122 0 0 0 0 1 0 0 0
122 120 0 0 1 0 0 0 1 0
122 121 0 0 0 0 1 0 0 0
122 122 1 1 0 1 0 0 1 0
explain extended SELECT g1.fid as first, g2.fid as second,
MBRWithin(g1.g, g2.g) as w, MBRContains(g1.g, g2.g) as c, MBROverlaps(g1.g, g2.g) as o,
MBREquals(g1.g, g2.g) as e, MBRDisjoint(g1.g, g2.g) as d, ST_Touches(g1.g, g2.g) as t,
MBRIntersects(g1.g, g2.g) as i, ST_Crosses(g1.g, g2.g) as r
FROM gis_geometrycollection g1, gis_geometrycollection g2 ORDER BY first, second;
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE g1 NULL ALL NULL NULL NULL NULL # 100.00 Using temporary; Using filesort
1 SIMPLE g2 NULL ALL NULL NULL NULL NULL # 100.00 Using join buffer (Block Nested Loop)
Warnings:
Warning 1681 'EXTENDED' is deprecated and will be removed in a future release.
Note 1003 /* select#1 */ select `test`.`g1`.`fid` AS `first`,`test`.`g2`.`fid` AS `second`,mbrwithin(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `w`,mbrcontains(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `c`,mbroverlaps(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `o`,mbrequals(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `e`,mbrdisjoint(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `d`,st_touches(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `t`,mbrintersects(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `i`,st_crosses(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `r` from `test`.`gis_geometrycollection` `g1` join `test`.`gis_geometrycollection` `g2` order by `first`,`second`
# check support of Foreign Key constraint
CREATE TABLE parent (id GEOMETRY NOT NULL,PRIMARY KEY (id(10))) ENGINE=INNODB;
CREATE TABLE child (id GEOMETRY, parent_id GEOMETRY,
INDEX par_ind (parent_id(10)),
FOREIGN KEY (parent_id(10)) REFERENCES parent(id)
ON DELETE CASCADE
) ENGINE=INNODB;
ERROR HY000: Cannot add foreign key constraint
#check partition table support
CREATE TABLE emp2(
id GEOMETRY NOT NULL,
store_name VARCHAR(30),
parts VARCHAR(30),
store_id GEOMETRY
)
PARTITION BY LIST(store_id) (
PARTITION pNorth VALUES IN (10,20,30) ,
PARTITION pEast VALUES IN (40,50,60) ,
PARTITION pWest VALUES IN (70,80,100)
);
ERROR 42000: The storage engine for the table doesn't support GEOMETRY
#check start transaction commit & Rollback
START TRANSACTION;
DELETE FROM tab3;
ROLLBACK;
SELECT COUNT(*) FROM tab3;
COUNT(*)
1
START TRANSACTION;
DELETE FROM tab3;
COMMIT;
SELECT COUNT(*) FROM tab3;
COUNT(*)
0
DROP TABLE IF EXISTS gis_point, gis_line, gis_polygon, gis_multi_point;
DROP TABLE IF EXISTS gis_multi_line, gis_multi_polygon;
DROP TABLE IF EXISTS gis_geometrycollection, gis_geometry;
DROP TABLE IF EXISTS tab,tab2,tab3,parent,emp2;
Warnings:
Note 1051 Unknown table 'test.emp2'
DROP PROCEDURE IF EXISTS geominout;
DROP PROCEDURE IF EXISTS geom_insert;
DROP TRIGGER IF EXISTS geom_trigger;
Warnings:
Note 1360 Trigger does not exist
DROP PROCEDURE IF EXISTS geom_cursor;
create table t1(a geometrycollection not null,spatial key(a))engine=innodb;
insert into t1(a) values( geometrycollection(multipolygon(polygon(linestring(point(-14,98), point(-14,98)), linestring(point(-97,64), point(-70,99), point(-97,64)), linestring(point(143851215403059150000000000000000000000.000000,13040009882500140000000000000000000000.000000), point(-73,85), point(-88,-29)))), multipolygon(polygon(linestring(point(41,95), point(4294967298,2050)), linestring(point(-61,85), point(-75,93), point(14,-2), point(1,84), point(-61,85)), linestring(point(-62,52), point(39,5), point(-18,12), point(-62,52))), polygon(linestring(point(-77,1), point(66,61), point(-77,1)), linestring(point(18446744073709551615,1125899906842622), point(-72,49), point(24,-66), point(82,73), point(68,22))), polygon(linestring(point(1048576,17179869181), point(-18,95), point(-90,-3), point(-33,82), point(20,-85)), linestring(point(-43,-97), point(-7,-3), point(39,-82), point(-65,-58), point(-43,-97)), linestring(point(44,-34), point(-69,58), point(44,-34)), linestring(point(57,-13), point(-17,74), point(57,-13)), linestring(point(3,71), point(-58,81), point(3,71)), linestring(point(9,25), point(77,-71), point(8388607,67108864), point(46,46), point(9,25)), linestring(point(98,-82), point(98,-82))))) ) ;
ERROR 22023: Invalid GIS data provided to function polygon.
insert into t1(a) values( geometrycollection(multilinestring(linestring(point(39,-60), point(-62,-11), point(-24,35), point(54,1)), linestring(point(-4,69), point(-22,-64), point(1.694824e+308,5.688896e+307), point(-33,-58), point(-64,-80), point(-15,-44), point(40,54)), linestring(point(-86,-54), point(11,41), point(-46,-38), point(-21,-8), point(10,70), point(-81,22), point(-46,-100)), linestring(point(-30,-48), point(50,58), point(-53,92), point(10,41), point(-46,-8)), linestring(point(-65,34), point(-92,93), point(-33,-74), point(75,-28)), linestring(point(25,-55), point(22,-10), point(-42,0), point(-86,-59), point(2,-37), point(63,-44), point(-55,-22)), linestring(point(28,0), point(-94,99), point(-32,-86)), linestring(point(9,-12), point(16,9), point(80,-73)), linestring(point(6,-55), point(83,-4)), linestring(point(-15,21), point(144115188075855876,16777212), point(-85,-31), point(-90,-50)), linestring(point(-33,33), point(21,90), point(-89,32)), linestring(point(16,24), point(73,-13), point(25,-48), point(71,52), point(-54,-78), point(-84,59), point(53,29)), linestring(point(-15,-81), point(83,43), point(-71,33), point(-8,0), point(84,-54), point(-35,38), point(-10,-50)), linestring(point(38,-50), point(20,-2), point(-57,-92)), linestring(point(5,-93), point(231601833467477080000000000000000000000.000000,51914987457169239000000000000000000000.000000), point(-94,62))), point(2,0)) ) ;
insert into t1(a) values( geometrycollection(multilinestring(linestring(point(80,-15), point(65,-57), point(-59,16), point(22,-67)), linestring(point(20,-55), point(-38,-64), point(19,-53), point(-63,-36), point(56,-37)), linestring(point(27,-8), point(-85,-75), point(4398046511106,2251799813685245)), linestring(point(45,32), point(-79,46))), multilinestring(linestring(point(8,-4), point(40,-38), point(100,95), point(5,-80), point(82,88)), linestring(point(-14,30), point(-94,51), point(-16,-29), point(37,-97), point(-26,92)), linestring(point(32,34), point(83,-23), point(-55,57), point(-15,90), point(32,-50), point(-20,-73), point(77,28)), linestring(point(4,88), point(87,74), point(-67,-58)), linestring(point(5.660747e+307,6.385657e+307), point(-58,-15), point(1.172095e+308,1.448533e+308)), linestring(point(-21,-37), point(-52,79), point(-16,-76), point(-65,-94), point(36,7), point(37,74), point(100,-57)), linestring(point(-23,-82), point(-73,23), point(18,-34)), linestring(point(20,-51), point(93,62), point(-65,84)), linestring(point(-48,31), point(-69,-96)), linestring(point(-5,78), point(10,-99), point(36,-33)), linestring(point(-84,55), point(96,1), point(-98,-29), point(-15,81), point(-27,-6), point(58,-32), point(54,-16)), linestring(point(2,5), point(2199023255553,8192)), linestring(point(12,-78), point(-97,-83)), linestring(point(-74,79), point(35,-56), point(50,95)), linestring(point(28,16), point(-39,-40), point(48,-3)), linestring(point(2199023255550,-65539), point(62,-25), point(94,-62)), linestring(point(-74,83), point(-18,75), point(91,17), point(-11,-48), point(30,100)), linestring(point(57,-13), point(88,-45)), linestring(point(20,-64), point(-37,13), point(20,35))), point(-3,-4)) ) ;
insert into t1(a) values( geometrycollection(multipolygon(polygon(linestring(point(-34,19), point(-25,92), point(61921390294166805000000000000000000000.000000,319674749161701840000000000000000000000.000000), point(56,50), point(-34,19)), linestring(point(-26,-58), point(99,-50), point(34,-20), point(-26,-58)), linestring(point(-42,45), point(-63,-7), point(5,-89), point(-97,36), point(-42,45)), linestring(point(94,11), point(-71,4), point(94,11)), linestring(point(16,25), point(4,-33), point(-45,-33), point(-64,-77), point(16,25)), linestring(point(19,45), point(36,45), point(-83,-96), point(19,45)), linestring(point(85,-31), point(-87,52), point(85,-31))), polygon(linestring(point(55,-88), point(63,-12), point(55,-88)), linestring(point(-49,10), point(-49,10)), linestring(point(-51,-32), point(-51,-32)))), multipolygon(polygon(linestring(point(-21,-8), point(66,-58), point(100,-27), point(-21,-8)), linestring(point(-29,-13), point(-29,-13))), polygon(linestring(point(91307574660224730000000000000000000000.000000,101214152547755520000000000000000000000.000000), point(89,64), point(77,87), point(66,29), point(-71,-53)), linestring(point(38,-78), point(-43,-90), point(37,20), point(81,65), point(38,-78))), polygon(linestring(point(51,0), point(-62,8), point(-11,22), point(51,0)), linestring(point(-4,-44), point(6,82), point(-19,-90), point(131,32)))), point(-4,-7)) ) ;
ERROR 22023: Invalid GIS data provided to function polygon.
insert into t1(a) values( geometrycollection(point(10,9), linestring(point(2305843009213693955,-1125899906842621), point(78,15)), multipoint(point(-1,3), point(4,-6))) ) ;
insert into t1(a) values( geometrycollection(polygon(linestring(point(0,13), point(-12,5), point(0,13)), linestring(point(11,-2), point(6,6), point(20,-14), point(-3,-10), point(1.330588e+308,2.666476e+307)), linestring(point(16382,67), point(7,4)), linestring(point(2,7), point(-14,15), point(2,7)), linestring(point(-14,12), point(-8,-8), point(-17,-2), point(-14,12)), linestring(point(-20,-10), point(-8,-13), point(-19,-17), point(13,-3), point(-20,-10)), linestring(point(-5,13), point(7,-9), point(6,8), point(-5,13))), linestring(point(-87,19), point(-64,51), point(-16,12)), multipoint(point(-1,-10), point(2,-10), point(3.670354e+307,2.501459e+307))) ) ;
ERROR 22023: Invalid GIS data provided to function polygon.
insert into t1(a) values( geometrycollection(multipoint(point(-3,7), point(4,-3), point(-6,-2), point(-9,1)), polygon(linestring(point(-17,-5), point(2,-8), point(-6,9), point(-9,19), point(-17,-5)), linestring(point(10,-1), point(15,-7), point(-13,6), point(10,-1))), multipolygon(polygon(linestring(point(69,-69), point(-90,-64), point(-17,4), point(47,-73), point(69,-69)), linestring(point(-35,-77), point(-35,-77)), linestring(point(95,-76), point(1.636688e+308,1.828723e+307), point(68719476740,536870916), point(95,-76)), linestring(point(-26,-85), point(-26,-85)), linestring(point(-53,57), point(-53,57)), linestring(point(-98,-64), point(79,-57), point(-98,-64)), linestring(point(-91,59), point(16,0), point(73,97), point(-35,-70), point(-91,59))))) ) ;
ERROR 22023: Invalid GIS data provided to function polygon.
insert into t1(a) values( geometrycollection(linestring(point(85,-29), point(15,84), point(39,-92), point(-99,19)), multilinestring(linestring(point(63,10), point(-47,95), point(10,-49), point(16,-65), point(-98,40), point(25,44), point(-55,-92)), linestring(point(5.266810e+307,6.648813e+307), point(47,33), point(-15,-13), point(-92,-58), point(36,73)), linestring(point(77,-56), point(-53,-10), point(-28,76), point(-51,6), point(51,-31), point(-95,81), point(92,26)), linestring(point(-91,7), point(58,53)), linestring(point(18,5), point(18,40), point(71,89), point(7.898707e+307,1.202585e+308), point(53,100)), linestring(point(-60,-18), point(-10,-31), point(-6,-25), point(-57,-95), point(16,77)))) ) ;
insert into t1(a) values( geometrycollection(polygon(linestring(point(-9,0), point(-17,-15), point(-9,0)), linestring(point(-11,1), point(18,12), point(15,3), point(7,0), point(-11,1)), linestring(point(19,5), point(19,5)), linestring(point(17,-11), point(8,4), point(17,-11)), linestring(point(14914539334033432000000000000000000000.000000,127247994336690690000000000000000000000.000000), point(-14,-7), point(13,-2))), point(-4,-7), polygon(linestring(point(-18,9), point(11,-1), point(-18,9)), linestring(point(9,-3), point(9,-3)), linestring(point(-7,-9), point(9,-11), point(11,14), point(1.663324e+308,1.572127e+308)), linestring(point(-15,4), point(18,12), point(7,2), point(-15,4)), linestring(point(-15,-18), point(-20,-15), point(1152921504606846972,34359738370))), polygon(linestring(point(-5,-19), point(-11,11), point(10,5), point(-7,13), point(-5,-19)), linestring(point(-8,-6), point(-4,16), point(-8,-6)), linestring(point(-6,-10), point(3,-12), point(-6,-10)), linestring(point(-16,1), point(20,-12), point(-16,1)), linestring(point(-8,5), point(-20,-4), point(4,1), point(-6,-6), point(-8,5)), linestring(point(-8,-11), point(-5,-14), point(-8,-11)), linestring(point(3,-16), point(-15,-13), point(1.166708e+308,1.901147e+307), point(-8,6), point(3,-16))), point(0,-5)) ) ;
ERROR 22023: Invalid GIS data provided to function polygon.
insert into t1(a) values( geometrycollection(linestring(point(-33,99), point(99,-87), point(38,-79), point(33,-39), point(-91,-8), point(46,-87))) ) ;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
drop table t1;
# Creating the spatial objects
USE test;
CREATE TABLE gis_point (fid INTEGER NOT NULL PRIMARY KEY, g POINT);
CREATE TABLE gis_linestring (fid INTEGER NOT NULL PRIMARY KEY, g LINESTRING);
CREATE TABLE gis_polygon (fid INTEGER NOT NULL PRIMARY KEY, g POLYGON);
CREATE TABLE gis_multi_point (fid INTEGER NOT NULL PRIMARY KEY, g MULTIPOINT);
CREATE TABLE gis_multi_linestring (fid INTEGER NOT NULL PRIMARY KEY, g MULTILINESTRING);
CREATE TABLE gis_multi_polygon (fid INTEGER NOT NULL PRIMARY KEY, g MULTIPOLYGON);
CREATE TABLE gis_geometrycollection (fid INTEGER NOT NULL PRIMARY KEY, g GEOMETRYCOLLECTION);
# Inserting POINT Geometry Values
INSERT INTO gis_point VALUES
(101, ST_POINTFROMTEXT('POINT(0 0)')),
(102, ST_POINTFROMTEXT('POINT(1 0)')),
(103, ST_POINTFROMTEXT('POINT(0 1)')),
(104, ST_POINTFROMTEXT('POINT(1 1)')),
(105, ST_POINTFROMTEXT('POINT(-1 1)'));
INSERT INTO gis_point VALUES
(106, ST_POINTFROMWKB(POINT(0,0))),
(107, ST_POINTFROMWKB(POINT(10,0))),
(108, ST_POINTFROMWKB(POINT(0,10))),
(109, ST_POINTFROMWKB(POINT(-10,0))),
(110, ST_POINTFROMWKB(POINT(0,-10)));
Warnings:
Warning 3195 st_geometryfromwkb(geometry) is deprecated and will be replaced by st_srid(geometry, 0) in a future version. Use st_geometryfromwkb(st_aswkb(geometry), 0) instead.
Warning 3195 st_geometryfromwkb(geometry) is deprecated and will be replaced by st_srid(geometry, 0) in a future version. Use st_geometryfromwkb(st_aswkb(geometry), 0) instead.
Warning 3195 st_geometryfromwkb(geometry) is deprecated and will be replaced by st_srid(geometry, 0) in a future version. Use st_geometryfromwkb(st_aswkb(geometry), 0) instead.
Warning 3195 st_geometryfromwkb(geometry) is deprecated and will be replaced by st_srid(geometry, 0) in a future version. Use st_geometryfromwkb(st_aswkb(geometry), 0) instead.
Warning 3195 st_geometryfromwkb(geometry) is deprecated and will be replaced by st_srid(geometry, 0) in a future version. Use st_geometryfromwkb(st_aswkb(geometry), 0) instead.
INSERT INTO gis_point VALUES
(111, ST_POINTFROMWKB(ST_ASWKB(ST_POINTFROMTEXT('POINT(1 1)')))),
(112, ST_POINTFROMWKB(ST_ASWKB(ST_POINTFROMTEXT('POINT(1e308 1e308)')))),
(113, ST_POINTFROMWKB(ST_ASWKB(ST_POINTFROMTEXT('POINT(1e308 -1e308)')))),
(114, ST_POINTFROMWKB(ST_ASWKB(ST_POINTFROMTEXT('POINT(-1e308 1e308)')))),
(115, ST_POINTFROMWKB(ST_ASWKB(ST_POINTFROMTEXT('POINT(-1e308 -1e308)'))));
# Inserting LINESTRING Geometry Values
INSERT INTO gis_linestring VALUES
(201, ST_LINEFROMTEXT('LINESTRING(0 0,5 5)')),
(202, ST_LINEFROMTEXT('LINESTRING(0 0,2 2,4 4)')),
(203, ST_LINEFROMTEXT('LINESTRING(0 0,5 5,10 10)'));
INSERT INTO gis_linestring VALUES
(204, ST_LINESTRINGFROMTEXT('LINESTRING(10 10,5 5)')),
(205, ST_LINESTRINGFROMTEXT('LINESTRING(0 0,12 12,24 24)')),
(206, ST_LINESTRINGFROMTEXT('LINESTRING(0 0,50 50,100 100)'));
INSERT INTO gis_linestring VALUES
(207, ST_LINEFROMWKB(LINESTRING(POINT(0,0), POINT(5,5)))),
(208, ST_LINEFROMWKB(LINESTRING(POINT(0,0), POINT(-5,-5), POINT(-10,10)))),
(209, ST_LINEFROMWKB(LINESTRING(POINT(0,0), POINT(2,2), POINT(4,4), POINT(6,6), POINT(8,8))));
Warnings:
Warning 3195 st_geometryfromwkb(geometry) is deprecated and will be replaced by st_srid(geometry, 0) in a future version. Use st_geometryfromwkb(st_aswkb(geometry), 0) instead.
Warning 3195 st_geometryfromwkb(geometry) is deprecated and will be replaced by st_srid(geometry, 0) in a future version. Use st_geometryfromwkb(st_aswkb(geometry), 0) instead.
Warning 3195 st_geometryfromwkb(geometry) is deprecated and will be replaced by st_srid(geometry, 0) in a future version. Use st_geometryfromwkb(st_aswkb(geometry), 0) instead.
INSERT INTO gis_linestring VALUES
(210, ST_LINESTRINGFROMWKB(LINESTRING(POINT(0,0), POINT(5,5)))),
(211, ST_LINESTRINGFROMWKB(LINESTRING(POINT(0,0), POINT(-50,-50), POINT(10,-10)))),
(212, ST_LINESTRINGFROMWKB(LINESTRING(POINT(0,0), POINT(1e308,1e308), POINT(1e308,-1e308))));
Warnings:
Warning 3195 st_geometryfromwkb(geometry) is deprecated and will be replaced by st_srid(geometry, 0) in a future version. Use st_geometryfromwkb(st_aswkb(geometry), 0) instead.
Warning 3195 st_geometryfromwkb(geometry) is deprecated and will be replaced by st_srid(geometry, 0) in a future version. Use st_geometryfromwkb(st_aswkb(geometry), 0) instead.
Warning 3195 st_geometryfromwkb(geometry) is deprecated and will be replaced by st_srid(geometry, 0) in a future version. Use st_geometryfromwkb(st_aswkb(geometry), 0) instead.
INSERT INTO gis_linestring VALUES
(213, ST_LINEFROMWKB(ST_ASWKB(ST_LINEFROMTEXT('LINESTRING(1e308 1e308,1e308 -1e308)')))),
(214, ST_LINEFROMWKB(ST_ASWKB(ST_LINEFROMTEXT('LINESTRING(1 1,2 2,3 3,4 4,5 5,6 6,7 7,8 8,9 9)')))),
(215, ST_LINESTRINGFROMWKB(ST_ASWKB(ST_LINESTRINGFROMTEXT('LINESTRING(10 10,10 -10,-10 -10,-10 10,10 10)'))));
# Inserting POLYGON Geometry Values
INSERT INTO gis_polygon VALUES
(301, ST_POLYFROMTEXT('POLYGON((0 0,0 5,5 5,0 0))')),
(302, ST_POLYFROMTEXT('POLYGON((0 0,0 5,5 5,5 0,0 0))')),
(303, ST_POLYFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0))'));
INSERT INTO gis_polygon VALUES
(304, ST_POLYGONFROMTEXT('POLYGON((0 0,0 50,50 50,50 0,0 0))')),
(305, ST_POLYGONFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0,0 0,0 0),(4 4,4 6,6 6,6 4,4 4))')),
(306, ST_POLYGONFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0,0 0,0 0),(2 2,2 4,4 4,4 2,2 2),(6 6,6 8,8 8,8 6,6 6))'));
INSERT INTO gis_polygon VALUES
(307, ST_POLYFROMWKB(POLYGON(LINESTRING(POINT(0,0), POINT(0,5), POINT(5,5), POINT(0,0))))),
(308, ST_POLYFROMWKB(POLYGON(LINESTRING(POINT(0,0), POINT(0,15), POINT(15,15), POINT(15,0), POINT(0,0))))),
(309, ST_POLYFROMWKB(POLYGON(LINESTRING(POINT(0,0), POINT(0,10), POINT(10,10), POINT(10,0), POINT(0,0)),
LINESTRING(POINT(4,4), POINT(4,6), POINT(6,6), POINT(6,4), POINT(4,4)))));
Warnings:
Warning 3195 st_geometryfromwkb(geometry) is deprecated and will be replaced by st_srid(geometry, 0) in a future version. Use st_geometryfromwkb(st_aswkb(geometry), 0) instead.
Warning 3195 st_geometryfromwkb(geometry) is deprecated and will be replaced by st_srid(geometry, 0) in a future version. Use st_geometryfromwkb(st_aswkb(geometry), 0) instead.
Warning 3195 st_geometryfromwkb(geometry) is deprecated and will be replaced by st_srid(geometry, 0) in a future version. Use st_geometryfromwkb(st_aswkb(geometry), 0) instead.
INSERT INTO gis_polygon VALUES
(310, ST_POLYGONFROMWKB(POLYGON(LINESTRING(POINT(0,0), POINT(0,5), POINT(5,5), POINT(0,0))))),
(311, ST_POLYGONFROMWKB(POLYGON(LINESTRING(POINT(10,10), POINT(10,15), POINT(15,15), POINT(15,10), POINT(10,10))))),
(312, ST_POLYGONFROMWKB(POLYGON(LINESTRING(POINT(10,10), POINT(10,20), POINT(20,20), POINT(20,10), POINT(10,10)),
LINESTRING(POINT(14,14), POINT(14,16), POINT(16,16), POINT(16,14), POINT(14,14)))));
Warnings:
Warning 3195 st_geometryfromwkb(geometry) is deprecated and will be replaced by st_srid(geometry, 0) in a future version. Use st_geometryfromwkb(st_aswkb(geometry), 0) instead.
Warning 3195 st_geometryfromwkb(geometry) is deprecated and will be replaced by st_srid(geometry, 0) in a future version. Use st_geometryfromwkb(st_aswkb(geometry), 0) instead.
Warning 3195 st_geometryfromwkb(geometry) is deprecated and will be replaced by st_srid(geometry, 0) in a future version. Use st_geometryfromwkb(st_aswkb(geometry), 0) instead.
INSERT INTO gis_polygon VALUES
(313, ST_POLYFROMWKB(ST_ASWKB(ST_POLYFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0,0 0,5 5,0 0))')))),
(314, ST_POLYFROMWKB(ST_ASWKB(ST_POLYGONFROMTEXT('POLYGON((10 0,10 10,0 10,-10 10,-10 0,-10 -10,0 10,10 -10,10 0))')))),
(315, ST_POLYGONFROMWKB(ST_ASWKB(ST_POLYGONFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0,0 0,0 0),(2 2,2 4,4 4,4 2,2 2),(6 6,6 8,8 8,8 6,6 6))'))));
# Inserting MULTIPOINT Geometry Values
INSERT INTO gis_multi_point VALUES
(401, ST_GEOMFROMTEXT('MULTIPOINT(0 0)')),
(402, ST_GEOMFROMTEXT('MULTIPOINT(0 0,2 2,4 4)')),
(403, ST_GEOMFROMTEXT('MULTIPOINT(0 0,5 5,10 10)'));
INSERT INTO gis_multi_point VALUES
(404, ST_GEOMFROMTEXT('MULTIPOINT(0 0,100 100)')),
(405, ST_GEOMFROMTEXT('MULTIPOINT(0 0,1e308 1e308)')),
(406, ST_GEOMFROMTEXT('MULTIPOINT(1e308 1e308,1e308 -1e308,-1e308 1e308,-1e308 -1e308)'));
INSERT INTO gis_multi_point VALUES
(407, ST_GEOMFROMWKB(MULTIPOINT(POINT(0,0)))),
(408, ST_GEOMFROMWKB(MULTIPOINT(POINT(0,0), POINT(10,10)))),
(409, ST_GEOMFROMWKB(MULTIPOINT(POINT(0,0), POINT(2,2), POINT(4,4), POINT(6,6))));
Warnings:
Warning 3195 st_geometryfromwkb(geometry) is deprecated and will be replaced by st_srid(geometry, 0) in a future version. Use st_geometryfromwkb(st_aswkb(geometry), 0) instead.
Warning 3195 st_geometryfromwkb(geometry) is deprecated and will be replaced by st_srid(geometry, 0) in a future version. Use st_geometryfromwkb(st_aswkb(geometry), 0) instead.
Warning 3195 st_geometryfromwkb(geometry) is deprecated and will be replaced by st_srid(geometry, 0) in a future version. Use st_geometryfromwkb(st_aswkb(geometry), 0) instead.
INSERT INTO gis_multi_point VALUES
(410, ST_GEOMFROMWKB(MULTIPOINT(POINT(0,0)))),
(411, ST_GEOMFROMWKB(MULTIPOINT(POINT(0,0), POINT(1e308,1e308)))),
(412, ST_GEOMFROMWKB(MULTIPOINT(POINT(1e308,1e308), POINT(-1e308,1e308), POINT(1e308,-1e308), POINT(-1e308,-1e308))));
Warnings:
Warning 3195 st_geometryfromwkb(geometry) is deprecated and will be replaced by st_srid(geometry, 0) in a future version. Use st_geometryfromwkb(st_aswkb(geometry), 0) instead.
Warning 3195 st_geometryfromwkb(geometry) is deprecated and will be replaced by st_srid(geometry, 0) in a future version. Use st_geometryfromwkb(st_aswkb(geometry), 0) instead.
Warning 3195 st_geometryfromwkb(geometry) is deprecated and will be replaced by st_srid(geometry, 0) in a future version. Use st_geometryfromwkb(st_aswkb(geometry), 0) instead.
INSERT INTO gis_multi_point VALUES
(413, ST_GEOMFROMWKB(ST_ASWKB(ST_GEOMFROMTEXT('MULTIPOINT(0 0)')))),
(414, ST_GEOMFROMWKB(ST_ASWKB(ST_GEOMFROMTEXT('MULTIPOINT(0 0,1e308 1e308,-1e308 -1e308)')))),
(415, ST_GEOMFROMWKB(ST_ASWKB(ST_GEOMFROMTEXT('MULTIPOINT(1e308 1e308,1e308 -1e308,-1e308 1e308,-1e308 -1e308,1e308 1e308)'))));
# Inserting MULTILINESTRING Geometry Values
INSERT INTO gis_multi_linestring VALUES
(501, ST_GEOMFROMTEXT('MULTILINESTRING((0 0,2 2))')),
(502, ST_GEOMFROMTEXT('MULTILINESTRING((0 0,2 2,4 4))')),
(503, ST_GEOMFROMTEXT('MULTILINESTRING((0 0,2 2,4 4),(6 6,8 8,10 10))'));
INSERT INTO gis_multi_linestring VALUES
(504, ST_GEOMFROMTEXT('MULTILINESTRING((0 0,100 100,-100 -100))')),
(505, ST_GEOMFROMTEXT('MULTILINESTRING((1e308 1e308,-1e308 -1e308))')),
(506, ST_GEOMFROMTEXT('MULTILINESTRING((1e308 1e308,-1e308 -1e308),(1e308 -1e308,-1e308 1e308))'));
INSERT INTO gis_multi_linestring VALUES
(507, ST_GEOMFROMWKB(MULTILINESTRING(LINESTRING(POINT(0,0), POINT(2,2))))),
(508, ST_GEOMFROMWKB(MULTILINESTRING(LINESTRING(POINT(0,0), POINT(12,12), POINT(24,24))))),
(509, ST_GEOMFROMWKB(MULTILINESTRING(LINESTRING(POINT(0,0), POINT(2,2), POINT(4,4)),
LINESTRING(POINT(6,6), POINT(8,8), POINT(10,10)))));
Warnings:
Warning 3195 st_geometryfromwkb(geometry) is deprecated and will be replaced by st_srid(geometry, 0) in a future version. Use st_geometryfromwkb(st_aswkb(geometry), 0) instead.
Warning 3195 st_geometryfromwkb(geometry) is deprecated and will be replaced by st_srid(geometry, 0) in a future version. Use st_geometryfromwkb(st_aswkb(geometry), 0) instead.
Warning 3195 st_geometryfromwkb(geometry) is deprecated and will be replaced by st_srid(geometry, 0) in a future version. Use st_geometryfromwkb(st_aswkb(geometry), 0) instead.
INSERT INTO gis_multi_linestring VALUES
(510, ST_GEOMFROMWKB(MULTILINESTRING(LINESTRING(POINT(0,0), POINT(2,2), POINT(4,4))))),
(511, ST_GEOMFROMWKB(MULTILINESTRING(LINESTRING(POINT(0,0), POINT(1,1), POINT(2,2))))),
(512, ST_GEOMFROMWKB(MULTILINESTRING(LINESTRING(POINT(0,0), POINT(12,12), POINT(24,24)),
LINESTRING(POINT(36,36), POINT(48,48), POINT(50,50)))));
Warnings:
Warning 3195 st_geometryfromwkb(geometry) is deprecated and will be replaced by st_srid(geometry, 0) in a future version. Use st_geometryfromwkb(st_aswkb(geometry), 0) instead.
Warning 3195 st_geometryfromwkb(geometry) is deprecated and will be replaced by st_srid(geometry, 0) in a future version. Use st_geometryfromwkb(st_aswkb(geometry), 0) instead.
Warning 3195 st_geometryfromwkb(geometry) is deprecated and will be replaced by st_srid(geometry, 0) in a future version. Use st_geometryfromwkb(st_aswkb(geometry), 0) instead.
INSERT INTO gis_multi_linestring VALUES
(513, ST_GEOMFROMWKB(ST_ASWKB(ST_GEOMFROMTEXT('MULTILINESTRING((0 0,10 10),(0 10,10 0))')))),
(514, ST_GEOMFROMWKB(ST_ASWKB(ST_GEOMFROMTEXT('MULTILINESTRING((0 0,10 10,-10 10,0 0),(0 0,-10 -10,10 -10,0 0))')))),
(515, ST_GEOMFROMWKB(ST_ASWKB(ST_GEOMFROMTEXT('MULTILINESTRING((0 0,0 100),(0 0,100 0),(0 0,0 -100),(0 0,-100 0))'))));
# Inserting MULTIPOLGYON Geometry Values
INSERT INTO gis_multi_polygon VALUES
(601, ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 5,5 5,0 0)))')),
(602, ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 5,5 5,0 0)),((5 5,5 10,10 10,5 5)))')),
(603, ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0,0 0,0 0),(4 4,4 6,6 6,6 4,4 4)))'));
INSERT INTO gis_multi_polygon VALUES
(604, ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 5,5 5,0 0)))')),
(605, ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0,0 0,0 0),(4 4,4 6,6 6,6 4,4 4)),((0 0,0 -2,-2 -2,0 0)))')),
(606, ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,5 5,-5 5,0 0)),((0 0,-5 -5,5 -5,0 0)))'));
INSERT INTO gis_multi_polygon VALUES
(607, ST_GEOMFROMWKB(MULTIPOLYGON(POLYGON(LINESTRING(POINT(0,0), POINT(5,0), POINT(5,5), POINT(0,5), POINT(0,0)))))),
(608, ST_GEOMFROMWKB(MULTIPOLYGON(POLYGON(LINESTRING(POINT(0,0), POINT(10,0), POINT(10,10), POINT(0,10), POINT(0,0)),
LINESTRING(POINT(4,4), POINT(4,6), POINT(6,6), POINT(6,4), POINT(4,4)))))),
(609, ST_GEOMFROMWKB(MULTIPOLYGON(POLYGON(LINESTRING(POINT(0,0), POINT(5,0), POINT(5,5), POINT(0,5), POINT(0,0))),
POLYGON(LINESTRING(POINT(0,0), POINT(-5,0), POINT(-5,-5), POINT(0,-5), POINT(0,0))))));
Warnings:
Warning 3195 st_geometryfromwkb(geometry) is deprecated and will be replaced by st_srid(geometry, 0) in a future version. Use st_geometryfromwkb(st_aswkb(geometry), 0) instead.
Warning 3195 st_geometryfromwkb(geometry) is deprecated and will be replaced by st_srid(geometry, 0) in a future version. Use st_geometryfromwkb(st_aswkb(geometry), 0) instead.
Warning 3195 st_geometryfromwkb(geometry) is deprecated and will be replaced by st_srid(geometry, 0) in a future version. Use st_geometryfromwkb(st_aswkb(geometry), 0) instead.
INSERT INTO gis_multi_polygon VALUES
(610, ST_GEOMFROMWKB(MULTIPOLYGON(POLYGON(LINESTRING(POINT(0,0), POINT(-5,0), POINT(-5,-5), POINT(0,-5), POINT(0,0)))))),
(611, ST_GEOMFROMWKB(MULTIPOLYGON(POLYGON(LINESTRING(POINT(10,10), POINT(20,10), POINT(20,20), POINT(10,20), POINT(10,10)),
LINESTRING(POINT(14,14), POINT(14,16), POINT(16,16), POINT(16,14), POINT(14,14)))))),
(612, ST_GEOMFROMWKB(MULTIPOLYGON(POLYGON(LINESTRING(POINT(0,0), POINT(0,10), POINT(10,10), POINT(10,0), POINT(0,0)),
LINESTRING(POINT(4,4), POINT(4,6), POINT(6,6), POINT(6,4), POINT(4,4))),
POLYGON(LINESTRING(POINT(0,0), POINT(-5,0), POINT(-5,-5), POINT(0,-5), POINT(0,0))))));
Warnings:
Warning 3195 st_geometryfromwkb(geometry) is deprecated and will be replaced by st_srid(geometry, 0) in a future version. Use st_geometryfromwkb(st_aswkb(geometry), 0) instead.
Warning 3195 st_geometryfromwkb(geometry) is deprecated and will be replaced by st_srid(geometry, 0) in a future version. Use st_geometryfromwkb(st_aswkb(geometry), 0) instead.
Warning 3195 st_geometryfromwkb(geometry) is deprecated and will be replaced by st_srid(geometry, 0) in a future version. Use st_geometryfromwkb(st_aswkb(geometry), 0) instead.
INSERT INTO gis_multi_polygon VALUES
(613, ST_GEOMFROMWKB(ST_ASWKB(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,5 5,5 -5,0 0)),((0 0,-5 5,-5 -5,0 0)))')))),
(614, ST_GEOMFROMWKB(ST_ASWKB(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,10 10,-10 10,0 0)),((0 0,-10 -10,10 -10,0 0)))')))),
(615, ST_GEOMFROMWKB(ST_ASWKB(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,5 5,10 0,5 -5,0 0)))'))));
# Inserting GEOMETRYCOLLECTION Geometry Values
INSERT INTO gis_geometrycollection VALUES
(701, ST_GEOMCOLLFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0))')),
(702, ST_GEOMCOLLFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')),
(703, ST_GEOMCOLLFROMTEXT('GEOMETRYCOLLECTION(POINT(5 5), POLYGON((0 0,0 10,10 10,10 0,0 0)))'));
INSERT INTO gis_geometrycollection VALUES
(704, ST_GEOMETRYCOLLECTIONFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')),
(705, ST_GEOMETRYCOLLECTIONFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0),'
'LINESTRING(0 0,10 10),'
'POLYGON((0 0,0 10,10 10,10 0,0 0,0 0, 0 0)))')),
(706, ST_GEOMETRYCOLLECTIONFROMTEXT('GEOMETRYCOLLECTION(MULTIPOINT(0 0,5 5,10 10),'
'MULTILINESTRING((0 0,10 10),(0 10,10 0)),'
'MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),'
'((0 0,-10 0,-10 -10,0 -10,0 0))))'));
INSERT INTO gis_geometrycollection VALUES
(707, ST_GEOMCOLLFROMWKB(GEOMETRYCOLLECTION(POINT(0,0)))),
(708, ST_GEOMCOLLFROMWKB(GEOMETRYCOLLECTION(POINT(0,0),
LINESTRING(POINT(0,0), POINT(2,2), POINT(4,4), POINT(6,6), POINT(8,8)),
POLYGON(LINESTRING(POINT(0,0), POINT(0,10), POINT(10,10), POINT(10,0), POINT(0,0)),
LINESTRING(POINT(4,4), POINT(4,6), POINT(6,6), POINT(6,4), POINT(4,4)))))),
(709, ST_GEOMCOLLFROMWKB(GEOMETRYCOLLECTION(MULTIPOINT(POINT(0,0), POINT(5,5), POINT(10,10)),
MULTILINESTRING(LINESTRING(POINT(0,0), POINT(2,2), POINT(4,4), POINT(6,6), POINT(8,8)),
LINESTRING(POINT(10,10), POINT(5,5), POINT(0,10))),
MULTIPOLYGON(POLYGON(LINESTRING(POINT(0,0), POINT(0,10), POINT(10,10), POINT(10,0), POINT(0,0)),
LINESTRING(POINT(4,4), POINT(4,6), POINT(6,6), POINT(6,4), POINT(4,4))),
POLYGON(LINESTRING(POINT(0,0), POINT(-10,0), POINT(-10,-10), POINT(0,0)))))));
Warnings:
Warning 3195 st_geometryfromwkb(geometry) is deprecated and will be replaced by st_srid(geometry, 0) in a future version. Use st_geometryfromwkb(st_aswkb(geometry), 0) instead.
Warning 3195 st_geometryfromwkb(geometry) is deprecated and will be replaced by st_srid(geometry, 0) in a future version. Use st_geometryfromwkb(st_aswkb(geometry), 0) instead.
Warning 3195 st_geometryfromwkb(geometry) is deprecated and will be replaced by st_srid(geometry, 0) in a future version. Use st_geometryfromwkb(st_aswkb(geometry), 0) instead.
INSERT INTO gis_geometrycollection VALUES
(710, ST_GEOMETRYCOLLECTIONFROMWKB(GEOMETRYCOLLECTION(POINT(0,0),
LINESTRING(POINT(0,0), POINT(100,100))))),
(711, ST_GEOMETRYCOLLECTIONFROMWKB(GEOMETRYCOLLECTION(POINT(10,10),
LINESTRING(POINT(10,10), POINT(12,12), POINT(14,14), POINT(16,16), POINT(18,18)),
POLYGON(LINESTRING(POINT(0,0), POINT(0,10), POINT(10,10), POINT(10,0), POINT(0,0)),
LINESTRING(POINT(4,4), POINT(4,6), POINT(6,6), POINT(6,4), POINT(4,4)))))),
(712, ST_GEOMETRYCOLLECTIONFROMWKB(GEOMETRYCOLLECTION(MULTIPOINT(POINT(10,10), POINT(15,15), POINT(20,20)),
MULTILINESTRING(LINESTRING(POINT(0,0), POINT(2,2), POINT(4,4), POINT(6,6), POINT(8,8)),
LINESTRING(POINT(10,10), POINT(5,5), POINT(0,10))),
MULTIPOLYGON(POLYGON(LINESTRING(POINT(0,0), POINT(0,10), POINT(10,10), POINT(10,0), POINT(0,0)),
LINESTRING(POINT(4,4), POINT(4,6), POINT(6,6), POINT(6,4), POINT(4,4))),
POLYGON(LINESTRING(POINT(0,0), POINT(-10,0), POINT(-10,-10), POINT(0,0)))))));
Warnings:
Warning 3195 st_geometryfromwkb(geometry) is deprecated and will be replaced by st_srid(geometry, 0) in a future version. Use st_geometryfromwkb(st_aswkb(geometry), 0) instead.
Warning 3195 st_geometryfromwkb(geometry) is deprecated and will be replaced by st_srid(geometry, 0) in a future version. Use st_geometryfromwkb(st_aswkb(geometry), 0) instead.
Warning 3195 st_geometryfromwkb(geometry) is deprecated and will be replaced by st_srid(geometry, 0) in a future version. Use st_geometryfromwkb(st_aswkb(geometry), 0) instead.
INSERT INTO gis_geometrycollection VALUES
(713, ST_GEOMCOLLFROMWKB(ST_ASWKB(ST_GEOMCOLLFROMTEXT('GEOMETRYCOLLECTION('
'POINT(0 0),'
'LINESTRING(0 0,10 10),'
'POLYGON((0 0,0 10,10 10,10 0,0 0)),'
'MULTIPOINT(0 0,2 2,4 4,6 6,8 8,10 10),'
'MULTILINESTRING((0 0,10 10),(0 10,10 0)),'
'MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 10,10 10,10 5,5 5))))')))),
(714, ST_GEOMCOLLFROMWKB(ST_ASWKB(ST_GEOMCOLLFROMTEXT('GEOMETRYCOLLECTION('
'GEOMETRYCOLLECTION('
'POINT(0 0)),'
'GEOMETRYCOLLECTION('
'LINESTRING(0 0,10 10)),'
'GEOMETRYCOLLECTION('
'POLYGON((0 0,0 10,10 10,10 0,0 0))),'
'GEOMETRYCOLLECTION('
'MULTIPOINT(0 0,2 2,4 4,6 6,8 8,10 10)),'
'GEOMETRYCOLLECTION('
'MULTILINESTRING((0 0,10 10),(0 10,10 0))),'
'GEOMETRYCOLLECTION('
'MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 10,10 10,10 5,5 5)))))')))),
(715, ST_GEOMCOLLFROMWKB(ST_ASWKB(ST_GEOMCOLLFROMTEXT('GEOMETRYCOLLECTION('
'GEOMETRYCOLLECTION(),'
'POINT(0 0),'
'GEOMETRYCOLLECTION('
'LINESTRING(0 0,10 10),'
'GEOMETRYCOLLECTION('
'GEOMETRYCOLLECTION())),'
'GEOMETRYCOLLECTION(),'
'GEOMETRYCOLLECTION('
'GEOMETRYCOLLECTION()),'
'POLYGON((0 0,0 10,10 10,10 0,0 0)),'
'MULTIPOINT(0 0,2 2,4 4,6 6,8 8,10 10),'
'MULTILINESTRING((0 0,10 10),(0 10,10 0)),'
'MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 10,10 10,10 5,5 5))))'))));
# Creating a table with spatial index column
CREATE TABLE geom_index (fid INTEGER NOT NULL PRIMARY KEY, g GEOMETRY NOT NULL, SPATIAL INDEX(g));
# Inserting geometry values
INSERT INTO geom_index SELECT * FROM gis_point;
INSERT INTO geom_index SELECT * FROM gis_linestring;
INSERT INTO geom_index SELECT * FROM gis_polygon;
INSERT INTO geom_index SELECT * FROM gis_multi_point;
INSERT INTO geom_index SELECT * FROM gis_multi_linestring;
INSERT INTO geom_index SELECT * FROM gis_multi_polygon;
INSERT INTO geom_index SELECT * FROM gis_geometrycollection;
check table geom_index;
Table Op Msg_type Msg_text
test.geom_index check status OK
# Final cleanup
DROP TABLE gis_point;
DROP TABLE gis_linestring;
DROP TABLE gis_polygon;
DROP TABLE gis_multi_point;
DROP TABLE gis_multi_linestring;
DROP TABLE gis_multi_polygon;
DROP TABLE gis_geometrycollection;
DROP TABLE geom_index;
create table t1 (c1 int, c2 geometry not null, spatial index (c2))engine=innodb;
create procedure insert_t1(IN total int)
begin
declare i int default 1;
while (i <= total) DO
insert into t1 values (i, Point(i, i));
set i = i + 1;
end while;
end|
CALL insert_t1(5000);
select count(*) from t1;
count(*)
5000
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
truncate table t1;
CALL insert_t1(10000);
select count(*) from t1;
count(*)
10000
drop index c2 on t1;
create spatial index idx on t1(c2);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) DEFAULT NULL,
`c2` geometry NOT NULL,
SPATIAL KEY `idx` (`c2`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
truncate table t1;
call mtr.add_suppression("InnoDB: page [0-9]+ in the doublewrite buffer is not within space bounds.*");
START TRANSACTION;
CALL insert_t1(5000);
COMMIT;
# Kill and restart
drop procedure insert_t1;
drop table t1;
create table t1 (c1 int, c2 varchar(255), c3 geometry not null, primary key(c1, c2), spatial index (c3))engine=innodb;
create function rand_string(str_length tinyint unsigned, str_type tinyint unsigned) returns varchar(255)
begin
declare counter int unsigned default 0;
declare const_chars varchar(64) default '0123456789';
declare result varchar(255) default '';
if str_type = 1 then
set const_chars = '0123456789';
elseif str_type = 2 then
set const_chars = 'abcdefghijklmnopqrstuvwxyz';
elseif str_type = 3 then
set const_chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
elseif str_type = 4 then
set const_chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
elseif str_type = 5 then
set const_chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
else
set const_chars = '0123456789';
end if;
while counter < str_length do
set result = concat(result,substr(const_chars,ceil(rand()*(length(const_chars)-1)),1));
set counter = counter + 1;
end while;
return result;
end|
create procedure insert_t1(IN total int)
begin
declare i int default 1;
declare i2 int default 1;
declare str varchar(100) default '';
declare dup_key int default 1;
while i <= total DO
set i2 = floor(0+(rand()*100));
set str = rand_string(i2, 5);
select count(*) into dup_key from t1 where c2 = str and c1 = i;
while dup_key <> 0 do
set i2 = floor(0+(rand()*100));
set str = rand_string(i2, 5);
select count(*) into dup_key from t1 where c2 = str and c1 = i;
end while;
insert into t1 values (i, str, Point(i, i));
set i = i + 1;
end while;
end|
CALL insert_t1(10000);
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
start transaction;
CALL insert_t1(30000);
rollback;
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
drop procedure insert_t1;
drop function rand_string;
drop table t1;
#
# Test for basic POINT operation
#
CREATE TABLE gis_point(p1 POINT, p2 POINT) ENGINE=InnoDB;
INSERT INTO gis_point VALUES
(ST_PointFromText('POINT(0 0)'), ST_PointFromText('POINT(0 0)')),
(ST_PointFromText('POINT(10 -20)'), ST_PointFromText('POINT(10 -20)')),
(ST_PointFromText('POINT(3.1415926 3.535897)'), ST_PointFromText('POINT(-3.932626 -3.488272)')),
(ST_PointFromText('POINT(-111.9876 234.1357)'), ST_PointFromText('POINT(-957.1914 958.1919)'));
SELECT ST_X(p1), ST_Y(p2) FROM gis_point;
ST_X(p1) ST_Y(p2)
0 0
10 -20
3.1415926 -3.488272
-111.9876 958.1919
DROP TABLE gis_point;
#
# Test when POINT is not on any indexes
#
CREATE TABLE gis_point(p1 POINT, p2 POINT) ENGINE=InnoDB;
INSERT INTO gis_point VALUES
(ST_PointFromText('POINT(100.32374832 101.23741821)'), ST_PointFromText('POINT(100.32374832 101.23741821)')),
(ST_PointFromText('POINT(105.34523342 103.18492302)'), ST_PointFromText('POINT(100.32374832 101.23741821)')),
(ST_PointFromText('POINT(100.32374832 101.23741821)'), ST_PointFromText('POINT(200.32247328 101.86728201)')),
(ST_PointFromText('POINT(100.32374832 101.23741821)'), ST_PointFromText('POINT(100.32374832 101.98527111)'));
EXPLAIN SELECT ST_AsText(p1), ST_AsText(p2) FROM gis_point GROUP BY p1, p2;
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE gis_point NULL ALL NULL NULL NULL NULL # 100.00 Using temporary; Using filesort
Warnings:
Note 1003 /* select#1 */ select st_astext(`test`.`gis_point`.`p1`) AS `ST_AsText(p1)`,st_astext(`test`.`gis_point`.`p2`) AS `ST_AsText(p2)` from `test`.`gis_point` group by `test`.`gis_point`.`p1`,`test`.`gis_point`.`p2`
SELECT ST_AsText(p1), ST_AsText(p2) FROM gis_point GROUP BY p1, p2;
ST_AsText(p1) ST_AsText(p2)
POINT(100.32374832 101.23741821) POINT(100.32374832 101.98527111)
POINT(100.32374832 101.23741821) POINT(100.32374832 101.23741821)
POINT(100.32374832 101.23741821) POINT(200.32247328 101.86728201)
POINT(105.34523342 103.18492302) POINT(100.32374832 101.23741821)
SELECT ST_AsText(p1) FROM gis_point WHERE p1 = p2;
ST_AsText(p1)
POINT(100.32374832 101.23741821)
SELECT ST_AsText(p1), ST_AsText(p2) FROM gis_point WHERE p1 = ST_PointFromText('POINT(100.32374832 101.23741821)');
ST_AsText(p1) ST_AsText(p2)
POINT(100.32374832 101.23741821) POINT(100.32374832 101.23741821)
POINT(100.32374832 101.23741821) POINT(200.32247328 101.86728201)
POINT(100.32374832 101.23741821) POINT(100.32374832 101.98527111)
SELECT ST_AsText(p1), ST_AsText(p2) FROM gis_point WHERE p2 = ST_PointFromText('POINT(200.32247328 101.86728201)');
ST_AsText(p1) ST_AsText(p2)
POINT(100.32374832 101.23741821) POINT(200.32247328 101.86728201)
DROP TABLE gis_point;
#
# Test some ALTER TABLE operations on POINT tables
#
CREATE TABLE t1 (
p POINT NOT NULL,
g GEOMETRY NOT NULL
) ENGINE=InnoDB;
INSERT INTO t1 VALUES(ST_PointFromText('POINT(0 1)'), ST_PointFromText('POINT(10 11)'));
INSERT INTO t1 VALUES(ST_PointFromText('POINT(1 1)'), ST_PointFromText('POINT(10 12)'));
INSERT INTO t1 VALUES(ST_PointFromText('POINT(1 0)'), ST_PointFromText('POINT(10 13)'));
INSERT INTO t1 VALUES(ST_PointFromText('POINT(0 0)'), ST_PointFromText('POINT(10 14)'));
SELECT ST_AsText(p), ST_AsText(g) FROM t1;
ST_AsText(p) ST_AsText(g)
POINT(0 1) POINT(10 11)
POINT(1 1) POINT(10 12)
POINT(1 0) POINT(10 13)
POINT(0 0) POINT(10 14)
SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE name = 'p' OR name = 'g';
name mtype prtype len
p 14 1535 12
g 14 1535 12
ALTER TABLE t1 ADD COLUMN p1 POINT, ADD COLUMN p2 POINT, ADD KEY(p);
SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE name = 'p' OR name = 'g' OR name = 'p1' OR name = 'p2';
name mtype prtype len
p 14 1535 12
g 14 1535 12
p1 14 1279 12
p2 14 1279 12
# NOT NULL POINT will use ''
SELECT count(*) AS `Expect 4` FROM t1 WHERE p1 = '';
Expect 4
0
SELECT count(*) AS `Expect 4` FROM t1 WHERE p2 = '';
Expect 4
0
SELECT ST_AsText(p), ST_AsText(p1) FROM t1 WHERE p = p1;
ST_AsText(p) ST_AsText(p1)
SELECT ST_AsText(p), ST_AsText(p1) FROM t1 WHERE p = p2;
ST_AsText(p) ST_AsText(p1)
ALTER TABLE t1 DROP COLUMN p2;
# NULLABLE POINT will use NULL
ALTER TABLE t1 ADD COLUMN p2 POINT, ADD KEY(p2);
SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE name = 'p' OR name = 'g' OR name = 'p1' OR name = 'p2';
name mtype prtype len
p 14 1535 12
g 14 1535 12
p1 14 1279 12
p2 14 1279 12
SELECT count(*) AS `Expect 4` FROM t1 WHERE p2 IS NULL;
Expect 4
4
UPDATE t1 SET p2 = ST_PointFromText('POINT(10 20)');
UPDATE t1 SET p1 = ST_PointFromText('POINT(10 20)');
ALTER TABLE t1 DROP COLUMN p2;
SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE name = 'p' OR name = 'g' OR name = 'p1';
name mtype prtype len
p 14 1535 12
g 14 1535 12
p1 14 1279 12
SELECT ST_AsText(p), ST_AsText(p1) FROM t1 WHERE p = p1;
ST_AsText(p) ST_AsText(p1)
INSERT INTO t1 VALUES (ST_PointFromText('POINT(0.5 0.5)'), ST_PointFromText('POINT(0 1)'), ST_PointFromText('POINT(10 19)'));
SELECT ST_AsText(p1) FROM t1;
ST_AsText(p1)
POINT(10 20)
POINT(10 20)
POINT(10 20)
POINT(10 20)
POINT(10 19)
DELETE FROM t1 WHERE p1 = ST_PointFromText('POINT(10 19)');
SELECT ST_AsText(p1) FROM t1;
ST_AsText(p1)
POINT(10 20)
POINT(10 20)
POINT(10 20)
POINT(10 20)
# Add spatial keys on the table
ALTER TABLE t1 ADD SPATIAL(p), ADD SPATIAL(p1);
ERROR 42000: All parts of a SPATIAL index must be NOT NULL
SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE name = 'p' OR name = 'g' OR name = 'p1';
name mtype prtype len
p 14 1535 12
g 14 1535 12
p1 14 1279 12
SELECT ST_AsText(p), ST_AsText(p1) FROM t1 WHERE p1 = ST_PointFromText('POINT(10 30)');
ST_AsText(p) ST_AsText(p1)
SELECT ST_AsText(p), ST_AsText(p1) FROM t1 WHERE p1 = ST_PointFromText('POINT(10 20)');
ST_AsText(p) ST_AsText(p1)
POINT(0 1) POINT(10 20)
POINT(1 1) POINT(10 20)
POINT(1 0) POINT(10 20)
POINT(0 0) POINT(10 20)
SELECT ST_AsText(p), ST_AsText(p1) FROM t1 WHERE MBRWithin(p1, ST_GeomFromText('POLYGON((5 5, 20 5, 20 21, 5 21, 5 5))'));
ST_AsText(p) ST_AsText(p1)
POINT(0 1) POINT(10 20)
POINT(1 1) POINT(10 20)
POINT(1 0) POINT(10 20)
POINT(0 0) POINT(10 20)
SELECT ST_AsText(p), ST_AsText(p1) FROM t1 WHERE MBRWithin(p, ST_GeomFromText('POLYGON((-1 0.5, -1 -0.5, 1 -0.5, 1 0.5, -1 0.5))'));
ST_AsText(p) ST_AsText(p1)
POINT(0 0) POINT(10 20)
# Drop spatial keys on the table
ALTER TABLE t1 DROP KEY p, DROP KEY p1;
ERROR 42000: Can't DROP 'p1'; check that column/key exists
SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE name = 'p' OR name = 'g' OR name = 'p1';
name mtype prtype len
p 14 1535 12
g 14 1535 12
p1 14 1279 12
SELECT ST_AsText(p), ST_AsText(p1) FROM t1 WHERE p1 = ST_PointFromText('POINT(10 30)');
ST_AsText(p) ST_AsText(p1)
SELECT ST_AsText(p), ST_AsText(p1) FROM t1 WHERE p1 = ST_PointFromText('POINT(10 20)');
ST_AsText(p) ST_AsText(p1)
POINT(0 1) POINT(10 20)
POINT(1 1) POINT(10 20)
POINT(1 0) POINT(10 20)
POINT(0 0) POINT(10 20)
SELECT ST_AsText(p), ST_AsText(p1) FROM t1 WHERE MBRWithin(p1, ST_GeomFromText('POLYGON((5 5, 20 5, 20 21, 5 21, 5 5))'));
ST_AsText(p) ST_AsText(p1)
POINT(0 1) POINT(10 20)
POINT(1 1) POINT(10 20)
POINT(1 0) POINT(10 20)
POINT(0 0) POINT(10 20)
SELECT ST_AsText(p), ST_AsText(p1) FROM t1 WHERE MBRWithin(p, ST_GeomFromText('POLYGON((-1 0.5, -1 -0.5, 1 -0.5, 1 0.5, -1 0.5))'));
ST_AsText(p) ST_AsText(p1)
POINT(0 0) POINT(10 20)
TRUNCATE t1;
ALTER TABLE t1 DROP COLUMN p, DROP COLUMN p1;
SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE name = 'p' OR name = 'g' OR name = 'p1';
name mtype prtype len
g 14 1535 12
ALTER TABLE t1 ADD COLUMN p POINT, ADD COLUMN p1 POINT;
SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE name = 'p' OR name = 'g' OR name = 'p1';
name mtype prtype len
g 14 1535 12
p 14 1279 12
p1 14 1279 12
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`g` geometry NOT NULL,
`p` point DEFAULT NULL,
`p1` point DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
INSERT INTO t1 VALUES(ST_PointFromText('POINT(0.5 0.5)'), ST_PointFromText('POINT(0 1)'), ST_PointFromText('POINT(10 19)'));
INSERT INTO t1 VALUES(ST_PointFromText('POINT(0.6 0.6)'), ST_PointFromText('POINT(1 1)'), ST_PointFromText('POINT(10 20)'));
INSERT INTO t1 VALUES(ST_PointFromText('POINT(0.7 0.7)'), ST_PointFromText('POINT(1 0)'), ST_PointFromText('POINT(10 21)'));
INSERT INTO t1 VALUES(ST_PointFromText('POINT(0.8 0.8)'), ST_PointFromText('POINT(0 0)'), ST_PointFromText('POINT(10 22)'));
SELECT ST_AsText(p), ST_AsText(p1) FROM t1 WHERE p1 = ST_PointFromText('POINT(10 30)');
ST_AsText(p) ST_AsText(p1)
SELECT ST_AsText(p), ST_AsText(p1) FROM t1 WHERE p1 = ST_PointFromText('POINT(10 20)');
ST_AsText(p) ST_AsText(p1)
POINT(1 1) POINT(10 20)
SELECT ST_AsText(p), ST_AsText(p1) FROM t1 WHERE MBRWithin(p1, ST_GeomFromText('POLYGON((5 5, 20 5, 20 21, 5 21, 5 5))'));
ST_AsText(p) ST_AsText(p1)
POINT(0 1) POINT(10 19)
POINT(1 1) POINT(10 20)
SELECT ST_AsText(p), ST_AsText(p1) FROM t1 WHERE MBRWithin(p, ST_GeomFromText('POLYGON((-1 0.5, -1 -0.5, 1 -0.5, 1 0.5, -1 0.5))'));
ST_AsText(p) ST_AsText(p1)
POINT(0 0) POINT(10 22)
ALTER TABLE t1 DROP COLUMN p1, ADD COLUMN p1 POINT, CHANGE COLUMN p pp POINT AFTER p1;
SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE name = 'pp' OR name = 'g' OR name = 'p1';
name mtype prtype len
g 14 1535 12
p1 14 1279 12
pp 14 1279 12
UPDATE t1 SET p1 = ST_PointFromText('POINT(5 5)');
SELECT ST_AsText(pp), ST_AsText(p1) FROM t1;
ST_AsText(pp) ST_AsText(p1)
POINT(0 1) POINT(5 5)
POINT(1 1) POINT(5 5)
POINT(1 0) POINT(5 5)
POINT(0 0) POINT(5 5)
ALTER TABLE t1 ADD SPATIAL(p1), ADD SPATIAL(pp), ALGORITHM = COPY;
ERROR 42000: All parts of a SPATIAL index must be NOT NULL
SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE name = 'pp' OR name = 'g' OR name = 'p1';
name mtype prtype len
g 14 1535 12
p1 14 1279 12
pp 14 1279 12
SELECT ST_AsText(pp), ST_AsText(p1) FROM t1 WHERE p1 = ST_PointFromText('POINT(10 30)');
ST_AsText(pp) ST_AsText(p1)
SELECT ST_AsText(pp), ST_AsText(p1) FROM t1 WHERE p1 = ST_PointFromText('POINT(10 20)');
ST_AsText(pp) ST_AsText(p1)
SELECT ST_AsText(pp), ST_AsText(p1) FROM t1 WHERE MBRWithin(p1, ST_GeomFromText('POLYGON((5 5, 20 5, 20 21, 5 21, 5 5))')) ORDER BY pp;
ST_AsText(pp) ST_AsText(p1)
SELECT ST_AsText(pp), ST_AsText(p1) FROM t1 WHERE MBRWithin(pp, ST_GeomFromText('POLYGON((-1 0.5, -1 -0.5, 1 -0.5, 1 0.5, -1 0.5))')) ORDER BY pp;
ST_AsText(pp) ST_AsText(p1)
POINT(0 0) POINT(5 5)
DROP TABLE t1;
#
# Test when the POINT is on B-TREE
#
CREATE TABLE gis_point(fid INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT, p POINT, KEY(p)) ENGINE=InnoDB;
INSERT INTO gis_point VALUES
(101, ST_PointFromText('POINT(10 10)')),
(102, ST_PointFromText('POINT(20 10)')),
(103, ST_PointFromText('POINT(20 20)')),
(104, ST_PointFromWKB(ST_AsWKB(ST_PointFromText('POINT(10 20)'))));
SELECT ST_AsText(p) FROM gis_point;
ST_AsText(p)
POINT(10 10)
POINT(20 10)
POINT(20 20)
POINT(10 20)
SELECT ST_AsText(p) FROM gis_point WHERE p = ST_PointFromText('POINT(20 20)');
ST_AsText(p)
POINT(20 20)
INSERT INTO gis_point VALUES
(201, ST_PointFromText('POINT(100.32374832 101.23741821)')),
(202, ST_PointFromText('POINT(102.43287328 100.23489233)')),
(203, ST_PointFromText('POINT(101.43284962 100.45892392)')),
(204, ST_PointFromWKB(ST_AsWKB(ST_PointFromText('POINT(103.43718640 105.248206478)')))),
(205, ST_PointFromText('POINT(101.43284962 100.45892392)')),
(206, ST_PointFromWKB(ST_AsWKB(ST_PointFromText('POINT(103.43718640 105.248206478)'))));
'The ORDER BY will use filesort'
EXPLAIN SELECT ST_AsText(p) FROM gis_point ORDER BY p;
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE gis_point NULL ALL NULL NULL NULL NULL # 100.00 Using filesort
Warnings:
Note 1003 /* select#1 */ select st_astext(`test`.`gis_point`.`p`) AS `ST_AsText(p)` from `test`.`gis_point` order by `test`.`gis_point`.`p`
SELECT ST_AsText(p) FROM gis_point ORDER BY p;
ST_AsText(p)
POINT(10 10)
POINT(10 20)
POINT(20 10)
POINT(20 20)
POINT(101.43284962 100.45892392)
POINT(101.43284962 100.45892392)
POINT(100.32374832 101.23741821)
POINT(102.43287328 100.23489233)
POINT(103.4371864 105.248206478)
POINT(103.4371864 105.248206478)
SELECT ST_AsText(p), COUNT(*) FROM gis_point GROUP BY p;
ST_AsText(p) COUNT(*)
POINT(10 10) 1
POINT(10 20) 1
POINT(20 10) 1
POINT(20 20) 1
POINT(101.43284962 100.45892392) 2
POINT(100.32374832 101.23741821) 1
POINT(102.43287328 100.23489233) 1
POINT(103.4371864 105.248206478) 2
TRUNCATE gis_point;
INSERT INTO gis_point VALUES
(101, ST_PointFromText('POINT(10 10)')),
(102, ST_PointFromText('POINT(20 10)')),
(103, ST_PointFromText('POINT(20 20)')),
(104, ST_PointFromWKB(ST_AsWKB(ST_PointFromText('POINT(10 20)'))));
# Check if we can create prefix index on POINT
ALTER TABLE gis_point ADD COLUMN g POINT, ADD KEY(g(8));
INSERT INTO gis_point VALUES
(105, ST_PointFromText('POINT(25 15)'), ST_PointFromText('POINT(100 100)')),
(106, ST_PointFromText('POINT(25 25)'), ST_PointFromText('POINT(110 110)'));
SELECT ST_AsText(p) FROM gis_point;
ST_AsText(p)
POINT(10 10)
POINT(20 10)
POINT(20 20)
POINT(10 20)
POINT(25 15)
POINT(25 25)
SELECT ST_AsText(p), ST_AsText(g) FROM gis_point WHERE g IS NULL;
ST_AsText(p) ST_AsText(g)
POINT(10 10) NULL
POINT(20 10) NULL
POINT(20 20) NULL
POINT(10 20) NULL
UPDATE gis_point SET g = ST_PointFromText('POINT(200 200)') WHERE g IS NULL OR g = ST_PointFromText('POINT(110 110)');
SELECT ST_AsText(g) FROM gis_point WHERE g IS NULL OR g = ST_PointFromText('POINT(200 200)');
ST_AsText(g)
POINT(200 200)
POINT(200 200)
POINT(200 200)
POINT(200 200)
POINT(200 200)
# Check the information schema tables
SELECT table_name, column_name, data_type, column_type FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name='gis_point' AND (column_name = 'p' OR column_name = 'g');
table_name column_name data_type column_type
gis_point p point point
gis_point g point point
SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE name = 'p' OR name = 'g';
name mtype prtype len
p 14 1279 12
g 14 1279 12
SELECT length(p) FROM gis_point;
length(p)
25
25
25
25
25
25
ALTER TABLE gis_point DROP COLUMN g, ALGORITHM = COPY;
TRUNCATE gis_point;
INSERT INTO gis_point VALUES
(101, ST_PointFromText('POINT(10 10)')),
(102, ST_PointFromText('POINT(20 10)')),
(103, ST_PointFromText('POINT(20 20)')),
(104, ST_PointFromWKB(ST_AsWKB(ST_PointFromText('POINT(10 20)'))));
# Check if we can create prefix index on POINT
ALTER TABLE gis_point ADD COLUMN g POINT, ADD KEY(g(8));
INSERT INTO gis_point VALUES
(105, ST_PointFromText('POINT(25 15)'), ST_PointFromText('POINT(100 100)')),
(106, ST_PointFromText('POINT(25 25)'), ST_PointFromText('POINT(110 110)'));
SELECT ST_AsText(p) FROM gis_point;
ST_AsText(p)
POINT(10 10)
POINT(20 10)
POINT(20 20)
POINT(10 20)
POINT(25 15)
POINT(25 25)
SELECT ST_AsText(p), ST_AsText(g) FROM gis_point WHERE g IS NULL;
ST_AsText(p) ST_AsText(g)
POINT(10 10) NULL
POINT(20 10) NULL
POINT(20 20) NULL
POINT(10 20) NULL
UPDATE gis_point SET g = ST_PointFromText('POINT(200 200)') WHERE g IS NULL OR g = ST_PointFromText('POINT(110 110)');
SELECT ST_AsText(g) FROM gis_point WHERE g IS NULL OR g = ST_PointFromText('POINT(200 200)');
ST_AsText(g)
POINT(200 200)
POINT(200 200)
POINT(200 200)
POINT(200 200)
POINT(200 200)
CHECK TABLE gis_point;
Table Op Msg_type Msg_text
test.gis_point check status OK
SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE name = 'p' OR name = 'g';
name mtype prtype len
p 14 1279 12
g 14 1279 12
DROP TABLE gis_point;
#
# Check the mtype of other geometry data types should be 15
#
CREATE TABLE g (
geom GEOMETRY NOT NULL,
l LINESTRING NOT NULL,
poly POLYGON NOT NULL,
mp MULTIPOINT NOT NULL,
ml MULTILINESTRING NOT NULL,
mpoly MULTIPOLYGON NOT NULL,
gc GEOMETRYCOLLECTION NOT NULL
) ENGINE=InnoDB;
SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE name = 'p' OR name = 'g' OR name = 'geom' OR name = 'l' OR name = 'poly' OR name = 'mp' OR name = 'ml' OR name = 'mpoly' OR name = 'gc';
name mtype prtype len
geom 14 1535 12
l 14 1535 12
poly 14 1535 12
mp 14 1535 12
ml 14 1535 12
mpoly 14 1535 12
gc 14 1535 12
DROP TABLE g;
#
# check the mtype and len with CREATE TABLE AS
#
CREATE TABLE t1 (
p POINT NOT NULL,
g GEOMETRY NOT NULL
) ENGINE=InnoDB;
INSERT INTO t1 VALUES(ST_PointFromText('POINT(10 10)'),ST_GeomFromText('POLYGON((30 30,40 40,50 50,30 50,30 40,30 30))'));
SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE name = 'p' OR name = 'g' AND name='t1';
name mtype prtype len
p 14 1535 12
CREATE TABLE t2 AS SELECT * FROM t1;
DROP TABLE t1;
SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE name = 'p' OR name = 'g' AND name='t2';
name mtype prtype len
p 14 1535 12
DROP table t2;
#
# Test when POINT is used in spatial index
#
SET @ls1 = ST_GeomFromText('LINESTRING(0 20, 10 0)');
SET @ls2 = ST_GeomFromText('LINESTRING(0 0, 10 20)');
SET @ls3 = ST_GeomFromText('LINESTRING(20 -40, 21 -42)');
SET @ls4 = ST_GeomFromText('LINESTRING(20 -42, 21 -40)');
SET @poly1 = ST_GeomFromText('POLYGON((2 2, 2 10, 10 10, 10 2, 2 2))');
SET @poly2 = ST_GeomFromText('POLYGON((0 0, -5 0, -4 -1, -6 -15, -3 -15, 0 0))');
SET @poly3 = ST_GeomFromText('POLYGON((10.0 10.0, 20.5 20, 20.5 50, 32.0 64.0, 32.3 64.6, 5 60, 10 10))');
SET @poly4 = ST_GeomFromText('POLYGON((0 10, -10 10, -10 -10, 0 -10, 0 10))');
SET @p1 = ST_PointFromText('POINT(0 0)');
SET @mpoly = ST_GeomFromText('MULTIPOLYGON(((3 3, 3 16, 16 16, 16 3, 3 3)), ((10 10, 10 50, 50 50, 50 10, 10 10)))');
CREATE TABLE gis_point (p1 POINT NOT NULL, p2 POINT NOT NULL, SPATIAL KEY k1 (p1), SPATIAL KEY k2 (p2)) ENGINE=InnoDB;
INSERT INTO gis_point VALUES
(ST_PointFromText('POINT(1 2)'), ST_PointFromText('POINT(-1 -3)')),
(ST_PointFromText('POINT(2 4)'), ST_PointFromText('POINT(-2 -6)')),
(ST_PointFromText('POINT(3 6)'), ST_PointFromText('POINT(-3 -9)')),
(ST_PointFromText('POINT(4 8)'), ST_PointFromText('POINT(-4 -12)')),
(ST_PointFromText('POINT(5 10)'), ST_PointFromText('POINT(-5 -15)')),
(ST_PointFromText('POINT(6 12)'), ST_PointFromText('POINT(-6 -18)')),
(ST_PointFromText('POINT(7 14)'), ST_PointFromText('POINT(-7 -21)')),
(ST_PointFromText('POINT(8 16)'), ST_PointFromText('POINT(0 0)')),
(ST_PointFromText('POINT(9 18)'), ST_PointFromText('POINT(-4 2)')),
(ST_PointFromText('POINT(10 21)'), ST_PointFromText('POINT(-6 3)')),
(ST_PointFromText('POINT(20.5 41)'), ST_PointFromText('POINT(-8 4)')),
(ST_PointFromText('POINT(26.25 57)'), ST_PointFromText('POINT(1 2)')),
(ST_PointFromText('POINT(32.1234 64.2468)'), ST_PointFromText('POINT(-1 -1)'));
CREATE TABLE gis_point1 SELECT * FROM gis_point;
SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE name = 'p1' OR name = 'p2';
name mtype prtype len
p1 14 1535 12
p2 14 1535 12
p1 14 1535 12
p2 14 1535 12
SELECT ST_AsText(p1), ST_AsText(p2) FROM gis_point1;
ST_AsText(p1) ST_AsText(p2)
POINT(1 2) POINT(-1 -3)
POINT(2 4) POINT(-2 -6)
POINT(3 6) POINT(-3 -9)
POINT(4 8) POINT(-4 -12)
POINT(5 10) POINT(-5 -15)
POINT(6 12) POINT(-6 -18)
POINT(7 14) POINT(-7 -21)
POINT(8 16) POINT(0 0)
POINT(9 18) POINT(-4 2)
POINT(10 21) POINT(-6 3)
POINT(20.5 41) POINT(-8 4)
POINT(26.25 57) POINT(1 2)
POINT(32.1234 64.2468) POINT(-1 -1)
SELECT ST_AsText(p1) FROM gis_point1 WHERE ST_Intersection(@ls1, @ls2) = p1;
ST_AsText(p1)
POINT(5 10)
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRWithin(p1, @poly1);
ST_AsText(p1)
POINT(3 6)
POINT(4 8)
SELECT ST_AsText(p2) FROM gis_point1 WHERE ST_Contains(@poly2, p2);
ST_AsText(p2)
POINT(-1 -3)
POINT(-2 -6)
POINT(-3 -9)
POINT(-4 -12)
POINT(-1 -1)
SELECT ST_AsText(p2) FROM gis_point1 WHERE ST_Equals(p2, @p1);
ST_AsText(p2)
POINT(0 0)
SELECT ST_AsText(p1) FROM gis_point1 WHERE ST_Touches(@poly3, p1) AND MBRWithin(p2, @poly4);
ST_AsText(p1)
POINT(20.5 41)
POINT(32.1234 64.2468)
SELECT ST_AsText(p1) FROM gis_point1 WHERE ST_Contains(@mpoly, p1);
ST_AsText(p1)
POINT(4 8)
POINT(5 10)
POINT(6 12)
POINT(7 14)
POINT(20.5 41)
SELECT ST_AsText(p1) FROM gis_point1 WHERE ST_Contains(@mpoly, p1) AND NOT MBRWithin(p1, @mpoly);
ST_AsText(p1)
# Check functions that use MBR, with line type data
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRIntersects(p1, @ls1);
ST_AsText(p1)
POINT(1 2)
POINT(2 4)
POINT(3 6)
POINT(4 8)
POINT(5 10)
POINT(6 12)
POINT(7 14)
POINT(8 16)
POINT(9 18)
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRWithin(p1, @ls1);
ST_AsText(p1)
POINT(1 2)
POINT(2 4)
POINT(3 6)
POINT(4 8)
POINT(5 10)
POINT(6 12)
POINT(7 14)
POINT(8 16)
POINT(9 18)
SELECT ST_AsText(p1) FROM gis_point1 WHERE ST_Touches(p1, @ls1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRDisjoint(p1, @ls1);
ST_AsText(p1)
POINT(10 21)
POINT(20.5 41)
POINT(26.25 57)
POINT(32.1234 64.2468)
# No matching records
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBREquals(p1, @ls1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRContains(p1, @ls1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBROverlaps(p1, @ls3);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point1 WHERE ST_Crosses(p1, @ls1);
ST_AsText(p1)
# Check functions that use MBR, with polygon type data
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRIntersects(p1, @poly1);
ST_AsText(p1)
POINT(2 4)
POINT(3 6)
POINT(4 8)
POINT(5 10)
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRWithin(p1, @poly1);
ST_AsText(p1)
POINT(3 6)
POINT(4 8)
SELECT ST_AsText(p1) FROM gis_point1 WHERE ST_Touches(p1, @poly1);
ST_AsText(p1)
POINT(2 4)
POINT(5 10)
SELECT ST_AsText(p1) FROM gis_point1 WHERE ST_Crosses(p1, @poly1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRDisjoint(p1, @poly1);
ST_AsText(p1)
POINT(1 2)
POINT(6 12)
POINT(7 14)
POINT(8 16)
POINT(9 18)
POINT(10 21)
POINT(20.5 41)
POINT(26.25 57)
POINT(32.1234 64.2468)
# No matching records
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBREquals(p1, @poly1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRContains(p1, @poly1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBROverlaps(p1, @poly1);
ST_AsText(p1)
# Check functions that use MBR, with point type data
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRIntersects(p1, @p1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRWithin(p1, @p1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point1 WHERE ST_Touches(p1, @p1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBREquals(p1, @p1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRContains(p1, @p1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRDisjoint(p1, @p1);
ST_AsText(p1)
POINT(1 2)
POINT(2 4)
POINT(3 6)
POINT(4 8)
POINT(5 10)
POINT(6 12)
POINT(7 14)
POINT(8 16)
POINT(9 18)
POINT(10 21)
POINT(20.5 41)
POINT(26.25 57)
POINT(32.1234 64.2468)
# No matching records
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBROverlaps(p1, @p1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point1 WHERE ST_Crosses(p1, @p1);
ST_AsText(p1)
# Check with MBR functions point type data
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRIntersects(p1, @p1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRWithin(p1, @p1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point1 WHERE ST_Touches(p1, @p1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRContains(p1, @p1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRDisjoint(p1, @p1);
ST_AsText(p1)
POINT(1 2)
POINT(2 4)
POINT(3 6)
POINT(4 8)
POINT(5 10)
POINT(6 12)
POINT(7 14)
POINT(8 16)
POINT(9 18)
POINT(10 21)
POINT(20.5 41)
POINT(26.25 57)
POINT(32.1234 64.2468)
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRequals(p1, @p1);
ST_AsText(p1)
# No matching records
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBROverlaps(p1, @p1);
ST_AsText(p1)
# Check with MBR functions point polygon data
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRIntersects(p1, @p1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRWithin(p1, @p1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point1 WHERE ST_Touches(p1, @p1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRContains(p1, @p1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRDisjoint(p1, @p1);
ST_AsText(p1)
POINT(1 2)
POINT(2 4)
POINT(3 6)
POINT(4 8)
POINT(5 10)
POINT(6 12)
POINT(7 14)
POINT(8 16)
POINT(9 18)
POINT(10 21)
POINT(20.5 41)
POINT(26.25 57)
POINT(32.1234 64.2468)
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRequals(p1, @p1);
ST_AsText(p1)
# No matching records
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBROverlaps(p1, @p1);
ST_AsText(p1)
# Check with MBR functions polygon type data
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRIntersects(p1, @poly1);
ST_AsText(p1)
POINT(2 4)
POINT(3 6)
POINT(4 8)
POINT(5 10)
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRWithin(p1, @poly1);
ST_AsText(p1)
POINT(3 6)
POINT(4 8)
SELECT ST_AsText(p1) FROM gis_point1 WHERE ST_Touches(p1, @poly1);
ST_AsText(p1)
POINT(2 4)
POINT(5 10)
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRDisjoint(p1, @poly1);
ST_AsText(p1)
POINT(1 2)
POINT(6 12)
POINT(7 14)
POINT(8 16)
POINT(9 18)
POINT(10 21)
POINT(20.5 41)
POINT(26.25 57)
POINT(32.1234 64.2468)
# No matching records
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBROverlaps(p1, @poly1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRContains(p1, @poly1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRequals(p1, @poly1);
ST_AsText(p1)
# Check with MBR functions line type data
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRIntersects(p1, @ls1);
ST_AsText(p1)
POINT(1 2)
POINT(2 4)
POINT(3 6)
POINT(4 8)
POINT(5 10)
POINT(6 12)
POINT(7 14)
POINT(8 16)
POINT(9 18)
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRWithin(p1, @ls1);
ST_AsText(p1)
POINT(1 2)
POINT(2 4)
POINT(3 6)
POINT(4 8)
POINT(5 10)
POINT(6 12)
POINT(7 14)
POINT(8 16)
POINT(9 18)
SELECT ST_AsText(p1) FROM gis_point1 WHERE ST_Touches(p1, @ls1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRDisjoint(p1, @ls1);
ST_AsText(p1)
POINT(10 21)
POINT(20.5 41)
POINT(26.25 57)
POINT(32.1234 64.2468)
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRequals(p1, @ls1);
ST_AsText(p1)
# No matching records
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBROverlaps(p1, @ls1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRContains(p1, @ls1);
ST_AsText(p1)
DROP TABLE gis_point1;
SELECT ST_AsText(p1), ST_AsText(p2) FROM gis_point;
ST_AsText(p1) ST_AsText(p2)
POINT(1 2) POINT(-1 -3)
POINT(2 4) POINT(-2 -6)
POINT(3 6) POINT(-3 -9)
POINT(4 8) POINT(-4 -12)
POINT(5 10) POINT(-5 -15)
POINT(6 12) POINT(-6 -18)
POINT(7 14) POINT(-7 -21)
POINT(8 16) POINT(0 0)
POINT(9 18) POINT(-4 2)
POINT(10 21) POINT(-6 3)
POINT(20.5 41) POINT(-8 4)
POINT(26.25 57) POINT(1 2)
POINT(32.1234 64.2468) POINT(-1 -1)
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Intersection(@ls1, @ls2) = p1;
ST_AsText(p1)
POINT(5 10)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRWithin(p1, @poly1);
ST_AsText(p1)
POINT(3 6)
POINT(4 8)
SELECT ST_AsText(p2) FROM gis_point WHERE ST_Contains(@poly2, p2);
ST_AsText(p2)
POINT(-1 -3)
POINT(-2 -6)
POINT(-3 -9)
POINT(-4 -12)
POINT(-1 -1)
SELECT ST_AsText(p2) FROM gis_point WHERE ST_Equals(p2, @p1);
ST_AsText(p2)
POINT(0 0)
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Touches(@poly3, p1) AND MBRWithin(p2, @poly4);
ST_AsText(p1)
POINT(20.5 41)
POINT(32.1234 64.2468)
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Contains(@mpoly, p1);
ST_AsText(p1)
POINT(4 8)
POINT(5 10)
POINT(6 12)
POINT(7 14)
POINT(20.5 41)
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Contains(@mpoly, p1) AND NOT MBRWithin(p1, @mpoly);
ST_AsText(p1)
# Check functions that use MBR, with line type data
SELECT ST_AsText(p1) FROM gis_point WHERE MBRIntersects(p1, @ls1);
ST_AsText(p1)
POINT(1 2)
POINT(2 4)
POINT(3 6)
POINT(4 8)
POINT(5 10)
POINT(6 12)
POINT(7 14)
POINT(8 16)
POINT(9 18)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRWithin(p1, @ls1);
ST_AsText(p1)
POINT(1 2)
POINT(2 4)
POINT(3 6)
POINT(4 8)
POINT(5 10)
POINT(6 12)
POINT(7 14)
POINT(8 16)
POINT(9 18)
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Touches(p1, @ls1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRDisjoint(p1, @ls1);
ST_AsText(p1)
POINT(32.1234 64.2468)
POINT(26.25 57)
POINT(20.5 41)
POINT(10 21)
# No matching records
SELECT ST_AsText(p1) FROM gis_point WHERE MBREquals(p1, @ls1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRContains(p1, @ls1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE MBROverlaps(p1, @ls3);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Crosses(p1, @ls1);
ST_AsText(p1)
# Check functions that use MBR, with polygon type data
SELECT ST_AsText(p1) FROM gis_point WHERE MBRIntersects(p1, @poly1);
ST_AsText(p1)
POINT(2 4)
POINT(3 6)
POINT(4 8)
POINT(5 10)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRWithin(p1, @poly1);
ST_AsText(p1)
POINT(3 6)
POINT(4 8)
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Touches(p1, @poly1);
ST_AsText(p1)
POINT(2 4)
POINT(5 10)
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Crosses(p1, @poly1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRDisjoint(p1, @poly1);
ST_AsText(p1)
POINT(32.1234 64.2468)
POINT(26.25 57)
POINT(20.5 41)
POINT(10 21)
POINT(9 18)
POINT(8 16)
POINT(7 14)
POINT(6 12)
POINT(1 2)
# No matching records
SELECT ST_AsText(p1) FROM gis_point WHERE MBREquals(p1, @poly1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRContains(p1, @poly1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE MBROverlaps(p1, @poly1);
ST_AsText(p1)
# Check functions that use MBR, with point type data
SELECT ST_AsText(p1) FROM gis_point WHERE MBRIntersects(p1, @p1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRWithin(p1, @p1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Touches(p1, @p1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE MBREquals(p1, @p1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRContains(p1, @p1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRDisjoint(p1, @p1);
ST_AsText(p1)
POINT(32.1234 64.2468)
POINT(26.25 57)
POINT(20.5 41)
POINT(10 21)
POINT(9 18)
POINT(8 16)
POINT(7 14)
POINT(6 12)
POINT(5 10)
POINT(4 8)
POINT(3 6)
POINT(2 4)
POINT(1 2)
# No matching records
SELECT ST_AsText(p1) FROM gis_point WHERE MBROverlaps(p1, @p1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Crosses(p1, @p1);
ST_AsText(p1)
# Check with MBR functions point type data
SELECT ST_AsText(p1) FROM gis_point WHERE MBRIntersects(p1, @p1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRWithin(p1, @p1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Touches(p1, @p1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRContains(p1, @p1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRDisjoint(p1, @p1);
ST_AsText(p1)
POINT(32.1234 64.2468)
POINT(26.25 57)
POINT(20.5 41)
POINT(10 21)
POINT(9 18)
POINT(8 16)
POINT(7 14)
POINT(6 12)
POINT(5 10)
POINT(4 8)
POINT(3 6)
POINT(2 4)
POINT(1 2)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRequals(p1, @p1);
ST_AsText(p1)
# No matching records
SELECT ST_AsText(p1) FROM gis_point WHERE MBROverlaps(p1, @p1);
ST_AsText(p1)
# Check with MBR functions point polygon data
SELECT ST_AsText(p1) FROM gis_point WHERE MBRIntersects(p1, @p1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRWithin(p1, @p1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Touches(p1, @p1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRContains(p1, @p1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRDisjoint(p1, @p1);
ST_AsText(p1)
POINT(32.1234 64.2468)
POINT(26.25 57)
POINT(20.5 41)
POINT(10 21)
POINT(9 18)
POINT(8 16)
POINT(7 14)
POINT(6 12)
POINT(5 10)
POINT(4 8)
POINT(3 6)
POINT(2 4)
POINT(1 2)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRequals(p1, @p1);
ST_AsText(p1)
# No matching records
SELECT ST_AsText(p1) FROM gis_point WHERE MBROverlaps(p1, @p1);
ST_AsText(p1)
# Check with MBR functions polygon type data
SELECT ST_AsText(p1) FROM gis_point WHERE MBRIntersects(p1, @poly1);
ST_AsText(p1)
POINT(2 4)
POINT(3 6)
POINT(4 8)
POINT(5 10)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRWithin(p1, @poly1);
ST_AsText(p1)
POINT(3 6)
POINT(4 8)
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Touches(p1, @poly1);
ST_AsText(p1)
POINT(2 4)
POINT(5 10)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRDisjoint(p1, @poly1);
ST_AsText(p1)
POINT(32.1234 64.2468)
POINT(26.25 57)
POINT(20.5 41)
POINT(10 21)
POINT(9 18)
POINT(8 16)
POINT(7 14)
POINT(6 12)
POINT(1 2)
# No matching records
SELECT ST_AsText(p1) FROM gis_point WHERE MBROverlaps(p1, @poly1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRContains(p1, @poly1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRequals(p1, @poly1);
ST_AsText(p1)
# Check with MBR functions line type data
SELECT ST_AsText(p1) FROM gis_point WHERE MBRIntersects(p1, @ls1);
ST_AsText(p1)
POINT(1 2)
POINT(2 4)
POINT(3 6)
POINT(4 8)
POINT(5 10)
POINT(6 12)
POINT(7 14)
POINT(8 16)
POINT(9 18)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRWithin(p1, @ls1);
ST_AsText(p1)
POINT(1 2)
POINT(2 4)
POINT(3 6)
POINT(4 8)
POINT(5 10)
POINT(6 12)
POINT(7 14)
POINT(8 16)
POINT(9 18)
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Touches(p1, @ls1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRDisjoint(p1, @ls1);
ST_AsText(p1)
POINT(32.1234 64.2468)
POINT(26.25 57)
POINT(20.5 41)
POINT(10 21)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRequals(p1, @ls1);
ST_AsText(p1)
# No matching records
SELECT ST_AsText(p1) FROM gis_point WHERE MBROverlaps(p1, @ls1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRContains(p1, @ls1);
ST_AsText(p1)
# Modify the storage engine to Myisam, Check the spatial functions
ALTER TABLE gis_point ENGINE Myisam;
# Check functions that use MBR, with line type data
SELECT ST_AsText(p1) FROM gis_point WHERE MBRIntersects(p1, @ls1);
ST_AsText(p1)
POINT(1 2)
POINT(2 4)
POINT(3 6)
POINT(4 8)
POINT(5 10)
POINT(6 12)
POINT(7 14)
POINT(8 16)
POINT(9 18)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRWithin(p1, @ls1);
ST_AsText(p1)
POINT(1 2)
POINT(2 4)
POINT(3 6)
POINT(4 8)
POINT(5 10)
POINT(6 12)
POINT(7 14)
POINT(8 16)
POINT(9 18)
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Touches(p1, @ls1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRDisjoint(p1, @ls1);
ST_AsText(p1)
POINT(10 21)
POINT(20.5 41)
POINT(26.25 57)
POINT(32.1234 64.2468)
# No matching records
SELECT ST_AsText(p1) FROM gis_point WHERE MBREquals(p1, @ls1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRContains(p1, @ls1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE MBROverlaps(p1, @ls3);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Crosses(p1, @ls1);
ST_AsText(p1)
# Check functions that use MBR, with polygon type data
SELECT ST_AsText(p1) FROM gis_point WHERE MBRIntersects(p1, @poly1);
ST_AsText(p1)
POINT(2 4)
POINT(3 6)
POINT(4 8)
POINT(5 10)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRWithin(p1, @poly1);
ST_AsText(p1)
POINT(3 6)
POINT(4 8)
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Touches(p1, @poly1);
ST_AsText(p1)
POINT(2 4)
POINT(5 10)
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Crosses(p1, @poly1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRDisjoint(p1, @poly1);
ST_AsText(p1)
POINT(1 2)
POINT(6 12)
POINT(7 14)
POINT(8 16)
POINT(9 18)
POINT(10 21)
POINT(20.5 41)
POINT(26.25 57)
POINT(32.1234 64.2468)
# No matching records
SELECT ST_AsText(p1) FROM gis_point WHERE MBREquals(p1, @poly1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRContains(p1, @poly1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE MBROverlaps(p1, @poly1);
ST_AsText(p1)
# Check functions that use MBR, with point type data
SELECT ST_AsText(p1) FROM gis_point WHERE MBRIntersects(p1, @p1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRWithin(p1, @p1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Touches(p1, @p1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE MBREquals(p1, @p1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRContains(p1, @p1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRDisjoint(p1, @p1);
ST_AsText(p1)
POINT(1 2)
POINT(2 4)
POINT(3 6)
POINT(4 8)
POINT(5 10)
POINT(6 12)
POINT(7 14)
POINT(8 16)
POINT(9 18)
POINT(10 21)
POINT(20.5 41)
POINT(26.25 57)
POINT(32.1234 64.2468)
# No matching records
SELECT ST_AsText(p1) FROM gis_point WHERE MBROverlaps(p1, @p1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Crosses(p1, @p1);
ST_AsText(p1)
# Check with MBR functions point type data
SELECT ST_AsText(p1) FROM gis_point WHERE MBRIntersects(p1, @p1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRWithin(p1, @p1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Touches(p1, @p1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRContains(p1, @p1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRDisjoint(p1, @p1);
ST_AsText(p1)
POINT(1 2)
POINT(2 4)
POINT(3 6)
POINT(4 8)
POINT(5 10)
POINT(6 12)
POINT(7 14)
POINT(8 16)
POINT(9 18)
POINT(10 21)
POINT(20.5 41)
POINT(26.25 57)
POINT(32.1234 64.2468)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRequals(p1, @p1);
ST_AsText(p1)
# No matching records
SELECT ST_AsText(p1) FROM gis_point WHERE MBROverlaps(p1, @p1);
ST_AsText(p1)
# Check with MBR functions point polygon data
SELECT ST_AsText(p1) FROM gis_point WHERE MBRIntersects(p1, @p1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRWithin(p1, @p1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Touches(p1, @p1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRContains(p1, @p1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRDisjoint(p1, @p1);
ST_AsText(p1)
POINT(1 2)
POINT(2 4)
POINT(3 6)
POINT(4 8)
POINT(5 10)
POINT(6 12)
POINT(7 14)
POINT(8 16)
POINT(9 18)
POINT(10 21)
POINT(20.5 41)
POINT(26.25 57)
POINT(32.1234 64.2468)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRequals(p1, @p1);
ST_AsText(p1)
# No matching records
SELECT ST_AsText(p1) FROM gis_point WHERE MBROverlaps(p1, @p1);
ST_AsText(p1)
# Check with MBR functions polygon type data
SELECT ST_AsText(p1) FROM gis_point WHERE MBRIntersects(p1, @poly1);
ST_AsText(p1)
POINT(2 4)
POINT(3 6)
POINT(4 8)
POINT(5 10)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRWithin(p1, @poly1);
ST_AsText(p1)
POINT(3 6)
POINT(4 8)
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Touches(p1, @poly1);
ST_AsText(p1)
POINT(2 4)
POINT(5 10)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRDisjoint(p1, @poly1);
ST_AsText(p1)
POINT(1 2)
POINT(6 12)
POINT(7 14)
POINT(8 16)
POINT(9 18)
POINT(10 21)
POINT(20.5 41)
POINT(26.25 57)
POINT(32.1234 64.2468)
# No matching records
SELECT ST_AsText(p1) FROM gis_point WHERE MBROverlaps(p1, @poly1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRContains(p1, @poly1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRequals(p1, @poly1);
ST_AsText(p1)
# Check with MBR functions line type data
SELECT ST_AsText(p1) FROM gis_point WHERE MBRIntersects(p1, @ls1);
ST_AsText(p1)
POINT(1 2)
POINT(2 4)
POINT(3 6)
POINT(4 8)
POINT(5 10)
POINT(6 12)
POINT(7 14)
POINT(8 16)
POINT(9 18)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRWithin(p1, @ls1);
ST_AsText(p1)
POINT(1 2)
POINT(2 4)
POINT(3 6)
POINT(4 8)
POINT(5 10)
POINT(6 12)
POINT(7 14)
POINT(8 16)
POINT(9 18)
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Touches(p1, @ls1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRDisjoint(p1, @ls1);
ST_AsText(p1)
POINT(10 21)
POINT(20.5 41)
POINT(26.25 57)
POINT(32.1234 64.2468)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRequals(p1, @ls1);
ST_AsText(p1)
# No matching records
SELECT ST_AsText(p1) FROM gis_point WHERE MBROverlaps(p1, @ls1);
ST_AsText(p1)
SELECT ST_AsText(p1) FROM gis_point WHERE MBRContains(p1, @ls1);
ST_AsText(p1)
# Modify the storage engine to InnoDB again, do following testing
ALTER TABLE gis_point ENGINE InnoDB;
CHECK TABLE gis_point;
Table Op Msg_type Msg_text
test.gis_point check status OK
The ORDER BY for spatial index will use filesort
EXPLAIN SELECT ST_AsText(p1), ST_AsText(p2) FROM gis_point ORDER BY p1, p2;
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE gis_point NULL ALL NULL NULL NULL NULL # 100.00 Using filesort
Warnings:
Note 1003 /* select#1 */ select st_astext(`test`.`gis_point`.`p1`) AS `ST_AsText(p1)`,st_astext(`test`.`gis_point`.`p2`) AS `ST_AsText(p2)` from `test`.`gis_point` order by `test`.`gis_point`.`p1`,`test`.`gis_point`.`p2`
SELECT ST_AsText(p1), ST_AsText(p2) FROM gis_point ORDER BY p1, p2;
ST_AsText(p1) ST_AsText(p2)
POINT(2 4) POINT(-2 -6)
POINT(3 6) POINT(-3 -9)
POINT(4 8) POINT(-4 -12)
POINT(5 10) POINT(-5 -15)
POINT(6 12) POINT(-6 -18)
POINT(7 14) POINT(-7 -21)
POINT(8 16) POINT(0 0)
POINT(9 18) POINT(-4 2)
POINT(10 21) POINT(-6 3)
POINT(1 2) POINT(-1 -3)
POINT(26.25 57) POINT(1 2)
POINT(20.5 41) POINT(-8 4)
POINT(32.1234 64.2468) POINT(-1 -1)
Try to do IDU on the table and verify the result
DELETE FROM gis_point WHERE ST_Equals(p2, ST_PointFromText('POINT(-8 4)'));
INSERT INTO gis_point VALUES(ST_PointFromText('POINT(20.5 -41)'), ST_PointFromText('POINT(8 -4)'));
SELECT ST_AsText(p1) AS 'Expect (32.1234 64.2468)' FROM gis_point WHERE ST_Touches(@poly3, p1) AND MBRWithin(p2, @poly4);
Expect (32.1234 64.2468)
POINT(32.1234 64.2468)
UPDATE gis_point SET p1 = ST_PointFromText('POINT(20.5 41)'), p2 = ST_PointFromText('POINT(-8 4)') WHERE ST_Intersection(@ls3, @ls4) = p1;
SELECT ST_AsText(p1) AS 'Expect (32.1234 64.2468) AND (20.5 41)' FROM gis_point WHERE ST_Touches(@poly3, p1) AND MBRWithin(p2, @poly4);
Expect (32.1234 64.2468) AND (20.5 41)
POINT(32.1234 64.2468)
POINT(20.5 41)
CHECK TABLE gis_point;
Table Op Msg_type Msg_text
test.gis_point check status OK
Use a trx to test the IDU on the table and verify the result
START TRANSACTION;
DELETE FROM gis_point WHERE ST_Equals(p2, ST_PointFromText('POINT(-8 4)'));
INSERT INTO gis_point VALUES(ST_PointFromText('POINT(20.5 -41)'), ST_PointFromText('POINT(8 -4)'));
SELECT ST_AsText(p1) AS 'Expect (32.1234 64.2468)' FROM gis_point WHERE ST_Touches(@poly3, p1) AND MBRWithin(p2, @poly4);
Expect (32.1234 64.2468)
POINT(32.1234 64.2468)
UPDATE gis_point SET p1 = ST_PointFromText('POINT(20.5 49)'), p2 = ST_PointFromText('POINT(-8 4)') WHERE ST_Intersection(@ls3, @ls4) = p1;
SELECT ST_AsText(p1) AS 'Expect (32.1234 64.2468) AND (20.5 49)' FROM gis_point WHERE ST_Touches(@poly3, p1) AND MBRWithin(p2, @poly4);
Expect (32.1234 64.2468) AND (20.5 49)
POINT(32.1234 64.2468)
POINT(20.5 49)
ROLLBACK;
SELECT ST_AsText(p1) AS 'Expect (32.1234 64.2468) AND (20.5 41)' FROM gis_point WHERE ST_Touches(@poly3, p1) AND MBRWithin(p2, @poly4);
Expect (32.1234 64.2468) AND (20.5 41)
POINT(32.1234 64.2468)
POINT(20.5 41)
CHECK TABLE gis_point;
Table Op Msg_type Msg_text
test.gis_point check status OK
DROP TABLE gis_point;
#
# Test inserting/updating different type data into POINT field
#
CREATE TABLE gis_point (i INT, p POINT) ENGINE=InnoDB;
CREATE TABLE geom (i INT, g GEOMETRY NOT NULL, SPATIAL KEY(g)) ENGINE=InnoDB;
INSERT INTO gis_point VALUES(0, ST_PointFromText('POINT(1 1)'));
INSERT INTO gis_point VALUES(1, ST_PointFromText('POINT(2 2)'));
INSERT INTO gis_point VALUES(2, NULL);
ALTER TABLE gis_point ADD COLUMN j INT, ALGORITHM = COPY;
SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE name = 'p';
name mtype prtype len
p 14 1279 12
SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE name = 'p';
name mtype prtype len
p 14 1279 12
SELECT i, ST_AsText(p) FROM gis_point;
i ST_AsText(p)
0 POINT(1 1)
1 POINT(2 2)
2 NULL
UPDATE gis_point SET p = NULL WHERE p = ST_PointFromText('POINT(1 1)');
UPDATE gis_point SET p = ST_PointFromText('POINT(1 2)') WHERE p = ST_PointFromText('POINT(2 2)');
UPDATE gis_point SET p = ST_PointFromText('POINT(1 1)') WHERE p IS NULL;
SELECT i, ST_AsText(p) FROM gis_point;
i ST_AsText(p)
0 POINT(1 1)
1 POINT(1 2)
2 POINT(1 1)
INSERT INTO geom VALUES(0, ST_PointFromText('POINT(0 0)'));
INSERT INTO geom VALUES(1, ST_PointFromText('POINT(10 10)'));
INSERT INTO geom VALUES(2, ST_GeomFromText('POLYGON((7 1,6 2,6 3,10 3,10 1,7 1))'));
SELECT ST_AsText(g) FROM geom;
ST_AsText(g)
POINT(0 0)
POINT(10 10)
POLYGON((7 1,6 2,6 3,10 3,10 1,7 1))
SELECT ST_AsText(p) FROM gis_point;
ST_AsText(p)
POINT(1 1)
POINT(1 2)
POINT(1 1)
DELETE FROM geom WHERE g = ST_GeomFromText('POLYGON((7 1,6 2,6 3,10 3,10 1,7 1))');
From GEOMETRY to POINT, now ALL the data are POINT
ALTER TABLE geom MODIFY g POINT NOT NULL;
SHOW CREATE TABLE geom;
Table Create Table
geom CREATE TABLE `geom` (
`i` int(11) DEFAULT NULL,
`g` point NOT NULL,
SPATIAL KEY `g` (`g`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
SELECT ST_AsText(g) FROM geom;
ST_AsText(g)
POINT(0 0)
POINT(10 10)
From POINT to GEOMETRY, all data are POINT
ALTER TABLE geom MODIFY g GEOMETRY NOT NULL;
SHOW CREATE TABLE geom;
Table Create Table
geom CREATE TABLE `geom` (
`i` int(11) DEFAULT NULL,
`g` geometry NOT NULL,
SPATIAL KEY `g` (`g`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
TRUNCATE TABLE geom;
From GEOMETRY to POINT, the table is empty
ALTER TABLE geom MODIFY g POINT NOT NULL;
SHOW CREATE TABLE geom;
Table Create Table
geom CREATE TABLE `geom` (
`i` int(11) DEFAULT NULL,
`g` point NOT NULL,
SPATIAL KEY `g` (`g`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
SELECT ST_AsText(g) FROM geom;
ST_AsText(g)
CHECK TABLE gis_point;
Table Op Msg_type Msg_text
test.gis_point check status OK
CHECK TABLE geom;
Table Op Msg_type Msg_text
test.geom check status OK
DROP TABLE gis_point, geom;
#
# Test when a geom field, such as POINT, is also a primary key
#
CREATE TABLE t1 (
a INT NOT NULL,
p POINT NOT NULL,
l LINESTRING NOT NULL,
g GEOMETRY NOT NULL,
PRIMARY KEY(p),
SPATIAL KEY `idx2` (p),
SPATIAL KEY `idx3` (l),
SPATIAL KEY `idx4` (g)
) ENGINE=InnoDB;
INSERT INTO t1 VALUES(
1, ST_GeomFromText('POINT(10 10)'),
ST_GeomFromText('LINESTRING(1 1, 5 5, 10 10)'),
ST_GeomFromText('POLYGON((30 30, 40 40, 50 50, 30 50, 30 40, 30 30))'));
INSERT INTO t1 VALUES(
2, ST_GeomFromText('POINT(20 20)'),
ST_GeomFromText('LINESTRING(2 3, 7 8, 9 10, 15 16)'),
ST_GeomFromText('POLYGON((10 30, 30 40, 40 50, 40 30, 30 20, 10 30))'));
SELECT a, ST_AsText(p), ST_AsText(l), ST_AsText(g) FROM t1;
a ST_AsText(p) ST_AsText(l) ST_AsText(g)
1 POINT(10 10) LINESTRING(1 1,5 5,10 10) POLYGON((30 30,40 40,50 50,30 50,30 40,30 30))
2 POINT(20 20) LINESTRING(2 3,7 8,9 10,15 16) POLYGON((10 30,30 40,40 50,40 30,30 20,10 30))
EXPLAIN UPDATE t1 SET p = ST_GeomFromText('POINT(30 30)') WHERE p = ST_GeomFromText('POINT(20 20)');
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 UPDATE t1 NULL range PRIMARY PRIMARY 27 const # 100.00 Using where
UPDATE t1 SET p = ST_GeomFromText('POINT(30 30)') WHERE p = ST_GeomFromText('POINT(20 20)');
SELECT a, ST_AsText(p), ST_AsText(l), ST_AsText(g) FROM t1;
a ST_AsText(p) ST_AsText(l) ST_AsText(g)
1 POINT(10 10) LINESTRING(1 1,5 5,10 10) POLYGON((30 30,40 40,50 50,30 50,30 40,30 30))
2 POINT(30 30) LINESTRING(2 3,7 8,9 10,15 16) POLYGON((10 30,30 40,40 50,40 30,30 20,10 30))
ALTER TABLE t1 DROP PRIMARY KEY;
ALTER TABLE t1 ADD PRIMARY KEY(a);
SELECT a, ST_AsText(p), ST_AsText(l), ST_AsText(g) FROM t1;
a ST_AsText(p) ST_AsText(l) ST_AsText(g)
1 POINT(10 10) LINESTRING(1 1,5 5,10 10) POLYGON((30 30,40 40,50 50,30 50,30 40,30 30))
2 POINT(30 30) LINESTRING(2 3,7 8,9 10,15 16) POLYGON((10 30,30 40,40 50,40 30,30 20,10 30))
ALTER TABLE t1 DROP PRIMARY KEY;
ALTER TABLE t1 ADD PRIMARY KEY(p);
SELECT a, ST_AsText(p), ST_AsText(l), ST_AsText(g) FROM t1;
a ST_AsText(p) ST_AsText(l) ST_AsText(g)
1 POINT(10 10) LINESTRING(1 1,5 5,10 10) POLYGON((30 30,40 40,50 50,30 50,30 40,30 30))
2 POINT(30 30) LINESTRING(2 3,7 8,9 10,15 16) POLYGON((10 30,30 40,40 50,40 30,30 20,10 30))
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`p` point NOT NULL,
`l` linestring NOT NULL,
`g` geometry NOT NULL,
PRIMARY KEY (`p`(25)),
SPATIAL KEY `idx2` (`p`),
SPATIAL KEY `idx3` (`l`),
SPATIAL KEY `idx4` (`g`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
SELECT a, ST_AsText(p), ST_AsText(l), ST_AsText(g) FROM t1;
a ST_AsText(p) ST_AsText(l) ST_AsText(g)
1 POINT(10 10) LINESTRING(1 1,5 5,10 10) POLYGON((30 30,40 40,50 50,30 50,30 40,30 30))
2 POINT(30 30) LINESTRING(2 3,7 8,9 10,15 16) POLYGON((10 30,30 40,40 50,40 30,30 20,10 30))
ALTER TABLE t1 DROP PRIMARY KEY;
ALTER TABLE t1 ADD PRIMARY KEY(p);
EXPLAIN SELECT a, ST_AsText(p) FROM t1 WHERE a = 2 AND p = ST_GeomFromText('POINT(30 30)');
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 NULL const PRIMARY,idx2 PRIMARY 27 const # 100.00 NULL
Warnings:
Note 1003 /* select#1 */ select '2' AS `a`,st_astext('
SELECT a, ST_AsText(p) FROM t1 WHERE a = 2 AND p = ST_GeomFromText('POINT(30 30)');
a ST_AsText(p)
2 POINT(30 30)
SELECT a, ST_AsText(p), ST_AsText(l), ST_AsText(g) FROM t1;
a ST_AsText(p) ST_AsText(l) ST_AsText(g)
1 POINT(10 10) LINESTRING(1 1,5 5,10 10) POLYGON((30 30,40 40,50 50,30 50,30 40,30 30))
2 POINT(30 30) LINESTRING(2 3,7 8,9 10,15 16) POLYGON((10 30,30 40,40 50,40 30,30 20,10 30))
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
DROP TABLE t1;
#
# Test for foreign keys.
#
CREATE TABLE parent(p POINT, PRIMARY KEY(p)) ENGINE=InnoDB;
CREATE TABLE child(p POINT NOT NULL) ENGINE=InnoDB;
ALTER TABLE parent ADD SPATIAL INDEX idx1(p ASC);
ALTER TABLE child ADD SPATIAL INDEX idx2(p ASC);
SHOW CREATE TABLE parent;
Table Create Table
parent CREATE TABLE `parent` (
`p` point NOT NULL,
PRIMARY KEY (`p`(25)),
SPATIAL KEY `idx1` (`p`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
SHOW CREATE TABLE child;
Table Create Table
child CREATE TABLE `child` (
`p` point NOT NULL,
SPATIAL KEY `idx2` (`p`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
ALTER TABLE child ADD FOREIGN KEY(p) REFERENCES parent(p);
ERROR HY000: Cannot add foreign key constraint
ALTER TABLE parent DROP INDEX idx1;
ALTER TABLE child ADD FOREIGN KEY(p) REFERENCES parent(p);
ERROR HY000: Cannot add foreign key constraint
ALTER TABLE child DROP INDEX idx2;
ALTER TABLE child ADD FOREIGN KEY(p) REFERENCES parent(p);
ERROR HY000: Cannot add foreign key constraint
DROP TABLE child, parent;
#
# Bug#28763: Selecting geometry fields in UNION caused server crash.
#
CREATE TABLE t1(f1 GEOMETRY, f2 POINT, f3 GEOMETRY) ENGINE=InnoDB;
SELECT f1 FROM t1 UNION SELECT f1 FROM t1;
f1
INSERT INTO t1 (f2,f3) VALUES (ST_GeomFromText('POINT(1 1)'),
ST_GeomFromText('POINT(2 2)'));
SELECT ST_AsText(f2),ST_AsText(f3) FROM t1;
ST_AsText(f2) ST_AsText(f3)
POINT(1 1) POINT(2 2)
SELECT ST_AsText(a) FROM (SELECT f2 AS a FROM t1 UNION SELECT f3 FROM t1) t;
ST_AsText(a)
POINT(1 1)
POINT(2 2)
CREATE TABLE t2 AS SELECT f2 AS a FROM t1 UNION SELECT f3 FROM t1;
DESC t2;
Field Type Null Key Default Extra
a geometry YES NULL
SELECT ST_AsText(a) FROM t2;
ST_AsText(a)
POINT(1 1)
POINT(2 2)
DROP TABLE t1, t2;
#
# Test when the POINT is on B-TREE
#
CREATE TABLE t1(fid INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT, p POINT, KEY(p)) ENGINE=InnoDB;
INSERT INTO t1 VALUES
(101, ST_PointFromText('POINT(10 10)')),
(102, ST_PointFromText('POINT(20 10)')),
(103, ST_PointFromText('POINT(20 20)')),
(104, ST_PointFromWKB(ST_AsWKB(ST_PointFromText('POINT(10 20)'))));
SELECT ST_AsText(p) FROM t1;
ST_AsText(p)
POINT(10 10)
POINT(20 10)
POINT(20 20)
POINT(10 20)
SELECT ST_AsText(p) FROM t1 WHERE p = ST_PointFromText('POINT(20 20)');
ST_AsText(p)
POINT(20 20)
INSERT INTO t1 VALUES
(201, ST_PointFromText('POINT(100.32374832 101.23741821)')),
(202, ST_PointFromText('POINT(102.43287328 100.23489233)')),
(203, ST_PointFromText('POINT(101.43284962 100.45892392)')),
(204, ST_PointFromWKB(ST_AsWKB(ST_PointFromText('POINT(103.43718640 105.248206478)')))),
(205, ST_PointFromText('POINT(101.43284962 100.45892392)')),
(206, ST_PointFromWKB(ST_AsWKB(ST_PointFromText('POINT(103.43718640 105.248206478)'))));
SELECT ST_AsText(p), COUNT(*) FROM t1 GROUP BY p;
ST_AsText(p) COUNT(*)
POINT(10 10) 1
POINT(10 20) 1
POINT(20 10) 1
POINT(20 20) 1
POINT(101.43284962 100.45892392) 2
POINT(100.32374832 101.23741821) 1
POINT(102.43287328 100.23489233) 1
POINT(103.4371864 105.248206478) 2
TRUNCATE t1;
SELECT * FROM t1;
fid p
INSERT INTO t1(p) VALUES(ST_PointFromText('POINT(10 10)')),
(ST_PointFromText('POINT(10 20)')),
(ST_PointFromText('POINT(10 40)')),
(ST_PointFromText('POINT(10 60)')),
(ST_PointFromText('POINT(20 15)')),
(ST_PointFromText('POINT(30 10)')),
(ST_PointFromText('POINT(40 10)')),
(ST_PointFromText('POINT(50 10)')),
(ST_PointFromText('POINT(60 5)')),
(ST_PointFromText('POINT(60 10)')),
(ST_PointFromText('POINT(60 20)')),
(ST_PointFromText('POINT(60 100)')),
(ST_PointFromText('POINT(100 100)')),
(ST_PointFromText('POINT(80 60)')),
(ST_PointFromText('POINT(81 50)')),
(ST_PointFromText('POINT(82 70)')),
(ST_PointFromText('POINT(83 30)')),
(ST_PointFromText('POINT(20 100)')),
(ST_PointFromText('POINT(150 2000)')),
(ST_PointFromText('POINT(109 230)')),
(ST_PointFromText('POINT(280 250)')),
(ST_PointFromText('POINT(176 175)')),
(ST_PointFromText('POINT(200 10)')),
(NULL),
(NULL);
SELECT ST_AsText(p) FROM t1;
ST_AsText(p)
POINT(10 10)
POINT(10 20)
POINT(10 40)
POINT(10 60)
POINT(20 15)
POINT(30 10)
POINT(40 10)
POINT(50 10)
POINT(60 5)
POINT(60 10)
POINT(60 20)
POINT(60 100)
POINT(100 100)
POINT(80 60)
POINT(81 50)
POINT(82 70)
POINT(83 30)
POINT(20 100)
POINT(150 2000)
POINT(109 230)
POINT(280 250)
POINT(176 175)
POINT(200 10)
NULL
NULL
SELECT COUNT(*) FROM t1;
COUNT(*)
25
SELECT ST_AsText(p) FROM t1;
ST_AsText(p)
POINT(10 10)
POINT(10 20)
POINT(10 40)
POINT(10 60)
POINT(20 15)
POINT(30 10)
POINT(40 10)
POINT(50 10)
POINT(60 5)
POINT(60 10)
POINT(60 20)
POINT(60 100)
POINT(100 100)
POINT(80 60)
POINT(81 50)
POINT(82 70)
POINT(83 30)
POINT(20 100)
POINT(150 2000)
POINT(109 230)
POINT(280 250)
POINT(176 175)
POINT(200 10)
NULL
NULL
SELECT COUNT(*) FROM t1;
COUNT(*)
25
INSERT INTO t1(p) SELECT p FROM t1;
INSERT INTO t1(p) SELECT p FROM t1;
INSERT INTO t1(p) SELECT p FROM t1;
INSERT INTO t1(p) SELECT p FROM t1;
INSERT INTO t1(p) SELECT p FROM t1;
INSERT INTO t1(p) SELECT p FROM t1;
INSERT INTO t1(p) SELECT p FROM t1;
INSERT INTO t1(p) SELECT p FROM t1;
INSERT INTO t1(p) SELECT p FROM t1;
INSERT INTO t1(p) SELECT p FROM t1;
INSERT INTO t1(p) SELECT p FROM t1;
INSERT INTO t1(p) SELECT p FROM t1;
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
SELECT COUNT(*) FROM t1;
COUNT(*)
102400
SELECT ST_AsText(p), COUNT(*) FROM t1 GROUP BY p;
ST_AsText(p) COUNT(*)
NULL 8192
POINT(10 10) 4096
POINT(10 20) 4096
POINT(10 40) 4096
POINT(10 60) 4096
POINT(20 15) 4096
POINT(20 100) 4096
POINT(30 10) 4096
POINT(40 10) 4096
POINT(50 10) 4096
POINT(60 5) 4096
POINT(60 10) 4096
POINT(60 20) 4096
POINT(60 100) 4096
POINT(80 60) 4096
POINT(100 100) 4096
POINT(176 175) 4096
POINT(200 10) 4096
POINT(81 50) 4096
POINT(109 230) 4096
POINT(82 70) 4096
POINT(280 250) 4096
POINT(83 30) 4096
POINT(150 2000) 4096
SELECT COUNT(*) FROM t1 WHERE p = ST_PointFromText('POINT(280 250)');
COUNT(*)
4096
DELETE FROM t1 WHERE p = ST_PointFromText('POINT(280 250)');
SELECT COUNT(*) FROM t1 WHERE p = ST_PointFromText('POINT(280 250)');
COUNT(*)
0
SELECT COUNT(*) FROM t1 WHERE p = ST_PointFromText('POINT(60 5)');
COUNT(*)
4096
DELETE FROM t1 WHERE P = ST_PointFromText('POINT(60 5)');
SELECT COUNT(*) FROM t1 WHERE p = ST_PointFromText('POINT(60 5)');
COUNT(*)
0
SELECT ST_AsText(p), COUNT(*) FROM t1 WHERE p = ST_PointFromText('POINT(60 10)') OR p = ST_PointFromText('POINT(60 20)') OR p = ST_PointFromText('POINT(60 30)') GROUP BY p;
ST_AsText(p) COUNT(*)
POINT(60 10) 4096
POINT(60 20) 4096
UPDATE t1 SET p = ST_PointFromText('POINT(101 102)') WHERE p = ST_PointFromText('POINT(60 10)') OR p = ST_PointFromText('POINT(60 20)') OR p = ST_PointFromText('POINT(60 30)');
SELECT ST_AsText(p), COUNT(*) FROM t1 WHERE p = ST_PointFromText('POINT(60 10)') OR p = ST_PointFromText('POINT(60 20)') OR p = ST_PointFromText('POINT(60 30)') GROUP BY p;
ST_AsText(p) COUNT(*)
SELECT COUNT(*) FROM t1 WHERE p = ST_PointFromText('POINT(101 102)');
COUNT(*)
8192
SELECT COUNT(*) FROM t1 WHERE p IS NULL;
COUNT(*)
8192
UPDATE t1 SET p = ST_PointFromText('POINT(160 160)') WHERE p IS NULL;
SELECT COUNT(*) FROM t1 WHERE p IS NULL;
COUNT(*)
0
SELECT COUNT(*) FROM t1 WHERE p = ST_PointFromText('POINT(160 160)');
COUNT(*)
8192
SELECT ST_AsText(p), COUNT(*) FROM t1 GROUP BY p;
ST_AsText(p) COUNT(*)
POINT(10 10) 4096
POINT(10 20) 4096
POINT(10 40) 4096
POINT(10 60) 4096
POINT(20 15) 4096
POINT(20 100) 4096
POINT(30 10) 4096
POINT(40 10) 4096
POINT(50 10) 4096
POINT(60 100) 4096
POINT(80 60) 4096
POINT(100 100) 4096
POINT(160 160) 8192
POINT(176 175) 4096
POINT(200 10) 4096
POINT(81 50) 4096
POINT(101 102) 8192
POINT(109 230) 4096
POINT(82 70) 4096
POINT(83 30) 4096
POINT(150 2000) 4096
SELECT COUNT(*) FROM t1;
COUNT(*)
94208
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
DROP TABLE t1;
#
# Test when POINT is used in spatial index
#
SET @ls1 = ST_GeomFromText('LINESTRING(0 20, 10 0)');
SET @ls2 = ST_GeomFromText('LINESTRING(0 0, 10 20)');
SET @ls3 = ST_GeomFromText('LINESTRING(20 -40, 21 -42)');
SET @ls4 = ST_GeomFromText('LINESTRING(20 -42, 21 -40)');
SET @poly1 = ST_GeomFromText('POLYGON((2 2, 2 10, 10 10, 10 2, 2 2))');
SET @poly2 = ST_GeomFromText('POLYGON((0 0, -5 0, -4 -1, -6 -15, -3 -15, 0 0))');
SET @poly3 = ST_GeomFromText('POLYGON((10.0 10.0, 20.5 20, 20.5 50, 32.0 64.0, 32.3 64.6, 5 60, 10 10))');
SET @poly4 = ST_GeomFromText('POLYGON((0 10, -10 10, -10 -10, 0 -10, 0 10))');
SET @p1 = ST_PointFromText('POINT(0 0)');
SET @mpoly = ST_GeomFromText('MULTIPOLYGON(((3 3, 3 16, 16 16, 16 3, 3 3)), ((10 10, 10 50, 50 50, 50 10, 10 10)))');
CREATE TABLE gis_point (p1 POINT NOT NULL, p2 POINT NOT NULL, SPATIAL KEY k1 (p1), SPATIAL KEY k2 (p2)) ENGINE=InnoDB;
INSERT INTO gis_point VALUES
(ST_PointFromText('POINT(1 2)'), ST_PointFromText('POINT(-1 -3)')),
(ST_PointFromText('POINT(2 4)'), ST_PointFromText('POINT(-2 -6)')),
(ST_PointFromText('POINT(3 6)'), ST_PointFromText('POINT(-3 -9)')),
(ST_PointFromText('POINT(4 8)'), ST_PointFromText('POINT(-4 -12)')),
(ST_PointFromText('POINT(5 10)'), ST_PointFromText('POINT(-5 -15)')),
(ST_PointFromText('POINT(6 12)'), ST_PointFromText('POINT(-6 -18)')),
(ST_PointFromText('POINT(7 14)'), ST_PointFromText('POINT(-7 -21)')),
(ST_PointFromText('POINT(8 16)'), ST_PointFromText('POINT(0 0)')),
(ST_PointFromText('POINT(9 18)'), ST_PointFromText('POINT(-4 2)')),
(ST_PointFromText('POINT(10 21)'), ST_PointFromText('POINT(-6 3)')),
(ST_PointFromText('POINT(20.5 41)'), ST_PointFromText('POINT(-8 4)')),
(ST_PointFromText('POINT(26.25 57)'), ST_PointFromText('POINT(1 2)')),
(ST_PointFromText('POINT(32.1234 64.2468)'), ST_PointFromText('POINT(-1 -1)'));
'The ORDER BY for spatial index will use filesort'
EXPLAIN SELECT ST_AsText(p1), ST_AsText(p2) FROM gis_point ORDER BY p1, p2;
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE gis_point NULL ALL NULL NULL NULL NULL # 100.00 Using filesort
Warnings:
Note 1003 /* select#1 */ select st_astext(`test`.`gis_point`.`p1`) AS `ST_AsText(p1)`,st_astext(`test`.`gis_point`.`p2`) AS `ST_AsText(p2)` from `test`.`gis_point` order by `test`.`gis_point`.`p1`,`test`.`gis_point`.`p2`
SELECT ST_AsText(p1), ST_AsText(p2) FROM gis_point ORDER BY p1, p2;
ST_AsText(p1) ST_AsText(p2)
POINT(2 4) POINT(-2 -6)
POINT(3 6) POINT(-3 -9)
POINT(4 8) POINT(-4 -12)
POINT(5 10) POINT(-5 -15)
POINT(6 12) POINT(-6 -18)
POINT(7 14) POINT(-7 -21)
POINT(8 16) POINT(0 0)
POINT(9 18) POINT(-4 2)
POINT(10 21) POINT(-6 3)
POINT(1 2) POINT(-1 -3)
POINT(26.25 57) POINT(1 2)
POINT(20.5 41) POINT(-8 4)
POINT(32.1234 64.2468) POINT(-1 -1)
'Try to do IDU on the table and verify the result'
DELETE FROM gis_point WHERE ST_Equals(p2, ST_PointFromText('POINT(-8 4)'));
INSERT INTO gis_point VALUES(ST_PointFromText('POINT(20.5 -41)'), ST_PointFromText('POINT(8 -4)'));
SELECT ST_AsText(p1) AS 'Expect (32.1234 64.2468)' FROM gis_point WHERE ST_TOUCHES(@poly3, p1) AND MBRWithin(p2, @poly4);
Expect (32.1234 64.2468)
POINT(32.1234 64.2468)
UPDATE gis_point SET p1 = ST_PointFromText('POINT(20.5 41)'), p2 = ST_PointFromText('POINT(-8 4)') WHERE ST_Intersection(@ls3, @ls4) = p1;
SELECT ST_AsText(p1) AS 'Expect (32.1234 64.2468) AND (20.5 41)' FROM gis_point WHERE ST_TOUCHES(@poly3, p1) AND MBRWithin(p2, @poly4);
Expect (32.1234 64.2468) AND (20.5 41)
POINT(32.1234 64.2468)
POINT(20.5 41)
CHECK TABLE gis_point;
Table Op Msg_type Msg_text
test.gis_point check status OK
============================================================
Use a trx to test the IDU on the table and verify the result
============================================================
START TRANSACTION;
DELETE FROM gis_point WHERE ST_Equals(p2, ST_PointFromText('POINT(-8 4)'));
INSERT INTO gis_point VALUES(ST_PointFromText('POINT(20.5 -41)'), ST_PointFromText('POINT(8 -4)'));
SELECT ST_AsText(p1) AS 'Expect (32.1234 64.2468)' FROM gis_point WHERE ST_TOUCHES(@poly3, p1) AND MBRWithin(p2, @poly4);
Expect (32.1234 64.2468)
POINT(32.1234 64.2468)
UPDATE gis_point SET p1 = ST_PointFromText('POINT(20.5 49)'), p2 = ST_PointFromText('POINT(-8 4)') WHERE ST_Intersection(@ls3, @ls4) = p1;
SELECT ST_AsText(p1) AS 'Expect (32.1234 64.2468) AND (20.5 49)' FROM gis_point WHERE ST_TOUCHES(@poly3, p1) AND MBRWithin(p2, @poly4);
Expect (32.1234 64.2468) AND (20.5 49)
POINT(32.1234 64.2468)
POINT(20.5 49)
ROLLBACK;
SELECT ST_AsText(p1) AS 'Expect (32.1234 64.2468) AND (20.5 41)' FROM gis_point WHERE ST_TOUCHES(@poly3, p1) AND MBRWithin(p2, @poly4);
Expect (32.1234 64.2468) AND (20.5 41)
POINT(32.1234 64.2468)
POINT(20.5 41)
CHECK TABLE gis_point;
Table Op Msg_type Msg_text
test.gis_point check status OK
=======================================================
Enlarge the table by inserting the same data and verify
=======================================================
INSERT INTO gis_point SELECT * FROM gis_point;
INSERT INTO gis_point SELECT * FROM gis_point;
INSERT INTO gis_point SELECT * FROM gis_point;
INSERT INTO gis_point SELECT * FROM gis_point;
INSERT INTO gis_point SELECT * FROM gis_point;
INSERT INTO gis_point SELECT * FROM gis_point;
INSERT INTO gis_point SELECT * FROM gis_point;
INSERT INTO gis_point SELECT * FROM gis_point;
INSERT INTO gis_point SELECT * FROM gis_point;
INSERT INTO gis_point SELECT * FROM gis_point;
CHECK TABLE gis_point;
Table Op Msg_type Msg_text
test.gis_point check status OK
SELECT COUNT(*), ST_AsText(p1), ST_AsText(p2) FROM gis_point GROUP BY p1, p2;
COUNT(*) ST_AsText(p1) ST_AsText(p2)
1024 POINT(2 4) POINT(-2 -6)
1024 POINT(3 6) POINT(-3 -9)
1024 POINT(4 8) POINT(-4 -12)
1024 POINT(5 10) POINT(-5 -15)
1024 POINT(6 12) POINT(-6 -18)
1024 POINT(7 14) POINT(-7 -21)
1024 POINT(8 16) POINT(0 0)
1024 POINT(9 18) POINT(-4 2)
1024 POINT(10 21) POINT(-6 3)
1024 POINT(1 2) POINT(-1 -3)
1024 POINT(26.25 57) POINT(1 2)
1024 POINT(20.5 41) POINT(-8 4)
1024 POINT(32.1234 64.2468) POINT(-1 -1)
SELECT COUNT(*), ST_AsText(p1) FROM gis_point WHERE ST_Intersection(@ls1, @ls2) = p1 GROUP BY p1;
COUNT(*) ST_AsText(p1)
1024 POINT(5 10)
SELECT COUNT(*), ST_AsText(p1) FROM gis_point WHERE MBRWithin(p1, @poly1) GROUP BY p1;
COUNT(*) ST_AsText(p1)
1024 POINT(3 6)
1024 POINT(4 8)
SELECT COUNT(*), ST_AsText(p2) FROM gis_point WHERE ST_Contains(@poly2, p2) GROUP BY p2;
COUNT(*) ST_AsText(p2)
1024 POINT(-2 -6)
1024 POINT(-3 -9)
1024 POINT(-4 -12)
1024 POINT(-1 -3)
1024 POINT(-1 -1)
SELECT COUNT(*), ST_AsText(p2) FROM gis_point WHERE ST_Equals(p2, @p1) GROUP BY p2;
COUNT(*) ST_AsText(p2)
1024 POINT(0 0)
SELECT COUNT(*), ST_AsText(p1) FROM gis_point WHERE ST_TOUCHES(@poly3, p1) AND MBRWithin(p2, @poly4) GROUP BY p1;
COUNT(*) ST_AsText(p1)
1024 POINT(20.5 41)
1024 POINT(32.1234 64.2468)
SELECT COUNT(*), ST_AsText(p1), ST_AsText(p2) FROM gis_point WHERE ST_Contains(@mpoly, p1) GROUP BY p1, p2;
COUNT(*) ST_AsText(p1) ST_AsText(p2)
1024 POINT(4 8) POINT(-4 -12)
1024 POINT(5 10) POINT(-5 -15)
1024 POINT(6 12) POINT(-6 -18)
1024 POINT(7 14) POINT(-7 -21)
1024 POINT(20.5 41) POINT(-8 4)
SELECT COUNT(*), ST_AsText(p1), ST_AsText(p2) FROM gis_point WHERE ST_Contains(@mpoly, p1) AND NOT MBRWithin(p1, @mpoly) GROUP BY p1, p2;
COUNT(*) ST_AsText(p1) ST_AsText(p2)
======================================================================
Build another new table with the same schema, will insert data from this table to the orignal one
======================================================================
CREATE TABLE p(p1 POINT NOT NULL, p2 POINT NOT NULL, SPATIAL INDEX k1(p2)) ENGINE=InnoDB;
INSERT INTO p VALUES(ST_PointFromText('POINT(1000 -1000)'), ST_PointFromText('POINT(-201 203.56)'));
INSERT INTO p VALUES(ST_PointFromText('POINT(20.5 43.9832)'), ST_PointFromText('POINT(-0 0)'));
INSERT INTO p VALUES(ST_PointFromText('POINT(-4.2 -6.98)'), ST_PointFromText('POINT(-120.5 343.9832)'));
INSERT INTO p SELECT * FROM p WHERE MBRWithin(p1, ST_GeomFromText('POLYGON((0 0, 0 2000, 2000 2000, 2000 -2000, 0 -2000, 0 0))'));
INSERT INTO p SELECT * FROM p WHERE MBRWithin(p1, ST_GeomFromText('POLYGON((0 0, -10 0, -100 -100, 0 -50, 0 0))'));
SELECT COUNT(*), ST_AsText(p1), ST_AsText(p2) FROM p GROUP BY p1, p2;
COUNT(*) ST_AsText(p1) ST_AsText(p2)
2 POINT(1000 -1000) POINT(-201 203.56)
2 POINT(20.5 43.9832) POINT(-0 0)
2 POINT(-4.2 -6.98) POINT(-120.5 343.9832)
INSERT INTO gis_point SELECT * FROM p;
INSERT INTO gis_point SELECT * FROM p;
INSERT INTO gis_point SELECT * FROM p;
INSERT INTO gis_point SELECT * FROM p;
INSERT INTO gis_point SELECT * FROM p;
INSERT INTO gis_point SELECT * FROM p;
INSERT INTO gis_point SELECT * FROM p;
CHECK TABLE gis_point;
Table Op Msg_type Msg_text
test.gis_point check status OK
SELECT COUNT(*), ST_AsText(p1), ST_AsText(p2) FROM gis_point GROUP BY p1, p2;
COUNT(*) ST_AsText(p1) ST_AsText(p2)
1024 POINT(2 4) POINT(-2 -6)
1024 POINT(3 6) POINT(-3 -9)
1024 POINT(4 8) POINT(-4 -12)
1024 POINT(5 10) POINT(-5 -15)
1024 POINT(6 12) POINT(-6 -18)
1024 POINT(7 14) POINT(-7 -21)
1024 POINT(8 16) POINT(0 0)
1024 POINT(9 18) POINT(-4 2)
1024 POINT(10 21) POINT(-6 3)
1024 POINT(1 2) POINT(-1 -3)
1024 POINT(26.25 57) POINT(1 2)
14 POINT(1000 -1000) POINT(-201 203.56)
1024 POINT(20.5 41) POINT(-8 4)
14 POINT(20.5 43.9832) POINT(-0 0)
1024 POINT(32.1234 64.2468) POINT(-1 -1)
14 POINT(-4.2 -6.98) POINT(-120.5 343.9832)
SELECT COUNT(*), ST_AsText(p1) FROM gis_point WHERE ST_TOUCHES(@poly3, p1) AND MBRWithin(p2, @poly4) GROUP BY p1;
COUNT(*) ST_AsText(p1)
1024 POINT(20.5 41)
1024 POINT(32.1234 64.2468)
SELECT COUNT(*), ST_AsText(p2) FROM gis_point WHERE MBRWithin(p2, @poly2) GROUP BY p2;
COUNT(*) ST_AsText(p2)
1024 POINT(-2 -6)
1024 POINT(-3 -9)
1024 POINT(-4 -12)
1024 POINT(-1 -3)
1024 POINT(-1 -1)
DROP TABLE p;
================================
Use a trx to test IUD and verify
================================
=============================================
Delete those rows selected from another table
=============================================
SELECT COUNT(*), ST_AsText(p1), ST_AsText(p2) FROM gis_point GROUP BY p1, p2;
COUNT(*) ST_AsText(p1) ST_AsText(p2)
1024 POINT(2 4) POINT(-2 -6)
1024 POINT(3 6) POINT(-3 -9)
1024 POINT(4 8) POINT(-4 -12)
1024 POINT(5 10) POINT(-5 -15)
1024 POINT(6 12) POINT(-6 -18)
1024 POINT(7 14) POINT(-7 -21)
1024 POINT(8 16) POINT(0 0)
1024 POINT(9 18) POINT(-4 2)
1024 POINT(10 21) POINT(-6 3)
1024 POINT(1 2) POINT(-1 -3)
1024 POINT(26.25 57) POINT(1 2)
14 POINT(1000 -1000) POINT(-201 203.56)
1024 POINT(20.5 41) POINT(-8 4)
14 POINT(20.5 43.9832) POINT(-0 0)
1024 POINT(32.1234 64.2468) POINT(-1 -1)
14 POINT(-4.2 -6.98) POINT(-120.5 343.9832)
UPDATE gis_point SET p2 = ST_PointFromText('POINT(2000 2000)') WHERE ST_Contains(ST_GeomFromText('POLYGON((-100 100, -400 100, -400 400, -100 400, -100 100))'), p2) OR ST_Contains(ST_GeomFromText('POLYGON((-0.0001 -0.0002, -0.0001 0.00002, 0.00000005 0.000001, 0.0000025 -0.001, -0.0001 -0.0002))'), p2);
CHECK TABLE gis_point;
Table Op Msg_type Msg_text
test.gis_point check status OK
'To remove all the just updated rows'
DELETE FROM gis_point WHERE ST_Intersection(ST_GeomFromText('LINESTRING(1800 1900, 2200 2100)'), ST_GeomFromText('LINESTRING(0 0, 2001 2001)')) = p2;
INSERT INTO gis_point VALUES
(ST_PointFromText('POINT(8 16)'), ST_PointFromText('POINT(0 0)')),
(ST_PointFromText('POINT(8 16)'), ST_PointFromText('POINT(0 0)'));
======================================================================
Following results should be almost the same with those at the beginning
======================================================================
SELECT COUNT(*), ST_AsText(p1), ST_AsText(p2) FROM gis_point GROUP BY p1, p2;
COUNT(*) ST_AsText(p1) ST_AsText(p2)
1024 POINT(2 4) POINT(-2 -6)
1024 POINT(3 6) POINT(-3 -9)
1024 POINT(4 8) POINT(-4 -12)
1024 POINT(5 10) POINT(-5 -15)
1024 POINT(6 12) POINT(-6 -18)
1024 POINT(7 14) POINT(-7 -21)
2 POINT(8 16) POINT(0 0)
1024 POINT(9 18) POINT(-4 2)
1024 POINT(10 21) POINT(-6 3)
1024 POINT(1 2) POINT(-1 -3)
1024 POINT(26.25 57) POINT(1 2)
1024 POINT(20.5 41) POINT(-8 4)
1024 POINT(32.1234 64.2468) POINT(-1 -1)
SELECT COUNT(*), ST_AsText(p1), ST_AsText(p2)
FROM gis_point
WHERE ST_Contains(ST_GeomFromText('POLYGON((-1000 -1000, -1000 1000, 1000 1000, 1001 -1001, -1000 -1000))'), p1)
GROUP BY p1, p2;
COUNT(*) ST_AsText(p1) ST_AsText(p2)
1024 POINT(2 4) POINT(-2 -6)
1024 POINT(3 6) POINT(-3 -9)
1024 POINT(4 8) POINT(-4 -12)
1024 POINT(5 10) POINT(-5 -15)
1024 POINT(6 12) POINT(-6 -18)
1024 POINT(7 14) POINT(-7 -21)
2 POINT(8 16) POINT(0 0)
1024 POINT(9 18) POINT(-4 2)
1024 POINT(10 21) POINT(-6 3)
1024 POINT(1 2) POINT(-1 -3)
1024 POINT(26.25 57) POINT(1 2)
1024 POINT(20.5 41) POINT(-8 4)
1024 POINT(32.1234 64.2468) POINT(-1 -1)
SELECT ST_AsText(p1), ST_AsText(p2) FROM gis_point GROUP BY p1, p2;
ST_AsText(p1) ST_AsText(p2)
POINT(2 4) POINT(-2 -6)
POINT(3 6) POINT(-3 -9)
POINT(4 8) POINT(-4 -12)
POINT(5 10) POINT(-5 -15)
POINT(6 12) POINT(-6 -18)
POINT(7 14) POINT(-7 -21)
POINT(8 16) POINT(0 0)
POINT(9 18) POINT(-4 2)
POINT(10 21) POINT(-6 3)
POINT(1 2) POINT(-1 -3)
POINT(26.25 57) POINT(1 2)
POINT(20.5 41) POINT(-8 4)
POINT(32.1234 64.2468) POINT(-1 -1)
SELECT COUNT(*), ST_AsText(p1) FROM gis_point WHERE ST_Intersection(@ls1, @ls2) = p1 GROUP BY p1;
COUNT(*) ST_AsText(p1)
1024 POINT(5 10)
SELECT COUNT(*), ST_AsText(p1) FROM gis_point WHERE MBRWithin(p1, @poly1) GROUP BY p1;
COUNT(*) ST_AsText(p1)
1024 POINT(3 6)
1024 POINT(4 8)
SELECT COUNT(*), ST_AsText(p2) FROM gis_point WHERE ST_Contains(@poly2, p2) GROUP BY p2;
COUNT(*) ST_AsText(p2)
1024 POINT(-2 -6)
1024 POINT(-3 -9)
1024 POINT(-4 -12)
1024 POINT(-1 -3)
1024 POINT(-1 -1)
SELECT COUNT(*), ST_AsText(p2) FROM gis_point WHERE ST_Equals(p2, @p1) GROUP BY p2;
COUNT(*) ST_AsText(p2)
2 POINT(0 0)
SELECT COUNT(*), ST_AsText(p1) FROM gis_point WHERE ST_TOUCHES(@poly3, p1) AND MBRWithin(p2, @poly4) GROUP BY p1;
COUNT(*) ST_AsText(p1)
1024 POINT(20.5 41)
1024 POINT(32.1234 64.2468)
SELECT COUNT(*), ST_AsText(p1), ST_AsText(p2) FROM gis_point WHERE ST_Contains(@mpoly, p1) GROUP BY p1, p2;
COUNT(*) ST_AsText(p1) ST_AsText(p2)
1024 POINT(4 8) POINT(-4 -12)
1024 POINT(5 10) POINT(-5 -15)
1024 POINT(6 12) POINT(-6 -18)
1024 POINT(7 14) POINT(-7 -21)
1024 POINT(20.5 41) POINT(-8 4)
SELECT COUNT(*), ST_AsText(p1), ST_AsText(p2) FROM gis_point WHERE ST_Contains(@mpoly, p1) AND NOT MBRWithin(p1, @mpoly) GROUP BY p1, p2;
COUNT(*) ST_AsText(p1) ST_AsText(p2)
CHECK TABLE gis_point;
Table Op Msg_type Msg_text
test.gis_point check status OK
DROP TABLE gis_point;
CREATE TABLE tab(c1 int NOT NULL PRIMARY KEY,c2 POINT NOT NULL,
c3 LINESTRING NOT NULL,c4 POLYGON NOT NULL,c5 GEOMETRY NOT NULL)
ENGINE=InnoDB;
ALTER TABLE tab ADD SPATIAL INDEX idx2(c2 ASC);
ALTER TABLE tab ADD SPATIAL KEY idx3(c3 DESC);
ALTER TABLE tab ADD SPATIAL INDEX idx4(c4 ASC) COMMENT 'testing spatial index on Polygon';
ALTER TABLE tab ADD SPATIAL KEY idx5(c5 ASC) COMMENT 'testing spatial index on Geometry';
INSERT INTO tab(c1,c2,c3,c4,c5)
VALUES(1,ST_GeomFromText('POINT(10 10)'),ST_GeomFromText('LINESTRING(5 5,20 20,30 30)'),
ST_GeomFromText('POLYGON((30 30,40 40,50 50,30 50,30 40,30 30))'),
ST_GeomFromText('POLYGON((30 30,40 40,50 50,30 50,30 40,30 30))'));
SELECT c1,ST_AsText(c2),ST_AsText(c3),ST_AsText(c4),ST_AsText(c5) FROM tab;
c1 ST_AsText(c2) ST_AsText(c3) ST_AsText(c4) ST_AsText(c5)
1 POINT(10 10) LINESTRING(5 5,20 20,30 30) POLYGON((30 30,40 40,50 50,30 50,30 40,30 30)) POLYGON((30 30,40 40,50 50,30 50,30 40,30 30))
SELECT COUNT(*) FROM tab;
COUNT(*)
1
"In connection 1"
SET GLOBAL TRANSACTION ISOLATION LEVEL REPEATABLE READ;
SELECT @@tx_isolation;
@@tx_isolation
REPEATABLE-READ
SELECT COUNT(*) FROM tab;
COUNT(*)
1
SELECT c1,ST_AsText(c2),ST_AsText(c3),ST_AsText(c4),ST_AsText(c5) FROM tab;
c1 ST_AsText(c2) ST_AsText(c3) ST_AsText(c4) ST_AsText(c5)
1 POINT(10 10) LINESTRING(5 5,20 20,30 30) POLYGON((30 30,40 40,50 50,30 50,30 40,30 30)) POLYGON((30 30,40 40,50 50,30 50,30 40,30 30))
"In connection 2"
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
SELECT @@tx_isolation;
@@tx_isolation
READ-COMMITTED
START TRANSACTION;
INSERT INTO tab(c1,c2,c3,c4,c5)
VALUES(2,ST_GeomFromText('POINT(20 20)'),ST_GeomFromText('LINESTRING(20 20,30 30,40 40)'),
ST_GeomFromText('POLYGON((40 50,40 70,50 100,70 100,80 80,70 50,40 50))'),
ST_GeomFromText('POLYGON((40 50,40 70,50 100,70 100,80 80,70 50,40 50))'));
SET @g1 = ST_GeomFromText('POLYGON((30 30,40 40,50 50,30 50,30 40,30 30))');
SET @g2 = ST_GeomFromText('POINT(10 10)');
UPDATE tab SET C5 = ST_GeomFromText('POLYGON((300 300,400 400,500 500,300 500,300 400,300 300))')
WHERE MBREquals(tab.c4, @g1) AND MBREquals(tab.c2, @g2);
"In connection 1"
SET @g3 = ST_GeomFromText('POLYGON((40 50,40 70,50 100,70 100,80 80,70 50,40 50))');
SELECT c1,ST_AsText(c2),ST_AsText(c4),ST_AsText(c5) FROM tab WHERE MBREquals(tab.c5, @g3);
c1 ST_AsText(c2) ST_AsText(c4) ST_AsText(c5)
SELECT COUNT(*) FROM tab;
COUNT(*)
1
START TRANSACTION;
SELECT COUNT(*) FROM tab;
COUNT(*)
1
"In connection 2"
SELECT COUNT(*) FROM tab;
COUNT(*)
2
COMMIT;
"In connection 1"
SELECT COUNT(*) FROM tab;
COUNT(*)
1
SET @g4 = ST_GeomFromText('POLYGON((300 300,400 400,500 500,300 500,300 400,300 300))');
SELECT ST_AsText(c5) FROM tab WHERE MBREquals(tab.c5, @g4);
ST_AsText(c5)
COMMIT;
SELECT ST_AsText(c5) FROM tab WHERE MBREquals(tab.c5, @g4);
ST_AsText(c5)
POLYGON((300 300,400 400,500 500,300 500,300 400,300 300))
SELECT COUNT(*) FROM tab;
COUNT(*)
2
SELECT c1,ST_AsText(c2),ST_AsText(c4),ST_AsText(c5) FROM tab;
c1 ST_AsText(c2) ST_AsText(c4) ST_AsText(c5)
1 POINT(10 10) POLYGON((30 30,40 40,50 50,30 50,30 40,30 30)) POLYGON((300 300,400 400,500 500,300 500,300 400,300 300))
2 POINT(20 20) POLYGON((40 50,40 70,50 100,70 100,80 80,70 50,40 50)) POLYGON((40 50,40 70,50 100,70 100,80 80,70 50,40 50))
DROP TABLE tab;
CREATE TABLE tab(c1 int NOT NULL PRIMARY KEY,c2 POINT NOT NULL,
c3 LINESTRING NOT NULL,c4 POLYGON NOT NULL,c5 GEOMETRY NOT NULL)
ENGINE=InnoDB;
ALTER TABLE tab ADD SPATIAL INDEX idx2(c2 ASC);
ALTER TABLE tab ADD SPATIAL KEY idx3(c3 DESC);
ALTER TABLE tab ADD SPATIAL INDEX idx4(c4 ASC) COMMENT 'testing spatial index on Polygon';
ALTER TABLE tab ADD SPATIAL KEY idx5(c5 ASC) COMMENT 'testing spatial index on Geometry';
INSERT INTO tab(c1,c2,c3,c4,c5)
VALUES(1,ST_GeomFromText('POINT(10 10)'),ST_GeomFromText('LINESTRING(5 5,20 20,30 30)'),
ST_GeomFromText('POLYGON((30 30,40 40,50 50,30 50,30 40,30 30))'),
ST_GeomFromText('POLYGON((30 30,40 40,50 50,30 50,30 40,30 30))'));
SELECT c1,ST_AsText(c2),ST_AsText(c3),ST_AsText(c4),ST_AsText(c5) FROM tab;
c1 ST_AsText(c2) ST_AsText(c3) ST_AsText(c4) ST_AsText(c5)
1 POINT(10 10) LINESTRING(5 5,20 20,30 30) POLYGON((30 30,40 40,50 50,30 50,30 40,30 30)) POLYGON((30 30,40 40,50 50,30 50,30 40,30 30))
SELECT COUNT(*) FROM tab;
COUNT(*)
1
"In connection 1"
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
SELECT @@tx_isolation;
@@tx_isolation
REPEATABLE-READ
SELECT COUNT(*) FROM tab;
COUNT(*)
1
SELECT c1,ST_AsText(c2),ST_AsText(c3),ST_AsText(c4),ST_AsText(c5) FROM tab;
c1 ST_AsText(c2) ST_AsText(c3) ST_AsText(c4) ST_AsText(c5)
1 POINT(10 10) LINESTRING(5 5,20 20,30 30) POLYGON((30 30,40 40,50 50,30 50,30 40,30 30)) POLYGON((30 30,40 40,50 50,30 50,30 40,30 30))
"In connection 2"
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
SELECT @@tx_isolation;
@@tx_isolation
READ-COMMITTED
START TRANSACTION;
INSERT INTO tab(c1,c2,c3,c4,c5)
VALUES(2,ST_GeomFromText('POINT(20 20)'),ST_GeomFromText('LINESTRING(20 20,30 30,40 40)'),
ST_GeomFromText('POLYGON((40 50,40 70,50 100,70 100,80 80,70 50,40 50))'),
ST_GeomFromText('POLYGON((40 50,40 70,50 100,70 100,80 80,70 50,40 50))'));
SET @g1 = ST_GeomFromText('POLYGON((30 30,40 40,50 50,30 50,30 40,30 30))');
SET @g2 = ST_GeomFromText('POINT(10 10)');
UPDATE tab SET C5 = ST_GeomFromText('POLYGON((300 300,400 400,500 500,300 500,300 400,300 300))')
WHERE MBREquals(tab.c4, @g1) AND MBREquals(tab.c2, @g2);
"In connection 1"
SET @g3 = ST_GeomFromText('POLYGON((40 50,40 70,50 100,70 100,80 80,70 50,40 50))');
SELECT c1,ST_AsText(c2),ST_AsText(c4),ST_AsText(c5) FROM tab WHERE MBREquals(tab.c5, @g3);
c1 ST_AsText(c2) ST_AsText(c4) ST_AsText(c5)
SELECT COUNT(*) FROM tab;
COUNT(*)
1
START TRANSACTION;
SELECT COUNT(*) FROM tab;
COUNT(*)
1
"In connection 2"
SELECT COUNT(*) FROM tab;
COUNT(*)
2
COMMIT;
"In connection 1"
SELECT COUNT(*) FROM tab;
COUNT(*)
1
SET @g4 = ST_GeomFromText('POLYGON((300 300,400 400,500 500,300 500,300 400,300 300))');
SELECT ST_AsText(c5) FROM tab WHERE MBREquals(tab.c5, @g4);
ST_AsText(c5)
COMMIT;
SELECT ST_AsText(c5) FROM tab WHERE MBREquals(tab.c5, @g4);
ST_AsText(c5)
POLYGON((300 300,400 400,500 500,300 500,300 400,300 300))
SELECT COUNT(*) FROM tab;
COUNT(*)
2
SELECT c1,ST_AsText(c2),ST_AsText(c4),ST_AsText(c5) FROM tab;
c1 ST_AsText(c2) ST_AsText(c4) ST_AsText(c5)
1 POINT(10 10) POLYGON((30 30,40 40,50 50,30 50,30 40,30 30)) POLYGON((300 300,400 400,500 500,300 500,300 400,300 300))
2 POINT(20 20) POLYGON((40 50,40 70,50 100,70 100,80 80,70 50,40 50)) POLYGON((40 50,40 70,50 100,70 100,80 80,70 50,40 50))
DROP TABLE tab;
This source diff could not be displayed because it is too large. You can view the blob instead.
SET GLOBAL innodb_file_per_table='off';
SET GLOBAL innodb_file_format='Antelope';
Warnings:
Warning 131 Using innodb_file_format is deprecated and the parameter may be removed in future releases. See http://dev.mysql.com/doc/refman/5.7/en/innodb-file-format.html
CREATE TABLE t1 (
id bigint(12) unsigned NOT NULL auto_increment,
c2 varchar(15) collate utf8_bin DEFAULT NULL,
c1 varchar(15) collate utf8_bin DEFAULT NULL,
c3 varchar(10) collate utf8_bin DEFAULT NULL,
spatial_point point NOT NULL,
PRIMARY KEY(id),
SPATIAL KEY (spatial_point)
) ROW_FORMAT=REDUNDANT ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
INSERT INTO t1 (c2, c1, c3, spatial_poINT) VALUES
('y', 's', 'j', ST_GeomFromText('POINT(167 74)')),
('r', 'n', 'd', ST_GeomFromText('POINT(215 118)')),
('g', 'n', 'e', ST_GeomFromText('POINT(203 98)')),
('h', 'd', 'd', ST_GeomFromText('POINT(54 193)')),
('r', 'x', 'y', ST_GeomFromText('POINT(47 69)')),
('t', 'q', 'r', ST_GeomFromText('POINT(109 42)')),
('a', 'z', 'd', ST_GeomFromText('POINT(0 154)')),
('x', 'v', 'o', ST_GeomFromText('POINT(174 131)')),
('b', 'r', 'a', ST_GeomFromText('POINT(114 253)')),
('x', 'z', 'i', ST_GeomFromText('POINT(163 21)')),
('w', 'p', 'i', ST_GeomFromText('POINT(42 102)')),
('g', 'j', 'j', ST_GeomFromText('POINT(170 133)')),
('m', 'g', 'n', ST_GeomFromText('POINT(28 22)')),
('b', 'z', 'h', ST_GeomFromText('POINT(174 28)')),
('q', 'k', 'f', ST_GeomFromText('POINT(233 73)')),
('w', 'w', 'a', ST_GeomFromText('POINT(124 200)')),
('t', 'j', 'w', ST_GeomFromText('POINT(252 101)')),
('d', 'r', 'd', ST_GeomFromText('POINT(98 18)')),
('w', 'o', 'y', ST_GeomFromText('POINT(165 31)')),
('y', 'h', 't', ST_GeomFromText('POINT(14 220)')),
('d', 'p', 'u', ST_GeomFromText('POINT(223 196)')),
('g', 'y', 'g', ST_GeomFromText('POINT(207 96)')),
('x', 'm', 'n', ST_GeomFromText('POINT(214 3)')),
('g', 'v', 'e', ST_GeomFromText('POINT(140 205)')),
('g', 'm', 'm', ST_GeomFromText('POINT(10 236)')),
('i', 'r', 'j', ST_GeomFromText('POINT(137 228)')),
('w', 's', 'p', ST_GeomFromText('POINT(115 6)')),
('o', 'n', 'k', ST_GeomFromText('POINT(158 129)')),
('j', 'h', 'l', ST_GeomFromText('POINT(129 72)')),
('f', 'x', 'l', ST_GeomFromText('POINT(139 207)')),
('u', 'd', 'n', ST_GeomFromText('POINT(125 109)')),
('b', 'a', 'z', ST_GeomFromText('POINT(30 32)')),
('m', 'h', 'o', ST_GeomFromText('POINT(251 251)')),
('f', 'r', 'd', ST_GeomFromText('POINT(243 211)')),
('b', 'd', 'r', ST_GeomFromText('POINT(232 80)')),
('g', 'k', 'v', ST_GeomFromText('POINT(15 100)')),
('i', 'f', 'c', ST_GeomFromText('POINT(109 66)')),
('r', 't', 'j', ST_GeomFromText('POINT(178 6)')),
('y', 'n', 'f', ST_GeomFromText('POINT(233 211)')),
('f', 'y', 'm', ST_GeomFromText('POINT(99 16)')),
('z', 'q', 'l', ST_GeomFromText('POINT(39 49)')),
('j', 'c', 'r', ST_GeomFromText('POINT(75 187)')),
('c', 'y', 'y', ST_GeomFromText('POINT(246 253)')),
('w', 'u', 'd', ST_GeomFromText('POINT(56 190)')),
('n', 'q', 'm', ST_GeomFromText('POINT(73 149)')),
('d', 'y', 'a', ST_GeomFromText('POINT(134 6)')),
('z', 's', 'w', ST_GeomFromText('POINT(216 225)')),
('d', 'u', 'k', ST_GeomFromText('POINT(132 70)')),
('f', 'v', 't', ST_GeomFromText('POINT(187 141)')),
('r', 'r', 'a', ST_GeomFromText('POINT(152 39)')),
('y', 'p', 'o', ST_GeomFromText('POINT(45 27)')),
('p', 'n', 'm', ST_GeomFromText('POINT(228 148)')),
('e', 'g', 'e', ST_GeomFromText('POINT(88 81)')),
('m', 'a', 'h', ST_GeomFromText('POINT(35 29)')),
('m', 'h', 'f', ST_GeomFromText('POINT(30 71)')),
('h', 'k', 'i', ST_GeomFromText('POINT(244 78)')),
('z', 'v', 'd', ST_GeomFromText('POINT(241 38)')),
('q', 'l', 'j', ST_GeomFromText('POINT(13 71)')),
('s', 'p', 'g', ST_GeomFromText('POINT(108 38)')),
('q', 's', 'j', ST_GeomFromText('POINT(92 101)')),
('l', 'h', 'g', ST_GeomFromText('POINT(120 78)')),
('w', 't', 'b', ST_GeomFromText('POINT(193 109)')),
('b', 's', 's', ST_GeomFromText('POINT(223 211)')),
('w', 'w', 'y', ST_GeomFromText('POINT(122 42)')),
('q', 'c', 'c', ST_GeomFromText('POINT(104 102)')),
('w', 'g', 'n', ST_GeomFromText('POINT(213 120)')),
('p', 'q', 'a', ST_GeomFromText('POINT(247 148)')),
('c', 'z', 'e', ST_GeomFromText('POINT(18 106)')),
('z', 'u', 'n', ST_GeomFromText('POINT(70 133)')),
('j', 'n', 'x', ST_GeomFromText('POINT(232 13)')),
('e', 'h', 'f', ST_GeomFromText('POINT(22 135)')),
('w', 'l', 'f', ST_GeomFromText('POINT(9 180)')),
('a', 'v', 'q', ST_GeomFromText('POINT(163 228)')),
('i', 'z', 'o', ST_GeomFromText('POINT(180 100)')),
('e', 'c', 'l', ST_GeomFromText('POINT(182 231)')),
('c', 'k', 'o', ST_GeomFromText('POINT(19 60)')),
('q', 'f', 'p', ST_GeomFromText('POINT(79 95)')),
('m', 'd', 'r', ST_GeomFromText('POINT(3 127)')),
('m', 'e', 't', ST_GeomFromText('POINT(136 154)')),
('w', 'w', 'w', ST_GeomFromText('POINT(102 15)')),
('l', 'n', 'q', ST_GeomFromText('POINT(71 196)')),
('p', 'k', 'c', ST_GeomFromText('POINT(47 139)')),
('j', 'o', 'r', ST_GeomFromText('POINT(177 128)')),
('j', 'q', 'a', ST_GeomFromText('POINT(170 6)')),
('b', 'a', 'o', ST_GeomFromText('POINT(63 211)')),
('g', 's', 'o', ST_GeomFromText('POINT(144 251)')),
('w', 'u', 'w', ST_GeomFromText('POINT(221 214)')),
('g', 'a', 'm', ST_GeomFromText('POINT(14 102)')),
('u', 'q', 'z', ST_GeomFromText('POINT(86 200)')),
('k', 'a', 'm', ST_GeomFromText('POINT(144 222)')),
('j', 'u', 'r', ST_GeomFromText('POINT(216 142)')),
('q', 'k', 'v', ST_GeomFromText('POINT(121 236)')),
('p', 'o', 'r', ST_GeomFromText('POINT(108 102)')),
('b', 'd', 'x', ST_GeomFromText('POINT(127 198)')),
('k', 's', 'a', ST_GeomFromText('POINT(2 150)')),
('f', 'm', 'f', ST_GeomFromText('POINT(160 191)')),
('q', 'y', 'x', ST_GeomFromText('POINT(98 111)')),
('o', 'f', 'm', ST_GeomFromText('POINT(232 218)')),
('c', 'w', 'j', ST_GeomFromText('POINT(156 165)')),
('s', 'q', 'v', ST_GeomFromText('POINT(98 161)'));
INSERT INTO t1 (c2, c1, c3, spatial_poINT) VALUES
('f', 'y', 'p', ST_GeomFromText('POINT(109 235)')),
('b', 'e', 'v', ST_GeomFromText('POINT(20 48)')),
('i', 'u', 'f', ST_GeomFromText('POINT(15 55)')),
('o', 'r', 'z', ST_GeomFromText('POINT(105 64)')),
('a', 'p', 'a', ST_GeomFromText('POINT(142 236)')),
('g', 'i', 'k', ST_GeomFromText('POINT(10 49)')),
('x', 'z', 'x', ST_GeomFromText('POINT(192 200)')),
('c', 'v', 'r', ST_GeomFromText('POINT(94 168)')),
('y', 'z', 'e', ST_GeomFromText('POINT(141 51)')),
('h', 'm', 'd', ST_GeomFromText('POINT(35 251)')),
('v', 'm', 'q', ST_GeomFromText('POINT(44 90)')),
('j', 'l', 'z', ST_GeomFromText('POINT(67 237)')),
('i', 'v', 'a', ST_GeomFromText('POINT(75 14)')),
('b', 'q', 't', ST_GeomFromText('POINT(153 33)')),
('e', 'm', 'a', ST_GeomFromText('POINT(247 49)')),
('l', 'y', 'g', ST_GeomFromText('POINT(56 203)')),
('v', 'o', 'r', ST_GeomFromText('POINT(90 54)')),
('r', 'n', 'd', ST_GeomFromText('POINT(135 83)')),
('j', 't', 'u', ST_GeomFromText('POINT(174 239)')),
('u', 'n', 'g', ST_GeomFromText('POINT(104 191)')),
('p', 'q', 'y', ST_GeomFromText('POINT(63 171)')),
('o', 'q', 'p', ST_GeomFromText('POINT(192 103)')),
('f', 'x', 'e', ST_GeomFromText('POINT(244 30)')),
('n', 'x', 'c', ST_GeomFromText('POINT(92 103)')),
('r', 'q', 'z', ST_GeomFromText('POINT(166 20)')),
('s', 'a', 'j', ST_GeomFromText('POINT(137 205)')),
('z', 't', 't', ST_GeomFromText('POINT(99 134)')),
('o', 'm', 'j', ST_GeomFromText('POINT(217 3)')),
('n', 'h', 'j', ST_GeomFromText('POINT(211 17)')),
('v', 'v', 'a', ST_GeomFromText('POINT(41 137)')),
('q', 'o', 'j', ST_GeomFromText('POINT(5 92)')),
('z', 'y', 'e', ST_GeomFromText('POINT(175 212)')),
('j', 'z', 'h', ST_GeomFromText('POINT(224 194)')),
('a', 'g', 'm', ST_GeomFromText('POINT(31 119)')),
('p', 'c', 'f', ST_GeomFromText('POINT(17 221)')),
('t', 'h', 'k', ST_GeomFromText('POINT(26 203)')),
('u', 'w', 'p', ST_GeomFromText('POINT(47 185)')),
('z', 'a', 'c', ST_GeomFromText('POINT(61 133)')),
('u', 'k', 'a', ST_GeomFromText('POINT(210 115)')),
('k', 'f', 'h', ST_GeomFromText('POINT(125 113)')),
('t', 'v', 'y', ST_GeomFromText('POINT(12 239)')),
('u', 'v', 'd', ST_GeomFromText('POINT(90 24)')),
('m', 'y', 'w', ST_GeomFromText('POINT(25 243)')),
('d', 'n', 'g', ST_GeomFromText('POINT(122 92)')),
('z', 'm', 'f', ST_GeomFromText('POINT(235 110)')),
('q', 'd', 'f', ST_GeomFromText('POINT(233 217)')),
('a', 'v', 'u', ST_GeomFromText('POINT(69 59)')),
('x', 'k', 'p', ST_GeomFromText('POINT(240 14)')),
('i', 'v', 'r', ST_GeomFromText('POINT(154 42)')),
('w', 'h', 'l', ST_GeomFromText('POINT(178 156)')),
('d', 'h', 'n', ST_GeomFromText('POINT(65 157)')),
('c', 'k', 'z', ST_GeomFromText('POINT(62 33)')),
('e', 'l', 'w', ST_GeomFromText('POINT(162 1)')),
('r', 'f', 'i', ST_GeomFromText('POINT(127 71)')),
('q', 'm', 'c', ST_GeomFromText('POINT(63 118)')),
('c', 'h', 'u', ST_GeomFromText('POINT(205 203)')),
('d', 't', 'p', ST_GeomFromText('POINT(234 87)')),
('s', 'g', 'h', ST_GeomFromText('POINT(149 34)')),
('o', 'b', 'q', ST_GeomFromText('POINT(159 179)')),
('k', 'u', 'f', ST_GeomFromText('POINT(202 254)')),
('u', 'f', 'g', ST_GeomFromText('POINT(70 15)')),
('x', 's', 'b', ST_GeomFromText('POINT(25 181)')),
('s', 'c', 'g', ST_GeomFromText('POINT(252 17)')),
('a', 'c', 'f', ST_GeomFromText('POINT(89 67)')),
('r', 'e', 'q', ST_GeomFromText('POINT(55 54)')),
('f', 'i', 'k', ST_GeomFromText('POINT(178 230)')),
('p', 'e', 'l', ST_GeomFromText('POINT(198 28)')),
('w', 'o', 'd', ST_GeomFromText('POINT(204 189)')),
('c', 'a', 'g', ST_GeomFromText('POINT(230 178)')),
('r', 'o', 'e', ST_GeomFromText('POINT(61 116)')),
('w', 'a', 'a', ST_GeomFromText('POINT(178 237)')),
('v', 'd', 'e', ST_GeomFromText('POINT(70 85)')),
('k', 'c', 'e', ST_GeomFromText('POINT(147 118)')),
('d', 'q', 't', ST_GeomFromText('POINT(218 77)')),
('k', 'g', 'f', ST_GeomFromText('POINT(192 113)')),
('w', 'n', 'e', ST_GeomFromText('POINT(92 124)')),
('r', 'm', 'q', ST_GeomFromText('POINT(130 65)')),
('o', 'r', 'r', ST_GeomFromText('POINT(174 233)')),
('k', 'n', 't', ST_GeomFromText('POINT(175 147)')),
('q', 'm', 'r', ST_GeomFromText('POINT(18 208)')),
('l', 'd', 'i', ST_GeomFromText('POINT(13 104)')),
('w', 'o', 'y', ST_GeomFromText('POINT(207 39)')),
('p', 'u', 'o', ST_GeomFromText('POINT(114 31)')),
('y', 'a', 'p', ST_GeomFromText('POINT(106 59)')),
('a', 'x', 'z', ST_GeomFromText('POINT(17 57)')),
('v', 'h', 'x', ST_GeomFromText('POINT(170 13)')),
('t', 's', 'u', ST_GeomFromText('POINT(84 18)')),
('z', 'z', 'f', ST_GeomFromText('POINT(250 197)')),
('l', 'z', 't', ST_GeomFromText('POINT(59 80)')),
('j', 'g', 's', ST_GeomFromText('POINT(54 26)')),
('g', 'v', 'm', ST_GeomFromText('POINT(89 98)')),
('q', 'v', 'b', ST_GeomFromText('POINT(39 240)')),
('x', 'k', 'v', ST_GeomFromText('POINT(246 207)')),
('k', 'u', 'i', ST_GeomFromText('POINT(105 111)')),
('w', 'z', 's', ST_GeomFromText('POINT(235 8)')),
('d', 'd', 'd', ST_GeomFromText('POINT(105 4)')),
('c', 'z', 'q', ST_GeomFromText('POINT(13 140)')),
('m', 'k', 'i', ST_GeomFromText('POINT(208 120)')),
('g', 'a', 'g', ST_GeomFromText('POINT(9 182)')),
('z', 'j', 'r', ST_GeomFromText('POINT(149 153)')),
('h', 'f', 'g', ST_GeomFromText('POINT(81 236)')),
('m', 'e', 'q', ST_GeomFromText('POINT(209 215)')),
('c', 'h', 'y', ST_GeomFromText('POINT(235 70)')),
('i', 'e', 'g', ST_GeomFromText('POINT(138 26)')),
('m', 't', 'u', ST_GeomFromText('POINT(119 237)')),
('o', 'w', 's', ST_GeomFromText('POINT(193 166)')),
('f', 'm', 'q', ST_GeomFromText('POINT(85 96)')),
('x', 'l', 'x', ST_GeomFromText('POINT(58 115)')),
('x', 'q', 'u', ST_GeomFromText('POINT(108 210)')),
('b', 'h', 'i', ST_GeomFromText('POINT(250 139)')),
('y', 'd', 'x', ST_GeomFromText('POINT(199 135)')),
('w', 'h', 'p', ST_GeomFromText('POINT(247 233)')),
('p', 'z', 't', ST_GeomFromText('POINT(148 249)')),
('q', 'a', 'u', ST_GeomFromText('POINT(174 78)')),
('v', 't', 'm', ST_GeomFromText('POINT(70 228)')),
('t', 'n', 'f', ST_GeomFromText('POINT(123 2)')),
('x', 't', 'b', ST_GeomFromText('POINT(35 50)')),
('r', 'j', 'f', ST_GeomFromText('POINT(200 51)')),
('s', 'q', 'o', ST_GeomFromText('POINT(23 184)')),
('u', 'v', 'z', ST_GeomFromText('POINT(7 113)')),
('v', 'u', 'l', ST_GeomFromText('POINT(145 190)')),
('o', 'k', 'i', ST_GeomFromText('POINT(161 122)')),
('l', 'y', 'e', ST_GeomFromText('POINT(17 232)')),
('t', 'b', 'e', ST_GeomFromText('POINT(120 50)')),
('e', 's', 'u', ST_GeomFromText('POINT(254 1)')),
('d', 'd', 'u', ST_GeomFromText('POINT(167 140)')),
('o', 'b', 'x', ST_GeomFromText('POINT(186 237)')),
('m', 's', 's', ST_GeomFromText('POINT(172 149)')),
('t', 'y', 'a', ST_GeomFromText('POINT(149 85)')),
('x', 't', 'r', ST_GeomFromText('POINT(10 165)')),
('g', 'c', 'e', ST_GeomFromText('POINT(95 165)')),
('e', 'e', 'z', ST_GeomFromText('POINT(98 65)')),
('f', 'v', 'i', ST_GeomFromText('POINT(149 144)')),
('o', 'p', 'm', ST_GeomFromText('POINT(233 67)')),
('t', 'u', 'b', ST_GeomFromText('POINT(109 215)')),
('o', 'o', 'b', ST_GeomFromText('POINT(130 48)')),
('e', 'm', 'h', ST_GeomFromText('POINT(88 189)')),
('e', 'v', 'y', ST_GeomFromText('POINT(55 29)')),
('e', 't', 'm', ST_GeomFromText('POINT(129 55)')),
('p', 'p', 'i', ST_GeomFromText('POINT(126 222)')),
('c', 'i', 'c', ST_GeomFromText('POINT(19 158)')),
('c', 'b', 's', ST_GeomFromText('POINT(13 19)')),
('u', 'y', 'a', ST_GeomFromText('POINT(114 5)')),
('a', 'o', 'f', ST_GeomFromText('POINT(227 232)')),
('t', 'c', 'z', ST_GeomFromText('POINT(63 62)')),
('d', 'o', 'k', ST_GeomFromText('POINT(48 228)')),
('x', 'c', 'e', ST_GeomFromText('POINT(204 2)')),
('e', 'e', 'g', ST_GeomFromText('POINT(125 43)')),
('o', 'r', 'f', ST_GeomFromText('POINT(171 140)'));
INSERT INTO t1 (c2, c1, c3, spatial_poINT) VALUES
('b', 'c', 'e', ST_GeomFromText('POINT(41 137)')),
('p', 'y', 'k', ST_GeomFromText('POINT(50 22)')),
('s', 'c', 'h', ST_GeomFromText('POINT(208 173)')),
('x', 'u', 'l', ST_GeomFromText('POINT(199 175)')),
('s', 'r', 'h', ST_GeomFromText('POINT(85 192)')),
('j', 'k', 'u', ST_GeomFromText('POINT(18 25)')),
('p', 'w', 'h', ST_GeomFromText('POINT(152 197)')),
('e', 'd', 'c', ST_GeomFromText('POINT(229 3)')),
('o', 'x', 'k', ST_GeomFromText('POINT(187 155)')),
('o', 'b', 'k', ST_GeomFromText('POINT(208 150)')),
('d', 'a', 'j', ST_GeomFromText('POINT(70 87)')),
('f', 'e', 'k', ST_GeomFromText('POINT(156 96)')),
('u', 'y', 'p', ST_GeomFromText('POINT(239 193)')),
('n', 'v', 'p', ST_GeomFromText('POINT(223 98)')),
('z', 'j', 'r', ST_GeomFromText('POINT(87 89)')),
('h', 'x', 'x', ST_GeomFromText('POINT(92 0)')),
('r', 'v', 'r', ST_GeomFromText('POINT(159 139)')),
('v', 'g', 'g', ST_GeomFromText('POINT(16 229)')),
('z', 'k', 'u', ST_GeomFromText('POINT(99 52)')),
('p', 'p', 'o', ST_GeomFromText('POINT(105 125)')),
('w', 'h', 'y', ST_GeomFromText('POINT(105 154)')),
('v', 'y', 'z', ST_GeomFromText('POINT(134 238)')),
('x', 'o', 'o', ST_GeomFromText('POINT(178 88)')),
('z', 'w', 'd', ST_GeomFromText('POINT(123 60)')),
('q', 'f', 'u', ST_GeomFromText('POINT(64 90)')),
('s', 'n', 't', ST_GeomFromText('POINT(50 138)')),
('v', 'p', 't', ST_GeomFromText('POINT(114 91)')),
('a', 'o', 'n', ST_GeomFromText('POINT(78 43)')),
('k', 'u', 'd', ST_GeomFromText('POINT(185 161)')),
('w', 'd', 'n', ST_GeomFromText('POINT(25 92)')),
('k', 'w', 'a', ST_GeomFromText('POINT(59 238)')),
('t', 'c', 'f', ST_GeomFromText('POINT(65 87)')),
('g', 's', 'p', ST_GeomFromText('POINT(238 126)')),
('d', 'n', 'y', ST_GeomFromText('POINT(107 173)')),
('l', 'a', 'w', ST_GeomFromText('POINT(125 152)')),
('m', 'd', 'j', ST_GeomFromText('POINT(146 53)')),
('q', 'm', 'c', ST_GeomFromText('POINT(217 187)')),
('i', 'r', 'r', ST_GeomFromText('POINT(6 113)')),
('e', 'j', 'b', ST_GeomFromText('POINT(37 83)')),
('w', 'w', 'h', ST_GeomFromText('POINT(83 199)')),
('k', 'b', 's', ST_GeomFromText('POINT(170 64)')),
('s', 'b', 'c', ST_GeomFromText('POINT(163 130)')),
('c', 'h', 'a', ST_GeomFromText('POINT(141 3)')),
('k', 'j', 'u', ST_GeomFromText('POINT(143 76)')),
('r', 'h', 'o', ST_GeomFromText('POINT(243 92)')),
('i', 'd', 'b', ST_GeomFromText('POINT(205 13)')),
('r', 'y', 'q', ST_GeomFromText('POINT(138 8)')),
('m', 'o', 'i', ST_GeomFromText('POINT(36 45)')),
('v', 'g', 'm', ST_GeomFromText('POINT(0 40)')),
('f', 'e', 'i', ST_GeomFromText('POINT(76 6)')),
('c', 'q', 'q', ST_GeomFromText('POINT(115 248)')),
('x', 'c', 'i', ST_GeomFromText('POINT(29 74)')),
('l', 's', 't', ST_GeomFromText('POINT(83 18)')),
('t', 't', 'a', ST_GeomFromText('POINT(26 168)')),
('u', 'n', 'x', ST_GeomFromText('POINT(200 110)')),
('j', 'b', 'd', ST_GeomFromText('POINT(216 136)')),
('s', 'p', 'w', ST_GeomFromText('POINT(38 156)')),
('f', 'b', 'v', ST_GeomFromText('POINT(29 186)')),
('v', 'e', 'r', ST_GeomFromText('POINT(149 40)')),
('v', 't', 'm', ST_GeomFromText('POINT(184 24)')),
('y', 'g', 'a', ST_GeomFromText('POINT(219 105)')),
('s', 'f', 'i', ST_GeomFromText('POINT(114 130)')),
('e', 'q', 'h', ST_GeomFromText('POINT(203 135)')),
('h', 'g', 'b', ST_GeomFromText('POINT(9 208)')),
('o', 'l', 'r', ST_GeomFromText('POINT(245 79)')),
('s', 's', 'v', ST_GeomFromText('POINT(238 198)')),
('w', 'w', 'z', ST_GeomFromText('POINT(209 232)')),
('v', 'd', 'n', ST_GeomFromText('POINT(30 193)')),
('q', 'w', 'k', ST_GeomFromText('POINT(133 18)')),
('o', 'h', 'o', ST_GeomFromText('POINT(42 140)')),
('f', 'f', 'h', ST_GeomFromText('POINT(145 1)')),
('u', 's', 'r', ST_GeomFromText('POINT(70 62)')),
('x', 'n', 'q', ST_GeomFromText('POINT(33 86)')),
('u', 'p', 'v', ST_GeomFromText('POINT(232 220)')),
('z', 'e', 'a', ST_GeomFromText('POINT(130 69)')),
('r', 'u', 'z', ST_GeomFromText('POINT(243 241)')),
('b', 'n', 't', ST_GeomFromText('POINT(120 12)')),
('u', 'f', 's', ST_GeomFromText('POINT(190 212)')),
('a', 'd', 'q', ST_GeomFromText('POINT(235 191)')),
('f', 'q', 'm', ST_GeomFromText('POINT(176 2)')),
('n', 'c', 's', ST_GeomFromText('POINT(218 163)')),
('e', 'm', 'h', ST_GeomFromText('POINT(163 108)')),
('c', 'f', 'l', ST_GeomFromText('POINT(220 115)')),
('c', 'v', 'q', ST_GeomFromText('POINT(66 45)')),
('w', 'v', 'x', ST_GeomFromText('POINT(251 220)')),
('f', 'w', 'z', ST_GeomFromText('POINT(146 149)')),
('h', 'n', 'h', ST_GeomFromText('POINT(148 128)')),
('y', 'k', 'v', ST_GeomFromText('POINT(28 110)')),
('c', 'x', 'q', ST_GeomFromText('POINT(13 13)')),
('e', 'd', 's', ST_GeomFromText('POINT(91 190)')),
('c', 'w', 'c', ST_GeomFromText('POINT(10 231)')),
('u', 'j', 'n', ST_GeomFromText('POINT(250 21)')),
('w', 'n', 'x', ST_GeomFromText('POINT(141 69)')),
('f', 'p', 'y', ST_GeomFromText('POINT(228 246)')),
('d', 'q', 'f', ST_GeomFromText('POINT(194 22)')),
('d', 'z', 'l', ST_GeomFromText('POINT(233 181)')),
('c', 'a', 'q', ST_GeomFromText('POINT(183 96)')),
('m', 'i', 'd', ST_GeomFromText('POINT(117 226)')),
('z', 'y', 'y', ST_GeomFromText('POINT(62 81)')),
('g', 'v', 'm', ST_GeomFromText('POINT(66 158)'));
START TRANSACTION;
INSERT INTO t1 (c2, c1, c3, spatial_poINT) VALUES
('f', 'x', 'p', ST_GeomFromText('POINT(92 181)'));
ROLLBACK;
INSERT INTO t1 (c2, c1, c3, spatial_poINT) VALUES
('f', 'x', 'p', ST_GeomFromText('POINT(92 181)'));
INSERT INTO t1 (c2, c1, c3, spatial_poINT) VALUES ('n', 'x', 'p', ST_GeomFromText('POINT(0 1280)'));
INSERT INTO t1 (c2, c1, c3, spatial_poINT) VALUES ('n', 'x', 'p', ST_GeomFromText('POINT(45 1280)'));
INSERT INTO t1 VALUES (1280, 'n', 'x', 'p', ST_GeomFromText('POINT(44 253)'));
DELETE FROM t1 WHERE id = 1280;
INSERT INTO t1 VALUES (1280, 'n', 'x', 'p', ST_GeomFromText('POINT(44 253)'));
START TRANSACTION;
DELETE FROM t1 WHERE id = 1280;
ROLLBACK;
START TRANSACTION;
INSERT INTO t1 (c2, c1, c3, spatial_point) VALUES
('m', 'u', 'p', ST_GeomFromText('POINT(1192 1181)'));
ROLLBACK;
SELECT COUNT(*) FROM t1;
COUNT(*)
353
UPDATE t1 SET spatial_point = ST_GeomFromText('POINT(123 456)') WHERE id < 2000;
SET @g1 = ST_GeomFromText('Polygon((123 456, 123 678, 456 678,456 456,123 456))');
DELETE FROM t1 WHERE MBRContains(@g1, t1.spatial_point);
SELECT COUNT(*) FROM t1;
COUNT(*)
353
DROP TABLE t1;
SET GLOBAL innodb_file_per_table=default;
SET GLOBAL innodb_file_format=default;
Warnings:
Warning 131 Using innodb_file_format is deprecated and the parameter may be removed in future releases. See http://dev.mysql.com/doc/refman/5.7/en/innodb-file-format.html
SET GLOBAL innodb_file_per_table='on';
SET GLOBAL innodb_file_format='Barracuda';
Warnings:
Warning 131 Using innodb_file_format is deprecated and the parameter may be removed in future releases. See http://dev.mysql.com/doc/refman/5.7/en/innodb-file-format.html
CREATE TABLE t1 (
id bigint(12) unsigned NOT NULL auto_increment,
c2 varchar(15) collate utf8_bin DEFAULT NULL,
c1 varchar(15) collate utf8_bin DEFAULT NULL,
c3 varchar(10) collate utf8_bin DEFAULT NULL,
spatial_point point NOT NULL,
PRIMARY KEY(id),
SPATIAL KEY (spatial_point)
) ROW_FORMAT=COMPRESSED ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
INSERT INTO t1 (c2, c1, c3, spatial_poINT) VALUES
('y', 's', 'j', ST_GeomFromText('POINT(167 74)')),
('r', 'n', 'd', ST_GeomFromText('POINT(215 118)')),
('g', 'n', 'e', ST_GeomFromText('POINT(203 98)')),
('h', 'd', 'd', ST_GeomFromText('POINT(54 193)')),
('r', 'x', 'y', ST_GeomFromText('POINT(47 69)')),
('t', 'q', 'r', ST_GeomFromText('POINT(109 42)')),
('a', 'z', 'd', ST_GeomFromText('POINT(0 154)')),
('x', 'v', 'o', ST_GeomFromText('POINT(174 131)')),
('b', 'r', 'a', ST_GeomFromText('POINT(114 253)')),
('x', 'z', 'i', ST_GeomFromText('POINT(163 21)')),
('w', 'p', 'i', ST_GeomFromText('POINT(42 102)')),
('g', 'j', 'j', ST_GeomFromText('POINT(170 133)')),
('m', 'g', 'n', ST_GeomFromText('POINT(28 22)')),
('b', 'z', 'h', ST_GeomFromText('POINT(174 28)')),
('q', 'k', 'f', ST_GeomFromText('POINT(233 73)')),
('w', 'w', 'a', ST_GeomFromText('POINT(124 200)')),
('t', 'j', 'w', ST_GeomFromText('POINT(252 101)')),
('d', 'r', 'd', ST_GeomFromText('POINT(98 18)')),
('w', 'o', 'y', ST_GeomFromText('POINT(165 31)')),
('y', 'h', 't', ST_GeomFromText('POINT(14 220)')),
('d', 'p', 'u', ST_GeomFromText('POINT(223 196)')),
('g', 'y', 'g', ST_GeomFromText('POINT(207 96)')),
('x', 'm', 'n', ST_GeomFromText('POINT(214 3)')),
('g', 'v', 'e', ST_GeomFromText('POINT(140 205)')),
('g', 'm', 'm', ST_GeomFromText('POINT(10 236)')),
('i', 'r', 'j', ST_GeomFromText('POINT(137 228)')),
('w', 's', 'p', ST_GeomFromText('POINT(115 6)')),
('o', 'n', 'k', ST_GeomFromText('POINT(158 129)')),
('j', 'h', 'l', ST_GeomFromText('POINT(129 72)')),
('f', 'x', 'l', ST_GeomFromText('POINT(139 207)')),
('u', 'd', 'n', ST_GeomFromText('POINT(125 109)')),
('b', 'a', 'z', ST_GeomFromText('POINT(30 32)')),
('m', 'h', 'o', ST_GeomFromText('POINT(251 251)')),
('f', 'r', 'd', ST_GeomFromText('POINT(243 211)')),
('b', 'd', 'r', ST_GeomFromText('POINT(232 80)')),
('g', 'k', 'v', ST_GeomFromText('POINT(15 100)')),
('i', 'f', 'c', ST_GeomFromText('POINT(109 66)')),
('r', 't', 'j', ST_GeomFromText('POINT(178 6)')),
('y', 'n', 'f', ST_GeomFromText('POINT(233 211)')),
('f', 'y', 'm', ST_GeomFromText('POINT(99 16)')),
('z', 'q', 'l', ST_GeomFromText('POINT(39 49)')),
('j', 'c', 'r', ST_GeomFromText('POINT(75 187)')),
('c', 'y', 'y', ST_GeomFromText('POINT(246 253)')),
('w', 'u', 'd', ST_GeomFromText('POINT(56 190)')),
('n', 'q', 'm', ST_GeomFromText('POINT(73 149)')),
('d', 'y', 'a', ST_GeomFromText('POINT(134 6)')),
('z', 's', 'w', ST_GeomFromText('POINT(216 225)')),
('d', 'u', 'k', ST_GeomFromText('POINT(132 70)')),
('f', 'v', 't', ST_GeomFromText('POINT(187 141)')),
('r', 'r', 'a', ST_GeomFromText('POINT(152 39)')),
('y', 'p', 'o', ST_GeomFromText('POINT(45 27)')),
('p', 'n', 'm', ST_GeomFromText('POINT(228 148)')),
('e', 'g', 'e', ST_GeomFromText('POINT(88 81)')),
('m', 'a', 'h', ST_GeomFromText('POINT(35 29)')),
('m', 'h', 'f', ST_GeomFromText('POINT(30 71)')),
('h', 'k', 'i', ST_GeomFromText('POINT(244 78)')),
('z', 'v', 'd', ST_GeomFromText('POINT(241 38)')),
('q', 'l', 'j', ST_GeomFromText('POINT(13 71)')),
('s', 'p', 'g', ST_GeomFromText('POINT(108 38)')),
('q', 's', 'j', ST_GeomFromText('POINT(92 101)')),
('l', 'h', 'g', ST_GeomFromText('POINT(120 78)')),
('w', 't', 'b', ST_GeomFromText('POINT(193 109)')),
('b', 's', 's', ST_GeomFromText('POINT(223 211)')),
('w', 'w', 'y', ST_GeomFromText('POINT(122 42)')),
('q', 'c', 'c', ST_GeomFromText('POINT(104 102)')),
('w', 'g', 'n', ST_GeomFromText('POINT(213 120)')),
('p', 'q', 'a', ST_GeomFromText('POINT(247 148)')),
('c', 'z', 'e', ST_GeomFromText('POINT(18 106)')),
('z', 'u', 'n', ST_GeomFromText('POINT(70 133)')),
('j', 'n', 'x', ST_GeomFromText('POINT(232 13)')),
('e', 'h', 'f', ST_GeomFromText('POINT(22 135)')),
('w', 'l', 'f', ST_GeomFromText('POINT(9 180)')),
('a', 'v', 'q', ST_GeomFromText('POINT(163 228)')),
('i', 'z', 'o', ST_GeomFromText('POINT(180 100)')),
('e', 'c', 'l', ST_GeomFromText('POINT(182 231)')),
('c', 'k', 'o', ST_GeomFromText('POINT(19 60)')),
('q', 'f', 'p', ST_GeomFromText('POINT(79 95)')),
('m', 'd', 'r', ST_GeomFromText('POINT(3 127)')),
('m', 'e', 't', ST_GeomFromText('POINT(136 154)')),
('w', 'w', 'w', ST_GeomFromText('POINT(102 15)')),
('l', 'n', 'q', ST_GeomFromText('POINT(71 196)')),
('p', 'k', 'c', ST_GeomFromText('POINT(47 139)')),
('j', 'o', 'r', ST_GeomFromText('POINT(177 128)')),
('j', 'q', 'a', ST_GeomFromText('POINT(170 6)')),
('b', 'a', 'o', ST_GeomFromText('POINT(63 211)')),
('g', 's', 'o', ST_GeomFromText('POINT(144 251)')),
('w', 'u', 'w', ST_GeomFromText('POINT(221 214)')),
('g', 'a', 'm', ST_GeomFromText('POINT(14 102)')),
('u', 'q', 'z', ST_GeomFromText('POINT(86 200)')),
('k', 'a', 'm', ST_GeomFromText('POINT(144 222)')),
('j', 'u', 'r', ST_GeomFromText('POINT(216 142)')),
('q', 'k', 'v', ST_GeomFromText('POINT(121 236)')),
('p', 'o', 'r', ST_GeomFromText('POINT(108 102)')),
('b', 'd', 'x', ST_GeomFromText('POINT(127 198)')),
('k', 's', 'a', ST_GeomFromText('POINT(2 150)')),
('f', 'm', 'f', ST_GeomFromText('POINT(160 191)')),
('q', 'y', 'x', ST_GeomFromText('POINT(98 111)')),
('o', 'f', 'm', ST_GeomFromText('POINT(232 218)')),
('c', 'w', 'j', ST_GeomFromText('POINT(156 165)')),
('s', 'q', 'v', ST_GeomFromText('POINT(98 161)'));
INSERT INTO t1 (c2, c1, c3, spatial_poINT) VALUES
('f', 'y', 'p', ST_GeomFromText('POINT(109 235)')),
('b', 'e', 'v', ST_GeomFromText('POINT(20 48)')),
('i', 'u', 'f', ST_GeomFromText('POINT(15 55)')),
('o', 'r', 'z', ST_GeomFromText('POINT(105 64)')),
('a', 'p', 'a', ST_GeomFromText('POINT(142 236)')),
('g', 'i', 'k', ST_GeomFromText('POINT(10 49)')),
('x', 'z', 'x', ST_GeomFromText('POINT(192 200)')),
('c', 'v', 'r', ST_GeomFromText('POINT(94 168)')),
('y', 'z', 'e', ST_GeomFromText('POINT(141 51)')),
('h', 'm', 'd', ST_GeomFromText('POINT(35 251)')),
('v', 'm', 'q', ST_GeomFromText('POINT(44 90)')),
('j', 'l', 'z', ST_GeomFromText('POINT(67 237)')),
('i', 'v', 'a', ST_GeomFromText('POINT(75 14)')),
('b', 'q', 't', ST_GeomFromText('POINT(153 33)')),
('e', 'm', 'a', ST_GeomFromText('POINT(247 49)')),
('l', 'y', 'g', ST_GeomFromText('POINT(56 203)')),
('v', 'o', 'r', ST_GeomFromText('POINT(90 54)')),
('r', 'n', 'd', ST_GeomFromText('POINT(135 83)')),
('j', 't', 'u', ST_GeomFromText('POINT(174 239)')),
('u', 'n', 'g', ST_GeomFromText('POINT(104 191)')),
('p', 'q', 'y', ST_GeomFromText('POINT(63 171)')),
('o', 'q', 'p', ST_GeomFromText('POINT(192 103)')),
('f', 'x', 'e', ST_GeomFromText('POINT(244 30)')),
('n', 'x', 'c', ST_GeomFromText('POINT(92 103)')),
('r', 'q', 'z', ST_GeomFromText('POINT(166 20)')),
('s', 'a', 'j', ST_GeomFromText('POINT(137 205)')),
('z', 't', 't', ST_GeomFromText('POINT(99 134)')),
('o', 'm', 'j', ST_GeomFromText('POINT(217 3)')),
('n', 'h', 'j', ST_GeomFromText('POINT(211 17)')),
('v', 'v', 'a', ST_GeomFromText('POINT(41 137)')),
('q', 'o', 'j', ST_GeomFromText('POINT(5 92)')),
('z', 'y', 'e', ST_GeomFromText('POINT(175 212)')),
('j', 'z', 'h', ST_GeomFromText('POINT(224 194)')),
('a', 'g', 'm', ST_GeomFromText('POINT(31 119)')),
('p', 'c', 'f', ST_GeomFromText('POINT(17 221)')),
('t', 'h', 'k', ST_GeomFromText('POINT(26 203)')),
('u', 'w', 'p', ST_GeomFromText('POINT(47 185)')),
('z', 'a', 'c', ST_GeomFromText('POINT(61 133)')),
('u', 'k', 'a', ST_GeomFromText('POINT(210 115)')),
('k', 'f', 'h', ST_GeomFromText('POINT(125 113)')),
('t', 'v', 'y', ST_GeomFromText('POINT(12 239)')),
('u', 'v', 'd', ST_GeomFromText('POINT(90 24)')),
('m', 'y', 'w', ST_GeomFromText('POINT(25 243)')),
('d', 'n', 'g', ST_GeomFromText('POINT(122 92)')),
('z', 'm', 'f', ST_GeomFromText('POINT(235 110)')),
('q', 'd', 'f', ST_GeomFromText('POINT(233 217)')),
('a', 'v', 'u', ST_GeomFromText('POINT(69 59)')),
('x', 'k', 'p', ST_GeomFromText('POINT(240 14)')),
('i', 'v', 'r', ST_GeomFromText('POINT(154 42)')),
('w', 'h', 'l', ST_GeomFromText('POINT(178 156)')),
('d', 'h', 'n', ST_GeomFromText('POINT(65 157)')),
('c', 'k', 'z', ST_GeomFromText('POINT(62 33)')),
('e', 'l', 'w', ST_GeomFromText('POINT(162 1)')),
('r', 'f', 'i', ST_GeomFromText('POINT(127 71)')),
('q', 'm', 'c', ST_GeomFromText('POINT(63 118)')),
('c', 'h', 'u', ST_GeomFromText('POINT(205 203)')),
('d', 't', 'p', ST_GeomFromText('POINT(234 87)')),
('s', 'g', 'h', ST_GeomFromText('POINT(149 34)')),
('o', 'b', 'q', ST_GeomFromText('POINT(159 179)')),
('k', 'u', 'f', ST_GeomFromText('POINT(202 254)')),
('u', 'f', 'g', ST_GeomFromText('POINT(70 15)')),
('x', 's', 'b', ST_GeomFromText('POINT(25 181)')),
('s', 'c', 'g', ST_GeomFromText('POINT(252 17)')),
('a', 'c', 'f', ST_GeomFromText('POINT(89 67)')),
('r', 'e', 'q', ST_GeomFromText('POINT(55 54)')),
('f', 'i', 'k', ST_GeomFromText('POINT(178 230)')),
('p', 'e', 'l', ST_GeomFromText('POINT(198 28)')),
('w', 'o', 'd', ST_GeomFromText('POINT(204 189)')),
('c', 'a', 'g', ST_GeomFromText('POINT(230 178)')),
('r', 'o', 'e', ST_GeomFromText('POINT(61 116)')),
('w', 'a', 'a', ST_GeomFromText('POINT(178 237)')),
('v', 'd', 'e', ST_GeomFromText('POINT(70 85)')),
('k', 'c', 'e', ST_GeomFromText('POINT(147 118)')),
('d', 'q', 't', ST_GeomFromText('POINT(218 77)')),
('k', 'g', 'f', ST_GeomFromText('POINT(192 113)')),
('w', 'n', 'e', ST_GeomFromText('POINT(92 124)')),
('r', 'm', 'q', ST_GeomFromText('POINT(130 65)')),
('o', 'r', 'r', ST_GeomFromText('POINT(174 233)')),
('k', 'n', 't', ST_GeomFromText('POINT(175 147)')),
('q', 'm', 'r', ST_GeomFromText('POINT(18 208)')),
('l', 'd', 'i', ST_GeomFromText('POINT(13 104)')),
('w', 'o', 'y', ST_GeomFromText('POINT(207 39)')),
('p', 'u', 'o', ST_GeomFromText('POINT(114 31)')),
('y', 'a', 'p', ST_GeomFromText('POINT(106 59)')),
('a', 'x', 'z', ST_GeomFromText('POINT(17 57)')),
('v', 'h', 'x', ST_GeomFromText('POINT(170 13)')),
('t', 's', 'u', ST_GeomFromText('POINT(84 18)')),
('z', 'z', 'f', ST_GeomFromText('POINT(250 197)')),
('l', 'z', 't', ST_GeomFromText('POINT(59 80)')),
('j', 'g', 's', ST_GeomFromText('POINT(54 26)')),
('g', 'v', 'm', ST_GeomFromText('POINT(89 98)')),
('q', 'v', 'b', ST_GeomFromText('POINT(39 240)')),
('x', 'k', 'v', ST_GeomFromText('POINT(246 207)')),
('k', 'u', 'i', ST_GeomFromText('POINT(105 111)')),
('w', 'z', 's', ST_GeomFromText('POINT(235 8)')),
('d', 'd', 'd', ST_GeomFromText('POINT(105 4)')),
('c', 'z', 'q', ST_GeomFromText('POINT(13 140)')),
('m', 'k', 'i', ST_GeomFromText('POINT(208 120)')),
('g', 'a', 'g', ST_GeomFromText('POINT(9 182)')),
('z', 'j', 'r', ST_GeomFromText('POINT(149 153)')),
('h', 'f', 'g', ST_GeomFromText('POINT(81 236)')),
('m', 'e', 'q', ST_GeomFromText('POINT(209 215)')),
('c', 'h', 'y', ST_GeomFromText('POINT(235 70)')),
('i', 'e', 'g', ST_GeomFromText('POINT(138 26)')),
('m', 't', 'u', ST_GeomFromText('POINT(119 237)')),
('o', 'w', 's', ST_GeomFromText('POINT(193 166)')),
('f', 'm', 'q', ST_GeomFromText('POINT(85 96)')),
('x', 'l', 'x', ST_GeomFromText('POINT(58 115)')),
('x', 'q', 'u', ST_GeomFromText('POINT(108 210)')),
('b', 'h', 'i', ST_GeomFromText('POINT(250 139)')),
('y', 'd', 'x', ST_GeomFromText('POINT(199 135)')),
('w', 'h', 'p', ST_GeomFromText('POINT(247 233)')),
('p', 'z', 't', ST_GeomFromText('POINT(148 249)')),
('q', 'a', 'u', ST_GeomFromText('POINT(174 78)')),
('v', 't', 'm', ST_GeomFromText('POINT(70 228)')),
('t', 'n', 'f', ST_GeomFromText('POINT(123 2)')),
('x', 't', 'b', ST_GeomFromText('POINT(35 50)')),
('r', 'j', 'f', ST_GeomFromText('POINT(200 51)')),
('s', 'q', 'o', ST_GeomFromText('POINT(23 184)')),
('u', 'v', 'z', ST_GeomFromText('POINT(7 113)')),
('v', 'u', 'l', ST_GeomFromText('POINT(145 190)')),
('o', 'k', 'i', ST_GeomFromText('POINT(161 122)')),
('l', 'y', 'e', ST_GeomFromText('POINT(17 232)')),
('t', 'b', 'e', ST_GeomFromText('POINT(120 50)')),
('e', 's', 'u', ST_GeomFromText('POINT(254 1)')),
('d', 'd', 'u', ST_GeomFromText('POINT(167 140)')),
('o', 'b', 'x', ST_GeomFromText('POINT(186 237)')),
('m', 's', 's', ST_GeomFromText('POINT(172 149)')),
('t', 'y', 'a', ST_GeomFromText('POINT(149 85)')),
('x', 't', 'r', ST_GeomFromText('POINT(10 165)')),
('g', 'c', 'e', ST_GeomFromText('POINT(95 165)')),
('e', 'e', 'z', ST_GeomFromText('POINT(98 65)')),
('f', 'v', 'i', ST_GeomFromText('POINT(149 144)')),
('o', 'p', 'm', ST_GeomFromText('POINT(233 67)')),
('t', 'u', 'b', ST_GeomFromText('POINT(109 215)')),
('o', 'o', 'b', ST_GeomFromText('POINT(130 48)')),
('e', 'm', 'h', ST_GeomFromText('POINT(88 189)')),
('e', 'v', 'y', ST_GeomFromText('POINT(55 29)')),
('e', 't', 'm', ST_GeomFromText('POINT(129 55)')),
('p', 'p', 'i', ST_GeomFromText('POINT(126 222)')),
('c', 'i', 'c', ST_GeomFromText('POINT(19 158)')),
('c', 'b', 's', ST_GeomFromText('POINT(13 19)')),
('u', 'y', 'a', ST_GeomFromText('POINT(114 5)')),
('a', 'o', 'f', ST_GeomFromText('POINT(227 232)')),
('t', 'c', 'z', ST_GeomFromText('POINT(63 62)')),
('d', 'o', 'k', ST_GeomFromText('POINT(48 228)')),
('x', 'c', 'e', ST_GeomFromText('POINT(204 2)')),
('e', 'e', 'g', ST_GeomFromText('POINT(125 43)')),
('o', 'r', 'f', ST_GeomFromText('POINT(171 140)'));
INSERT INTO t1 (c2, c1, c3, spatial_poINT) VALUES
('b', 'c', 'e', ST_GeomFromText('POINT(41 137)')),
('p', 'y', 'k', ST_GeomFromText('POINT(50 22)')),
('s', 'c', 'h', ST_GeomFromText('POINT(208 173)')),
('x', 'u', 'l', ST_GeomFromText('POINT(199 175)')),
('s', 'r', 'h', ST_GeomFromText('POINT(85 192)')),
('j', 'k', 'u', ST_GeomFromText('POINT(18 25)')),
('p', 'w', 'h', ST_GeomFromText('POINT(152 197)')),
('e', 'd', 'c', ST_GeomFromText('POINT(229 3)')),
('o', 'x', 'k', ST_GeomFromText('POINT(187 155)')),
('o', 'b', 'k', ST_GeomFromText('POINT(208 150)')),
('d', 'a', 'j', ST_GeomFromText('POINT(70 87)')),
('f', 'e', 'k', ST_GeomFromText('POINT(156 96)')),
('u', 'y', 'p', ST_GeomFromText('POINT(239 193)')),
('n', 'v', 'p', ST_GeomFromText('POINT(223 98)')),
('z', 'j', 'r', ST_GeomFromText('POINT(87 89)')),
('h', 'x', 'x', ST_GeomFromText('POINT(92 0)')),
('r', 'v', 'r', ST_GeomFromText('POINT(159 139)')),
('v', 'g', 'g', ST_GeomFromText('POINT(16 229)')),
('z', 'k', 'u', ST_GeomFromText('POINT(99 52)')),
('p', 'p', 'o', ST_GeomFromText('POINT(105 125)')),
('w', 'h', 'y', ST_GeomFromText('POINT(105 154)')),
('v', 'y', 'z', ST_GeomFromText('POINT(134 238)')),
('x', 'o', 'o', ST_GeomFromText('POINT(178 88)')),
('z', 'w', 'd', ST_GeomFromText('POINT(123 60)')),
('q', 'f', 'u', ST_GeomFromText('POINT(64 90)')),
('s', 'n', 't', ST_GeomFromText('POINT(50 138)')),
('v', 'p', 't', ST_GeomFromText('POINT(114 91)')),
('a', 'o', 'n', ST_GeomFromText('POINT(78 43)')),
('k', 'u', 'd', ST_GeomFromText('POINT(185 161)')),
('w', 'd', 'n', ST_GeomFromText('POINT(25 92)')),
('k', 'w', 'a', ST_GeomFromText('POINT(59 238)')),
('t', 'c', 'f', ST_GeomFromText('POINT(65 87)')),
('g', 's', 'p', ST_GeomFromText('POINT(238 126)')),
('d', 'n', 'y', ST_GeomFromText('POINT(107 173)')),
('l', 'a', 'w', ST_GeomFromText('POINT(125 152)')),
('m', 'd', 'j', ST_GeomFromText('POINT(146 53)')),
('q', 'm', 'c', ST_GeomFromText('POINT(217 187)')),
('i', 'r', 'r', ST_GeomFromText('POINT(6 113)')),
('e', 'j', 'b', ST_GeomFromText('POINT(37 83)')),
('w', 'w', 'h', ST_GeomFromText('POINT(83 199)')),
('k', 'b', 's', ST_GeomFromText('POINT(170 64)')),
('s', 'b', 'c', ST_GeomFromText('POINT(163 130)')),
('c', 'h', 'a', ST_GeomFromText('POINT(141 3)')),
('k', 'j', 'u', ST_GeomFromText('POINT(143 76)')),
('r', 'h', 'o', ST_GeomFromText('POINT(243 92)')),
('i', 'd', 'b', ST_GeomFromText('POINT(205 13)')),
('r', 'y', 'q', ST_GeomFromText('POINT(138 8)')),
('m', 'o', 'i', ST_GeomFromText('POINT(36 45)')),
('v', 'g', 'm', ST_GeomFromText('POINT(0 40)')),
('f', 'e', 'i', ST_GeomFromText('POINT(76 6)')),
('c', 'q', 'q', ST_GeomFromText('POINT(115 248)')),
('x', 'c', 'i', ST_GeomFromText('POINT(29 74)')),
('l', 's', 't', ST_GeomFromText('POINT(83 18)')),
('t', 't', 'a', ST_GeomFromText('POINT(26 168)')),
('u', 'n', 'x', ST_GeomFromText('POINT(200 110)')),
('j', 'b', 'd', ST_GeomFromText('POINT(216 136)')),
('s', 'p', 'w', ST_GeomFromText('POINT(38 156)')),
('f', 'b', 'v', ST_GeomFromText('POINT(29 186)')),
('v', 'e', 'r', ST_GeomFromText('POINT(149 40)')),
('v', 't', 'm', ST_GeomFromText('POINT(184 24)')),
('y', 'g', 'a', ST_GeomFromText('POINT(219 105)')),
('s', 'f', 'i', ST_GeomFromText('POINT(114 130)')),
('e', 'q', 'h', ST_GeomFromText('POINT(203 135)')),
('h', 'g', 'b', ST_GeomFromText('POINT(9 208)')),
('o', 'l', 'r', ST_GeomFromText('POINT(245 79)')),
('s', 's', 'v', ST_GeomFromText('POINT(238 198)')),
('w', 'w', 'z', ST_GeomFromText('POINT(209 232)')),
('v', 'd', 'n', ST_GeomFromText('POINT(30 193)')),
('q', 'w', 'k', ST_GeomFromText('POINT(133 18)')),
('o', 'h', 'o', ST_GeomFromText('POINT(42 140)')),
('f', 'f', 'h', ST_GeomFromText('POINT(145 1)')),
('u', 's', 'r', ST_GeomFromText('POINT(70 62)')),
('x', 'n', 'q', ST_GeomFromText('POINT(33 86)')),
('u', 'p', 'v', ST_GeomFromText('POINT(232 220)')),
('z', 'e', 'a', ST_GeomFromText('POINT(130 69)')),
('r', 'u', 'z', ST_GeomFromText('POINT(243 241)')),
('b', 'n', 't', ST_GeomFromText('POINT(120 12)')),
('u', 'f', 's', ST_GeomFromText('POINT(190 212)')),
('a', 'd', 'q', ST_GeomFromText('POINT(235 191)')),
('f', 'q', 'm', ST_GeomFromText('POINT(176 2)')),
('n', 'c', 's', ST_GeomFromText('POINT(218 163)')),
('e', 'm', 'h', ST_GeomFromText('POINT(163 108)')),
('c', 'f', 'l', ST_GeomFromText('POINT(220 115)')),
('c', 'v', 'q', ST_GeomFromText('POINT(66 45)')),
('w', 'v', 'x', ST_GeomFromText('POINT(251 220)')),
('f', 'w', 'z', ST_GeomFromText('POINT(146 149)')),
('h', 'n', 'h', ST_GeomFromText('POINT(148 128)')),
('y', 'k', 'v', ST_GeomFromText('POINT(28 110)')),
('c', 'x', 'q', ST_GeomFromText('POINT(13 13)')),
('e', 'd', 's', ST_GeomFromText('POINT(91 190)')),
('c', 'w', 'c', ST_GeomFromText('POINT(10 231)')),
('u', 'j', 'n', ST_GeomFromText('POINT(250 21)')),
('w', 'n', 'x', ST_GeomFromText('POINT(141 69)')),
('f', 'p', 'y', ST_GeomFromText('POINT(228 246)')),
('d', 'q', 'f', ST_GeomFromText('POINT(194 22)')),
('d', 'z', 'l', ST_GeomFromText('POINT(233 181)')),
('c', 'a', 'q', ST_GeomFromText('POINT(183 96)')),
('m', 'i', 'd', ST_GeomFromText('POINT(117 226)')),
('z', 'y', 'y', ST_GeomFromText('POINT(62 81)')),
('g', 'v', 'm', ST_GeomFromText('POINT(66 158)'));
START TRANSACTION;
INSERT INTO t1 (c2, c1, c3, spatial_poINT) VALUES
('f', 'x', 'p', ST_GeomFromText('POINT(92 181)'));
ROLLBACK;
INSERT INTO t1 (c2, c1, c3, spatial_poINT) VALUES
('f', 'x', 'p', ST_GeomFromText('POINT(92 181)'));
INSERT INTO t1 (c2, c1, c3, spatial_poINT) VALUES ('n', 'x', 'p', ST_GeomFromText('POINT(0 1280)'));
INSERT INTO t1 (c2, c1, c3, spatial_poINT) VALUES ('n', 'x', 'p', ST_GeomFromText('POINT(45 1280)'));
INSERT INTO t1 VALUES (1280, 'n', 'x', 'p', ST_GeomFromText('POINT(44 253)'));
DELETE FROM t1 WHERE id = 1280;
INSERT INTO t1 VALUES (1280, 'n', 'x', 'p', ST_GeomFromText('POINT(44 253)'));
START TRANSACTION;
DELETE FROM t1 WHERE id = 1280;
ROLLBACK;
START TRANSACTION;
INSERT INTO t1 (c2, c1, c3, spatial_point) VALUES
('m', 'u', 'p', ST_GeomFromText('POINT(1192 1181)'));
ROLLBACK;
SELECT COUNT(*) FROM t1;
COUNT(*)
353
UPDATE t1 SET spatial_point = ST_GeomFromText('POINT(123 456)') WHERE id < 2000;
SET @g1 = ST_GeomFromText('Polygon((123 456, 123 678, 456 678,456 456,123 456))');
DELETE FROM t1 WHERE MBRContains(@g1, t1.spatial_point);
SELECT COUNT(*) FROM t1;
COUNT(*)
353
DROP TABLE t1;
SET GLOBAL innodb_file_per_table=default;
SET GLOBAL innodb_file_format=default;
Warnings:
Warning 131 Using innodb_file_format is deprecated and the parameter may be removed in future releases. See http://dev.mysql.com/doc/refman/5.7/en/innodb-file-format.html
SET GLOBAL innodb_file_per_table='on';
SET GLOBAL innodb_file_format='Barracuda';
Warnings:
Warning 131 Using innodb_file_format is deprecated and the parameter may be removed in future releases. See http://dev.mysql.com/doc/refman/5.7/en/innodb-file-format.html
CREATE TABLE t1 (
id bigint(12) unsigned NOT NULL auto_increment,
c2 varchar(15) collate utf8_bin DEFAULT NULL,
c1 varchar(15) collate utf8_bin DEFAULT NULL,
c3 varchar(10) collate utf8_bin DEFAULT NULL,
spatial_point point NOT NULL,
PRIMARY KEY(id),
SPATIAL KEY (spatial_point)
) ROW_FORMAT=DYNAMIC ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
INSERT INTO t1 (c2, c1, c3, spatial_poINT) VALUES
('y', 's', 'j', ST_GeomFromText('POINT(167 74)')),
('r', 'n', 'd', ST_GeomFromText('POINT(215 118)')),
('g', 'n', 'e', ST_GeomFromText('POINT(203 98)')),
('h', 'd', 'd', ST_GeomFromText('POINT(54 193)')),
('r', 'x', 'y', ST_GeomFromText('POINT(47 69)')),
('t', 'q', 'r', ST_GeomFromText('POINT(109 42)')),
('a', 'z', 'd', ST_GeomFromText('POINT(0 154)')),
('x', 'v', 'o', ST_GeomFromText('POINT(174 131)')),
('b', 'r', 'a', ST_GeomFromText('POINT(114 253)')),
('x', 'z', 'i', ST_GeomFromText('POINT(163 21)')),
('w', 'p', 'i', ST_GeomFromText('POINT(42 102)')),
('g', 'j', 'j', ST_GeomFromText('POINT(170 133)')),
('m', 'g', 'n', ST_GeomFromText('POINT(28 22)')),
('b', 'z', 'h', ST_GeomFromText('POINT(174 28)')),
('q', 'k', 'f', ST_GeomFromText('POINT(233 73)')),
('w', 'w', 'a', ST_GeomFromText('POINT(124 200)')),
('t', 'j', 'w', ST_GeomFromText('POINT(252 101)')),
('d', 'r', 'd', ST_GeomFromText('POINT(98 18)')),
('w', 'o', 'y', ST_GeomFromText('POINT(165 31)')),
('y', 'h', 't', ST_GeomFromText('POINT(14 220)')),
('d', 'p', 'u', ST_GeomFromText('POINT(223 196)')),
('g', 'y', 'g', ST_GeomFromText('POINT(207 96)')),
('x', 'm', 'n', ST_GeomFromText('POINT(214 3)')),
('g', 'v', 'e', ST_GeomFromText('POINT(140 205)')),
('g', 'm', 'm', ST_GeomFromText('POINT(10 236)')),
('i', 'r', 'j', ST_GeomFromText('POINT(137 228)')),
('w', 's', 'p', ST_GeomFromText('POINT(115 6)')),
('o', 'n', 'k', ST_GeomFromText('POINT(158 129)')),
('j', 'h', 'l', ST_GeomFromText('POINT(129 72)')),
('f', 'x', 'l', ST_GeomFromText('POINT(139 207)')),
('u', 'd', 'n', ST_GeomFromText('POINT(125 109)')),
('b', 'a', 'z', ST_GeomFromText('POINT(30 32)')),
('m', 'h', 'o', ST_GeomFromText('POINT(251 251)')),
('f', 'r', 'd', ST_GeomFromText('POINT(243 211)')),
('b', 'd', 'r', ST_GeomFromText('POINT(232 80)')),
('g', 'k', 'v', ST_GeomFromText('POINT(15 100)')),
('i', 'f', 'c', ST_GeomFromText('POINT(109 66)')),
('r', 't', 'j', ST_GeomFromText('POINT(178 6)')),
('y', 'n', 'f', ST_GeomFromText('POINT(233 211)')),
('f', 'y', 'm', ST_GeomFromText('POINT(99 16)')),
('z', 'q', 'l', ST_GeomFromText('POINT(39 49)')),
('j', 'c', 'r', ST_GeomFromText('POINT(75 187)')),
('c', 'y', 'y', ST_GeomFromText('POINT(246 253)')),
('w', 'u', 'd', ST_GeomFromText('POINT(56 190)')),
('n', 'q', 'm', ST_GeomFromText('POINT(73 149)')),
('d', 'y', 'a', ST_GeomFromText('POINT(134 6)')),
('z', 's', 'w', ST_GeomFromText('POINT(216 225)')),
('d', 'u', 'k', ST_GeomFromText('POINT(132 70)')),
('f', 'v', 't', ST_GeomFromText('POINT(187 141)')),
('r', 'r', 'a', ST_GeomFromText('POINT(152 39)')),
('y', 'p', 'o', ST_GeomFromText('POINT(45 27)')),
('p', 'n', 'm', ST_GeomFromText('POINT(228 148)')),
('e', 'g', 'e', ST_GeomFromText('POINT(88 81)')),
('m', 'a', 'h', ST_GeomFromText('POINT(35 29)')),
('m', 'h', 'f', ST_GeomFromText('POINT(30 71)')),
('h', 'k', 'i', ST_GeomFromText('POINT(244 78)')),
('z', 'v', 'd', ST_GeomFromText('POINT(241 38)')),
('q', 'l', 'j', ST_GeomFromText('POINT(13 71)')),
('s', 'p', 'g', ST_GeomFromText('POINT(108 38)')),
('q', 's', 'j', ST_GeomFromText('POINT(92 101)')),
('l', 'h', 'g', ST_GeomFromText('POINT(120 78)')),
('w', 't', 'b', ST_GeomFromText('POINT(193 109)')),
('b', 's', 's', ST_GeomFromText('POINT(223 211)')),
('w', 'w', 'y', ST_GeomFromText('POINT(122 42)')),
('q', 'c', 'c', ST_GeomFromText('POINT(104 102)')),
('w', 'g', 'n', ST_GeomFromText('POINT(213 120)')),
('p', 'q', 'a', ST_GeomFromText('POINT(247 148)')),
('c', 'z', 'e', ST_GeomFromText('POINT(18 106)')),
('z', 'u', 'n', ST_GeomFromText('POINT(70 133)')),
('j', 'n', 'x', ST_GeomFromText('POINT(232 13)')),
('e', 'h', 'f', ST_GeomFromText('POINT(22 135)')),
('w', 'l', 'f', ST_GeomFromText('POINT(9 180)')),
('a', 'v', 'q', ST_GeomFromText('POINT(163 228)')),
('i', 'z', 'o', ST_GeomFromText('POINT(180 100)')),
('e', 'c', 'l', ST_GeomFromText('POINT(182 231)')),
('c', 'k', 'o', ST_GeomFromText('POINT(19 60)')),
('q', 'f', 'p', ST_GeomFromText('POINT(79 95)')),
('m', 'd', 'r', ST_GeomFromText('POINT(3 127)')),
('m', 'e', 't', ST_GeomFromText('POINT(136 154)')),
('w', 'w', 'w', ST_GeomFromText('POINT(102 15)')),
('l', 'n', 'q', ST_GeomFromText('POINT(71 196)')),
('p', 'k', 'c', ST_GeomFromText('POINT(47 139)')),
('j', 'o', 'r', ST_GeomFromText('POINT(177 128)')),
('j', 'q', 'a', ST_GeomFromText('POINT(170 6)')),
('b', 'a', 'o', ST_GeomFromText('POINT(63 211)')),
('g', 's', 'o', ST_GeomFromText('POINT(144 251)')),
('w', 'u', 'w', ST_GeomFromText('POINT(221 214)')),
('g', 'a', 'm', ST_GeomFromText('POINT(14 102)')),
('u', 'q', 'z', ST_GeomFromText('POINT(86 200)')),
('k', 'a', 'm', ST_GeomFromText('POINT(144 222)')),
('j', 'u', 'r', ST_GeomFromText('POINT(216 142)')),
('q', 'k', 'v', ST_GeomFromText('POINT(121 236)')),
('p', 'o', 'r', ST_GeomFromText('POINT(108 102)')),
('b', 'd', 'x', ST_GeomFromText('POINT(127 198)')),
('k', 's', 'a', ST_GeomFromText('POINT(2 150)')),
('f', 'm', 'f', ST_GeomFromText('POINT(160 191)')),
('q', 'y', 'x', ST_GeomFromText('POINT(98 111)')),
('o', 'f', 'm', ST_GeomFromText('POINT(232 218)')),
('c', 'w', 'j', ST_GeomFromText('POINT(156 165)')),
('s', 'q', 'v', ST_GeomFromText('POINT(98 161)'));
INSERT INTO t1 (c2, c1, c3, spatial_poINT) VALUES
('f', 'y', 'p', ST_GeomFromText('POINT(109 235)')),
('b', 'e', 'v', ST_GeomFromText('POINT(20 48)')),
('i', 'u', 'f', ST_GeomFromText('POINT(15 55)')),
('o', 'r', 'z', ST_GeomFromText('POINT(105 64)')),
('a', 'p', 'a', ST_GeomFromText('POINT(142 236)')),
('g', 'i', 'k', ST_GeomFromText('POINT(10 49)')),
('x', 'z', 'x', ST_GeomFromText('POINT(192 200)')),
('c', 'v', 'r', ST_GeomFromText('POINT(94 168)')),
('y', 'z', 'e', ST_GeomFromText('POINT(141 51)')),
('h', 'm', 'd', ST_GeomFromText('POINT(35 251)')),
('v', 'm', 'q', ST_GeomFromText('POINT(44 90)')),
('j', 'l', 'z', ST_GeomFromText('POINT(67 237)')),
('i', 'v', 'a', ST_GeomFromText('POINT(75 14)')),
('b', 'q', 't', ST_GeomFromText('POINT(153 33)')),
('e', 'm', 'a', ST_GeomFromText('POINT(247 49)')),
('l', 'y', 'g', ST_GeomFromText('POINT(56 203)')),
('v', 'o', 'r', ST_GeomFromText('POINT(90 54)')),
('r', 'n', 'd', ST_GeomFromText('POINT(135 83)')),
('j', 't', 'u', ST_GeomFromText('POINT(174 239)')),
('u', 'n', 'g', ST_GeomFromText('POINT(104 191)')),
('p', 'q', 'y', ST_GeomFromText('POINT(63 171)')),
('o', 'q', 'p', ST_GeomFromText('POINT(192 103)')),
('f', 'x', 'e', ST_GeomFromText('POINT(244 30)')),
('n', 'x', 'c', ST_GeomFromText('POINT(92 103)')),
('r', 'q', 'z', ST_GeomFromText('POINT(166 20)')),
('s', 'a', 'j', ST_GeomFromText('POINT(137 205)')),
('z', 't', 't', ST_GeomFromText('POINT(99 134)')),
('o', 'm', 'j', ST_GeomFromText('POINT(217 3)')),
('n', 'h', 'j', ST_GeomFromText('POINT(211 17)')),
('v', 'v', 'a', ST_GeomFromText('POINT(41 137)')),
('q', 'o', 'j', ST_GeomFromText('POINT(5 92)')),
('z', 'y', 'e', ST_GeomFromText('POINT(175 212)')),
('j', 'z', 'h', ST_GeomFromText('POINT(224 194)')),
('a', 'g', 'm', ST_GeomFromText('POINT(31 119)')),
('p', 'c', 'f', ST_GeomFromText('POINT(17 221)')),
('t', 'h', 'k', ST_GeomFromText('POINT(26 203)')),
('u', 'w', 'p', ST_GeomFromText('POINT(47 185)')),
('z', 'a', 'c', ST_GeomFromText('POINT(61 133)')),
('u', 'k', 'a', ST_GeomFromText('POINT(210 115)')),
('k', 'f', 'h', ST_GeomFromText('POINT(125 113)')),
('t', 'v', 'y', ST_GeomFromText('POINT(12 239)')),
('u', 'v', 'd', ST_GeomFromText('POINT(90 24)')),
('m', 'y', 'w', ST_GeomFromText('POINT(25 243)')),
('d', 'n', 'g', ST_GeomFromText('POINT(122 92)')),
('z', 'm', 'f', ST_GeomFromText('POINT(235 110)')),
('q', 'd', 'f', ST_GeomFromText('POINT(233 217)')),
('a', 'v', 'u', ST_GeomFromText('POINT(69 59)')),
('x', 'k', 'p', ST_GeomFromText('POINT(240 14)')),
('i', 'v', 'r', ST_GeomFromText('POINT(154 42)')),
('w', 'h', 'l', ST_GeomFromText('POINT(178 156)')),
('d', 'h', 'n', ST_GeomFromText('POINT(65 157)')),
('c', 'k', 'z', ST_GeomFromText('POINT(62 33)')),
('e', 'l', 'w', ST_GeomFromText('POINT(162 1)')),
('r', 'f', 'i', ST_GeomFromText('POINT(127 71)')),
('q', 'm', 'c', ST_GeomFromText('POINT(63 118)')),
('c', 'h', 'u', ST_GeomFromText('POINT(205 203)')),
('d', 't', 'p', ST_GeomFromText('POINT(234 87)')),
('s', 'g', 'h', ST_GeomFromText('POINT(149 34)')),
('o', 'b', 'q', ST_GeomFromText('POINT(159 179)')),
('k', 'u', 'f', ST_GeomFromText('POINT(202 254)')),
('u', 'f', 'g', ST_GeomFromText('POINT(70 15)')),
('x', 's', 'b', ST_GeomFromText('POINT(25 181)')),
('s', 'c', 'g', ST_GeomFromText('POINT(252 17)')),
('a', 'c', 'f', ST_GeomFromText('POINT(89 67)')),
('r', 'e', 'q', ST_GeomFromText('POINT(55 54)')),
('f', 'i', 'k', ST_GeomFromText('POINT(178 230)')),
('p', 'e', 'l', ST_GeomFromText('POINT(198 28)')),
('w', 'o', 'd', ST_GeomFromText('POINT(204 189)')),
('c', 'a', 'g', ST_GeomFromText('POINT(230 178)')),
('r', 'o', 'e', ST_GeomFromText('POINT(61 116)')),
('w', 'a', 'a', ST_GeomFromText('POINT(178 237)')),
('v', 'd', 'e', ST_GeomFromText('POINT(70 85)')),
('k', 'c', 'e', ST_GeomFromText('POINT(147 118)')),
('d', 'q', 't', ST_GeomFromText('POINT(218 77)')),
('k', 'g', 'f', ST_GeomFromText('POINT(192 113)')),
('w', 'n', 'e', ST_GeomFromText('POINT(92 124)')),
('r', 'm', 'q', ST_GeomFromText('POINT(130 65)')),
('o', 'r', 'r', ST_GeomFromText('POINT(174 233)')),
('k', 'n', 't', ST_GeomFromText('POINT(175 147)')),
('q', 'm', 'r', ST_GeomFromText('POINT(18 208)')),
('l', 'd', 'i', ST_GeomFromText('POINT(13 104)')),
('w', 'o', 'y', ST_GeomFromText('POINT(207 39)')),
('p', 'u', 'o', ST_GeomFromText('POINT(114 31)')),
('y', 'a', 'p', ST_GeomFromText('POINT(106 59)')),
('a', 'x', 'z', ST_GeomFromText('POINT(17 57)')),
('v', 'h', 'x', ST_GeomFromText('POINT(170 13)')),
('t', 's', 'u', ST_GeomFromText('POINT(84 18)')),
('z', 'z', 'f', ST_GeomFromText('POINT(250 197)')),
('l', 'z', 't', ST_GeomFromText('POINT(59 80)')),
('j', 'g', 's', ST_GeomFromText('POINT(54 26)')),
('g', 'v', 'm', ST_GeomFromText('POINT(89 98)')),
('q', 'v', 'b', ST_GeomFromText('POINT(39 240)')),
('x', 'k', 'v', ST_GeomFromText('POINT(246 207)')),
('k', 'u', 'i', ST_GeomFromText('POINT(105 111)')),
('w', 'z', 's', ST_GeomFromText('POINT(235 8)')),
('d', 'd', 'd', ST_GeomFromText('POINT(105 4)')),
('c', 'z', 'q', ST_GeomFromText('POINT(13 140)')),
('m', 'k', 'i', ST_GeomFromText('POINT(208 120)')),
('g', 'a', 'g', ST_GeomFromText('POINT(9 182)')),
('z', 'j', 'r', ST_GeomFromText('POINT(149 153)')),
('h', 'f', 'g', ST_GeomFromText('POINT(81 236)')),
('m', 'e', 'q', ST_GeomFromText('POINT(209 215)')),
('c', 'h', 'y', ST_GeomFromText('POINT(235 70)')),
('i', 'e', 'g', ST_GeomFromText('POINT(138 26)')),
('m', 't', 'u', ST_GeomFromText('POINT(119 237)')),
('o', 'w', 's', ST_GeomFromText('POINT(193 166)')),
('f', 'm', 'q', ST_GeomFromText('POINT(85 96)')),
('x', 'l', 'x', ST_GeomFromText('POINT(58 115)')),
('x', 'q', 'u', ST_GeomFromText('POINT(108 210)')),
('b', 'h', 'i', ST_GeomFromText('POINT(250 139)')),
('y', 'd', 'x', ST_GeomFromText('POINT(199 135)')),
('w', 'h', 'p', ST_GeomFromText('POINT(247 233)')),
('p', 'z', 't', ST_GeomFromText('POINT(148 249)')),
('q', 'a', 'u', ST_GeomFromText('POINT(174 78)')),
('v', 't', 'm', ST_GeomFromText('POINT(70 228)')),
('t', 'n', 'f', ST_GeomFromText('POINT(123 2)')),
('x', 't', 'b', ST_GeomFromText('POINT(35 50)')),
('r', 'j', 'f', ST_GeomFromText('POINT(200 51)')),
('s', 'q', 'o', ST_GeomFromText('POINT(23 184)')),
('u', 'v', 'z', ST_GeomFromText('POINT(7 113)')),
('v', 'u', 'l', ST_GeomFromText('POINT(145 190)')),
('o', 'k', 'i', ST_GeomFromText('POINT(161 122)')),
('l', 'y', 'e', ST_GeomFromText('POINT(17 232)')),
('t', 'b', 'e', ST_GeomFromText('POINT(120 50)')),
('e', 's', 'u', ST_GeomFromText('POINT(254 1)')),
('d', 'd', 'u', ST_GeomFromText('POINT(167 140)')),
('o', 'b', 'x', ST_GeomFromText('POINT(186 237)')),
('m', 's', 's', ST_GeomFromText('POINT(172 149)')),
('t', 'y', 'a', ST_GeomFromText('POINT(149 85)')),
('x', 't', 'r', ST_GeomFromText('POINT(10 165)')),
('g', 'c', 'e', ST_GeomFromText('POINT(95 165)')),
('e', 'e', 'z', ST_GeomFromText('POINT(98 65)')),
('f', 'v', 'i', ST_GeomFromText('POINT(149 144)')),
('o', 'p', 'm', ST_GeomFromText('POINT(233 67)')),
('t', 'u', 'b', ST_GeomFromText('POINT(109 215)')),
('o', 'o', 'b', ST_GeomFromText('POINT(130 48)')),
('e', 'm', 'h', ST_GeomFromText('POINT(88 189)')),
('e', 'v', 'y', ST_GeomFromText('POINT(55 29)')),
('e', 't', 'm', ST_GeomFromText('POINT(129 55)')),
('p', 'p', 'i', ST_GeomFromText('POINT(126 222)')),
('c', 'i', 'c', ST_GeomFromText('POINT(19 158)')),
('c', 'b', 's', ST_GeomFromText('POINT(13 19)')),
('u', 'y', 'a', ST_GeomFromText('POINT(114 5)')),
('a', 'o', 'f', ST_GeomFromText('POINT(227 232)')),
('t', 'c', 'z', ST_GeomFromText('POINT(63 62)')),
('d', 'o', 'k', ST_GeomFromText('POINT(48 228)')),
('x', 'c', 'e', ST_GeomFromText('POINT(204 2)')),
('e', 'e', 'g', ST_GeomFromText('POINT(125 43)')),
('o', 'r', 'f', ST_GeomFromText('POINT(171 140)'));
INSERT INTO t1 (c2, c1, c3, spatial_poINT) VALUES
('b', 'c', 'e', ST_GeomFromText('POINT(41 137)')),
('p', 'y', 'k', ST_GeomFromText('POINT(50 22)')),
('s', 'c', 'h', ST_GeomFromText('POINT(208 173)')),
('x', 'u', 'l', ST_GeomFromText('POINT(199 175)')),
('s', 'r', 'h', ST_GeomFromText('POINT(85 192)')),
('j', 'k', 'u', ST_GeomFromText('POINT(18 25)')),
('p', 'w', 'h', ST_GeomFromText('POINT(152 197)')),
('e', 'd', 'c', ST_GeomFromText('POINT(229 3)')),
('o', 'x', 'k', ST_GeomFromText('POINT(187 155)')),
('o', 'b', 'k', ST_GeomFromText('POINT(208 150)')),
('d', 'a', 'j', ST_GeomFromText('POINT(70 87)')),
('f', 'e', 'k', ST_GeomFromText('POINT(156 96)')),
('u', 'y', 'p', ST_GeomFromText('POINT(239 193)')),
('n', 'v', 'p', ST_GeomFromText('POINT(223 98)')),
('z', 'j', 'r', ST_GeomFromText('POINT(87 89)')),
('h', 'x', 'x', ST_GeomFromText('POINT(92 0)')),
('r', 'v', 'r', ST_GeomFromText('POINT(159 139)')),
('v', 'g', 'g', ST_GeomFromText('POINT(16 229)')),
('z', 'k', 'u', ST_GeomFromText('POINT(99 52)')),
('p', 'p', 'o', ST_GeomFromText('POINT(105 125)')),
('w', 'h', 'y', ST_GeomFromText('POINT(105 154)')),
('v', 'y', 'z', ST_GeomFromText('POINT(134 238)')),
('x', 'o', 'o', ST_GeomFromText('POINT(178 88)')),
('z', 'w', 'd', ST_GeomFromText('POINT(123 60)')),
('q', 'f', 'u', ST_GeomFromText('POINT(64 90)')),
('s', 'n', 't', ST_GeomFromText('POINT(50 138)')),
('v', 'p', 't', ST_GeomFromText('POINT(114 91)')),
('a', 'o', 'n', ST_GeomFromText('POINT(78 43)')),
('k', 'u', 'd', ST_GeomFromText('POINT(185 161)')),
('w', 'd', 'n', ST_GeomFromText('POINT(25 92)')),
('k', 'w', 'a', ST_GeomFromText('POINT(59 238)')),
('t', 'c', 'f', ST_GeomFromText('POINT(65 87)')),
('g', 's', 'p', ST_GeomFromText('POINT(238 126)')),
('d', 'n', 'y', ST_GeomFromText('POINT(107 173)')),
('l', 'a', 'w', ST_GeomFromText('POINT(125 152)')),
('m', 'd', 'j', ST_GeomFromText('POINT(146 53)')),
('q', 'm', 'c', ST_GeomFromText('POINT(217 187)')),
('i', 'r', 'r', ST_GeomFromText('POINT(6 113)')),
('e', 'j', 'b', ST_GeomFromText('POINT(37 83)')),
('w', 'w', 'h', ST_GeomFromText('POINT(83 199)')),
('k', 'b', 's', ST_GeomFromText('POINT(170 64)')),
('s', 'b', 'c', ST_GeomFromText('POINT(163 130)')),
('c', 'h', 'a', ST_GeomFromText('POINT(141 3)')),
('k', 'j', 'u', ST_GeomFromText('POINT(143 76)')),
('r', 'h', 'o', ST_GeomFromText('POINT(243 92)')),
('i', 'd', 'b', ST_GeomFromText('POINT(205 13)')),
('r', 'y', 'q', ST_GeomFromText('POINT(138 8)')),
('m', 'o', 'i', ST_GeomFromText('POINT(36 45)')),
('v', 'g', 'm', ST_GeomFromText('POINT(0 40)')),
('f', 'e', 'i', ST_GeomFromText('POINT(76 6)')),
('c', 'q', 'q', ST_GeomFromText('POINT(115 248)')),
('x', 'c', 'i', ST_GeomFromText('POINT(29 74)')),
('l', 's', 't', ST_GeomFromText('POINT(83 18)')),
('t', 't', 'a', ST_GeomFromText('POINT(26 168)')),
('u', 'n', 'x', ST_GeomFromText('POINT(200 110)')),
('j', 'b', 'd', ST_GeomFromText('POINT(216 136)')),
('s', 'p', 'w', ST_GeomFromText('POINT(38 156)')),
('f', 'b', 'v', ST_GeomFromText('POINT(29 186)')),
('v', 'e', 'r', ST_GeomFromText('POINT(149 40)')),
('v', 't', 'm', ST_GeomFromText('POINT(184 24)')),
('y', 'g', 'a', ST_GeomFromText('POINT(219 105)')),
('s', 'f', 'i', ST_GeomFromText('POINT(114 130)')),
('e', 'q', 'h', ST_GeomFromText('POINT(203 135)')),
('h', 'g', 'b', ST_GeomFromText('POINT(9 208)')),
('o', 'l', 'r', ST_GeomFromText('POINT(245 79)')),
('s', 's', 'v', ST_GeomFromText('POINT(238 198)')),
('w', 'w', 'z', ST_GeomFromText('POINT(209 232)')),
('v', 'd', 'n', ST_GeomFromText('POINT(30 193)')),
('q', 'w', 'k', ST_GeomFromText('POINT(133 18)')),
('o', 'h', 'o', ST_GeomFromText('POINT(42 140)')),
('f', 'f', 'h', ST_GeomFromText('POINT(145 1)')),
('u', 's', 'r', ST_GeomFromText('POINT(70 62)')),
('x', 'n', 'q', ST_GeomFromText('POINT(33 86)')),
('u', 'p', 'v', ST_GeomFromText('POINT(232 220)')),
('z', 'e', 'a', ST_GeomFromText('POINT(130 69)')),
('r', 'u', 'z', ST_GeomFromText('POINT(243 241)')),
('b', 'n', 't', ST_GeomFromText('POINT(120 12)')),
('u', 'f', 's', ST_GeomFromText('POINT(190 212)')),
('a', 'd', 'q', ST_GeomFromText('POINT(235 191)')),
('f', 'q', 'm', ST_GeomFromText('POINT(176 2)')),
('n', 'c', 's', ST_GeomFromText('POINT(218 163)')),
('e', 'm', 'h', ST_GeomFromText('POINT(163 108)')),
('c', 'f', 'l', ST_GeomFromText('POINT(220 115)')),
('c', 'v', 'q', ST_GeomFromText('POINT(66 45)')),
('w', 'v', 'x', ST_GeomFromText('POINT(251 220)')),
('f', 'w', 'z', ST_GeomFromText('POINT(146 149)')),
('h', 'n', 'h', ST_GeomFromText('POINT(148 128)')),
('y', 'k', 'v', ST_GeomFromText('POINT(28 110)')),
('c', 'x', 'q', ST_GeomFromText('POINT(13 13)')),
('e', 'd', 's', ST_GeomFromText('POINT(91 190)')),
('c', 'w', 'c', ST_GeomFromText('POINT(10 231)')),
('u', 'j', 'n', ST_GeomFromText('POINT(250 21)')),
('w', 'n', 'x', ST_GeomFromText('POINT(141 69)')),
('f', 'p', 'y', ST_GeomFromText('POINT(228 246)')),
('d', 'q', 'f', ST_GeomFromText('POINT(194 22)')),
('d', 'z', 'l', ST_GeomFromText('POINT(233 181)')),
('c', 'a', 'q', ST_GeomFromText('POINT(183 96)')),
('m', 'i', 'd', ST_GeomFromText('POINT(117 226)')),
('z', 'y', 'y', ST_GeomFromText('POINT(62 81)')),
('g', 'v', 'm', ST_GeomFromText('POINT(66 158)'));
START TRANSACTION;
INSERT INTO t1 (c2, c1, c3, spatial_poINT) VALUES
('f', 'x', 'p', ST_GeomFromText('POINT(92 181)'));
ROLLBACK;
INSERT INTO t1 (c2, c1, c3, spatial_poINT) VALUES
('f', 'x', 'p', ST_GeomFromText('POINT(92 181)'));
INSERT INTO t1 (c2, c1, c3, spatial_poINT) VALUES ('n', 'x', 'p', ST_GeomFromText('POINT(0 1280)'));
INSERT INTO t1 (c2, c1, c3, spatial_poINT) VALUES ('n', 'x', 'p', ST_GeomFromText('POINT(45 1280)'));
INSERT INTO t1 VALUES (1280, 'n', 'x', 'p', ST_GeomFromText('POINT(44 253)'));
DELETE FROM t1 WHERE id = 1280;
INSERT INTO t1 VALUES (1280, 'n', 'x', 'p', ST_GeomFromText('POINT(44 253)'));
START TRANSACTION;
DELETE FROM t1 WHERE id = 1280;
ROLLBACK;
START TRANSACTION;
INSERT INTO t1 (c2, c1, c3, spatial_point) VALUES
('m', 'u', 'p', ST_GeomFromText('POINT(1192 1181)'));
ROLLBACK;
SELECT COUNT(*) FROM t1;
COUNT(*)
353
UPDATE t1 SET spatial_point = ST_GeomFromText('POINT(123 456)') WHERE id < 2000;
SET @g1 = ST_GeomFromText('Polygon((123 456, 123 678, 456 678,456 456,123 456))');
DELETE FROM t1 WHERE MBRContains(@g1, t1.spatial_point);
SELECT COUNT(*) FROM t1;
COUNT(*)
353
DROP TABLE t1;
SET GLOBAL innodb_file_per_table=default;
SET GLOBAL innodb_file_format=default;
Warnings:
Warning 131 Using innodb_file_format is deprecated and the parameter may be removed in future releases. See http://dev.mysql.com/doc/refman/5.7/en/innodb-file-format.html
SET GLOBAL innodb_file_per_table='off';
SET GLOBAL innodb_file_format='Antelope';
Warnings:
Warning 131 Using innodb_file_format is deprecated and the parameter may be removed in future releases. See http://dev.mysql.com/doc/refman/5.7/en/innodb-file-format.html
CREATE TABLE t1 (
id bigint(12) unsigned NOT NULL auto_increment,
c2 varchar(15) collate utf8_bin DEFAULT NULL,
c1 varchar(15) collate utf8_bin DEFAULT NULL,
c3 varchar(10) collate utf8_bin DEFAULT NULL,
spatial_point point NOT NULL,
PRIMARY KEY(id),
SPATIAL KEY (spatial_point)
) ROW_FORMAT=COMPACT ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
INSERT INTO t1 (c2, c1, c3, spatial_poINT) VALUES
('y', 's', 'j', ST_GeomFromText('POINT(167 74)')),
('r', 'n', 'd', ST_GeomFromText('POINT(215 118)')),
('g', 'n', 'e', ST_GeomFromText('POINT(203 98)')),
('h', 'd', 'd', ST_GeomFromText('POINT(54 193)')),
('r', 'x', 'y', ST_GeomFromText('POINT(47 69)')),
('t', 'q', 'r', ST_GeomFromText('POINT(109 42)')),
('a', 'z', 'd', ST_GeomFromText('POINT(0 154)')),
('x', 'v', 'o', ST_GeomFromText('POINT(174 131)')),
('b', 'r', 'a', ST_GeomFromText('POINT(114 253)')),
('x', 'z', 'i', ST_GeomFromText('POINT(163 21)')),
('w', 'p', 'i', ST_GeomFromText('POINT(42 102)')),
('g', 'j', 'j', ST_GeomFromText('POINT(170 133)')),
('m', 'g', 'n', ST_GeomFromText('POINT(28 22)')),
('b', 'z', 'h', ST_GeomFromText('POINT(174 28)')),
('q', 'k', 'f', ST_GeomFromText('POINT(233 73)')),
('w', 'w', 'a', ST_GeomFromText('POINT(124 200)')),
('t', 'j', 'w', ST_GeomFromText('POINT(252 101)')),
('d', 'r', 'd', ST_GeomFromText('POINT(98 18)')),
('w', 'o', 'y', ST_GeomFromText('POINT(165 31)')),
('y', 'h', 't', ST_GeomFromText('POINT(14 220)')),
('d', 'p', 'u', ST_GeomFromText('POINT(223 196)')),
('g', 'y', 'g', ST_GeomFromText('POINT(207 96)')),
('x', 'm', 'n', ST_GeomFromText('POINT(214 3)')),
('g', 'v', 'e', ST_GeomFromText('POINT(140 205)')),
('g', 'm', 'm', ST_GeomFromText('POINT(10 236)')),
('i', 'r', 'j', ST_GeomFromText('POINT(137 228)')),
('w', 's', 'p', ST_GeomFromText('POINT(115 6)')),
('o', 'n', 'k', ST_GeomFromText('POINT(158 129)')),
('j', 'h', 'l', ST_GeomFromText('POINT(129 72)')),
('f', 'x', 'l', ST_GeomFromText('POINT(139 207)')),
('u', 'd', 'n', ST_GeomFromText('POINT(125 109)')),
('b', 'a', 'z', ST_GeomFromText('POINT(30 32)')),
('m', 'h', 'o', ST_GeomFromText('POINT(251 251)')),
('f', 'r', 'd', ST_GeomFromText('POINT(243 211)')),
('b', 'd', 'r', ST_GeomFromText('POINT(232 80)')),
('g', 'k', 'v', ST_GeomFromText('POINT(15 100)')),
('i', 'f', 'c', ST_GeomFromText('POINT(109 66)')),
('r', 't', 'j', ST_GeomFromText('POINT(178 6)')),
('y', 'n', 'f', ST_GeomFromText('POINT(233 211)')),
('f', 'y', 'm', ST_GeomFromText('POINT(99 16)')),
('z', 'q', 'l', ST_GeomFromText('POINT(39 49)')),
('j', 'c', 'r', ST_GeomFromText('POINT(75 187)')),
('c', 'y', 'y', ST_GeomFromText('POINT(246 253)')),
('w', 'u', 'd', ST_GeomFromText('POINT(56 190)')),
('n', 'q', 'm', ST_GeomFromText('POINT(73 149)')),
('d', 'y', 'a', ST_GeomFromText('POINT(134 6)')),
('z', 's', 'w', ST_GeomFromText('POINT(216 225)')),
('d', 'u', 'k', ST_GeomFromText('POINT(132 70)')),
('f', 'v', 't', ST_GeomFromText('POINT(187 141)')),
('r', 'r', 'a', ST_GeomFromText('POINT(152 39)')),
('y', 'p', 'o', ST_GeomFromText('POINT(45 27)')),
('p', 'n', 'm', ST_GeomFromText('POINT(228 148)')),
('e', 'g', 'e', ST_GeomFromText('POINT(88 81)')),
('m', 'a', 'h', ST_GeomFromText('POINT(35 29)')),
('m', 'h', 'f', ST_GeomFromText('POINT(30 71)')),
('h', 'k', 'i', ST_GeomFromText('POINT(244 78)')),
('z', 'v', 'd', ST_GeomFromText('POINT(241 38)')),
('q', 'l', 'j', ST_GeomFromText('POINT(13 71)')),
('s', 'p', 'g', ST_GeomFromText('POINT(108 38)')),
('q', 's', 'j', ST_GeomFromText('POINT(92 101)')),
('l', 'h', 'g', ST_GeomFromText('POINT(120 78)')),
('w', 't', 'b', ST_GeomFromText('POINT(193 109)')),
('b', 's', 's', ST_GeomFromText('POINT(223 211)')),
('w', 'w', 'y', ST_GeomFromText('POINT(122 42)')),
('q', 'c', 'c', ST_GeomFromText('POINT(104 102)')),
('w', 'g', 'n', ST_GeomFromText('POINT(213 120)')),
('p', 'q', 'a', ST_GeomFromText('POINT(247 148)')),
('c', 'z', 'e', ST_GeomFromText('POINT(18 106)')),
('z', 'u', 'n', ST_GeomFromText('POINT(70 133)')),
('j', 'n', 'x', ST_GeomFromText('POINT(232 13)')),
('e', 'h', 'f', ST_GeomFromText('POINT(22 135)')),
('w', 'l', 'f', ST_GeomFromText('POINT(9 180)')),
('a', 'v', 'q', ST_GeomFromText('POINT(163 228)')),
('i', 'z', 'o', ST_GeomFromText('POINT(180 100)')),
('e', 'c', 'l', ST_GeomFromText('POINT(182 231)')),
('c', 'k', 'o', ST_GeomFromText('POINT(19 60)')),
('q', 'f', 'p', ST_GeomFromText('POINT(79 95)')),
('m', 'd', 'r', ST_GeomFromText('POINT(3 127)')),
('m', 'e', 't', ST_GeomFromText('POINT(136 154)')),
('w', 'w', 'w', ST_GeomFromText('POINT(102 15)')),
('l', 'n', 'q', ST_GeomFromText('POINT(71 196)')),
('p', 'k', 'c', ST_GeomFromText('POINT(47 139)')),
('j', 'o', 'r', ST_GeomFromText('POINT(177 128)')),
('j', 'q', 'a', ST_GeomFromText('POINT(170 6)')),
('b', 'a', 'o', ST_GeomFromText('POINT(63 211)')),
('g', 's', 'o', ST_GeomFromText('POINT(144 251)')),
('w', 'u', 'w', ST_GeomFromText('POINT(221 214)')),
('g', 'a', 'm', ST_GeomFromText('POINT(14 102)')),
('u', 'q', 'z', ST_GeomFromText('POINT(86 200)')),
('k', 'a', 'm', ST_GeomFromText('POINT(144 222)')),
('j', 'u', 'r', ST_GeomFromText('POINT(216 142)')),
('q', 'k', 'v', ST_GeomFromText('POINT(121 236)')),
('p', 'o', 'r', ST_GeomFromText('POINT(108 102)')),
('b', 'd', 'x', ST_GeomFromText('POINT(127 198)')),
('k', 's', 'a', ST_GeomFromText('POINT(2 150)')),
('f', 'm', 'f', ST_GeomFromText('POINT(160 191)')),
('q', 'y', 'x', ST_GeomFromText('POINT(98 111)')),
('o', 'f', 'm', ST_GeomFromText('POINT(232 218)')),
('c', 'w', 'j', ST_GeomFromText('POINT(156 165)')),
('s', 'q', 'v', ST_GeomFromText('POINT(98 161)'));
INSERT INTO t1 (c2, c1, c3, spatial_poINT) VALUES
('f', 'y', 'p', ST_GeomFromText('POINT(109 235)')),
('b', 'e', 'v', ST_GeomFromText('POINT(20 48)')),
('i', 'u', 'f', ST_GeomFromText('POINT(15 55)')),
('o', 'r', 'z', ST_GeomFromText('POINT(105 64)')),
('a', 'p', 'a', ST_GeomFromText('POINT(142 236)')),
('g', 'i', 'k', ST_GeomFromText('POINT(10 49)')),
('x', 'z', 'x', ST_GeomFromText('POINT(192 200)')),
('c', 'v', 'r', ST_GeomFromText('POINT(94 168)')),
('y', 'z', 'e', ST_GeomFromText('POINT(141 51)')),
('h', 'm', 'd', ST_GeomFromText('POINT(35 251)')),
('v', 'm', 'q', ST_GeomFromText('POINT(44 90)')),
('j', 'l', 'z', ST_GeomFromText('POINT(67 237)')),
('i', 'v', 'a', ST_GeomFromText('POINT(75 14)')),
('b', 'q', 't', ST_GeomFromText('POINT(153 33)')),
('e', 'm', 'a', ST_GeomFromText('POINT(247 49)')),
('l', 'y', 'g', ST_GeomFromText('POINT(56 203)')),
('v', 'o', 'r', ST_GeomFromText('POINT(90 54)')),
('r', 'n', 'd', ST_GeomFromText('POINT(135 83)')),
('j', 't', 'u', ST_GeomFromText('POINT(174 239)')),
('u', 'n', 'g', ST_GeomFromText('POINT(104 191)')),
('p', 'q', 'y', ST_GeomFromText('POINT(63 171)')),
('o', 'q', 'p', ST_GeomFromText('POINT(192 103)')),
('f', 'x', 'e', ST_GeomFromText('POINT(244 30)')),
('n', 'x', 'c', ST_GeomFromText('POINT(92 103)')),
('r', 'q', 'z', ST_GeomFromText('POINT(166 20)')),
('s', 'a', 'j', ST_GeomFromText('POINT(137 205)')),
('z', 't', 't', ST_GeomFromText('POINT(99 134)')),
('o', 'm', 'j', ST_GeomFromText('POINT(217 3)')),
('n', 'h', 'j', ST_GeomFromText('POINT(211 17)')),
('v', 'v', 'a', ST_GeomFromText('POINT(41 137)')),
('q', 'o', 'j', ST_GeomFromText('POINT(5 92)')),
('z', 'y', 'e', ST_GeomFromText('POINT(175 212)')),
('j', 'z', 'h', ST_GeomFromText('POINT(224 194)')),
('a', 'g', 'm', ST_GeomFromText('POINT(31 119)')),
('p', 'c', 'f', ST_GeomFromText('POINT(17 221)')),
('t', 'h', 'k', ST_GeomFromText('POINT(26 203)')),
('u', 'w', 'p', ST_GeomFromText('POINT(47 185)')),
('z', 'a', 'c', ST_GeomFromText('POINT(61 133)')),
('u', 'k', 'a', ST_GeomFromText('POINT(210 115)')),
('k', 'f', 'h', ST_GeomFromText('POINT(125 113)')),
('t', 'v', 'y', ST_GeomFromText('POINT(12 239)')),
('u', 'v', 'd', ST_GeomFromText('POINT(90 24)')),
('m', 'y', 'w', ST_GeomFromText('POINT(25 243)')),
('d', 'n', 'g', ST_GeomFromText('POINT(122 92)')),
('z', 'm', 'f', ST_GeomFromText('POINT(235 110)')),
('q', 'd', 'f', ST_GeomFromText('POINT(233 217)')),
('a', 'v', 'u', ST_GeomFromText('POINT(69 59)')),
('x', 'k', 'p', ST_GeomFromText('POINT(240 14)')),
('i', 'v', 'r', ST_GeomFromText('POINT(154 42)')),
('w', 'h', 'l', ST_GeomFromText('POINT(178 156)')),
('d', 'h', 'n', ST_GeomFromText('POINT(65 157)')),
('c', 'k', 'z', ST_GeomFromText('POINT(62 33)')),
('e', 'l', 'w', ST_GeomFromText('POINT(162 1)')),
('r', 'f', 'i', ST_GeomFromText('POINT(127 71)')),
('q', 'm', 'c', ST_GeomFromText('POINT(63 118)')),
('c', 'h', 'u', ST_GeomFromText('POINT(205 203)')),
('d', 't', 'p', ST_GeomFromText('POINT(234 87)')),
('s', 'g', 'h', ST_GeomFromText('POINT(149 34)')),
('o', 'b', 'q', ST_GeomFromText('POINT(159 179)')),
('k', 'u', 'f', ST_GeomFromText('POINT(202 254)')),
('u', 'f', 'g', ST_GeomFromText('POINT(70 15)')),
('x', 's', 'b', ST_GeomFromText('POINT(25 181)')),
('s', 'c', 'g', ST_GeomFromText('POINT(252 17)')),
('a', 'c', 'f', ST_GeomFromText('POINT(89 67)')),
('r', 'e', 'q', ST_GeomFromText('POINT(55 54)')),
('f', 'i', 'k', ST_GeomFromText('POINT(178 230)')),
('p', 'e', 'l', ST_GeomFromText('POINT(198 28)')),
('w', 'o', 'd', ST_GeomFromText('POINT(204 189)')),
('c', 'a', 'g', ST_GeomFromText('POINT(230 178)')),
('r', 'o', 'e', ST_GeomFromText('POINT(61 116)')),
('w', 'a', 'a', ST_GeomFromText('POINT(178 237)')),
('v', 'd', 'e', ST_GeomFromText('POINT(70 85)')),
('k', 'c', 'e', ST_GeomFromText('POINT(147 118)')),
('d', 'q', 't', ST_GeomFromText('POINT(218 77)')),
('k', 'g', 'f', ST_GeomFromText('POINT(192 113)')),
('w', 'n', 'e', ST_GeomFromText('POINT(92 124)')),
('r', 'm', 'q', ST_GeomFromText('POINT(130 65)')),
('o', 'r', 'r', ST_GeomFromText('POINT(174 233)')),
('k', 'n', 't', ST_GeomFromText('POINT(175 147)')),
('q', 'm', 'r', ST_GeomFromText('POINT(18 208)')),
('l', 'd', 'i', ST_GeomFromText('POINT(13 104)')),
('w', 'o', 'y', ST_GeomFromText('POINT(207 39)')),
('p', 'u', 'o', ST_GeomFromText('POINT(114 31)')),
('y', 'a', 'p', ST_GeomFromText('POINT(106 59)')),
('a', 'x', 'z', ST_GeomFromText('POINT(17 57)')),
('v', 'h', 'x', ST_GeomFromText('POINT(170 13)')),
('t', 's', 'u', ST_GeomFromText('POINT(84 18)')),
('z', 'z', 'f', ST_GeomFromText('POINT(250 197)')),
('l', 'z', 't', ST_GeomFromText('POINT(59 80)')),
('j', 'g', 's', ST_GeomFromText('POINT(54 26)')),
('g', 'v', 'm', ST_GeomFromText('POINT(89 98)')),
('q', 'v', 'b', ST_GeomFromText('POINT(39 240)')),
('x', 'k', 'v', ST_GeomFromText('POINT(246 207)')),
('k', 'u', 'i', ST_GeomFromText('POINT(105 111)')),
('w', 'z', 's', ST_GeomFromText('POINT(235 8)')),
('d', 'd', 'd', ST_GeomFromText('POINT(105 4)')),
('c', 'z', 'q', ST_GeomFromText('POINT(13 140)')),
('m', 'k', 'i', ST_GeomFromText('POINT(208 120)')),
('g', 'a', 'g', ST_GeomFromText('POINT(9 182)')),
('z', 'j', 'r', ST_GeomFromText('POINT(149 153)')),
('h', 'f', 'g', ST_GeomFromText('POINT(81 236)')),
('m', 'e', 'q', ST_GeomFromText('POINT(209 215)')),
('c', 'h', 'y', ST_GeomFromText('POINT(235 70)')),
('i', 'e', 'g', ST_GeomFromText('POINT(138 26)')),
('m', 't', 'u', ST_GeomFromText('POINT(119 237)')),
('o', 'w', 's', ST_GeomFromText('POINT(193 166)')),
('f', 'm', 'q', ST_GeomFromText('POINT(85 96)')),
('x', 'l', 'x', ST_GeomFromText('POINT(58 115)')),
('x', 'q', 'u', ST_GeomFromText('POINT(108 210)')),
('b', 'h', 'i', ST_GeomFromText('POINT(250 139)')),
('y', 'd', 'x', ST_GeomFromText('POINT(199 135)')),
('w', 'h', 'p', ST_GeomFromText('POINT(247 233)')),
('p', 'z', 't', ST_GeomFromText('POINT(148 249)')),
('q', 'a', 'u', ST_GeomFromText('POINT(174 78)')),
('v', 't', 'm', ST_GeomFromText('POINT(70 228)')),
('t', 'n', 'f', ST_GeomFromText('POINT(123 2)')),
('x', 't', 'b', ST_GeomFromText('POINT(35 50)')),
('r', 'j', 'f', ST_GeomFromText('POINT(200 51)')),
('s', 'q', 'o', ST_GeomFromText('POINT(23 184)')),
('u', 'v', 'z', ST_GeomFromText('POINT(7 113)')),
('v', 'u', 'l', ST_GeomFromText('POINT(145 190)')),
('o', 'k', 'i', ST_GeomFromText('POINT(161 122)')),
('l', 'y', 'e', ST_GeomFromText('POINT(17 232)')),
('t', 'b', 'e', ST_GeomFromText('POINT(120 50)')),
('e', 's', 'u', ST_GeomFromText('POINT(254 1)')),
('d', 'd', 'u', ST_GeomFromText('POINT(167 140)')),
('o', 'b', 'x', ST_GeomFromText('POINT(186 237)')),
('m', 's', 's', ST_GeomFromText('POINT(172 149)')),
('t', 'y', 'a', ST_GeomFromText('POINT(149 85)')),
('x', 't', 'r', ST_GeomFromText('POINT(10 165)')),
('g', 'c', 'e', ST_GeomFromText('POINT(95 165)')),
('e', 'e', 'z', ST_GeomFromText('POINT(98 65)')),
('f', 'v', 'i', ST_GeomFromText('POINT(149 144)')),
('o', 'p', 'm', ST_GeomFromText('POINT(233 67)')),
('t', 'u', 'b', ST_GeomFromText('POINT(109 215)')),
('o', 'o', 'b', ST_GeomFromText('POINT(130 48)')),
('e', 'm', 'h', ST_GeomFromText('POINT(88 189)')),
('e', 'v', 'y', ST_GeomFromText('POINT(55 29)')),
('e', 't', 'm', ST_GeomFromText('POINT(129 55)')),
('p', 'p', 'i', ST_GeomFromText('POINT(126 222)')),
('c', 'i', 'c', ST_GeomFromText('POINT(19 158)')),
('c', 'b', 's', ST_GeomFromText('POINT(13 19)')),
('u', 'y', 'a', ST_GeomFromText('POINT(114 5)')),
('a', 'o', 'f', ST_GeomFromText('POINT(227 232)')),
('t', 'c', 'z', ST_GeomFromText('POINT(63 62)')),
('d', 'o', 'k', ST_GeomFromText('POINT(48 228)')),
('x', 'c', 'e', ST_GeomFromText('POINT(204 2)')),
('e', 'e', 'g', ST_GeomFromText('POINT(125 43)')),
('o', 'r', 'f', ST_GeomFromText('POINT(171 140)'));
INSERT INTO t1 (c2, c1, c3, spatial_poINT) VALUES
('b', 'c', 'e', ST_GeomFromText('POINT(41 137)')),
('p', 'y', 'k', ST_GeomFromText('POINT(50 22)')),
('s', 'c', 'h', ST_GeomFromText('POINT(208 173)')),
('x', 'u', 'l', ST_GeomFromText('POINT(199 175)')),
('s', 'r', 'h', ST_GeomFromText('POINT(85 192)')),
('j', 'k', 'u', ST_GeomFromText('POINT(18 25)')),
('p', 'w', 'h', ST_GeomFromText('POINT(152 197)')),
('e', 'd', 'c', ST_GeomFromText('POINT(229 3)')),
('o', 'x', 'k', ST_GeomFromText('POINT(187 155)')),
('o', 'b', 'k', ST_GeomFromText('POINT(208 150)')),
('d', 'a', 'j', ST_GeomFromText('POINT(70 87)')),
('f', 'e', 'k', ST_GeomFromText('POINT(156 96)')),
('u', 'y', 'p', ST_GeomFromText('POINT(239 193)')),
('n', 'v', 'p', ST_GeomFromText('POINT(223 98)')),
('z', 'j', 'r', ST_GeomFromText('POINT(87 89)')),
('h', 'x', 'x', ST_GeomFromText('POINT(92 0)')),
('r', 'v', 'r', ST_GeomFromText('POINT(159 139)')),
('v', 'g', 'g', ST_GeomFromText('POINT(16 229)')),
('z', 'k', 'u', ST_GeomFromText('POINT(99 52)')),
('p', 'p', 'o', ST_GeomFromText('POINT(105 125)')),
('w', 'h', 'y', ST_GeomFromText('POINT(105 154)')),
('v', 'y', 'z', ST_GeomFromText('POINT(134 238)')),
('x', 'o', 'o', ST_GeomFromText('POINT(178 88)')),
('z', 'w', 'd', ST_GeomFromText('POINT(123 60)')),
('q', 'f', 'u', ST_GeomFromText('POINT(64 90)')),
('s', 'n', 't', ST_GeomFromText('POINT(50 138)')),
('v', 'p', 't', ST_GeomFromText('POINT(114 91)')),
('a', 'o', 'n', ST_GeomFromText('POINT(78 43)')),
('k', 'u', 'd', ST_GeomFromText('POINT(185 161)')),
('w', 'd', 'n', ST_GeomFromText('POINT(25 92)')),
('k', 'w', 'a', ST_GeomFromText('POINT(59 238)')),
('t', 'c', 'f', ST_GeomFromText('POINT(65 87)')),
('g', 's', 'p', ST_GeomFromText('POINT(238 126)')),
('d', 'n', 'y', ST_GeomFromText('POINT(107 173)')),
('l', 'a', 'w', ST_GeomFromText('POINT(125 152)')),
('m', 'd', 'j', ST_GeomFromText('POINT(146 53)')),
('q', 'm', 'c', ST_GeomFromText('POINT(217 187)')),
('i', 'r', 'r', ST_GeomFromText('POINT(6 113)')),
('e', 'j', 'b', ST_GeomFromText('POINT(37 83)')),
('w', 'w', 'h', ST_GeomFromText('POINT(83 199)')),
('k', 'b', 's', ST_GeomFromText('POINT(170 64)')),
('s', 'b', 'c', ST_GeomFromText('POINT(163 130)')),
('c', 'h', 'a', ST_GeomFromText('POINT(141 3)')),
('k', 'j', 'u', ST_GeomFromText('POINT(143 76)')),
('r', 'h', 'o', ST_GeomFromText('POINT(243 92)')),
('i', 'd', 'b', ST_GeomFromText('POINT(205 13)')),
('r', 'y', 'q', ST_GeomFromText('POINT(138 8)')),
('m', 'o', 'i', ST_GeomFromText('POINT(36 45)')),
('v', 'g', 'm', ST_GeomFromText('POINT(0 40)')),
('f', 'e', 'i', ST_GeomFromText('POINT(76 6)')),
('c', 'q', 'q', ST_GeomFromText('POINT(115 248)')),
('x', 'c', 'i', ST_GeomFromText('POINT(29 74)')),
('l', 's', 't', ST_GeomFromText('POINT(83 18)')),
('t', 't', 'a', ST_GeomFromText('POINT(26 168)')),
('u', 'n', 'x', ST_GeomFromText('POINT(200 110)')),
('j', 'b', 'd', ST_GeomFromText('POINT(216 136)')),
('s', 'p', 'w', ST_GeomFromText('POINT(38 156)')),
('f', 'b', 'v', ST_GeomFromText('POINT(29 186)')),
('v', 'e', 'r', ST_GeomFromText('POINT(149 40)')),
('v', 't', 'm', ST_GeomFromText('POINT(184 24)')),
('y', 'g', 'a', ST_GeomFromText('POINT(219 105)')),
('s', 'f', 'i', ST_GeomFromText('POINT(114 130)')),
('e', 'q', 'h', ST_GeomFromText('POINT(203 135)')),
('h', 'g', 'b', ST_GeomFromText('POINT(9 208)')),
('o', 'l', 'r', ST_GeomFromText('POINT(245 79)')),
('s', 's', 'v', ST_GeomFromText('POINT(238 198)')),
('w', 'w', 'z', ST_GeomFromText('POINT(209 232)')),
('v', 'd', 'n', ST_GeomFromText('POINT(30 193)')),
('q', 'w', 'k', ST_GeomFromText('POINT(133 18)')),
('o', 'h', 'o', ST_GeomFromText('POINT(42 140)')),
('f', 'f', 'h', ST_GeomFromText('POINT(145 1)')),
('u', 's', 'r', ST_GeomFromText('POINT(70 62)')),
('x', 'n', 'q', ST_GeomFromText('POINT(33 86)')),
('u', 'p', 'v', ST_GeomFromText('POINT(232 220)')),
('z', 'e', 'a', ST_GeomFromText('POINT(130 69)')),
('r', 'u', 'z', ST_GeomFromText('POINT(243 241)')),
('b', 'n', 't', ST_GeomFromText('POINT(120 12)')),
('u', 'f', 's', ST_GeomFromText('POINT(190 212)')),
('a', 'd', 'q', ST_GeomFromText('POINT(235 191)')),
('f', 'q', 'm', ST_GeomFromText('POINT(176 2)')),
('n', 'c', 's', ST_GeomFromText('POINT(218 163)')),
('e', 'm', 'h', ST_GeomFromText('POINT(163 108)')),
('c', 'f', 'l', ST_GeomFromText('POINT(220 115)')),
('c', 'v', 'q', ST_GeomFromText('POINT(66 45)')),
('w', 'v', 'x', ST_GeomFromText('POINT(251 220)')),
('f', 'w', 'z', ST_GeomFromText('POINT(146 149)')),
('h', 'n', 'h', ST_GeomFromText('POINT(148 128)')),
('y', 'k', 'v', ST_GeomFromText('POINT(28 110)')),
('c', 'x', 'q', ST_GeomFromText('POINT(13 13)')),
('e', 'd', 's', ST_GeomFromText('POINT(91 190)')),
('c', 'w', 'c', ST_GeomFromText('POINT(10 231)')),
('u', 'j', 'n', ST_GeomFromText('POINT(250 21)')),
('w', 'n', 'x', ST_GeomFromText('POINT(141 69)')),
('f', 'p', 'y', ST_GeomFromText('POINT(228 246)')),
('d', 'q', 'f', ST_GeomFromText('POINT(194 22)')),
('d', 'z', 'l', ST_GeomFromText('POINT(233 181)')),
('c', 'a', 'q', ST_GeomFromText('POINT(183 96)')),
('m', 'i', 'd', ST_GeomFromText('POINT(117 226)')),
('z', 'y', 'y', ST_GeomFromText('POINT(62 81)')),
('g', 'v', 'm', ST_GeomFromText('POINT(66 158)'));
START TRANSACTION;
INSERT INTO t1 (c2, c1, c3, spatial_poINT) VALUES
('f', 'x', 'p', ST_GeomFromText('POINT(92 181)'));
ROLLBACK;
INSERT INTO t1 (c2, c1, c3, spatial_poINT) VALUES
('f', 'x', 'p', ST_GeomFromText('POINT(92 181)'));
INSERT INTO t1 (c2, c1, c3, spatial_poINT) VALUES ('n', 'x', 'p', ST_GeomFromText('POINT(0 1280)'));
INSERT INTO t1 (c2, c1, c3, spatial_poINT) VALUES ('n', 'x', 'p', ST_GeomFromText('POINT(45 1280)'));
INSERT INTO t1 VALUES (1280, 'n', 'x', 'p', ST_GeomFromText('POINT(44 253)'));
DELETE FROM t1 WHERE id = 1280;
INSERT INTO t1 VALUES (1280, 'n', 'x', 'p', ST_GeomFromText('POINT(44 253)'));
START TRANSACTION;
DELETE FROM t1 WHERE id = 1280;
ROLLBACK;
START TRANSACTION;
INSERT INTO t1 (c2, c1, c3, spatial_point) VALUES
('m', 'u', 'p', ST_GeomFromText('POINT(1192 1181)'));
ROLLBACK;
SELECT COUNT(*) FROM t1;
COUNT(*)
353
UPDATE t1 SET spatial_point = ST_GeomFromText('POINT(123 456)') WHERE id < 2000;
SET @g1 = ST_GeomFromText('Polygon((123 456, 123 678, 456 678,456 456,123 456))');
DELETE FROM t1 WHERE MBRContains(@g1, t1.spatial_point);
SELECT COUNT(*) FROM t1;
COUNT(*)
353
DROP TABLE t1;
SET GLOBAL innodb_file_per_table=default;
SET GLOBAL innodb_file_format=default;
Warnings:
Warning 131 Using innodb_file_format is deprecated and the parameter may be removed in future releases. See http://dev.mysql.com/doc/refman/5.7/en/innodb-file-format.html
SET GLOBAL innodb_file_per_table=1;
create table t1 (c1 int, c2 geometry not null, spatial index (c2))engine=innodb ROW_FORMAT=COMPRESSED;
insert into t1 values(1, Point(1,1));
insert into t1 values(2, Point(2,2));
insert into t1 values(3, Point(3,3));
insert into t1 values(4, Point(4,4));
insert into t1 values(5, Point(5,5));
insert into t1 values(6, Point(6,6));
insert into t1 values(7, Point(7,7));
insert into t1 values(8, Point(8,8));
insert into t1 values(9, Point(9,9));
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
start transaction;
insert into t1 select * from t1;
select count(*) from t1;
count(*)
18432
rollback;
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
select count(*) from t1;
count(*)
9216
set @g1 = ST_GeomFromText('Polygon((0 0,0 100,100 100,100 0,0 0))');
select count(*) from t1 where MBRWithin(t1.c2, @g1);
count(*)
9216
set @g1 = ST_GeomFromText('Polygon((10 10,10 800,800 800,800 10,10 10))');
select count(*) from t1 where MBRWithin(t1.c2, @g1);
count(*)
0
SET DEBUG='+d,page_copy_rec_list_start_compress_fail';
delete from t1;
SET DEBUG='-d,page_copy_rec_list_start_compress_fail';
select count(*) from t1 where MBRWithin(t1.c2, @g1);
count(*)
0
drop table t1;
SET GLOBAL innodb_file_per_table=1;
create table t1 (c1 int, c2 geometry not null, spatial index (c2))engine=innodb ROW_FORMAT=COMPRESSED;
create procedure insert_t1(IN total int)
begin
declare i int default 1;
while (i <= total) DO
insert into t1 values (i, Point(i, i));
set i = i + 1;
end while;
end|
CALL insert_t1(70000);
select count(*) from t1;
count(*)
70000
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
truncate table t1;
call mtr.add_suppression("InnoDB: page [0-9]+ in the doublewrite buffer is not within space bounds.*");
START TRANSACTION;
CALL insert_t1(5000);
COMMIT;
# Kill and restart
drop procedure insert_t1;
drop table t1;
create table t1 (c1 int, c2 geometry not null, spatial index (c2))engine=innodb;
insert into t1 values(1, Point(1,1));
insert into t1 values(2, Point(2,2));
insert into t1 values(3, Point(3,3));
insert into t1 values(4, Point(4,4));
insert into t1 values(5, Point(5,5));
insert into t1 values(6, Point(6,6));
insert into t1 values(7, Point(7,7));
insert into t1 values(8, Point(8,8));
insert into t1 values(9, Point(9,9));
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
SET SESSION debug="+d,rtr_pcur_move_to_next_return";
set session transaction isolation level serializable;
set @g1 = ST_GeomFromText('Polygon((0 0,0 100,100 100,100 0,0 0))');
SET DEBUG_SYNC = 'RESET';
SET DEBUG_SYNC = 'row_search_for_mysql_before_return SIGNAL started WAIT_FOR go_ahead';
select count(*) from t1 where MBRWithin(t1.c2, @g1);;
# Establish session con1 (user=root)
set session transaction isolation level serializable;
SET DEBUG_SYNC = 'now WAIT_FOR started';
insert into t1 select * from t1;
SET DEBUG_SYNC = 'now SIGNAL go_ahead';
count(*)
576
select count(*) from t1 where MBRWithin(t1.c2, @g1);
count(*)
1152
insert into t1 select * from t1;
insert into t1 select * from t1;
set @g1 = ST_GeomFromText('Polygon((0 0,0 100,100 100,100 0,0 0))');
select count(*) from t1 where MBRWithin(t1.c2, @g1);
count(*)
4608
set @g1 = ST_GeomFromText('Polygon((10 10,10 800,800 800,800 10,10 10))');
select count(*) from t1 where MBRWithin(t1.c2, @g1);
count(*)
0
set session transaction isolation level serializable;
truncate t1;
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(2 2, 150 150)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(3 3, 160 160)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(4 4, 170 170)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(5 5, 180 180)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(6 6, 190 190)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(7 7, 200 200)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(8 8, 210 210)'));
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
set session transaction isolation level serializable;
select @@tx_isolation;
@@tx_isolation
SERIALIZABLE
start transaction;
set @g1 = ST_GeomFromText('Polygon((100 100, 100 110, 110 110, 110 100, 100 100))');
select count(*) from t1 where MBRwithin(t1.c2, @g1);
count(*)
0
set session transaction isolation level serializable;
set session innodb_lock_wait_timeout = 1;
select @@tx_isolation;
@@tx_isolation
SERIALIZABLE
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
commit;
select count(*) from t1;
count(*)
896
insert into t1 values (105, Point(105, 105));
start transaction;
set @g1 = ST_GeomFromText('Polygon((100 100, 100 110, 110 110, 110 100, 100 100))');
select count(*) from t1 where MBRwithin(t1.c2, @g1);
count(*)
1
select @@innodb_lock_wait_timeout;
@@innodb_lock_wait_timeout
1
select @@tx_isolation;
@@tx_isolation
SERIALIZABLE
insert into t1 select * from t1;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select count(*) from t1;
count(*)
897
select sleep(2);
sleep(2)
0
commit;
truncate t1;
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(2 2, 150 150)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(3 3, 160 160)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(4 4, 170 170)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(5 5, 180 180)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(6 6, 190 190)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(7 7, 200 200)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(8 8, 210 210)'));
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
set session transaction isolation level serializable;
select @@tx_isolation;
@@tx_isolation
SERIALIZABLE
start transaction;
set @g1 = ST_GeomFromText('Polygon((100 100, 100 110, 110 110, 110 100, 100 100))');
select count(*) from t1 where MBRwithin(t1.c2, @g1);
count(*)
0
set session transaction isolation level serializable;
set session innodb_lock_wait_timeout = 1;
select @@tx_isolation;
@@tx_isolation
SERIALIZABLE
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
commit;
select count(*) from t1;
count(*)
1792
insert into t1 values (105, Point(105, 105));
start transaction;
set @g1 = ST_GeomFromText('Polygon((100 100, 100 110, 110 110, 110 100, 100 100))');
select count(*) from t1 where MBRwithin(t1.c2, @g1);
count(*)
1
select count(*) from t1 where MBRIntersects(t1.c2, @g1);
count(*)
1793
select @@innodb_lock_wait_timeout;
@@innodb_lock_wait_timeout
1
select @@tx_isolation;
@@tx_isolation
SERIALIZABLE
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(8 105, 200 105)'));
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select count(*) from t1;
count(*)
1793
select sleep(2);
sleep(2)
0
commit;
truncate t1;
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(2 2, 150 150)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(3 3, 160 160)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(5 5, 180 180)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(6 6, 190 190)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(7 7, 200 200)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(8 8, 210 210)'));
set @g1 = ST_GeomFromText('Polygon((3 3, 3 5, 5 5, 5 3, 3 3))');
start transaction;
delete from t1 where MBRWithin(t1.c2, @g1);
set session innodb_lock_wait_timeout = 1;
select @@innodb_lock_wait_timeout;
@@innodb_lock_wait_timeout
1
insert into t1 values(4, Point(4,4));
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
rollback;
truncate t1;
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(2 2, 150 150)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(3 3, 160 160)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(5 5, 180 180)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(6 6, 190 190)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(7 7, 200 200)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(8 8, 210 210)'));
set @g1 = ST_GeomFromText('Polygon((3 3, 3 5, 5 5, 5 3, 3 3))');
start transaction;
select count(*) from t1 where MBRWithin(t1.c2, @g1) for update;
count(*)
0
set session innodb_lock_wait_timeout = 1;
select @@innodb_lock_wait_timeout;
@@innodb_lock_wait_timeout
1
insert into t1 values(4, Point(4,4));
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
rollback;
truncate t1;
create procedure insert_t1(IN start int, IN total int)
begin
declare i int default 1;
set i = start;
while (i <= total) DO
insert into t1 values (i, Point(i, i));
set i = i + 1;
end while;
end|
CALL insert_t1(0, 1000);
set session transaction isolation level serializable;
select @@tx_isolation;
@@tx_isolation
SERIALIZABLE
start transaction;
set @g1 = ST_GeomFromText('Polygon((800 800, 800 1000, 1000 1000, 1000 800, 800 800))');
select count(*) from t1 where MBRwithin(t1.c2, @g1);
count(*)
199
CALL insert_t1(1001, 2000);
set session transaction isolation level serializable;
set session innodb_lock_wait_timeout = 1;
insert into t1 values (1200, Point(950, 950));
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
select sleep(2);
sleep(2)
0
commit;
SET SESSION debug="-d,rtr_pcur_move_to_next_return";
drop table t1;
drop procedure insert_t1;
create table t1 (c1 int, c2 geometry not null, spatial index (c2))engine=innodb;
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(2 2, 150 150)'));
INSERT INTO t1 VALUES (2, ST_GeomFromText('LineString(3 3, 160 160)'));
INSERT INTO t1 VALUES (2, ST_GeomFromText('LineString(4 4, 170 170)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(5 5, 180 180)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(6 6, 190 190)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(7 7, 200 200)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(8 8, 210 210)'));
SET SESSION debug="+d,rtr_pcur_move_to_next_return";
set transaction isolation level serializable;
start transaction;
set @g1 = ST_GeomFromText('Polygon((100 100, 100 110, 110 110, 110 100, 100 100))');
select count(*) from t1 where MBRwithin(t1.c2, @g1);
count(*)
0
delete from t1 where c1 = 1;
commit;
set transaction isolation level serializable;
start transaction;
set @g1 = ST_GeomFromText('Polygon((0 0, 0 300, 300 300, 300 0, 0 0))');
select count(*) from t1 where MBRwithin(t1.c2, @g1);
count(*)
2
set session innodb_lock_wait_timeout = 1;
delete from t1 where c1 = 2;
ERROR HY000: Lock wait timeout exceeded; try restarting transaction
commit;
drop table t1;
SET DEBUG_SYNC= 'RESET';
create table t1 (c1 int, c2 geometry not null, spatial index (c2))engine=innodb;
start transaction;
insert into t1 values(1, Point(1,1));
insert into t1 values(2, Point(2,2));
insert into t1 values(3, Point(3,3));
insert into t1 values(4, Point(4,4));
insert into t1 values(5, Point(5,5));
insert into t1 values(6, Point(6,6));
insert into t1 values(7, Point(7,7));
insert into t1 values(8, Point(8,8));
insert into t1 values(9, Point(9,9));
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
select count(*) from t1;
count(*)
4608
set @g1 = ST_GeomFromText('Polygon((0 0,0 100,100 100,100 0,0 0))');
set transaction isolation level read uncommitted;
SET DEBUG_SYNC= 'row_search_for_mysql_before_return SIGNAL siga WAIT_FOR sigb';
select count(*) from t1 where MBRWithin(t1.c2, @g1);
SET DEBUG_SYNC= 'now WAIT_FOR siga';
rollback;
SET DEBUG_SYNC= 'now SIGNAL sigb';
count(*)
1
select count(*) from t1 where MBRWithin(t1.c2, @g1);
count(*)
0
DROP TABLE t1;
SET DEBUG_SYNC = 'RESET';
create table t1 (c1 int, c2 geometry not null, spatial index (c2))engine=innodb;
create procedure insert_t1(IN total int)
begin
declare i int default 1;
while (i <= total) DO
insert into t1 values (i, Point(i, i));
set i = i + 1;
end while;
end|
start transaction;
CALL insert_t1(100);
set @g1 = ST_GeomFromText('Polygon((0 0,0 1000,1000 1000,1000 0,0 0))');
SET DEBUG_SYNC= 'rtr_pcur_move_to_next_return SIGNAL siga WAIT_FOR sigb';
select count(*) from t1 where MBRWithin(t1.c2, @g1);;
SET DEBUG_SYNC= 'now WAIT_FOR siga';
rollback;
SET DEBUG_SYNC= 'now SIGNAL sigb';
count(*)
0
drop procedure insert_t1;
DROP TABLE t1;
SET SESSION debug="-d,rtr_pcur_move_to_next_return";
SET DEBUG_SYNC = 'RESET';
create table t1 (c1 int, c2 geometry not null, spatial index (c2))engine=innodb;
create procedure insert_t1(IN total int)
begin
declare i int default 1;
while (i <= total) DO
insert into t1 values (i, Point(i, i));
set i = i + 1;
end while;
end|
CALL insert_t1(5000);
select count(*) from t1;
count(*)
5000
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
truncate table t1;
CALL insert_t1(10000);
select count(*) from t1;
count(*)
10000
drop index c2 on t1;
create spatial index idx on t1(c2);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) DEFAULT NULL,
`c2` geometry NOT NULL,
SPATIAL KEY `idx` (`c2`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
truncate table t1;
call mtr.add_suppression("InnoDB: page [0-9]+ in the doublewrite buffer is not within space bounds.*");
START TRANSACTION;
CALL insert_t1(5000);
COMMIT;
# Kill and restart
drop procedure insert_t1;
drop table t1;
CREATE TABLE t1 (c1 INT, c2 GEOMETRY NOT NULL, c3 GEOMETRY NOT NULL) ENGINE=INNODB;
INSERT INTO t1 VALUES(1, Point(1,1), ST_GeomFromText('POLYGON (( 0 -1, 0 1, 2 1, 2 -1, 0 -1))'));
INSERT INTO t1 VALUES(2, Point(2,2), ST_GeomFromText('POLYGON (( 0 -3, 0 -1, 2 -1, 2 -3, 0 -3))'));
INSERT INTO t1 VALUES(3, Point(3,3), ST_GeomFromText('POLYGON (( 1 0, 1 2, 3 2, 3 0, 1 0))'));
INSERT INTO t1 VALUES(4, Point(4,4), ST_GeomFromText('POLYGON (( -3 0, -3 2, -1 2, -1 0, -3 0))'));
INSERT INTO t1 VALUES(5, Point(5,5), ST_GeomFromText('POLYGON (( 0 0, 0 1, 1 1, 1 0, 0 0))'));
INSERT INTO t1 VALUES(6, Point(6,6), ST_GeomFromText('POLYGON (( 2 0, 2 2, 4 2, 4 0, 2 0))'));
INSERT INTO t1 VALUES(7, Point(7,7), ST_GeomFromText('POLYGON (( 0 3, 0 5, 2 5, 2 3, 0 3))'));
INSERT INTO t1 VALUES(8, Point(8,8), ST_GeomFromText('POLYGON (( 0 1, 0 3, 2 3, 2 1, 0 1))'));
INSERT INTO t1 VALUES(9, Point(9,9), ST_GeomFromText('POLYGON (( 0 0, 0 3, 3 3, 3 0, 0 0))'));
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
CREATE SPATIAL INDEX idx ON t1(c2);
SELECT COUNT(*) FROM t1;
COUNT(*)
4608
SET @g1 = ST_GeomFromText('Polygon((0 0,0 100,100 100,100 0,0 0))');
SELECT COUNT(*) FROM t1 WHERE MBRWithin(t1.c2, @g1);
COUNT(*)
4608
SET @g1 = ST_GeomFromText('Polygon((10 10,10 800,800 800,800 10,10 10))');
SELECT COUNT(*) FROM t1 WHERE MBRWithin(t1.c2, @g1);
COUNT(*)
0
ALTER TABLE t1 DROP INDEX idx, ADD SPATIAL INDEX idx3(c2);
SET SESSION debug="+d,row_merge_instrument_log_check_flush";
ALTER TABLE t1 DROP INDEX idx3, ADD SPATIAL INDEX idx4(c2), ADD SPATIAL INDEX idx5(c3);
DROP TABLE t1;
create table t1 (c1 int, c2 geometry not null, spatial index (c2))engine=innodb;
create procedure insert_t1(IN total int)
begin
declare i int default 1;
while (i <= total) DO
insert into t1 values
(i, Point(i, i)),
(i + 1, Point(i + 1, i + 1)),
(i + 2, Point(i + 2, i + 2)),
(i + 3, Point(i + 3, i + 3)),
(i + 4, Point(i + 4, i + 4)),
(i + 5, Point(i + 5, i + 5)),
(i + 6, Point(i + 6, i + 6)),
(i + 7, Point(i + 7, i + 7)),
(i + 8, Point(i + 8, i + 8)),
(i + 9, Point(i + 9, i + 9));
set i = i + 10;
end while;
end|
CALL insert_t1(5000);
select count(*) from t1;
count(*)
5000
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
truncate table t1;
CALL insert_t1(10000);
select count(*) from t1;
count(*)
10000
drop index c2 on t1;
create spatial index idx on t1(c2);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) DEFAULT NULL,
`c2` geometry NOT NULL,
SPATIAL KEY `idx` (`c2`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
SET DEBUG='+d,row_merge_ins_spatial_fail';
create spatial index idx2 on t1(c2);
ERROR HY000: Got error 1000 from storage engine
SET DEBUG='-d,row_merge_ins_spatial_fail';
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) DEFAULT NULL,
`c2` geometry NOT NULL,
SPATIAL KEY `idx` (`c2`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
truncate table t1;
CALL insert_t1(100000);
select count(*) from t1;
count(*)
100000
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
truncate table t1;
drop procedure insert_t1;
drop table t1;
This source diff could not be displayed because it is too large. You can view the blob instead.
CREATE TABLE t1 (
g GEOMETRY NOT NULL
) ENGINE=InnoDB;
ALTER TABLE t1 ADD SPATIAL(g);
SET @g1 = ST_GeomFromText('POINT(10 10)');
SET @g2 = ST_GeomFromText('POLYGON((5 5, 20 5, 20 21, 5 21, 5 5))');
SET @g3 = ST_GeomFromText('POLYGON((1.79769e+308 1.79769e+308, 20 5, -1.79769e+308 -1.79769e+308, 1.79769e+308 1.79769e+308))');
EXPLAIN SELECT ST_AsText(g) FROM t1 WHERE MBRContains(g, @g1);
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 NULL ALL g NULL NULL NULL 1 100.00 Using where
Warnings:
Note 1003 /* select#1 */ select st_astext(`test`.`t1`.`g`) AS `ST_AsText(g)` from `test`.`t1` where mbrcontains(`test`.`t1`.`g`,(@`g1`))
SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g1);
ST_AsText(g)
INSERT INTO t1 VALUES(@g1);
INSERT INTO t1 VALUES(@g2);
INSERT INTO t1 VALUES(@g3);
SELECT ST_AsText(g) FROM t1;
ST_AsText(g)
POINT(10 10)
POLYGON((5 5,20 5,20 21,5 21,5 5))
POLYGON((1.79769e308 1.79769e308,20 5,-1.79769e308 -1.79769e308,1.79769e308 1.79769e308))
ANALYZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
EXPLAIN SELECT ST_AsText(g) FROM t1 WHERE MBRContains(g, @g1);
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 NULL range g g 34 NULL 1 100.00 Using where
Warnings:
Note 1003 /* select#1 */ select st_astext(`test`.`t1`.`g`) AS `ST_AsText(g)` from `test`.`t1` where mbrcontains(`test`.`t1`.`g`,(@`g1`))
SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g1);
ST_AsText(g)
POINT(10 10)
EXPLAIN SELECT ST_AsText(g) FROM t1 WHERE MBRDisjoint(g, @g1);
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 NULL range g g 34 NULL 2 100.00 Using where
Warnings:
Note 1003 /* select#1 */ select st_astext(`test`.`t1`.`g`) AS `ST_AsText(g)` from `test`.`t1` where mbrdisjoint(`test`.`t1`.`g`,(@`g1`))
SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g1);
ST_AsText(g)
POINT(10 10)
EXPLAIN SELECT ST_AsText(g) FROM t1 WHERE MBREquals(g, @g1);
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 NULL range g g 34 NULL 1 100.00 Using where
Warnings:
Note 1003 /* select#1 */ select st_astext(`test`.`t1`.`g`) AS `ST_AsText(g)` from `test`.`t1` where mbrequals(`test`.`t1`.`g`,(@`g1`))
SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g1);
ST_AsText(g)
POINT(10 10)
EXPLAIN SELECT ST_AsText(g) FROM t1 WHERE MBRIntersects(g, @g1);
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 NULL range g g 34 NULL 1 100.00 Using where
Warnings:
Note 1003 /* select#1 */ select st_astext(`test`.`t1`.`g`) AS `ST_AsText(g)` from `test`.`t1` where mbrintersects(`test`.`t1`.`g`,(@`g1`))
SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g1);
ST_AsText(g)
POINT(10 10)
EXPLAIN SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g1);
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 NULL range g g 34 NULL 1 100.00 Using where
Warnings:
Note 1003 /* select#1 */ select st_astext(`test`.`t1`.`g`) AS `ST_AsText(g)` from `test`.`t1` where mbrwithin(`test`.`t1`.`g`,(@`g1`))
SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g1);
ST_AsText(g)
POINT(10 10)
EXPLAIN SELECT ST_AsText(g) FROM t1 WHERE MBRContains(g, @g2);
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 NULL range g g 34 NULL 1 100.00 Using where
Warnings:
Note 1003 /* select#1 */ select st_astext(`test`.`t1`.`g`) AS `ST_AsText(g)` from `test`.`t1` where mbrcontains(`test`.`t1`.`g`,(@`g2`))
SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g2);
ST_AsText(g)
POINT(10 10)
POLYGON((5 5,20 5,20 21,5 21,5 5))
EXPLAIN SELECT ST_AsText(g) FROM t1 WHERE MBRDisjoint(g, @g2);
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 NULL range g g 34 NULL 1 100.00 Using where
Warnings:
Note 1003 /* select#1 */ select st_astext(`test`.`t1`.`g`) AS `ST_AsText(g)` from `test`.`t1` where mbrdisjoint(`test`.`t1`.`g`,(@`g2`))
SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g2);
ST_AsText(g)
POINT(10 10)
POLYGON((5 5,20 5,20 21,5 21,5 5))
EXPLAIN SELECT ST_AsText(g) FROM t1 WHERE MBREquals(g, @g2);
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 NULL range g g 34 NULL 1 100.00 Using where
Warnings:
Note 1003 /* select#1 */ select st_astext(`test`.`t1`.`g`) AS `ST_AsText(g)` from `test`.`t1` where mbrequals(`test`.`t1`.`g`,(@`g2`))
SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g2);
ST_AsText(g)
POINT(10 10)
POLYGON((5 5,20 5,20 21,5 21,5 5))
EXPLAIN SELECT ST_AsText(g) FROM t1 WHERE MBRIntersects(g, @g2);
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 NULL range g g 34 NULL 2 100.00 Using where
Warnings:
Note 1003 /* select#1 */ select st_astext(`test`.`t1`.`g`) AS `ST_AsText(g)` from `test`.`t1` where mbrintersects(`test`.`t1`.`g`,(@`g2`))
SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g2);
ST_AsText(g)
POINT(10 10)
POLYGON((5 5,20 5,20 21,5 21,5 5))
EXPLAIN SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g2);
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 NULL range g g 34 NULL 2 100.00 Using where
Warnings:
Note 1003 /* select#1 */ select st_astext(`test`.`t1`.`g`) AS `ST_AsText(g)` from `test`.`t1` where mbrwithin(`test`.`t1`.`g`,(@`g2`))
SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g2);
ST_AsText(g)
POINT(10 10)
POLYGON((5 5,20 5,20 21,5 21,5 5))
EXPLAIN SELECT ST_AsText(g) FROM t1 WHERE MBRContains(g, @g3);
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 NULL ALL g NULL NULL NULL 3 100.00 Using where
Warnings:
Note 1003 /* select#1 */ select st_astext(`test`.`t1`.`g`) AS `ST_AsText(g)` from `test`.`t1` where mbrcontains(`test`.`t1`.`g`,(@`g3`))
SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g3);
ST_AsText(g)
POINT(10 10)
POLYGON((5 5,20 5,20 21,5 21,5 5))
POLYGON((1.79769e308 1.79769e308,20 5,-1.79769e308 -1.79769e308,1.79769e308 1.79769e308))
EXPLAIN SELECT ST_AsText(g) FROM t1 WHERE MBRDisjoint(g, @g3);
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 NULL ALL g NULL NULL NULL 3 100.00 Using where
Warnings:
Note 1003 /* select#1 */ select st_astext(`test`.`t1`.`g`) AS `ST_AsText(g)` from `test`.`t1` where mbrdisjoint(`test`.`t1`.`g`,(@`g3`))
SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g3);
ST_AsText(g)
POINT(10 10)
POLYGON((5 5,20 5,20 21,5 21,5 5))
POLYGON((1.79769e308 1.79769e308,20 5,-1.79769e308 -1.79769e308,1.79769e308 1.79769e308))
EXPLAIN SELECT ST_AsText(g) FROM t1 WHERE MBREquals(g, @g3);
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 NULL ALL g NULL NULL NULL 3 100.00 Using where
Warnings:
Note 1003 /* select#1 */ select st_astext(`test`.`t1`.`g`) AS `ST_AsText(g)` from `test`.`t1` where mbrequals(`test`.`t1`.`g`,(@`g3`))
SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g3);
ST_AsText(g)
POINT(10 10)
POLYGON((5 5,20 5,20 21,5 21,5 5))
POLYGON((1.79769e308 1.79769e308,20 5,-1.79769e308 -1.79769e308,1.79769e308 1.79769e308))
EXPLAIN SELECT ST_AsText(g) FROM t1 WHERE MBRIntersects(g, @g3);
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 NULL ALL g NULL NULL NULL 3 100.00 Using where
Warnings:
Note 1003 /* select#1 */ select st_astext(`test`.`t1`.`g`) AS `ST_AsText(g)` from `test`.`t1` where mbrintersects(`test`.`t1`.`g`,(@`g3`))
SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g3);
ST_AsText(g)
POINT(10 10)
POLYGON((5 5,20 5,20 21,5 21,5 5))
POLYGON((1.79769e308 1.79769e308,20 5,-1.79769e308 -1.79769e308,1.79769e308 1.79769e308))
EXPLAIN SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g3);
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 NULL ALL g NULL NULL NULL 3 100.00 Using where
Warnings:
Note 1003 /* select#1 */ select st_astext(`test`.`t1`.`g`) AS `ST_AsText(g)` from `test`.`t1` where mbrwithin(`test`.`t1`.`g`,(@`g3`))
SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g3);
ST_AsText(g)
POINT(10 10)
POLYGON((5 5,20 5,20 21,5 21,5 5))
POLYGON((1.79769e308 1.79769e308,20 5,-1.79769e308 -1.79769e308,1.79769e308 1.79769e308))
DROP TABLE t1;
create table t1 (i int, i2 char(10), g geometry not null, primary key (i, i2), spatial index (g))engine=innodb;
insert into t1 values (1, "111", POINT(1,1));
insert into t1 values (2, "222", POINT(1.5,1.5));
insert into t1 values (3, "333", POINT(3,3));
insert into t1 values (4, "444", POINT(3.1,3.1));
insert into t1 values (5, "555", POINT(5,5));
analyze table t1;
Table Op Msg_type Msg_text
test.t1 analyze status OK
set @g1 = ST_GeomFromText('Polygon((0 0,0 3,3 3,3 0,0 0))');
explain select ST_astext(t1.g) from t1 where MBRWithin(t1.g, @g1);
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1 NULL ALL g NULL NULL NULL 5 100.00 Using where
Warnings:
Note 1003 /* select#1 */ select st_astext(`test`.`t1`.`g`) AS `ST_astext(t1.g)` from `test`.`t1` where mbrwithin(`test`.`t1`.`g`,(@`g1`))
select ST_astext(t1.g) from t1 where MBRWithin(t1.g, @g1);
ST_astext(t1.g)
POINT(1 1)
POINT(1.5 1.5)
set @g1 = ST_GeomFromText('Polygon((0 0,0 3,3 3,3 0,0 0))');
delete from t1 where MBRWithin(t1.g, @g1);
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
select ST_astext(t1.g) from t1;
ST_astext(t1.g)
POINT(3 3)
POINT(3.1 3.1)
POINT(5 5)
set @g1 = ST_GeomFromText('Polygon((5 5,5 5,5 5,5 5,5 5))');
update t1 set g = POINT(2,2) where MBRWithin(t1.g, @g1);
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
select ST_astext(t1.g) from t1;
ST_astext(t1.g)
POINT(3 3)
POINT(3.1 3.1)
POINT(2 2)
show indexes from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
t1 0 PRIMARY 1 i A # NULL NULL BTREE
t1 0 PRIMARY 2 i2 A # NULL NULL BTREE
t1 1 g 1 g A # 32 NULL SPATIAL
drop table t1;
create table t1 (name VARCHAR(100), square GEOMETRY not null, spatial index (square))engine=innodb;
INSERT INTO t1 VALUES("small", ST_GeomFromText('POLYGON (( 0 0, 0 1, 1 1, 1 0, 0 0))'));
INSERT INTO t1 VALUES("big", ST_GeomFromText('POLYGON (( 0 0, 0 3, 3 3, 3 0, 0 0))'));
INSERT INTO t1 VALUES("up", ST_GeomFromText('POLYGON (( 0 1, 0 3, 2 3, 2 1, 0 1))'));
INSERT INTO t1 VALUES("up2", ST_GeomFromText('POLYGON (( 0 2, 0 4, 2 4, 2 2, 0 2))'));
INSERT INTO t1 VALUES("up3", ST_GeomFromText('POLYGON (( 0 3, 0 5, 2 5, 2 3, 0 3))'));
INSERT INTO t1 VALUES("down", ST_GeomFromText('POLYGON (( 0 -1, 0 1, 2 1, 2 -1, 0 -1))'));
INSERT INTO t1 VALUES("down2", ST_GeomFromText('POLYGON (( 0 -2, 0 0, 2 0, 2 -2, 0 -2))'));
INSERT INTO t1 VALUES("down3", ST_GeomFromText('POLYGON (( 0 -3, 0 -1, 2 -1, 2 -3, 0 -3))'));
INSERT INTO t1 VALUES("right", ST_GeomFromText('POLYGON (( 1 0, 1 2, 3 2, 3 0, 1 0))'));
INSERT INTO t1 VALUES("right2", ST_GeomFromText('POLYGON (( 2 0, 2 2, 4 2, 4 0, 2 0))'));
INSERT INTO t1 VALUES("right3", ST_GeomFromText('POLYGON (( 3 0, 3 2, 5 2, 5 0, 3 0))'));
INSERT INTO t1 VALUES("left", ST_GeomFromText('POLYGON (( -1 0, -1 2, 1 2, 1 0, -1 0))'));
INSERT INTO t1 VALUES("left2", ST_GeomFromText('POLYGON (( -2 0, -2 2, 0 2, 0 0, -2 0))'));
INSERT INTO t1 VALUES("left3", ST_GeomFromText('POLYGON (( -3 0, -3 2, -1 2, -1 0, -3 0))'));
SET @p = ST_GeomFromText('POLYGON (( 0 0, 0 2, 2 2, 2 0, 0 0))');
SELECT name, ST_AsText(square) from t1 where MBRContains(@p, square);
name ST_AsText(square)
small POLYGON((0 0,0 1,1 1,1 0,0 0))
SELECT name, ST_AsText(square) from t1 where MBRDisjoint(@p, square);
name ST_AsText(square)
up3 POLYGON((0 3,0 5,2 5,2 3,0 3))
down3 POLYGON((0 -3,0 -1,2 -1,2 -3,0 -3))
right3 POLYGON((3 0,3 2,5 2,5 0,3 0))
left3 POLYGON((-3 0,-3 2,-1 2,-1 0,-3 0))
SELECT name, ST_AsText(square) from t1 where MBREquals(@p, square);
name ST_AsText(square)
SELECT name, ST_AsText(square) from t1 where MBRIntersects(@p, square);
name ST_AsText(square)
right2 POLYGON((2 0,2 2,4 2,4 0,2 0))
right POLYGON((1 0,1 2,3 2,3 0,1 0))
up2 POLYGON((0 2,0 4,2 4,2 2,0 2))
up POLYGON((0 1,0 3,2 3,2 1,0 1))
big POLYGON((0 0,0 3,3 3,3 0,0 0))
small POLYGON((0 0,0 1,1 1,1 0,0 0))
down POLYGON((0 -1,0 1,2 1,2 -1,0 -1))
down2 POLYGON((0 -2,0 0,2 0,2 -2,0 -2))
left POLYGON((-1 0,-1 2,1 2,1 0,-1 0))
left2 POLYGON((-2 0,-2 2,0 2,0 0,-2 0))
SELECT name, ST_AsText(square) from t1 where MBROverlaps(@p, square);
name ST_AsText(square)
right POLYGON((1 0,1 2,3 2,3 0,1 0))
up POLYGON((0 1,0 3,2 3,2 1,0 1))
down POLYGON((0 -1,0 1,2 1,2 -1,0 -1))
left POLYGON((-1 0,-1 2,1 2,1 0,-1 0))
SELECT name, ST_AsText(square) from t1 where MBRTouches(@p, square);
name ST_AsText(square)
right2 POLYGON((2 0,2 2,4 2,4 0,2 0))
up2 POLYGON((0 2,0 4,2 4,2 2,0 2))
down2 POLYGON((0 -2,0 0,2 0,2 -2,0 -2))
left2 POLYGON((-2 0,-2 2,0 2,0 0,-2 0))
SELECT name, ST_AsText(square) from t1 where MBRWithin(@p, square);
name ST_AsText(square)
big POLYGON((0 0,0 3,3 3,3 0,0 0))
SET @vert1 = ST_GeomFromText('POLYGON ((0 -2, 0 2, 0 -2))');
ERROR 22023: Invalid GIS data provided to function st_geometryfromtext.
SET @horiz1 = ST_GeomFromText('POLYGON ((-2 0, 2 0, -2 0))');
ERROR 22023: Invalid GIS data provided to function st_geometryfromtext.
SET @horiz2 = ST_GeomFromText('POLYGON ((-1 0, 3 0, -1 0))');
ERROR 22023: Invalid GIS data provided to function st_geometryfromtext.
SET @horiz3 = ST_GeomFromText('POLYGON ((2 0, 3 0, 2 0))');
ERROR 22023: Invalid GIS data provided to function st_geometryfromtext.
SET @point1 = ST_GeomFromText('POLYGON ((0 0))');
ERROR 22023: Invalid GIS data provided to function st_geometryfromtext.
SET @point2 = ST_GeomFromText('POLYGON ((-2 0))');
ERROR 22023: Invalid GIS data provided to function st_geometryfromtext.
SELECT GROUP_CONCAT(a1.name ORDER BY a1.name) AS MBRoverlaps FROM t1 a1 WHERE MBROverlaps(a1.square, @vert1) GROUP BY a1.name;
MBRoverlaps
SELECT GROUP_CONCAT(a1.name ORDER BY a1.name) AS MBRoverlaps FROM t1 a1 WHERE MBROverlaps(a1.square, @horiz1) GROUP BY a1.name;
MBRoverlaps
SELECT MBROverlaps(@horiz1, @vert1) FROM DUAL;
MBROverlaps(@horiz1, @vert1)
NULL
SELECT MBROverlaps(@horiz1, @horiz2) FROM DUAL;
MBROverlaps(@horiz1, @horiz2)
NULL
SELECT MBROverlaps(@horiz1, @horiz3) FROM DUAL;
MBROverlaps(@horiz1, @horiz3)
NULL
SELECT MBROverlaps(@horiz1, @point1) FROM DUAL;
MBROverlaps(@horiz1, @point1)
NULL
SELECT MBROverlaps(@horiz1, @point2) FROM DUAL;
MBROverlaps(@horiz1, @point2)
NULL
DROP TABLE t1;
create table t1 (i int not null, g geometry not null)engine=innodb;
insert into t1 values (1, POINT(1,1));
insert into t1 values (2, POINT(1.5,1.5));
insert into t1 values (3, POINT(3,3));
insert into t1 values (4, POINT(3.1,3.1));
insert into t1 values (5, POINT(5,5));
alter table t1 add primary key(i), algorithm=inplace;
alter table t1 drop primary key;
create spatial index idx on t1(g) algorithm=inplace;
create spatial index idx2 on t1(g);
Warnings:
Warning 1831 Duplicate index 'idx2' defined on the table 'test.t1'. This is deprecated and will be disallowed in a future release.
alter table t1 add primary key(i), algorithm=inplace;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`i` int(11) NOT NULL,
`g` geometry NOT NULL,
PRIMARY KEY (`i`),
SPATIAL KEY `idx` (`g`),
SPATIAL KEY `idx2` (`g`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop index idx on t1;
drop table t1;
This source diff could not be displayed because it is too large. You can view the blob instead.
create table t (
a point not null,b point not null,c point,
d point not null,e point,f point,
spatial key (d),spatial key (b)
) engine=innodb;
create procedure p(i int)
begin
declare n int default 0;
declare continue handler for sqlexception begin end;
delete from t;
repeat
set @p=point(1,1);
insert into t values(@p,@p,@p,@p,@p,@p);
insert into t values(@p,@p,@p,@p,@p,@p);
insert into t select @p,@p,@p,@p,@p,@p
from t a,t b,t c,t d,t e,t f,t g,t h,t i,t j;
delete from t;
set n:=n+1;
until n >= i end repeat;
end|
call p(200);
drop procedure p;
drop table t;
# restart
create table t1 (c1 int, c2 geometry not null, spatial index (c2))engine=innodb;
create procedure insert_t1(IN total int)
begin
declare i int default 1;
while (i <= total) DO
insert into t1 values (i, Point(i, i));
set i = i + 1;
end while;
end|
create procedure update_t1(IN total int)
begin
declare i int default 1;
while (i <= total) DO
update t1 set c2 = Point(i + 10000, i + 10000) where c2 = Point(i, i);
set i = i + 1;
end while;
end|
CALL insert_t1(367);
COMMIT;
# Kill and restart
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
drop table t1;
create table t1 (c1 int, c2 point not null, spatial index (c2))engine=innodb;
CALL insert_t1(367);
CALL update_t1(367);
SET @poly1 = ST_GeomFromText('POLYGON((10000 10000, 10000 10350, 10350 10350, 10350 10000, 10000 10000))');
delete from t1 where ST_Contains(@poly1, c2);
COMMIT;
# Kill and restart
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
select count(*) from t1;
count(*)
18
select c1, ST_astext(c2) from t1;
c1 ST_astext(c2)
350 POINT(10350 10350)
351 POINT(10351 10351)
352 POINT(10352 10352)
353 POINT(10353 10353)
354 POINT(10354 10354)
355 POINT(10355 10355)
356 POINT(10356 10356)
357 POINT(10357 10357)
358 POINT(10358 10358)
359 POINT(10359 10359)
360 POINT(10360 10360)
361 POINT(10361 10361)
362 POINT(10362 10362)
363 POINT(10363 10363)
364 POINT(10364 10364)
365 POINT(10365 10365)
366 POINT(10366 10366)
367 POINT(10367 10367)
drop procedure insert_t1;
drop procedure update_t1;
drop table t1;
create table t1 (c1 int, c2 geometry not null, spatial index (c2))engine=innodb;
insert into t1 values(1, Point(1,1));
insert into t1 values(2, Point(2,2));
insert into t1 values(3, Point(3,3));
insert into t1 values(4, Point(4,4));
insert into t1 values(5, Point(5,5));
insert into t1 values(6, Point(6,6));
insert into t1 values(7, Point(7,7));
insert into t1 values(8, Point(8,8));
insert into t1 values(9, Point(9,9));
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
start transaction;
insert into t1 select * from t1;
select count(*) from t1;
count(*)
73728
rollback;
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
select count(*) from t1;
count(*)
36864
set @g1 = ST_GeomFromText('Polygon((0 0,0 100,100 100,100 0,0 0))');
select count(*) from t1 where MBRWithin(t1.c2, @g1);
count(*)
36864
set @g1 = ST_GeomFromText('Polygon((10 10,10 800,800 800,800 10,10 10))');
select count(*) from t1 where MBRWithin(t1.c2, @g1);
count(*)
0
drop table t1;
create table t1 (c1 int, c2 geometry not null, spatial index (c2))engine=innodb;
create procedure insert_t1(IN total int)
begin
declare i int default 1;
while (i <= total) DO
insert into t1 values (i, Point(i, i));
set i = i + 1;
end while;
end|
start transaction;
CALL insert_t1(70000);
rollback;
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
drop procedure insert_t1;
drop table t1;
create table t1 (c1 int, c2 geometry not null, spatial index (c2))engine=innodb;
create procedure insert_t1(IN total int)
begin
declare i int default 1;
while (i <= total) DO
insert into t1 values (i, Point(i, i));
set i = i + 1;
end while;
end|
CALL insert_t1(1000);
select count(*) from t1;
count(*)
1000
set @g1 = ST_GeomFromText('Polygon((0 0,0 1000,1000 1000,1000 0,0 0))');
select count(*) from t1 where MBRWithin(t1.c2, @g1);
count(*)
999
set @g1 = ST_GeomFromText('Polygon((0 0,0 100,100 100,100 0,0 0))');
select count(*) from t1 where MBRWithin(t1.c2, @g1);
count(*)
99
set @g1 = ST_GeomFromText('Polygon((10 10,10 800,800 800,800 10,10 10))');
select count(*) from t1 where MBRWithin(t1.c2, @g1);
count(*)
789
set @g1 = ST_GeomFromText('Polygon((100 100,100 800,800 800,800 100,100 100))');
select count(*) from t1 where MBRWithin(t1.c2, @g1);
count(*)
699
set @g1 = ST_GeomFromText('Point(1 1)');
select count(*) from t1 where MBRequals(t1.c2, @g1);
count(*)
1
set @g1 = ST_GeomFromText('Polygon((0 0,0 100,100 100,100 0,0 0))');
select count(*) from t1 where MBRdisjoint(t1.c2, @g1);
count(*)
900
DROP PROCEDURE insert_t1;
truncate t1;
INSERT INTO t1 VALUES (150, ST_GeomFromText('LineString(150 150, 150 150)'));
INSERT INTO t1 VALUES (149, ST_GeomFromText('LineString(149 149, 151 151)'));
INSERT INTO t1 VALUES (148, ST_GeomFromText('LineString(148 148, 152 152)'));
INSERT INTO t1 VALUES (147, ST_GeomFromText('LineString(147 147, 153 153)'));
INSERT INTO t1 VALUES (146, ST_GeomFromText('LineString(146 146, 154 154)'));
INSERT INTO t1 VALUES (145, ST_GeomFromText('LineString(145 145, 155 155)'));
INSERT INTO t1 VALUES (144, ST_GeomFromText('LineString(144 144, 156 156)'));
INSERT INTO t1 VALUES (143, ST_GeomFromText('LineString(143 143, 157 157)'));
INSERT INTO t1 VALUES (142, ST_GeomFromText('LineString(142 142, 158 158)'));
INSERT INTO t1 VALUES (141, ST_GeomFromText('LineString(141 141, 159 159)'));
INSERT INTO t1 VALUES (140, ST_GeomFromText('LineString(140 140, 160 160)'));
INSERT INTO t1 VALUES (139, ST_GeomFromText('LineString(139 139, 161 161)'));
INSERT INTO t1 VALUES (138, ST_GeomFromText('LineString(138 138, 162 162)'));
INSERT INTO t1 VALUES (137, ST_GeomFromText('LineString(137 137, 163 163)'));
INSERT INTO t1 VALUES (136, ST_GeomFromText('LineString(136 136, 164 164)'));
INSERT INTO t1 VALUES (135, ST_GeomFromText('LineString(135 135, 165 165)'));
INSERT INTO t1 VALUES (134, ST_GeomFromText('LineString(134 134, 166 166)'));
INSERT INTO t1 VALUES (133, ST_GeomFromText('LineString(133 133, 167 167)'));
INSERT INTO t1 VALUES (132, ST_GeomFromText('LineString(132 132, 168 168)'));
INSERT INTO t1 VALUES (131, ST_GeomFromText('LineString(131 131, 169 169)'));
INSERT INTO t1 VALUES (130, ST_GeomFromText('LineString(130 130, 170 170)'));
INSERT INTO t1 VALUES (129, ST_GeomFromText('LineString(129 129, 171 171)'));
INSERT INTO t1 VALUES (128, ST_GeomFromText('LineString(128 128, 172 172)'));
INSERT INTO t1 VALUES (127, ST_GeomFromText('LineString(127 127, 173 173)'));
INSERT INTO t1 VALUES (126, ST_GeomFromText('LineString(126 126, 174 174)'));
INSERT INTO t1 VALUES (125, ST_GeomFromText('LineString(125 125, 175 175)'));
INSERT INTO t1 VALUES (124, ST_GeomFromText('LineString(124 124, 176 176)'));
INSERT INTO t1 VALUES (123, ST_GeomFromText('LineString(123 123, 177 177)'));
INSERT INTO t1 VALUES (122, ST_GeomFromText('LineString(122 122, 178 178)'));
INSERT INTO t1 VALUES (121, ST_GeomFromText('LineString(121 121, 179 179)'));
INSERT INTO t1 VALUES (120, ST_GeomFromText('LineString(120 120, 180 180)'));
INSERT INTO t1 VALUES (119, ST_GeomFromText('LineString(119 119, 181 181)'));
INSERT INTO t1 VALUES (118, ST_GeomFromText('LineString(118 118, 182 182)'));
INSERT INTO t1 VALUES (117, ST_GeomFromText('LineString(117 117, 183 183)'));
INSERT INTO t1 VALUES (116, ST_GeomFromText('LineString(116 116, 184 184)'));
INSERT INTO t1 VALUES (115, ST_GeomFromText('LineString(115 115, 185 185)'));
INSERT INTO t1 VALUES (114, ST_GeomFromText('LineString(114 114, 186 186)'));
INSERT INTO t1 VALUES (113, ST_GeomFromText('LineString(113 113, 187 187)'));
INSERT INTO t1 VALUES (112, ST_GeomFromText('LineString(112 112, 188 188)'));
INSERT INTO t1 VALUES (111, ST_GeomFromText('LineString(111 111, 189 189)'));
INSERT INTO t1 VALUES (110, ST_GeomFromText('LineString(110 110, 190 190)'));
INSERT INTO t1 VALUES (109, ST_GeomFromText('LineString(109 109, 191 191)'));
INSERT INTO t1 VALUES (108, ST_GeomFromText('LineString(108 108, 192 192)'));
INSERT INTO t1 VALUES (107, ST_GeomFromText('LineString(107 107, 193 193)'));
INSERT INTO t1 VALUES (106, ST_GeomFromText('LineString(106 106, 194 194)'));
INSERT INTO t1 VALUES (105, ST_GeomFromText('LineString(105 105, 195 195)'));
INSERT INTO t1 VALUES (104, ST_GeomFromText('LineString(104 104, 196 196)'));
INSERT INTO t1 VALUES (103, ST_GeomFromText('LineString(103 103, 197 197)'));
INSERT INTO t1 VALUES (102, ST_GeomFromText('LineString(102 102, 198 198)'));
INSERT INTO t1 VALUES (101, ST_GeomFromText('LineString(101 101, 199 199)'));
INSERT INTO t1 VALUES (100, ST_GeomFromText('LineString(100 100, 200 200)'));
INSERT INTO t1 VALUES (99, ST_GeomFromText('LineString(99 99, 201 201)'));
INSERT INTO t1 VALUES (98, ST_GeomFromText('LineString(98 98, 202 202)'));
INSERT INTO t1 VALUES (97, ST_GeomFromText('LineString(97 97, 203 203)'));
INSERT INTO t1 VALUES (96, ST_GeomFromText('LineString(96 96, 204 204)'));
INSERT INTO t1 VALUES (95, ST_GeomFromText('LineString(95 95, 205 205)'));
INSERT INTO t1 VALUES (94, ST_GeomFromText('LineString(94 94, 206 206)'));
INSERT INTO t1 VALUES (93, ST_GeomFromText('LineString(93 93, 207 207)'));
INSERT INTO t1 VALUES (92, ST_GeomFromText('LineString(92 92, 208 208)'));
INSERT INTO t1 VALUES (91, ST_GeomFromText('LineString(91 91, 209 209)'));
INSERT INTO t1 VALUES (90, ST_GeomFromText('LineString(90 90, 210 210)'));
INSERT INTO t1 VALUES (89, ST_GeomFromText('LineString(89 89, 211 211)'));
INSERT INTO t1 VALUES (88, ST_GeomFromText('LineString(88 88, 212 212)'));
INSERT INTO t1 VALUES (87, ST_GeomFromText('LineString(87 87, 213 213)'));
INSERT INTO t1 VALUES (86, ST_GeomFromText('LineString(86 86, 214 214)'));
INSERT INTO t1 VALUES (85, ST_GeomFromText('LineString(85 85, 215 215)'));
INSERT INTO t1 VALUES (84, ST_GeomFromText('LineString(84 84, 216 216)'));
INSERT INTO t1 VALUES (83, ST_GeomFromText('LineString(83 83, 217 217)'));
INSERT INTO t1 VALUES (82, ST_GeomFromText('LineString(82 82, 218 218)'));
INSERT INTO t1 VALUES (81, ST_GeomFromText('LineString(81 81, 219 219)'));
INSERT INTO t1 VALUES (80, ST_GeomFromText('LineString(80 80, 220 220)'));
INSERT INTO t1 VALUES (79, ST_GeomFromText('LineString(79 79, 221 221)'));
INSERT INTO t1 VALUES (78, ST_GeomFromText('LineString(78 78, 222 222)'));
INSERT INTO t1 VALUES (77, ST_GeomFromText('LineString(77 77, 223 223)'));
INSERT INTO t1 VALUES (76, ST_GeomFromText('LineString(76 76, 224 224)'));
INSERT INTO t1 VALUES (75, ST_GeomFromText('LineString(75 75, 225 225)'));
INSERT INTO t1 VALUES (74, ST_GeomFromText('LineString(74 74, 226 226)'));
INSERT INTO t1 VALUES (73, ST_GeomFromText('LineString(73 73, 227 227)'));
INSERT INTO t1 VALUES (72, ST_GeomFromText('LineString(72 72, 228 228)'));
INSERT INTO t1 VALUES (71, ST_GeomFromText('LineString(71 71, 229 229)'));
INSERT INTO t1 VALUES (70, ST_GeomFromText('LineString(70 70, 230 230)'));
INSERT INTO t1 VALUES (69, ST_GeomFromText('LineString(69 69, 231 231)'));
INSERT INTO t1 VALUES (68, ST_GeomFromText('LineString(68 68, 232 232)'));
INSERT INTO t1 VALUES (67, ST_GeomFromText('LineString(67 67, 233 233)'));
INSERT INTO t1 VALUES (66, ST_GeomFromText('LineString(66 66, 234 234)'));
INSERT INTO t1 VALUES (65, ST_GeomFromText('LineString(65 65, 235 235)'));
INSERT INTO t1 VALUES (64, ST_GeomFromText('LineString(64 64, 236 236)'));
INSERT INTO t1 VALUES (63, ST_GeomFromText('LineString(63 63, 237 237)'));
INSERT INTO t1 VALUES (62, ST_GeomFromText('LineString(62 62, 238 238)'));
INSERT INTO t1 VALUES (61, ST_GeomFromText('LineString(61 61, 239 239)'));
INSERT INTO t1 VALUES (60, ST_GeomFromText('LineString(60 60, 240 240)'));
INSERT INTO t1 VALUES (59, ST_GeomFromText('LineString(59 59, 241 241)'));
INSERT INTO t1 VALUES (58, ST_GeomFromText('LineString(58 58, 242 242)'));
INSERT INTO t1 VALUES (57, ST_GeomFromText('LineString(57 57, 243 243)'));
INSERT INTO t1 VALUES (56, ST_GeomFromText('LineString(56 56, 244 244)'));
INSERT INTO t1 VALUES (55, ST_GeomFromText('LineString(55 55, 245 245)'));
INSERT INTO t1 VALUES (54, ST_GeomFromText('LineString(54 54, 246 246)'));
INSERT INTO t1 VALUES (53, ST_GeomFromText('LineString(53 53, 247 247)'));
INSERT INTO t1 VALUES (52, ST_GeomFromText('LineString(52 52, 248 248)'));
INSERT INTO t1 VALUES (51, ST_GeomFromText('LineString(51 51, 249 249)'));
INSERT INTO t1 VALUES (50, ST_GeomFromText('LineString(50 50, 250 250)'));
INSERT INTO t1 VALUES (49, ST_GeomFromText('LineString(49 49, 251 251)'));
INSERT INTO t1 VALUES (48, ST_GeomFromText('LineString(48 48, 252 252)'));
INSERT INTO t1 VALUES (47, ST_GeomFromText('LineString(47 47, 253 253)'));
INSERT INTO t1 VALUES (46, ST_GeomFromText('LineString(46 46, 254 254)'));
INSERT INTO t1 VALUES (45, ST_GeomFromText('LineString(45 45, 255 255)'));
INSERT INTO t1 VALUES (44, ST_GeomFromText('LineString(44 44, 256 256)'));
INSERT INTO t1 VALUES (43, ST_GeomFromText('LineString(43 43, 257 257)'));
INSERT INTO t1 VALUES (42, ST_GeomFromText('LineString(42 42, 258 258)'));
INSERT INTO t1 VALUES (41, ST_GeomFromText('LineString(41 41, 259 259)'));
INSERT INTO t1 VALUES (40, ST_GeomFromText('LineString(40 40, 260 260)'));
INSERT INTO t1 VALUES (39, ST_GeomFromText('LineString(39 39, 261 261)'));
INSERT INTO t1 VALUES (38, ST_GeomFromText('LineString(38 38, 262 262)'));
INSERT INTO t1 VALUES (37, ST_GeomFromText('LineString(37 37, 263 263)'));
INSERT INTO t1 VALUES (36, ST_GeomFromText('LineString(36 36, 264 264)'));
INSERT INTO t1 VALUES (35, ST_GeomFromText('LineString(35 35, 265 265)'));
INSERT INTO t1 VALUES (34, ST_GeomFromText('LineString(34 34, 266 266)'));
INSERT INTO t1 VALUES (33, ST_GeomFromText('LineString(33 33, 267 267)'));
INSERT INTO t1 VALUES (32, ST_GeomFromText('LineString(32 32, 268 268)'));
INSERT INTO t1 VALUES (31, ST_GeomFromText('LineString(31 31, 269 269)'));
INSERT INTO t1 VALUES (30, ST_GeomFromText('LineString(30 30, 270 270)'));
INSERT INTO t1 VALUES (29, ST_GeomFromText('LineString(29 29, 271 271)'));
INSERT INTO t1 VALUES (28, ST_GeomFromText('LineString(28 28, 272 272)'));
INSERT INTO t1 VALUES (27, ST_GeomFromText('LineString(27 27, 273 273)'));
INSERT INTO t1 VALUES (26, ST_GeomFromText('LineString(26 26, 274 274)'));
INSERT INTO t1 VALUES (25, ST_GeomFromText('LineString(25 25, 275 275)'));
INSERT INTO t1 VALUES (24, ST_GeomFromText('LineString(24 24, 276 276)'));
INSERT INTO t1 VALUES (23, ST_GeomFromText('LineString(23 23, 277 277)'));
INSERT INTO t1 VALUES (22, ST_GeomFromText('LineString(22 22, 278 278)'));
INSERT INTO t1 VALUES (21, ST_GeomFromText('LineString(21 21, 279 279)'));
INSERT INTO t1 VALUES (20, ST_GeomFromText('LineString(20 20, 280 280)'));
INSERT INTO t1 VALUES (19, ST_GeomFromText('LineString(19 19, 281 281)'));
INSERT INTO t1 VALUES (18, ST_GeomFromText('LineString(18 18, 282 282)'));
INSERT INTO t1 VALUES (17, ST_GeomFromText('LineString(17 17, 283 283)'));
INSERT INTO t1 VALUES (16, ST_GeomFromText('LineString(16 16, 284 284)'));
INSERT INTO t1 VALUES (15, ST_GeomFromText('LineString(15 15, 285 285)'));
INSERT INTO t1 VALUES (14, ST_GeomFromText('LineString(14 14, 286 286)'));
INSERT INTO t1 VALUES (13, ST_GeomFromText('LineString(13 13, 287 287)'));
INSERT INTO t1 VALUES (12, ST_GeomFromText('LineString(12 12, 288 288)'));
INSERT INTO t1 VALUES (11, ST_GeomFromText('LineString(11 11, 289 289)'));
INSERT INTO t1 VALUES (10, ST_GeomFromText('LineString(10 10, 290 290)'));
INSERT INTO t1 VALUES (9, ST_GeomFromText('LineString(9 9, 291 291)'));
INSERT INTO t1 VALUES (8, ST_GeomFromText('LineString(8 8, 292 292)'));
INSERT INTO t1 VALUES (7, ST_GeomFromText('LineString(7 7, 293 293)'));
INSERT INTO t1 VALUES (6, ST_GeomFromText('LineString(6 6, 294 294)'));
INSERT INTO t1 VALUES (5, ST_GeomFromText('LineString(5 5, 295 295)'));
INSERT INTO t1 VALUES (4, ST_GeomFromText('LineString(4 4, 296 296)'));
INSERT INTO t1 VALUES (3, ST_GeomFromText('LineString(3 3, 297 297)'));
INSERT INTO t1 VALUES (2, ST_GeomFromText('LineString(2 2, 298 298)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(1 1, 299 299)'));
select count(*) from t1;
count(*)
150
set @g1 = ST_GeomFromText('Polygon((0 0,0 1000,1000 1000,1000 0,0 0))');
select count(*) from t1 where MBRwithin(t1.c2, @g1);
count(*)
150
truncate t1;
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(2 2, 150 150)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(3 3, 160 160)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(4 4, 170 170)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(5 5, 180 180)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(6 6, 190 190)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(7 7, 200 200)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(8 8, 210 210)'));
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
set @g1 = ST_GeomFromText('Polygon((0 0,0 2, 2 2, 2 0, 0 0))');
select count(*) from t1 where MBRtouches(t1.c2, @g1);
count(*)
2048
set @g1 = ST_GeomFromText('Polygon((0 0,0 200,200 200,200 0,0 0))');
select count(*) from t1 where MBRWithin(t1.c2, @g1);
count(*)
12288
set @g1 = ST_GeomFromText('LineString(2 2, 150 150)');
select count(*) from t1 where MBRequals(t1.c2, @g1);
count(*)
2048
set @g1 = ST_GeomFromText('Polygon((0 0,0 200,200 200,200 0,0 0))');
create table t3 (a int) engine = innodb;
CREATE PROCEDURE curdemo()
BEGIN
DECLARE done INT DEFAULT FALSE;
DECLARE a INT;
DECLARE cur1 CURSOR FOR SELECT c1 from t1 where MBRWithin(t1.c2, @g1);
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
OPEN cur1;
read_loop: LOOP
FETCH cur1 INTO a;
IF done THEN
LEAVE read_loop;
END IF;
INSERT INTO test.t3 VALUES (a);
END LOOP;
CLOSE cur1;
END|
call curdemo();
select count(*) from t3;
count(*)
12288
drop procedure curdemo;
drop table t3;
drop table t1;
create table t1 (c1 int, c2 geometry not null, spatial index (c2))engine=innodb;
insert into t1 values(1, Point(1,1));
insert into t1 values(2, Point(2,2));
insert into t1 values(3, Point(3,3));
insert into t1 values(4, Point(4,4));
insert into t1 values(5, Point(5,5));
insert into t1 values(6, Point(6,6));
insert into t1 values(7, Point(7,7));
insert into t1 values(8, Point(8,8));
insert into t1 values(9, Point(9,9));
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
SET SESSION debug="+d, rtr_page_need_second_split";
insert into t1 select * from t1;
SET SESSION debug="-d, rtr_page_need_second_split";
delete from t1;
insert into t1 values(1, Point(1,1));
insert into t1 values(2, Point(2,2));
insert into t1 values(3, Point(3,3));
insert into t1 values(4, Point(4,4));
insert into t1 values(5, Point(5,5));
insert into t1 values(6, Point(6,6));
insert into t1 values(7, Point(7,7));
insert into t1 values(8, Point(8,8));
insert into t1 values(9, Point(9,9));
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
start transaction;
insert into t1 select * from t1;
rollback;
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
select count(*) from t1;
count(*)
73728
set @g1 = ST_GeomFromText('Polygon((0 0,0 100,100 100,100 0,0 0))');
select count(*) from t1 where MBRWithin(t1.c2, @g1);
count(*)
73728
set @g1 = ST_GeomFromText('Polygon((10 10,10 800,800 800,800 10,10 10))');
select count(*) from t1 where MBRWithin(t1.c2, @g1);
count(*)
0
drop index c2 on t1;
create spatial index idx2 on t1(c2);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`c1` int(11) DEFAULT NULL,
`c2` geometry NOT NULL,
SPATIAL KEY `idx2` (`c2`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
set @g1 = ST_GeomFromText('Polygon((0 0,0 100,100 100,100 0,0 0))');
select count(*) from t1 where MBRWithin(t1.c2, @g1);
count(*)
73728
# restart: --innodb-read-only
set @g1 = ST_GeomFromText('Polygon((0 0,0 100,100 100,100 0,0 0))');
select count(*) from t1 where MBRWithin(t1.c2, @g1);
count(*)
73728
set @g1 = ST_GeomFromText('Polygon((2 2,2 800,800 800,800 2,2 2))');
select count(*) from t1 where MBRWithin(t1.c2, @g1);
count(*)
57344
# restart
drop table t1;
This source diff could not be displayed because it is too large. You can view the blob instead.
SET SESSION debug="+d,row_print_geometry_data";
CREATE TABLE t_wl6455 ( i INT, g GEOMETRY NOT NULL) ENGINE=InnoDB;
SHOW CREATE TABLE t_wl6455;
Table Create Table
t_wl6455 CREATE TABLE `t_wl6455` (
`i` int(11) DEFAULT NULL,
`g` geometry NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
INSERT INTO t_wl6455 VALUES(1, POINT(1,1));
INSERT INTO t_wl6455 VALUES(2, POINT(2,2));
SET @mp = 'MULTIPOINT(0 0, 20 20, 60 60)';
INSERT INTO t_wl6455 VALUES(3, ST_GeomFromText(@mp));
INSERT INTO t_wl6455 VALUES(4, LINESTRING(POINT(1,1), POINT(4, 4)));
INSERT INTO t_wl6455 VALUES(5, LINESTRING(POINT(2,2), POINT(5, 5)));
SET @mls = 'MultiLineString((1 1,2 2,3 3),(4 4,5 5))';
INSERT INTO t_wl6455 VALUES(6, ST_GeomFromText(@mls));
SET @poly = 'Polygon((0 0,0 3,3 0,0 0),(1 1,1 2,2 1,1 1))';
INSERT INTO t_wl6455 VALUES(7, ST_GeomFromText(@poly));
SET @mpoly = 'MultiPolygon(((0 0,0 3,3 3,3 0,0 0),(1 1,1 2,2 2,2 1,1 1)))';
INSERT INTO t_wl6455 VALUES(8, ST_GeomFromText(@mpoly));
SET @gc = 'GeometryCollection(Point(1 1),LineString(2 2, 3 3))';
INSERT INTO t_wl6455 VALUES(9, ST_GeomFromText(@gc));
SELECT ST_AsText(g) FROM t_wl6455;
ST_AsText(g)
POINT(1 1)
POINT(2 2)
MULTIPOINT((0 0),(20 20),(60 60))
LINESTRING(1 1,4 4)
LINESTRING(2 2,5 5)
MULTILINESTRING((1 1,2 2,3 3),(4 4,5 5))
POLYGON((0 0,0 3,3 0,0 0),(1 1,1 2,2 1,1 1))
MULTIPOLYGON(((0 0,0 3,3 3,3 0,0 0),(1 1,1 2,2 2,2 1,1 1)))
GEOMETRYCOLLECTION(POINT(1 1),LINESTRING(2 2,3 3))
CREATE INDEX i_p ON t_wl6455 (g(10));
EXPLAIN SELECT ST_AsText(g) FROM t_wl6455 WHERE g = POINT(2,2);
id select_type table partitions type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t_wl6455 NULL ref i_p i_p 12 const # 100.00 Using where
Warnings:
Note 1003 /* select#1 */ select st_astext(`test`.`t_wl6455`.`g`) AS `ST_AsText(g)` from `test`.`t_wl6455` where (`test`.`t_wl6455`.`g` = <cache>(point(2,2)))
SELECT ST_AsText(g) FROM t_wl6455 WHERE g = POINT(2,2);
ST_AsText(g)
POINT(2 2)
SET AUTOCOMMIT = 0;
INSERT INTO t_wl6455 VALUES(10, POINT(10,10));
SELECT ST_AsText(g) FROM t_wl6455 WHERE g = POINT(10,10);
ST_AsText(g)
POINT(10 10)
ROLLBACK;
SELECT ST_AsText(g) FROM t_wl6455 WHERE g = POINT(10,10);
ST_AsText(g)
INSERT INTO t_wl6455 VALUES(10, POINT(10,10));
COMMIT;
INSERT INTO t_wl6455 VALUES(11, POINT(11,11));
BEGIN;
INSERT INTO t_wl6455 VALUES(1, POINT(1,1));
# Kill and restart
CHECK TABLE t_wl6455;
Table Op Msg_type Msg_text
test.t_wl6455 check status OK
SELECT ST_AsText(g) FROM t_wl6455;
ST_AsText(g)
POINT(1 1)
POINT(2 2)
MULTIPOINT((0 0),(20 20),(60 60))
LINESTRING(1 1,4 4)
LINESTRING(2 2,5 5)
MULTILINESTRING((1 1,2 2,3 3),(4 4,5 5))
POLYGON((0 0,0 3,3 0,0 0),(1 1,1 2,2 1,1 1))
MULTIPOLYGON(((0 0,0 3,3 3,3 0,0 0),(1 1,1 2,2 2,2 1,1 1)))
GEOMETRYCOLLECTION(POINT(1 1),LINESTRING(2 2,3 3))
POINT(10 10)
POINT(11 11)
SELECT sc.name, sc.pos, sc.mtype
FROM information_schema.innodb_sys_columns sc
INNER JOIN information_schema.innodb_sys_tables st
ON sc.TABLE_ID=st.TABLE_ID
WHERE st.NAME='test/t_wl6455' AND sc.NAME='g';
name pos mtype
g 1 14
DROP TABLE t_wl6455;
create table t1 (c1 int, c2 geometry not null, spatial index (c2))engine=innodb;
create procedure insert_t1(IN total int)
begin
declare i int default 1;
while (i <= total) DO
insert into t1 values (i, Point(i, i));
set i = i + 1;
end while;
end|
CALL insert_t1(70000);
CALL insert_t1(90);
CALL insert_t1(90);
CALL insert_t1(83);
insert into t1 values (0, Point(0.9, 0.9));
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
drop procedure insert_t1;
drop table t1;
#********************************************************
# Bug 16236208 - GEOMETRY : SERVER CRASHES IN
# SEL_TREES_CAN_BE_ORED WHEN THE QUERY USES GIS COLS.
#********************************************************
--source include/have_geometry.inc
--source include/not_embedded.inc
--disable_warnings
DROP TABLE IF EXISTS linestring;
--enable_warnings
CREATE TABLE linestring (pk INTEGER NOT NULL PRIMARY KEY, linestring_key
GEOMETRY NOT NULL, linestring_nokey GEOMETRY NOT NULL) ENGINE=InnoDB ;
INSERT INTO linestring (pk, linestring_key, linestring_nokey) VALUES (1,
ST_GeomFromText('POINT(10 10) '), ST_GeomFromText('POINT(10 10) '));
INSERT INTO linestring (pk, linestring_key, linestring_nokey) VALUES (2,
ST_GeomFromText('LINESTRING(10 10,20 20,30 30)'), ST_GeomFromText('LINESTRING(10
10,20 20,30 30)'));
INSERT INTO linestring (pk, linestring_key, linestring_nokey) VALUES (3,
ST_GeomFromText('POLYGON((0 0,5 5,10 10,15 15,0 0),(10 10,20 20,30 30,40 40,10
10))'), ST_GeomFromText('POLYGON((0 0,5 5,10 10,15 15,0 0),(10 10,20 20,30 30,40
40,10 10))'));
INSERT INTO linestring (pk, linestring_key, linestring_nokey) VALUES (4,
ST_GeomFromText('MULTIPOINT(0 0,5 5,10 10,20 20) '), ST_GeomFromText('MULTIPOINT(0
0,5 5,10 10,20 20) '));
INSERT INTO linestring (pk, linestring_key, linestring_nokey) VALUES (5,
ST_GeomFromText('MULTILINESTRING((1 1,2 2,3 3),(10 10,20 20,30 30))'),
ST_GeomFromText('MULTILINESTRING((1 1,2 2,3 3),(10 10,20 20,30 30))'));
INSERT INTO linestring (pk, linestring_key, linestring_nokey) VALUES (6,
ST_GeomFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73
9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))'),
ST_GeomFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73
9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))'));
INSERT INTO linestring (pk, linestring_key, linestring_nokey) VALUES (7,
ST_GeomFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))'),
ST_GeomFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))'));
CREATE INDEX linestring_index ON linestring(linestring_nokey(5));
ALTER TABLE linestring ADD KEY (linestring_key(5));
--error ER_GIS_INVALID_DATA
SELECT ST_AsText(linestring_nokey) FROM linestring FORCE KEY (
linestring_key ) WHERE ST_CONTAINS( ST_GeomFromText('POLYGON( ( 3923 2815 , 4246
2122 , 4028 2971 , 4017 3019 , 3923 2815 ) )') , linestring_key ) AND
ST_WITHIN( ST_GeomFromText('POLYGON( ( 4135 3009 , 4914 3087 , 4236 3194 , 4091
3036 , 4022 3004 , 4087 3004 , 3853 2825 , 3490 3118 , 3784 3141 , 4052 3072
, 4205 2787 , 4024 2951 , 4076 3036 , 4041 3053 , 3789 3401 , 4080 3100 ,
4169 2867 , 4056 3029 , 4715 3943 , 4052 3098 , 4035 3080 , 4013 3077 , 4218
2915 , 3789 2980 , 4058 3046 , 4042 3043 , 4135 3009 ) )') , linestring_nokey
) AND ST_CONTAINS( ST_GeomFromText('POLYGON( ( 4082 2842 , 3678 3647 , 3420 3068
, 4018 3030 , 4082 2842 ) )') , linestring_key ) OR ST_INTERSECTS(
ST_GeomFromText('MULTILINESTRING( ( 4147 2871 , 4072 3042 , 4081 3099 , 3796
3021 , 4007 3463 ) , ( 4042 2808 , 4109 2816 , 3730 3673 ) )') ,
linestring_key ) AND ST_Length( linestring_nokey ) > 1;
DROP TABLE linestring;
#********************************************************
# Bug 16266012 - GEOMETRY : SERVER CRASHES IN
# COLLECTION_INIT_FROM_OPRESULT
#********************************************************
--source include/have_geometry.inc
--source include/not_embedded.inc
--source include/have_debug.inc
--error ER_BOOST_GEOMETRY_OVERLAY_INVALID_INPUT_EXCEPTION
SELECT ST_WITHIN( LINESTRINGFROMTEXT(' LINESTRING( 5 9 , 3 4 , 4 1 , 4
4 , 4 9 ) ') , ST_SYMDIFFERENCE( ST_UNION( ST_ENVELOPE( POLYGONFROMTEXT('
POLYGON( ( 3 2 , 0 6 , 2 3 , 8 0 , 4 6 , 7 2 , 3 2 ) ) ') ) ,
MULTIPOLYGONFROMTEXT('
MULTIPOLYGON( ( ( 0 0 , 7 1 , 6 8 , 0 0 ) ) , ( ( 9 9 , 4 0 , 4 7 , 9 9) ) )
') ) , ST_SYMDIFFERENCE( POLYGONFROMTEXT(' POLYGON( ( 9 9 , 6 5 , 2 3 , 9 9
) ) ') , MULTIPOLYGONFROMTEXT(' MULTIPOLYGON( ( ( 2 2 , 5 2 , 5 2 , 2 6 , 2
2 ) ) , ( ( 7 7 , 3 7 , 2 9 , 7 1 , 7 7 ) ) ) ') ) ) );
#********************************************************
# Bug 17057168 - LARGE PERFORMANCE REGRESSION FOR INNODB
# GEOMETRY/SPATIAL INDEX LOOKUP
#********************************************************
--source include/have_geometry.inc
--source include/not_embedded.inc
--source include/no_valgrind_without_big.inc
CREATE DATABASE geotest;
use geotest;
CREATE TABLE tmp (id int unsigned NOT NULL PRIMARY KEY);
INSERT INTO tmp VALUES (0), (1), (2), (3), (4), (5), (6), (7), (8), (9);
INSERT INTO tmp SELECT 10+id FROM tmp;
INSERT INTO tmp SELECT 20+id FROM tmp;
INSERT INTO tmp SELECT 40+id FROM tmp;
INSERT INTO tmp SELECT 80+id FROM tmp;
CREATE TABLE t1 (id int unsigned NOT NULL auto_increment PRIMARY KEY,
location point, INDEX (location)) ENGINE=InnoDB;
INSERT INTO t1 (location) SELECT POINT(tmp1.id, tmp2.id) FROM tmp tmp1,
tmp tmp2 ORDER BY tmp1.id, tmp2.id;
#Befor fix, the row number will be the total number of index recs,
#After fix, the row number will be 1.
EXPLAIN SELECT id, ST_AsText(location) FROM t1 WHERE location = POINT(1,
2);
SELECT id, ST_AsText(location) FROM t1 WHERE location = POINT(1, 2);
DROP TABLE t1;
DROP TABLE tmp;
DROP DATABASE geotest;
#********************************************************
# wl6455: GIS Datatypes covers the following tests.
# DDL: ALTER PRIMARY, DROP KEY,INDEX,COLUMN TYPE etc
# INSERT/SELECT operations with WKT & WKB functions
# SELECT/DELETE/UPDATE with =,>,< predicate conditions
# Datatypes with Procedure (IN/INOUT/OUT,Cursors,Trigger)
# Datatypes with Aggregate functions
# File Formts Compressed & Dynamic
# All Geometric functions.
#********************************************************
--source include/have_geometry.inc
--source include/not_embedded.inc
--source include/have_debug.inc
--source include/have_innodb_zip.inc
SET default_storage_engine=InnoDB;
SET innodb_strict_mode=OFF;
# Turn on the geometry data print.
SET SESSION debug="+d,row_print_geometry_data";
SHOW VARIABLES LIKE '%engine%';
#
# Spatial objects
#
USE test;
--disable_warnings
DROP TABLE IF EXISTS t1, gis_point, gis_line, gis_polygon;
DROP TABLE IF EXISTS gis_multi_point, gis_multi_line, gis_multi_polygon;
DROP TABLE IF EXISTS gis_geometrycollection, gis_geometry;
DROP TABLE IF EXISTS tab,tab2,tab3,parent,emp2;
DROP PROCEDURE IF EXISTS geominout;
DROP PROCEDURE IF EXISTS geom_insert;
DROP TRIGGER IF EXISTS geom_trigger;
DROP PROCEDURE IF EXISTS geom_cursor;
--enable_warnings
CREATE TABLE gis_point (fid INTEGER NOT NULL PRIMARY KEY, g POINT) ENGINE=InnoDB;
CREATE TABLE gis_line (fid INTEGER NOT NULL PRIMARY KEY, g LINESTRING) ENGINE=InnoDB;
CREATE TABLE gis_polygon (fid INTEGER NOT NULL PRIMARY KEY, g POLYGON) ENGINE=InnoDB;
CREATE TABLE gis_multi_point (fid INTEGER NOT NULL PRIMARY KEY, g MULTIPOINT) ENGINE=InnoDB;
CREATE TABLE gis_multi_line (fid INTEGER NOT NULL PRIMARY KEY, g MULTILINESTRING) ENGINE=InnoDB;
CREATE TABLE gis_multi_polygon (fid INTEGER NOT NULL PRIMARY KEY, g MULTIPOLYGON) ENGINE=InnoDB;
CREATE TABLE gis_geometrycollection (fid INTEGER NOT NULL PRIMARY KEY, g GEOMETRYCOLLECTION) ENGINE=InnoDB;
CREATE TABLE gis_geometry (fid INTEGER NOT NULL PRIMARY KEY, g GEOMETRY) ENGINE=InnoDB;
SHOW FIELDS FROM gis_point;
SHOW FIELDS FROM gis_line;
SHOW FIELDS FROM gis_polygon;
SHOW FIELDS FROM gis_multi_point;
SHOW FIELDS FROM gis_multi_line;
SHOW FIELDS FROM gis_multi_polygon;
SHOW FIELDS FROM gis_geometrycollection;
SHOW FIELDS FROM gis_geometry;
--echo #INSERT using all WKT & WKB functions
INSERT INTO gis_point VALUES
(101, ST_PointFromText('POINT(10 10)')),
(102, ST_PointFromText('POINT(20 10)')),
(103, ST_PointFromText('POINT(20 20)')),
(104, ST_PointFromWKB(ST_AsWKB(ST_PointFromText('POINT(10 20)'))));
INSERT INTO gis_line VALUES
(105, ST_LineFromText('LINESTRING(0 0,0 10,10 0)')),
(106, ST_LineStringFromText('LINESTRING(10 10,20 10,20 20,10 20,10 10)')),
(107, ST_LineStringFromWKB(ST_AsWKB(LineString(Point(10, 10), Point(40, 10)))));
INSERT INTO gis_polygon VALUES
(108, ST_PolygonFromText('POLYGON((10 10,20 10,20 20,10 20,10 10))')),
(109, ST_PolyFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))')),
(110, ST_PolyFromWKB(ST_AsWKB(Polygon(LineString(Point(0, 0), Point(30, 0), Point(30, 30), Point(0, 0))))));
INSERT INTO gis_multi_point VALUES
(111, ST_MultiPointFromText('MULTIPOINT(0 0,10 10,10 20,20 20)')),
(112, ST_MPointFromText('MULTIPOINT(1 1,11 11,11 21,21 21)')),
(113, ST_MPointFromWKB(ST_AsWKB(MultiPoint(Point(3, 6), Point(4, 10)))));
INSERT INTO gis_multi_line VALUES
(114, ST_MultiLineStringFromText('MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))')),
(115, ST_MLineFromText('MULTILINESTRING((10 48,10 21,10 0))')),
(116, ST_MLineFromWKB(ST_AsWKB(MultiLineString(LineString(Point(1, 2), Point(3, 5)), LineString(Point(2, 5), Point(5, 8), Point(21, 7))))));
INSERT INTO gis_multi_polygon VALUES
(117, ST_MultiPolygonFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),
((59 18,67 18,67 13,59 13,59 18)))')),
(118, ST_MPolyFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),
(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))')),
(119, ST_MPolyFromWKB(ST_AsWKB(MultiPolygon(Polygon(LineString(Point(0, 3), Point(3, 3), Point(3, 0), Point(0, 3)))))));
INSERT INTO gis_geometrycollection VALUES
(120, ST_GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')),
(121, ST_GeometryCollectionFromText('GEOMETRYCOLLECTION(POINT(10 10), LINESTRING(10 10,20 20))')),
(122, ST_GeometryFromWKB(ST_AsWKB(GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9))))));
--echo #check INSERT using SELECT query
INSERT into gis_geometry SELECT * FROM gis_point;
INSERT into gis_geometry SELECT * FROM gis_line;
INSERT into gis_geometry SELECT * FROM gis_polygon;
INSERT into gis_geometry SELECT * FROM gis_multi_point;
INSERT into gis_geometry SELECT * FROM gis_multi_line;
INSERT into gis_geometry SELECT * FROM gis_multi_polygon;
INSERT into gis_geometry SELECT * FROM gis_geometrycollection;
--echo #check format coversion functions & spatial values
SELECT fid, ST_AsText(g) FROM gis_point;
SELECT fid, ST_AsText(g) FROM gis_line;
SELECT fid, ST_AsText(g) FROM gis_polygon;
SELECT fid, ST_AsText(g) FROM gis_multi_point;
SELECT fid, ST_AsText(g) FROM gis_multi_line;
SELECT fid, ST_AsText(g) FROM gis_multi_polygon;
SELECT fid, ST_AsText(g) FROM gis_geometrycollection;
SELECT fid, ST_AsText(g) FROM gis_geometry;
--echo #2.1 check DDL functionality on GIS datatypes
CREATE TABLE tab(c1 POINT,c2 LINESTRING,c3 POLYGON,C4 MULTIPOINT,c5 MULTILINESTRING ,
c6 MULTIPOLYGON,c7 GEOMETRYCOLLECTION ,c8 GEOMETRY) ENGINE=InnoDB;
--echo #check information schema for all the columns refer to 14, except POINT which is 15
SELECT sc.name, sc.pos, sc.mtype
FROM information_schema.innodb_sys_columns sc
INNER JOIN information_schema.innodb_sys_tables st
ON sc.TABLE_ID=st.TABLE_ID
WHERE st.NAME='test/tab'
ORDER BY sc.name;
--echo #check Perform convesrion before INSERT using WKT functions
SET @c1=ST_PointFromText('POINT(10 10)');
SET @c2=ST_LineFromText('LINESTRING(10 10,20 20,30 30)');
SET @c3=ST_PolyFromText('POLYGON((0 0,5 5,10 10,15 15,0 0),(10 10,20 20,30 30,40 40,10 10))');
SET @c4=ST_MPointFromText('MULTIPOINT(0 0,5 5,10 10,20 20)');
SET @c5=ST_MLineFromText('MULTILINESTRING((1 1,2 2,3 3),(10 10,20 20,30 30))');
SET @c6=ST_MPolyFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))');
SET @c7=ST_GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))');
SET @c8=ST_GeomCollFromText('GeometryCollection(Point(1 1),LineString(2 2, 3 3))');
--echo #Insert the spatial values
INSERT INTO tab VALUES(@c1,@c2,@c3,@c4,@c5,@c6,@c7,@c8);
--echo #check index on GIS datatypes
CREATE INDEX idx1 on tab(c2(5) DESC) USING BTREE;
CREATE INDEX idx3 on tab(c3(5) ASC) USING BTREE;
CREATE UNIQUE INDEX idx2 on tab(c8(5) ASC) ;
--echo #check equality predicate on the index columns
--replace_column 10 #
EXPLAIN SELECT ST_ASText(c1),ST_AsText(c2),ST_AsText(c8) FROM tab
WHERE c2=ST_LineFromText('LINESTRING(10 10,20 20,30 30)');
--echo #check index with WKB function
--replace_column 10 #
EXPLAIN SELECT ST_ASText(c1),ST_AsText(c2),ST_AsText(c8)
FROM tab WHERE c2=ST_LineStringFromWKB(ST_AsWKB(ST_LineFromText('LINESTRING(10 10,20 20,30 30)')));
--echo #check index with WKT function
--replace_column 10 #
EXPLAIN SELECT ST_ASText(c1),ST_AsText(c2),ST_AsText(c8) FROM tab
WHERE c3=ST_PolyFromText('POLYGON((0 0,5 5,10 10,15 15,0 0),(10 10,20 20,30 30,40 40,10 10))');
--echo #check index with WKB function
--replace_column 10 #
EXPLAIN SELECT ST_ASText(c1),ST_AsText(c2),ST_AsText(c8)
FROM tab
WHERE c3=ST_PolyFromWKB(ST_AsWkB(ST_PolyFromText('POLYGON((0 0,5 5,10 10,15 15,0 0),(10 10,20 20,30 30,40 40,10 10))')));
--echo #check index with WKT function
--replace_column 10 #
EXPLAIN SELECT ST_ASText(c1),ST_AsText(c2),ST_AsText(c8) FROM tab
WHERE c8=ST_GeomCollFromText('GeometryCollection(Point(1 1),LineString(2 2, 3 3))');
--echo #check index with WKB function
--replace_column 10 #
EXPLAIN SELECT ST_ASText(c1),ST_AsText(c2),ST_AsText(c8)
FROM tab
WHERE c8=ST_GeometryFromWKB(ST_AsWKB(ST_GeomCollFromText('GeometryCollection(Point(1 1),LineString(2 2, 3 3))')));
--echo #check range predicate on the index columns
--replace_column 10 #
--error ER_WRONG_ARGUMENTS
EXPLAIN SELECT ST_ASText(c1),ST_AsText(c2),ST_AsText(c8) FROM tab
WHERE c2>=ST_LineFromText('LINESTRING(10 10,20 20,30 30)');
--replace_column 10 #
--error ER_WRONG_ARGUMENTS
EXPLAIN SELECT ST_ASText(c1),ST_AsText(c2),ST_AsText(c8) FROM tab
WHERE c3>=ST_PolyFromText('POLYGON((0 0,5 5,10 10,15 15,0 0),(10 10,20 20,30 30,40 40,10 10))');
--replace_column 10 #
--error ER_WRONG_ARGUMENTS
EXPLAIN SELECT ST_ASText(c1),ST_AsText(c2),ST_AsText(c8) FROM tab
WHERE c8>=ST_GeomCollFromText('GeometryCollection(Point(1 1),LineString(2 2, 3 3))');
--echo #check index with DELETE operation
--replace_column 10 #
EXPLAIN DELETE FROM tab
WHERE c8=ST_GeometryFromWKB(ST_AsWKB(ST_GeomCollFromText('GeometryCollection(Point(1 1),LineString(2 2, 3 3))')));
--echo #check the spatial values
SELECT ST_AsText(c1) FROM tab;
SELECT ST_AsText(c2) FROM tab;
SELECT ST_AsText(c3) FROM tab;
SELECT ST_AsText(c4) FROM tab;
SELECT ST_AsText(c5) FROM tab;
SELECT ST_AsText(c6) FROM tab;
SELECT ST_AsText(c7) FROM tab;
SELECT ST_AsText(c8) From tab;
--echo #check by modify the column type
ALTER TABLE tab MODIFY COLUMN c1 Geometry;
ALTER TABLE tab MODIFY COLUMN c2 Geometry;
ALTER TABLE tab MODIFY COLUMN c3 Geometry;
ALTER TABLE tab MODIFY COLUMN c4 Geometry;
ALTER TABLE tab MODIFY COLUMN c5 Geometry;
ALTER TABLE tab MODIFY COLUMN c6 Geometry;
ALTER TABLE tab MODIFY COLUMN c7 Geometry;
--echo #check column datatypes
SHOW FIELDS FROM tab;
--echo #check the data after modify
SELECT ST_AsText(c1) FROM tab;
SELECT ST_AsText(c2) FROM tab;
SELECT ST_AsText(c3) FROM tab;
SELECT ST_AsText(c4) FROM tab;
SELECT ST_AsText(c5) FROM tab;
SELECT ST_AsText(c6) FROM tab;
SELECT ST_AsText(c7) FROM tab;
SELECT ST_AsText(c8) From tab;
--echo #check by modify the column type
ALTER TABLE tab MODIFY COLUMN c1 POINT;
ALTER TABLE tab MODIFY COLUMN c2 LINESTRING;
ALTER TABLE tab MODIFY COLUMN c3 POLYGON;
ALTER TABLE tab MODIFY COLUMN c4 MULTIPOINT;
ALTER TABLE tab MODIFY COLUMN c5 MULTILINESTRING;
ALTER TABLE tab MODIFY COLUMN c6 MULTIPOLYGON;
ALTER TABLE tab MODIFY COLUMN c7 GEOMETRYCOLLECTION;
--echo #check column datatypes
SHOW FIELDS FROM tab;
--echo #check the data after modify
SELECT ST_AsText(c1) FROM tab;
SELECT ST_AsText(c2) FROM tab;
SELECT ST_AsText(c3) FROM tab;
SELECT ST_AsText(c4) FROM tab;
SELECT ST_AsText(c5) FROM tab;
SELECT ST_AsText(c6) FROM tab;
SELECT ST_AsText(c7) FROM tab;
SELECT ST_AsText(c8) From tab;
--echo #check change the column type
ALTER TABLE tab MODIFY COLUMN c1 BLOB;
--echo #check column datatypes
SHOW CREATE TABLE tab;
--echo #check the data after modify
SELECT ST_AsText(c1) FROM tab;
--echo #change the column name
ALTER TABLE tab CHANGE COLUMN c1 c0 GEOMETRY ;
--echo #check column datatypes
SHOW FIELDS FROM tab;
--echo #add primary key
ALTER TABLE tab ADD PRIMARY KEY pk2(c8(5));
--echo #check columns
SHOW FIELDS FROM tab;
--echo #drop key
ALTER TABLE tab DROP PRIMARY KEY;
--echo #check columns
SHOW FIELDS FROM tab;
--echo #cleanup the table
TRUNCATE TABLE tab;
--echo #check with procedures
delimiter |;
--echo #crate proc with INOUT params
CREATE PROCEDURE geom_insert(IN c1 POINT,IN c2 LINESTRING,IN c3 POLYGON,
IN c4 MULTIPOINT,IN c5 MULTILINESTRING, IN c6 MULTIPOLYGON,IN c7 GEOMETRYCOLLECTION,
IN c8 GEOMETRY)
BEGIN
INSERT INTO tab VALUES(@c1,@c2,@c3,@c4,@c5,@c6,@c7,@c8);
END |
delimiter ;|
--echo #set the spatial values
SET @c1=ST_PointFromText('POINT(10 10)');
SET @c2=ST_LineFromText('LINESTRING(10 10,20 20,30 30)');
SET @c3=ST_PolyFromText('POLYGON((0 0,5 5,10 10,15 15,0 0),(10 10,20 20,30 30,40 40,10 10))');
SET @c4=ST_MPointFromText('MULTIPOINT(0 0,5 5,10 10,20 20)');
SET @c5=ST_MLineFromText('MULTILINESTRING((1 1,2 2,3 3),(10 10,20 20,30 30))');
SET @c6=ST_MPolyFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))');
SET @c7=ST_GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))');
SET @c8=ST_GeomCollFromText('GeometryCollection(Point(1 1),LineString(2 2, 3 3))');
--echo #call the proc
CALL geom_insert(@c1,@c2,@c3,@c4,@c5,@c6,@c7,@c8);
--echo #check the values ofter proc call
SELECT ST_AsText(c0) FROM tab;
SELECT ST_AsText(c2) FROM tab;
SELECT ST_AsText(c3) FROM tab;
SELECT ST_AsText(c4) FROM tab;
SELECT ST_AsText(c5) FROM tab;
SELECT ST_AsText(c6) FROM tab;
SELECT ST_AsText(c7) FROM tab;
SELECT ST_AsText(c8) From tab;
--echo #set the input spatial value
SET @c9=ST_GeomCollFromText('GeometryCollection(Point(1 1),LineString(2 2, 3 3))');
delimiter |;
--echo #crate a proc with INOUT params and pass a value.
CREATE PROCEDURE geominout(INOUT c9 GEOMETRY)
BEGIN
SELECT ST_AsText(@c9);
SET c9=ST_GeomCollFromText('GeometryCollection(Point(10 10),LineString(20 20, 30 30))');
END|
delimiter ;|
--echo #call the proc and then change the spatial value of c8
CALL geominout(@c9);
--echo #now check the out spatial values should be changed to new values
SELECT ST_AsText(@c9);
#check GIS datatype with Triggers
--echo #delete the records
TRUNCATE TABLE tab;
--echo #create another table same as tab
CREATE TABLE tab2 AS SELECT * FROM tab;
--echo #check the table definition
SHOW CREATE TABLE tab2;
delimiter |;
--echo #create a tigger and populate the values into tab2
CREATE TRIGGER geom_trigger AFTER INSERT ON tab
FOR EACH ROW
BEGIN
INSERT INTO tab2 VALUES (@c1,@c2,@c3,@c4,@c5,@c6,@c7,@c8);
END|
delimiter ;|
--echo #set the spatial values
SET @c1=ST_PointFromText('POINT(10 10)');
SET @c2=ST_LineFromText('LINESTRING(10 10,20 20,30 30)');
SET @c3=ST_PolyFromText('POLYGON((0 0,5 5,10 10,15 15,0 0),(10 10,20 20,30 30,40 40,10 10))');
SET @c4=ST_MPointFromText('MULTIPOINT(0 0,5 5,10 10,20 20)');
SET @c5=ST_MLineFromText('MULTILINESTRING((1 1,2 2,3 3),(10 10,20 20,30 30))');
SET @c6=ST_MPolyFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))');
SET @c7=ST_GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))');
SET @c8=ST_GeomCollFromText('GeometryCollection(Point(1 1),LineString(2 2, 3 3))');
--echo #Insert the spatial values
INSERT INTO tab VALUES(@c1,@c2,@c3,@c4,@c5,@c6,@c7,@c8);
--echo #check the values whether populated
SELECT ST_AsText(c0) FROM tab2;
SELECT ST_AsText(c2) FROM tab2;
SELECT ST_AsText(c3) FROM tab2;
SELECT ST_AsText(c4) FROM tab2;
SELECT ST_AsText(c5) FROM tab2;
SELECT ST_AsText(c6) FROM tab2;
SELECT ST_AsText(c7) FROM tab2;
SELECT ST_AsText(c8) From tab2;
--echo #check Cursor with Geometry
delimiter |;
CREATE PROCEDURE geom_cursor()
BEGIN
DECLARE v GEOMETRY;
DECLARE c CURSOR FOR SELECT c8 FROM tab2;
OPEN c;
FETCH c INTO v;
CLOSE c;
SELECT ST_AsText(v);
END|
delimiter ;|
--echo # the following line was commented due the Bug#16282246
--echo # Once it is fixed, the comment will be removed.
--echo # right now bug fixing date is unknown.
#CALL geom_cursor();
--echo check self join
SELECT ST_AsText(a.c0),ST_AsText(a.c2),ST_AsText(a.c3)
FROM tab a,tab2 b WHERE a.c0=b.c0 AND a.c2=b.c2
AND a.c3=b.c3 AND a.c4=b.c4 AND a.c5=b.c5 AND a.c6=b.c6
AND a.c7=b.c7 AND a.c8=b.c8;
--echo #check equi join
SELECT ST_AsText(a.c2),ST_AsText(b.c2) FROM tab a,tab2 b WHERE a.c2=b.c2;
--echo #check DELETE stmt with Where clause and a constant predicate
DELETE FROM tab
Where c8=c8=ST_GeometryFromWKB(ST_AsWKB(ST_GeomCollFromText('GeometryCollection(Point(1 1),LineString(2 2, 3 3))')));
--echo #check the data, should 0
SELECT COUNT(*) FROM tab;
--echo #check UPDATE stmt with Where clause and a constant predicate
SET @c8=ST_GeomCollFromText('GeometryCollection(Point(10 10),LineString(20 20, 30 30))');
UPDATE tab2 SET c8=@c8
WHERE c2=ST_LineStringFromWKB(ST_AsWKB(ST_LineFromText('LINESTRING(10 10,20 20,30 30)')));
--echo #check the column should be modified to LINESTRING(10 10,20 20,30 30)
SELECT ST_AsText(c8) From tab2;
--echo #check GIS datatypes with aggregate functions
SELECT COUNT(ST_AsText(g)) FROM gis_point;
SELECT COUNT(ST_AsText(g)) FROM gis_line;
SELECT COUNT(ST_AsText(g)) FROM gis_polygon;
SELECT COUNT(ST_AsText(g)) FROM gis_multi_point;
SELECT COUNT(ST_AsText(g)) FROM gis_multi_line;
SELECT COUNT(ST_AsText(g)) FROM gis_multi_polygon;
SELECT COUNT(ST_AsText(g)) FROM gis_geometrycollection;
SELECT COUNT(ST_AsText(g)) FROM gis_geometry;
SELECT SUM(ST_AsText(g)) FROM gis_point;
SELECT SUM(ST_AsText(g)) FROM gis_line;
SELECT AVG(ST_AsText(g)) FROM gis_polygon;
--echo #here it show some string value no meaning
SELECT MAX(ST_AsText(g)) FROM gis_multi_point;
--echo #here it show some string value no meaning
SELECT MIN(ST_AsText(g)) FROM gis_multi_line;
SELECT STD(ST_AsText(g)) FROM gis_multi_polygon;
SELECT COUNT(ST_AsText(g)) FROM gis_geometrycollection;
SELECT AVG(ST_AsText(g)) FROM gis_geometry;
--disable_warnings
--echo #check Datatypes with compression tables
CREATE TABLE tab3(c1 POINT,c2 LINESTRING,c3 POLYGON,C4 MULTIPOINT,c5 MULTILINESTRING ,
c6 MULTIPOLYGON,c7 GEOMETRYCOLLECTION ,c8 GEOMETRY) ENGINE=InnoDB
KEY_BLOCK_SIZE=8 ROW_FORMAT=COMPRESSED;
--echo #check file format
SHOW CREATE TABLE tab3;
ALTER TABLE tab3 KEY_BLOCK_SIZE=16 ROW_FORMAT=Dynamic;
--echo #check file format
SHOW CREATE TABLE tab3;
--echo #check information schema for all the columns refer to 14, except POINT which is 15
SELECT sc.name, sc.pos, sc.mtype
FROM information_schema.innodb_sys_columns sc
INNER JOIN information_schema.innodb_sys_tables st
ON sc.TABLE_ID=st.TABLE_ID
WHERE st.NAME='test/tab3'
ORDER BY sc.name;
--echo #check Perform convesrion before INSERT using WKT functions
SET @c1=ST_PointFromText('POINT(10 10)');
SET @c2=ST_LineFromText('LINESTRING(10 10,20 20,30 30)');
SET @c3=ST_PolyFromText('POLYGON((0 0,5 5,10 10,15 15,0 0),(10 10,20 20,30 30,40 40,10 10))');
SET @c4=ST_MPointFromText('MULTIPOINT(0 0,5 5,10 10,20 20)');
SET @c5=ST_MLineFromText('MULTILINESTRING((1 1,2 2,3 3),(10 10,20 20,30 30))');
SET @c6=ST_MPolyFromText('MULTIPOLYGON(((28 26,28 0,84 0,84 42,28 26),(52 18,66 23,73 9,48 6,52 18)),((59 18,67 18,67 13,59 13,59 18)))');
SET @c7=ST_GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))');
SET @c8=ST_GeomCollFromText('GeometryCollection(Point(1 1),LineString(2 2, 3 3))');
--echo #Insert the spatial values
INSERT INTO tab3 VALUES(@c1,@c2,@c3,@c4,@c5,@c6,@c7,@c8);
--echo #check index on GIS datatypes
CREATE INDEX idx1 on tab3(c2(5) DESC) USING BTREE;
CREATE INDEX idx3 on tab3(c3(5) ASC) USING BTREE;
CREATE UNIQUE INDEX idx2 on tab3(c8(5) ASC) ;
--enable_warnings
--echo #check equality predicate on the index columns
--replace_column 10 #
EXPLAIN SELECT ST_ASText(c1),ST_AsText(c2),ST_AsText(c8) FROM tab3
WHERE c2=ST_LineFromText('LINESTRING(10 10,20 20,30 30)');
--echo #check index with WKB function
--replace_column 10 #
EXPLAIN SELECT ST_ASText(c1),ST_AsText(c2),ST_AsText(c8)
FROM tab3 WHERE c2=ST_LineStringFromWKB(ST_AsWKB(ST_LineFromText('LINESTRING(10 10,20 20,30 30)')));
--echo #check index with WKT function
--replace_column 10 #
EXPLAIN SELECT ST_ASText(c1),ST_AsText(c2),ST_AsText(c8) FROM tab3
WHERE c3=ST_PolyFromText('POLYGON((0 0,5 5,10 10,15 15,0 0),(10 10,20 20,30 30,40 40,10 10))');
--echo #check index with WKB function
--replace_column 10 #
EXPLAIN SELECT ST_ASText(c1),ST_AsText(c2),ST_AsText(c8)
FROM tab3
WHERE c3=ST_PolyFromWKB(ST_AsWkB(ST_PolyFromText('POLYGON((0 0,5 5,10 10,15 15,0 0),(10 10,20 20,30 30,40 40,10 10))')));
--echo #check index with WKT function
--replace_column 10 #
EXPLAIN SELECT ST_ASText(c1),ST_AsText(c2),ST_AsText(c8) FROM tab3
WHERE c8=ST_GeomCollFromText('GeometryCollection(Point(1 1),LineString(2 2, 3 3))');
--echo #check index with WKB function
--replace_column 10 #
EXPLAIN SELECT ST_ASText(c1),ST_AsText(c2),ST_AsText(c8)
FROM tab3
WHERE c8=ST_GeometryFromWKB(ST_AsWKB(ST_GeomCollFromText('GeometryCollection(Point(1 1),LineString(2 2, 3 3))')));
--echo #check range predicate on the index columns
--replace_column 10 #
--error ER_WRONG_ARGUMENTS
EXPLAIN SELECT ST_ASText(c1),ST_AsText(c2),ST_AsText(c8) FROM tab3
WHERE c2>=ST_LineFromText('LINESTRING(10 10,20 20,30 30)');
--replace_column 10 #
--error ER_WRONG_ARGUMENTS
EXPLAIN SELECT ST_ASText(c1),ST_AsText(c2),ST_AsText(c8) FROM tab3
WHERE c3>=ST_PolyFromText('POLYGON((0 0,5 5,10 10,15 15,0 0),(10 10,20 20,30 30,40 40,10 10))');
--replace_column 10 #
--error ER_WRONG_ARGUMENTS
EXPLAIN SELECT ST_ASText(c1),ST_AsText(c2),ST_AsText(c8) FROM tab3
WHERE c8>=ST_GeomCollFromText('GeometryCollection(Point(1 1),LineString(2 2, 3 3))');
--echo #check index with DELETE operation
--replace_column 10 #
EXPLAIN DELETE FROM tab3
WHERE c8=ST_GeometryFromWKB(ST_AsWKB(ST_GeomCollFromText('GeometryCollection(Point(1 1),LineString(2 2, 3 3))')));
--echo #check the spatial values
SELECT ST_AsText(c1) FROM tab3;
SELECT ST_AsText(c2) FROM tab3;
SELECT ST_AsText(c3) FROM tab3;
SELECT ST_AsText(c4) FROM tab3;
SELECT ST_AsText(c5) FROM tab3;
SELECT ST_AsText(c6) FROM tab3;
SELECT ST_AsText(c7) FROM tab3;
SELECT ST_AsText(c8) From tab3;
--echo #check with Row_format = Dynamic
--disable_warnings
ALTER TABLE tab3 ROW_FORMAT=Dynamic;
--enable_warnings
--echo #check file format
SHOW CREATE TABLE tab3;
--echo #check index with WKB function
--replace_column 10 #
EXPLAIN SELECT ST_ASText(c1),ST_AsText(c2),ST_AsText(c8)
FROM tab3 WHERE c2=ST_LineStringFromWKB(ST_AsWKB(ST_LineFromText('LINESTRING(10 10,20 20,30 30)')));
--echo #check index with WKT function
--replace_column 10 #
EXPLAIN SELECT ST_ASText(c1),ST_AsText(c2),ST_AsText(c8) FROM tab3
WHERE c3=ST_PolyFromText('POLYGON((0 0,5 5,10 10,15 15,0 0),(10 10,20 20,30 30,40 40,10 10))');
--echo #check the Geometry property functions
SELECT fid, ST_Dimension(g) FROM gis_geometry;
SELECT fid, ST_GeometryType(g) FROM gis_geometry;
SELECT fid, ST_IsEmpty(g) FROM gis_geometry;
SELECT fid, ST_AsText(ST_Envelope(g)) FROM gis_geometry;
--replace_column 10 #
explain extended select ST_Dimension(g), ST_GeometryType(g), ST_IsEmpty(g), ST_AsText(ST_Envelope(g)) from gis_geometry;
--echo #check Geometry point functions
SELECT fid, ST_X(g) FROM gis_point;
SELECT fid, ST_Y(g) FROM gis_point;
--replace_column 10 #
explain extended select ST_X(g),ST_Y(g) FROM gis_point;
SELECT fid, ST_AsText(ST_StartPoint(g)) FROM gis_line;
SELECT fid, ST_AsText(ST_EndPoint(g)) FROM gis_line;
SELECT fid, ST_Length(g) FROM gis_line;
SELECT fid, ST_NumPoints(g) FROM gis_line;
SELECT fid, ST_AsText(ST_PointN(g, 2)) FROM gis_line;
SELECT fid, ST_IsClosed(g) FROM gis_line;
--replace_column 10 #
explain extended select ST_AsText(ST_StartPoint(g)),ST_AsText(ST_EndPoint(g)),
ST_Length(g),ST_NumPoints(g),ST_AsText(ST_PointN(g, 2)),ST_IsClosed(g) FROM gis_line;
SELECT fid, ST_AsText(ST_Centroid(g)) FROM gis_polygon;
SELECT fid, ST_Area(g) FROM gis_polygon;
SELECT fid, ST_AsText(ST_ExteriorRing(g)) FROM gis_polygon;
SELECT fid, ST_NumInteriorRings(g) FROM gis_polygon;
SELECT fid, ST_AsText(ST_InteriorRingN(g, 1)) FROM gis_polygon;
--replace_column 10 #
explain extended select ST_AsText(ST_Centroid(g)),ST_Area(g),ST_AsText(ST_ExteriorRing(g)),
ST_NumInteriorRings(g),ST_AsText(ST_InteriorRingN(g, 1)) FROM gis_polygon;
SELECT fid, ST_IsClosed(g) FROM gis_multi_line;
SELECT fid, ST_AsText(ST_Centroid(g)) FROM gis_multi_polygon;
SELECT fid, ST_Area(g) FROM gis_multi_polygon;
SELECT fid, ST_NumGeometries(g) from gis_multi_point;
SELECT fid, ST_NumGeometries(g) from gis_multi_line;
SELECT fid, ST_NumGeometries(g) from gis_multi_polygon;
SELECT fid, ST_NumGeometries(g) from gis_geometrycollection;
--replace_column 10 #
explain extended SELECT fid, ST_NumGeometries(g) from gis_multi_point;
SELECT fid, ST_AsText(ST_GeometryN(g, 2)) from gis_multi_point;
SELECT fid, ST_AsText(ST_GeometryN(g, 2)) from gis_multi_line;
SELECT fid, ST_AsText(ST_GeometryN(g, 2)) from gis_multi_polygon;
SELECT fid, ST_AsText(ST_GeometryN(g, 2)) from gis_geometrycollection;
SELECT fid, ST_AsText(ST_GeometryN(g, 1)) from gis_geometrycollection;
--replace_column 10 #
explain extended SELECT fid, ST_AsText(ST_GeometryN(g, 2)) from gis_multi_point;
SELECT g1.fid as first, g2.fid as second,
MBRWithin(g1.g, g2.g) as w, MBRContains(g1.g, g2.g) as c, MBROverlaps(g1.g, g2.g) as o,
MBREquals(g1.g, g2.g) as e, MBRDisjoint(g1.g, g2.g) as d, ST_Touches(g1.g, g2.g) as t,
MBRIntersects(g1.g, g2.g) as i, ST_Crosses(g1.g, g2.g) as r
FROM gis_geometrycollection g1, gis_geometrycollection g2 ORDER BY first, second;
--replace_column 10 #
explain extended SELECT g1.fid as first, g2.fid as second,
MBRWithin(g1.g, g2.g) as w, MBRContains(g1.g, g2.g) as c, MBROverlaps(g1.g, g2.g) as o,
MBREquals(g1.g, g2.g) as e, MBRDisjoint(g1.g, g2.g) as d, ST_Touches(g1.g, g2.g) as t,
MBRIntersects(g1.g, g2.g) as i, ST_Crosses(g1.g, g2.g) as r
FROM gis_geometrycollection g1, gis_geometrycollection g2 ORDER BY first, second;
--echo # check support of Foreign Key constraint
CREATE TABLE parent (id GEOMETRY NOT NULL,PRIMARY KEY (id(10))) ENGINE=INNODB;
--error 1215
CREATE TABLE child (id GEOMETRY, parent_id GEOMETRY,
INDEX par_ind (parent_id(10)),
FOREIGN KEY (parent_id(10)) REFERENCES parent(id)
ON DELETE CASCADE
) ENGINE=INNODB;
--echo #check partition table support
--error 1178
CREATE TABLE emp2(
id GEOMETRY NOT NULL,
store_name VARCHAR(30),
parts VARCHAR(30),
store_id GEOMETRY
)
PARTITION BY LIST(store_id) (
PARTITION pNorth VALUES IN (10,20,30) ,
PARTITION pEast VALUES IN (40,50,60) ,
PARTITION pWest VALUES IN (70,80,100)
);
--echo #check start transaction commit & Rollback
START TRANSACTION;
DELETE FROM tab3;
ROLLBACK;
SELECT COUNT(*) FROM tab3;
START TRANSACTION;
DELETE FROM tab3;
COMMIT;
SELECT COUNT(*) FROM tab3;
DROP TABLE IF EXISTS gis_point, gis_line, gis_polygon, gis_multi_point;
DROP TABLE IF EXISTS gis_multi_line, gis_multi_polygon;
DROP TABLE IF EXISTS gis_geometrycollection, gis_geometry;
DROP TABLE IF EXISTS tab,tab2,tab3,parent,emp2;
DROP PROCEDURE IF EXISTS geominout;
DROP PROCEDURE IF EXISTS geom_insert;
DROP TRIGGER IF EXISTS geom_trigger;
DROP PROCEDURE IF EXISTS geom_cursor;
--source include/have_innodb.inc
--source include/have_debug.inc
create table t1(a geometrycollection not null,spatial key(a))engine=innodb;
--error ER_GIS_INVALID_DATA
insert into t1(a) values( geometrycollection(multipolygon(polygon(linestring(point(-14,98), point(-14,98)), linestring(point(-97,64), point(-70,99), point(-97,64)), linestring(point(143851215403059150000000000000000000000.000000,13040009882500140000000000000000000000.000000), point(-73,85), point(-88,-29)))), multipolygon(polygon(linestring(point(41,95), point(4294967298,2050)), linestring(point(-61,85), point(-75,93), point(14,-2), point(1,84), point(-61,85)), linestring(point(-62,52), point(39,5), point(-18,12), point(-62,52))), polygon(linestring(point(-77,1), point(66,61), point(-77,1)), linestring(point(18446744073709551615,1125899906842622), point(-72,49), point(24,-66), point(82,73), point(68,22))), polygon(linestring(point(1048576,17179869181), point(-18,95), point(-90,-3), point(-33,82), point(20,-85)), linestring(point(-43,-97), point(-7,-3), point(39,-82), point(-65,-58), point(-43,-97)), linestring(point(44,-34), point(-69,58), point(44,-34)), linestring(point(57,-13), point(-17,74), point(57,-13)), linestring(point(3,71), point(-58,81), point(3,71)), linestring(point(9,25), point(77,-71), point(8388607,67108864), point(46,46), point(9,25)), linestring(point(98,-82), point(98,-82))))) ) ;
insert into t1(a) values( geometrycollection(multilinestring(linestring(point(39,-60), point(-62,-11), point(-24,35), point(54,1)), linestring(point(-4,69), point(-22,-64), point(1.694824e+308,5.688896e+307), point(-33,-58), point(-64,-80), point(-15,-44), point(40,54)), linestring(point(-86,-54), point(11,41), point(-46,-38), point(-21,-8), point(10,70), point(-81,22), point(-46,-100)), linestring(point(-30,-48), point(50,58), point(-53,92), point(10,41), point(-46,-8)), linestring(point(-65,34), point(-92,93), point(-33,-74), point(75,-28)), linestring(point(25,-55), point(22,-10), point(-42,0), point(-86,-59), point(2,-37), point(63,-44), point(-55,-22)), linestring(point(28,0), point(-94,99), point(-32,-86)), linestring(point(9,-12), point(16,9), point(80,-73)), linestring(point(6,-55), point(83,-4)), linestring(point(-15,21), point(144115188075855876,16777212), point(-85,-31), point(-90,-50)), linestring(point(-33,33), point(21,90), point(-89,32)), linestring(point(16,24), point(73,-13), point(25,-48), point(71,52), point(-54,-78), point(-84,59), point(53,29)), linestring(point(-15,-81), point(83,43), point(-71,33), point(-8,0), point(84,-54), point(-35,38), point(-10,-50)), linestring(point(38,-50), point(20,-2), point(-57,-92)), linestring(point(5,-93), point(231601833467477080000000000000000000000.000000,51914987457169239000000000000000000000.000000), point(-94,62))), point(2,0)) ) ;
insert into t1(a) values( geometrycollection(multilinestring(linestring(point(80,-15), point(65,-57), point(-59,16), point(22,-67)), linestring(point(20,-55), point(-38,-64), point(19,-53), point(-63,-36), point(56,-37)), linestring(point(27,-8), point(-85,-75), point(4398046511106,2251799813685245)), linestring(point(45,32), point(-79,46))), multilinestring(linestring(point(8,-4), point(40,-38), point(100,95), point(5,-80), point(82,88)), linestring(point(-14,30), point(-94,51), point(-16,-29), point(37,-97), point(-26,92)), linestring(point(32,34), point(83,-23), point(-55,57), point(-15,90), point(32,-50), point(-20,-73), point(77,28)), linestring(point(4,88), point(87,74), point(-67,-58)), linestring(point(5.660747e+307,6.385657e+307), point(-58,-15), point(1.172095e+308,1.448533e+308)), linestring(point(-21,-37), point(-52,79), point(-16,-76), point(-65,-94), point(36,7), point(37,74), point(100,-57)), linestring(point(-23,-82), point(-73,23), point(18,-34)), linestring(point(20,-51), point(93,62), point(-65,84)), linestring(point(-48,31), point(-69,-96)), linestring(point(-5,78), point(10,-99), point(36,-33)), linestring(point(-84,55), point(96,1), point(-98,-29), point(-15,81), point(-27,-6), point(58,-32), point(54,-16)), linestring(point(2,5), point(2199023255553,8192)), linestring(point(12,-78), point(-97,-83)), linestring(point(-74,79), point(35,-56), point(50,95)), linestring(point(28,16), point(-39,-40), point(48,-3)), linestring(point(2199023255550,-65539), point(62,-25), point(94,-62)), linestring(point(-74,83), point(-18,75), point(91,17), point(-11,-48), point(30,100)), linestring(point(57,-13), point(88,-45)), linestring(point(20,-64), point(-37,13), point(20,35))), point(-3,-4)) ) ;
--error ER_GIS_INVALID_DATA
insert into t1(a) values( geometrycollection(multipolygon(polygon(linestring(point(-34,19), point(-25,92), point(61921390294166805000000000000000000000.000000,319674749161701840000000000000000000000.000000), point(56,50), point(-34,19)), linestring(point(-26,-58), point(99,-50), point(34,-20), point(-26,-58)), linestring(point(-42,45), point(-63,-7), point(5,-89), point(-97,36), point(-42,45)), linestring(point(94,11), point(-71,4), point(94,11)), linestring(point(16,25), point(4,-33), point(-45,-33), point(-64,-77), point(16,25)), linestring(point(19,45), point(36,45), point(-83,-96), point(19,45)), linestring(point(85,-31), point(-87,52), point(85,-31))), polygon(linestring(point(55,-88), point(63,-12), point(55,-88)), linestring(point(-49,10), point(-49,10)), linestring(point(-51,-32), point(-51,-32)))), multipolygon(polygon(linestring(point(-21,-8), point(66,-58), point(100,-27), point(-21,-8)), linestring(point(-29,-13), point(-29,-13))), polygon(linestring(point(91307574660224730000000000000000000000.000000,101214152547755520000000000000000000000.000000), point(89,64), point(77,87), point(66,29), point(-71,-53)), linestring(point(38,-78), point(-43,-90), point(37,20), point(81,65), point(38,-78))), polygon(linestring(point(51,0), point(-62,8), point(-11,22), point(51,0)), linestring(point(-4,-44), point(6,82), point(-19,-90), point(131,32)))), point(-4,-7)) ) ;
insert into t1(a) values( geometrycollection(point(10,9), linestring(point(2305843009213693955,-1125899906842621), point(78,15)), multipoint(point(-1,3), point(4,-6))) ) ;
--error ER_GIS_INVALID_DATA
insert into t1(a) values( geometrycollection(polygon(linestring(point(0,13), point(-12,5), point(0,13)), linestring(point(11,-2), point(6,6), point(20,-14), point(-3,-10), point(1.330588e+308,2.666476e+307)), linestring(point(16382,67), point(7,4)), linestring(point(2,7), point(-14,15), point(2,7)), linestring(point(-14,12), point(-8,-8), point(-17,-2), point(-14,12)), linestring(point(-20,-10), point(-8,-13), point(-19,-17), point(13,-3), point(-20,-10)), linestring(point(-5,13), point(7,-9), point(6,8), point(-5,13))), linestring(point(-87,19), point(-64,51), point(-16,12)), multipoint(point(-1,-10), point(2,-10), point(3.670354e+307,2.501459e+307))) ) ;
--error ER_GIS_INVALID_DATA
insert into t1(a) values( geometrycollection(multipoint(point(-3,7), point(4,-3), point(-6,-2), point(-9,1)), polygon(linestring(point(-17,-5), point(2,-8), point(-6,9), point(-9,19), point(-17,-5)), linestring(point(10,-1), point(15,-7), point(-13,6), point(10,-1))), multipolygon(polygon(linestring(point(69,-69), point(-90,-64), point(-17,4), point(47,-73), point(69,-69)), linestring(point(-35,-77), point(-35,-77)), linestring(point(95,-76), point(1.636688e+308,1.828723e+307), point(68719476740,536870916), point(95,-76)), linestring(point(-26,-85), point(-26,-85)), linestring(point(-53,57), point(-53,57)), linestring(point(-98,-64), point(79,-57), point(-98,-64)), linestring(point(-91,59), point(16,0), point(73,97), point(-35,-70), point(-91,59))))) ) ;
insert into t1(a) values( geometrycollection(linestring(point(85,-29), point(15,84), point(39,-92), point(-99,19)), multilinestring(linestring(point(63,10), point(-47,95), point(10,-49), point(16,-65), point(-98,40), point(25,44), point(-55,-92)), linestring(point(5.266810e+307,6.648813e+307), point(47,33), point(-15,-13), point(-92,-58), point(36,73)), linestring(point(77,-56), point(-53,-10), point(-28,76), point(-51,6), point(51,-31), point(-95,81), point(92,26)), linestring(point(-91,7), point(58,53)), linestring(point(18,5), point(18,40), point(71,89), point(7.898707e+307,1.202585e+308), point(53,100)), linestring(point(-60,-18), point(-10,-31), point(-6,-25), point(-57,-95), point(16,77)))) ) ;
--error ER_GIS_INVALID_DATA
insert into t1(a) values( geometrycollection(polygon(linestring(point(-9,0), point(-17,-15), point(-9,0)), linestring(point(-11,1), point(18,12), point(15,3), point(7,0), point(-11,1)), linestring(point(19,5), point(19,5)), linestring(point(17,-11), point(8,4), point(17,-11)), linestring(point(14914539334033432000000000000000000000.000000,127247994336690690000000000000000000000.000000), point(-14,-7), point(13,-2))), point(-4,-7), polygon(linestring(point(-18,9), point(11,-1), point(-18,9)), linestring(point(9,-3), point(9,-3)), linestring(point(-7,-9), point(9,-11), point(11,14), point(1.663324e+308,1.572127e+308)), linestring(point(-15,4), point(18,12), point(7,2), point(-15,4)), linestring(point(-15,-18), point(-20,-15), point(1152921504606846972,34359738370))), polygon(linestring(point(-5,-19), point(-11,11), point(10,5), point(-7,13), point(-5,-19)), linestring(point(-8,-6), point(-4,16), point(-8,-6)), linestring(point(-6,-10), point(3,-12), point(-6,-10)), linestring(point(-16,1), point(20,-12), point(-16,1)), linestring(point(-8,5), point(-20,-4), point(4,1), point(-6,-6), point(-8,5)), linestring(point(-8,-11), point(-5,-14), point(-8,-11)), linestring(point(3,-16), point(-15,-13), point(1.166708e+308,1.901147e+307), point(-8,6), point(3,-16))), point(0,-5)) ) ;
insert into t1(a) values( geometrycollection(linestring(point(-33,99), point(99,-87), point(38,-79), point(33,-39), point(-91,-8), point(46,-87))) ) ;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
drop table t1;
--source include/have_innodb.inc
--source include/have_debug.inc
--source include/have_geometry.inc
--source include/have_innodb_4k.inc
############################################################################################
# Creating the spatial objects #
############################################################################################
--echo # Creating the spatial objects
USE test;
CREATE TABLE gis_point (fid INTEGER NOT NULL PRIMARY KEY, g POINT);
CREATE TABLE gis_linestring (fid INTEGER NOT NULL PRIMARY KEY, g LINESTRING);
CREATE TABLE gis_polygon (fid INTEGER NOT NULL PRIMARY KEY, g POLYGON);
CREATE TABLE gis_multi_point (fid INTEGER NOT NULL PRIMARY KEY, g MULTIPOINT);
CREATE TABLE gis_multi_linestring (fid INTEGER NOT NULL PRIMARY KEY, g MULTILINESTRING);
CREATE TABLE gis_multi_polygon (fid INTEGER NOT NULL PRIMARY KEY, g MULTIPOLYGON);
CREATE TABLE gis_geometrycollection (fid INTEGER NOT NULL PRIMARY KEY, g GEOMETRYCOLLECTION);
############################################################################################
# Inserting the values specific to the spatial objects #
############################################################################################
--echo # Inserting POINT Geometry Values
INSERT INTO gis_point VALUES
(101, ST_POINTFROMTEXT('POINT(0 0)')),
(102, ST_POINTFROMTEXT('POINT(1 0)')),
(103, ST_POINTFROMTEXT('POINT(0 1)')),
(104, ST_POINTFROMTEXT('POINT(1 1)')),
(105, ST_POINTFROMTEXT('POINT(-1 1)'));
INSERT INTO gis_point VALUES
(106, ST_POINTFROMWKB(POINT(0,0))),
(107, ST_POINTFROMWKB(POINT(10,0))),
(108, ST_POINTFROMWKB(POINT(0,10))),
(109, ST_POINTFROMWKB(POINT(-10,0))),
(110, ST_POINTFROMWKB(POINT(0,-10)));
INSERT INTO gis_point VALUES
(111, ST_POINTFROMWKB(ST_ASWKB(ST_POINTFROMTEXT('POINT(1 1)')))),
(112, ST_POINTFROMWKB(ST_ASWKB(ST_POINTFROMTEXT('POINT(1e308 1e308)')))),
(113, ST_POINTFROMWKB(ST_ASWKB(ST_POINTFROMTEXT('POINT(1e308 -1e308)')))),
(114, ST_POINTFROMWKB(ST_ASWKB(ST_POINTFROMTEXT('POINT(-1e308 1e308)')))),
(115, ST_POINTFROMWKB(ST_ASWKB(ST_POINTFROMTEXT('POINT(-1e308 -1e308)'))));
--echo # Inserting LINESTRING Geometry Values
INSERT INTO gis_linestring VALUES
(201, ST_LINEFROMTEXT('LINESTRING(0 0,5 5)')),
(202, ST_LINEFROMTEXT('LINESTRING(0 0,2 2,4 4)')),
(203, ST_LINEFROMTEXT('LINESTRING(0 0,5 5,10 10)'));
INSERT INTO gis_linestring VALUES
(204, ST_LINESTRINGFROMTEXT('LINESTRING(10 10,5 5)')),
(205, ST_LINESTRINGFROMTEXT('LINESTRING(0 0,12 12,24 24)')),
(206, ST_LINESTRINGFROMTEXT('LINESTRING(0 0,50 50,100 100)'));
INSERT INTO gis_linestring VALUES
(207, ST_LINEFROMWKB(LINESTRING(POINT(0,0), POINT(5,5)))),
(208, ST_LINEFROMWKB(LINESTRING(POINT(0,0), POINT(-5,-5), POINT(-10,10)))),
(209, ST_LINEFROMWKB(LINESTRING(POINT(0,0), POINT(2,2), POINT(4,4), POINT(6,6), POINT(8,8))));
INSERT INTO gis_linestring VALUES
(210, ST_LINESTRINGFROMWKB(LINESTRING(POINT(0,0), POINT(5,5)))),
(211, ST_LINESTRINGFROMWKB(LINESTRING(POINT(0,0), POINT(-50,-50), POINT(10,-10)))),
(212, ST_LINESTRINGFROMWKB(LINESTRING(POINT(0,0), POINT(1e308,1e308), POINT(1e308,-1e308))));
INSERT INTO gis_linestring VALUES
(213, ST_LINEFROMWKB(ST_ASWKB(ST_LINEFROMTEXT('LINESTRING(1e308 1e308,1e308 -1e308)')))),
(214, ST_LINEFROMWKB(ST_ASWKB(ST_LINEFROMTEXT('LINESTRING(1 1,2 2,3 3,4 4,5 5,6 6,7 7,8 8,9 9)')))),
(215, ST_LINESTRINGFROMWKB(ST_ASWKB(ST_LINESTRINGFROMTEXT('LINESTRING(10 10,10 -10,-10 -10,-10 10,10 10)'))));
--echo # Inserting POLYGON Geometry Values
INSERT INTO gis_polygon VALUES
(301, ST_POLYFROMTEXT('POLYGON((0 0,0 5,5 5,0 0))')),
(302, ST_POLYFROMTEXT('POLYGON((0 0,0 5,5 5,5 0,0 0))')),
(303, ST_POLYFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0))'));
INSERT INTO gis_polygon VALUES
(304, ST_POLYGONFROMTEXT('POLYGON((0 0,0 50,50 50,50 0,0 0))')),
(305, ST_POLYGONFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0,0 0,0 0),(4 4,4 6,6 6,6 4,4 4))')),
(306, ST_POLYGONFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0,0 0,0 0),(2 2,2 4,4 4,4 2,2 2),(6 6,6 8,8 8,8 6,6 6))'));
INSERT INTO gis_polygon VALUES
(307, ST_POLYFROMWKB(POLYGON(LINESTRING(POINT(0,0), POINT(0,5), POINT(5,5), POINT(0,0))))),
(308, ST_POLYFROMWKB(POLYGON(LINESTRING(POINT(0,0), POINT(0,15), POINT(15,15), POINT(15,0), POINT(0,0))))),
(309, ST_POLYFROMWKB(POLYGON(LINESTRING(POINT(0,0), POINT(0,10), POINT(10,10), POINT(10,0), POINT(0,0)),
LINESTRING(POINT(4,4), POINT(4,6), POINT(6,6), POINT(6,4), POINT(4,4)))));
INSERT INTO gis_polygon VALUES
(310, ST_POLYGONFROMWKB(POLYGON(LINESTRING(POINT(0,0), POINT(0,5), POINT(5,5), POINT(0,0))))),
(311, ST_POLYGONFROMWKB(POLYGON(LINESTRING(POINT(10,10), POINT(10,15), POINT(15,15), POINT(15,10), POINT(10,10))))),
(312, ST_POLYGONFROMWKB(POLYGON(LINESTRING(POINT(10,10), POINT(10,20), POINT(20,20), POINT(20,10), POINT(10,10)),
LINESTRING(POINT(14,14), POINT(14,16), POINT(16,16), POINT(16,14), POINT(14,14)))));
INSERT INTO gis_polygon VALUES
(313, ST_POLYFROMWKB(ST_ASWKB(ST_POLYFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0,0 0,5 5,0 0))')))),
(314, ST_POLYFROMWKB(ST_ASWKB(ST_POLYGONFROMTEXT('POLYGON((10 0,10 10,0 10,-10 10,-10 0,-10 -10,0 10,10 -10,10 0))')))),
(315, ST_POLYGONFROMWKB(ST_ASWKB(ST_POLYGONFROMTEXT('POLYGON((0 0,0 10,10 10,10 0,0 0,0 0,0 0),(2 2,2 4,4 4,4 2,2 2),(6 6,6 8,8 8,8 6,6 6))'))));
--echo # Inserting MULTIPOINT Geometry Values
INSERT INTO gis_multi_point VALUES
(401, ST_GEOMFROMTEXT('MULTIPOINT(0 0)')),
(402, ST_GEOMFROMTEXT('MULTIPOINT(0 0,2 2,4 4)')),
(403, ST_GEOMFROMTEXT('MULTIPOINT(0 0,5 5,10 10)'));
INSERT INTO gis_multi_point VALUES
(404, ST_GEOMFROMTEXT('MULTIPOINT(0 0,100 100)')),
(405, ST_GEOMFROMTEXT('MULTIPOINT(0 0,1e308 1e308)')),
(406, ST_GEOMFROMTEXT('MULTIPOINT(1e308 1e308,1e308 -1e308,-1e308 1e308,-1e308 -1e308)'));
INSERT INTO gis_multi_point VALUES
(407, ST_GEOMFROMWKB(MULTIPOINT(POINT(0,0)))),
(408, ST_GEOMFROMWKB(MULTIPOINT(POINT(0,0), POINT(10,10)))),
(409, ST_GEOMFROMWKB(MULTIPOINT(POINT(0,0), POINT(2,2), POINT(4,4), POINT(6,6))));
INSERT INTO gis_multi_point VALUES
(410, ST_GEOMFROMWKB(MULTIPOINT(POINT(0,0)))),
(411, ST_GEOMFROMWKB(MULTIPOINT(POINT(0,0), POINT(1e308,1e308)))),
(412, ST_GEOMFROMWKB(MULTIPOINT(POINT(1e308,1e308), POINT(-1e308,1e308), POINT(1e308,-1e308), POINT(-1e308,-1e308))));
INSERT INTO gis_multi_point VALUES
(413, ST_GEOMFROMWKB(ST_ASWKB(ST_GEOMFROMTEXT('MULTIPOINT(0 0)')))),
(414, ST_GEOMFROMWKB(ST_ASWKB(ST_GEOMFROMTEXT('MULTIPOINT(0 0,1e308 1e308,-1e308 -1e308)')))),
(415, ST_GEOMFROMWKB(ST_ASWKB(ST_GEOMFROMTEXT('MULTIPOINT(1e308 1e308,1e308 -1e308,-1e308 1e308,-1e308 -1e308,1e308 1e308)'))));
--echo # Inserting MULTILINESTRING Geometry Values
INSERT INTO gis_multi_linestring VALUES
(501, ST_GEOMFROMTEXT('MULTILINESTRING((0 0,2 2))')),
(502, ST_GEOMFROMTEXT('MULTILINESTRING((0 0,2 2,4 4))')),
(503, ST_GEOMFROMTEXT('MULTILINESTRING((0 0,2 2,4 4),(6 6,8 8,10 10))'));
INSERT INTO gis_multi_linestring VALUES
(504, ST_GEOMFROMTEXT('MULTILINESTRING((0 0,100 100,-100 -100))')),
(505, ST_GEOMFROMTEXT('MULTILINESTRING((1e308 1e308,-1e308 -1e308))')),
(506, ST_GEOMFROMTEXT('MULTILINESTRING((1e308 1e308,-1e308 -1e308),(1e308 -1e308,-1e308 1e308))'));
INSERT INTO gis_multi_linestring VALUES
(507, ST_GEOMFROMWKB(MULTILINESTRING(LINESTRING(POINT(0,0), POINT(2,2))))),
(508, ST_GEOMFROMWKB(MULTILINESTRING(LINESTRING(POINT(0,0), POINT(12,12), POINT(24,24))))),
(509, ST_GEOMFROMWKB(MULTILINESTRING(LINESTRING(POINT(0,0), POINT(2,2), POINT(4,4)),
LINESTRING(POINT(6,6), POINT(8,8), POINT(10,10)))));
INSERT INTO gis_multi_linestring VALUES
(510, ST_GEOMFROMWKB(MULTILINESTRING(LINESTRING(POINT(0,0), POINT(2,2), POINT(4,4))))),
(511, ST_GEOMFROMWKB(MULTILINESTRING(LINESTRING(POINT(0,0), POINT(1,1), POINT(2,2))))),
(512, ST_GEOMFROMWKB(MULTILINESTRING(LINESTRING(POINT(0,0), POINT(12,12), POINT(24,24)),
LINESTRING(POINT(36,36), POINT(48,48), POINT(50,50)))));
INSERT INTO gis_multi_linestring VALUES
(513, ST_GEOMFROMWKB(ST_ASWKB(ST_GEOMFROMTEXT('MULTILINESTRING((0 0,10 10),(0 10,10 0))')))),
(514, ST_GEOMFROMWKB(ST_ASWKB(ST_GEOMFROMTEXT('MULTILINESTRING((0 0,10 10,-10 10,0 0),(0 0,-10 -10,10 -10,0 0))')))),
(515, ST_GEOMFROMWKB(ST_ASWKB(ST_GEOMFROMTEXT('MULTILINESTRING((0 0,0 100),(0 0,100 0),(0 0,0 -100),(0 0,-100 0))'))));
--echo # Inserting MULTIPOLGYON Geometry Values
INSERT INTO gis_multi_polygon VALUES
(601, ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 5,5 5,0 0)))')),
(602, ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 5,5 5,0 0)),((5 5,5 10,10 10,5 5)))')),
(603, ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0,0 0,0 0),(4 4,4 6,6 6,6 4,4 4)))'));
INSERT INTO gis_multi_polygon VALUES
(604, ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 5,5 5,0 0)))')),
(605, ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0,0 0,0 0),(4 4,4 6,6 6,6 4,4 4)),((0 0,0 -2,-2 -2,0 0)))')),
(606, ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,5 5,-5 5,0 0)),((0 0,-5 -5,5 -5,0 0)))'));
INSERT INTO gis_multi_polygon VALUES
(607, ST_GEOMFROMWKB(MULTIPOLYGON(POLYGON(LINESTRING(POINT(0,0), POINT(5,0), POINT(5,5), POINT(0,5), POINT(0,0)))))),
(608, ST_GEOMFROMWKB(MULTIPOLYGON(POLYGON(LINESTRING(POINT(0,0), POINT(10,0), POINT(10,10), POINT(0,10), POINT(0,0)),
LINESTRING(POINT(4,4), POINT(4,6), POINT(6,6), POINT(6,4), POINT(4,4)))))),
(609, ST_GEOMFROMWKB(MULTIPOLYGON(POLYGON(LINESTRING(POINT(0,0), POINT(5,0), POINT(5,5), POINT(0,5), POINT(0,0))),
POLYGON(LINESTRING(POINT(0,0), POINT(-5,0), POINT(-5,-5), POINT(0,-5), POINT(0,0))))));
INSERT INTO gis_multi_polygon VALUES
(610, ST_GEOMFROMWKB(MULTIPOLYGON(POLYGON(LINESTRING(POINT(0,0), POINT(-5,0), POINT(-5,-5), POINT(0,-5), POINT(0,0)))))),
(611, ST_GEOMFROMWKB(MULTIPOLYGON(POLYGON(LINESTRING(POINT(10,10), POINT(20,10), POINT(20,20), POINT(10,20), POINT(10,10)),
LINESTRING(POINT(14,14), POINT(14,16), POINT(16,16), POINT(16,14), POINT(14,14)))))),
(612, ST_GEOMFROMWKB(MULTIPOLYGON(POLYGON(LINESTRING(POINT(0,0), POINT(0,10), POINT(10,10), POINT(10,0), POINT(0,0)),
LINESTRING(POINT(4,4), POINT(4,6), POINT(6,6), POINT(6,4), POINT(4,4))),
POLYGON(LINESTRING(POINT(0,0), POINT(-5,0), POINT(-5,-5), POINT(0,-5), POINT(0,0))))));
INSERT INTO gis_multi_polygon VALUES
(613, ST_GEOMFROMWKB(ST_ASWKB(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,5 5,5 -5,0 0)),((0 0,-5 5,-5 -5,0 0)))')))),
(614, ST_GEOMFROMWKB(ST_ASWKB(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,10 10,-10 10,0 0)),((0 0,-10 -10,10 -10,0 0)))')))),
(615, ST_GEOMFROMWKB(ST_ASWKB(ST_GEOMFROMTEXT('MULTIPOLYGON(((0 0,5 5,10 0,5 -5,0 0)))'))));
--echo # Inserting GEOMETRYCOLLECTION Geometry Values
INSERT INTO gis_geometrycollection VALUES
(701, ST_GEOMCOLLFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0))')),
(702, ST_GEOMCOLLFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')),
(703, ST_GEOMCOLLFROMTEXT('GEOMETRYCOLLECTION(POINT(5 5), POLYGON((0 0,0 10,10 10,10 0,0 0)))'));
INSERT INTO gis_geometrycollection VALUES
(704, ST_GEOMETRYCOLLECTIONFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')),
(705, ST_GEOMETRYCOLLECTIONFROMTEXT('GEOMETRYCOLLECTION(POINT(0 0),'
'LINESTRING(0 0,10 10),'
'POLYGON((0 0,0 10,10 10,10 0,0 0,0 0, 0 0)))')),
(706, ST_GEOMETRYCOLLECTIONFROMTEXT('GEOMETRYCOLLECTION(MULTIPOINT(0 0,5 5,10 10),'
'MULTILINESTRING((0 0,10 10),(0 10,10 0)),'
'MULTIPOLYGON(((0 0,0 10,10 10,10 0,0 0)),'
'((0 0,-10 0,-10 -10,0 -10,0 0))))'));
INSERT INTO gis_geometrycollection VALUES
(707, ST_GEOMCOLLFROMWKB(GEOMETRYCOLLECTION(POINT(0,0)))),
(708, ST_GEOMCOLLFROMWKB(GEOMETRYCOLLECTION(POINT(0,0),
LINESTRING(POINT(0,0), POINT(2,2), POINT(4,4), POINT(6,6), POINT(8,8)),
POLYGON(LINESTRING(POINT(0,0), POINT(0,10), POINT(10,10), POINT(10,0), POINT(0,0)),
LINESTRING(POINT(4,4), POINT(4,6), POINT(6,6), POINT(6,4), POINT(4,4)))))),
(709, ST_GEOMCOLLFROMWKB(GEOMETRYCOLLECTION(MULTIPOINT(POINT(0,0), POINT(5,5), POINT(10,10)),
MULTILINESTRING(LINESTRING(POINT(0,0), POINT(2,2), POINT(4,4), POINT(6,6), POINT(8,8)),
LINESTRING(POINT(10,10), POINT(5,5), POINT(0,10))),
MULTIPOLYGON(POLYGON(LINESTRING(POINT(0,0), POINT(0,10), POINT(10,10), POINT(10,0), POINT(0,0)),
LINESTRING(POINT(4,4), POINT(4,6), POINT(6,6), POINT(6,4), POINT(4,4))),
POLYGON(LINESTRING(POINT(0,0), POINT(-10,0), POINT(-10,-10), POINT(0,0)))))));
INSERT INTO gis_geometrycollection VALUES
(710, ST_GEOMETRYCOLLECTIONFROMWKB(GEOMETRYCOLLECTION(POINT(0,0),
LINESTRING(POINT(0,0), POINT(100,100))))),
(711, ST_GEOMETRYCOLLECTIONFROMWKB(GEOMETRYCOLLECTION(POINT(10,10),
LINESTRING(POINT(10,10), POINT(12,12), POINT(14,14), POINT(16,16), POINT(18,18)),
POLYGON(LINESTRING(POINT(0,0), POINT(0,10), POINT(10,10), POINT(10,0), POINT(0,0)),
LINESTRING(POINT(4,4), POINT(4,6), POINT(6,6), POINT(6,4), POINT(4,4)))))),
(712, ST_GEOMETRYCOLLECTIONFROMWKB(GEOMETRYCOLLECTION(MULTIPOINT(POINT(10,10), POINT(15,15), POINT(20,20)),
MULTILINESTRING(LINESTRING(POINT(0,0), POINT(2,2), POINT(4,4), POINT(6,6), POINT(8,8)),
LINESTRING(POINT(10,10), POINT(5,5), POINT(0,10))),
MULTIPOLYGON(POLYGON(LINESTRING(POINT(0,0), POINT(0,10), POINT(10,10), POINT(10,0), POINT(0,0)),
LINESTRING(POINT(4,4), POINT(4,6), POINT(6,6), POINT(6,4), POINT(4,4))),
POLYGON(LINESTRING(POINT(0,0), POINT(-10,0), POINT(-10,-10), POINT(0,0)))))));
INSERT INTO gis_geometrycollection VALUES
(713, ST_GEOMCOLLFROMWKB(ST_ASWKB(ST_GEOMCOLLFROMTEXT('GEOMETRYCOLLECTION('
'POINT(0 0),'
'LINESTRING(0 0,10 10),'
'POLYGON((0 0,0 10,10 10,10 0,0 0)),'
'MULTIPOINT(0 0,2 2,4 4,6 6,8 8,10 10),'
'MULTILINESTRING((0 0,10 10),(0 10,10 0)),'
'MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 10,10 10,10 5,5 5))))')))),
(714, ST_GEOMCOLLFROMWKB(ST_ASWKB(ST_GEOMCOLLFROMTEXT('GEOMETRYCOLLECTION('
'GEOMETRYCOLLECTION('
'POINT(0 0)),'
'GEOMETRYCOLLECTION('
'LINESTRING(0 0,10 10)),'
'GEOMETRYCOLLECTION('
'POLYGON((0 0,0 10,10 10,10 0,0 0))),'
'GEOMETRYCOLLECTION('
'MULTIPOINT(0 0,2 2,4 4,6 6,8 8,10 10)),'
'GEOMETRYCOLLECTION('
'MULTILINESTRING((0 0,10 10),(0 10,10 0))),'
'GEOMETRYCOLLECTION('
'MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 10,10 10,10 5,5 5)))))')))),
(715, ST_GEOMCOLLFROMWKB(ST_ASWKB(ST_GEOMCOLLFROMTEXT('GEOMETRYCOLLECTION('
'GEOMETRYCOLLECTION(),'
'POINT(0 0),'
'GEOMETRYCOLLECTION('
'LINESTRING(0 0,10 10),'
'GEOMETRYCOLLECTION('
'GEOMETRYCOLLECTION())),'
'GEOMETRYCOLLECTION(),'
'GEOMETRYCOLLECTION('
'GEOMETRYCOLLECTION()),'
'POLYGON((0 0,0 10,10 10,10 0,0 0)),'
'MULTIPOINT(0 0,2 2,4 4,6 6,8 8,10 10),'
'MULTILINESTRING((0 0,10 10),(0 10,10 0)),'
'MULTIPOLYGON(((0 0,0 5,5 5,5 0,0 0)),((5 5,5 10,10 10,10 5,5 5))))'))));
############################################################################################
# Checking spatial index with geometry data #
############################################################################################
--echo # Creating a table with spatial index column
CREATE TABLE geom_index (fid INTEGER NOT NULL PRIMARY KEY, g GEOMETRY NOT NULL, SPATIAL INDEX(g));
--echo # Inserting geometry values
INSERT INTO geom_index SELECT * FROM gis_point;
INSERT INTO geom_index SELECT * FROM gis_linestring;
INSERT INTO geom_index SELECT * FROM gis_polygon;
INSERT INTO geom_index SELECT * FROM gis_multi_point;
INSERT INTO geom_index SELECT * FROM gis_multi_linestring;
INSERT INTO geom_index SELECT * FROM gis_multi_polygon;
INSERT INTO geom_index SELECT * FROM gis_geometrycollection;
check table geom_index;
--echo # Final cleanup
DROP TABLE gis_point;
DROP TABLE gis_linestring;
DROP TABLE gis_polygon;
DROP TABLE gis_multi_point;
DROP TABLE gis_multi_linestring;
DROP TABLE gis_multi_polygon;
DROP TABLE gis_geometrycollection;
DROP TABLE geom_index;
# WL#6745 InnoDB R-tree support
# This test case will test R-tree multi level split.
# Not supported in embedded
--source include/not_embedded.inc
--source include/have_innodb.inc
--source include/big_test.inc
# Create table with R-tree index.
create table t1 (c1 int, c2 geometry not null, spatial index (c2))engine=innodb;
# Insert enough values to let R-tree split.
delimiter |;
create procedure insert_t1(IN total int)
begin
declare i int default 1;
while (i <= total) DO
insert into t1 values (i, Point(i, i));
set i = i + 1;
end while;
end|
delimiter ;|
# Test level 1 rtree.
CALL insert_t1(5000);
select count(*) from t1;
# Check table.
check table t1;
# Test level 2 rtree.
truncate table t1;
CALL insert_t1(10000);
select count(*) from t1;
drop index c2 on t1;
create spatial index idx on t1(c2);
show create table t1;
# Check table.
check table t1;
# Test level 3 rtree.
truncate table t1;
# Test crash recovery.
#
#
call mtr.add_suppression("InnoDB: page [0-9]+ in the doublewrite buffer is not within space bounds.*");
# Test rtree enlarge recovery.
START TRANSACTION;
CALL insert_t1(5000);
COMMIT;
--source include/kill_and_restart_mysqld.inc
# Clean up.
drop procedure insert_t1;
drop table t1;
# WL#6745 InnoDB R-tree support
# This test case will test R-tree split.
# Not supported in embedded
--source include/not_embedded.inc
--source include/have_innodb.inc
--source include/have_debug.inc
--source include/big_test.inc
--source include/not_valgrind.inc
# Create table with R-tree index.
create table t1 (c1 int, c2 varchar(255), c3 geometry not null, primary key(c1, c2), spatial index (c3))engine=innodb;
# Insert enough values to let R-tree split.
delimiter |;
create function rand_string(str_length tinyint unsigned, str_type tinyint unsigned) returns varchar(255)
begin
declare counter int unsigned default 0;
declare const_chars varchar(64) default '0123456789';
declare result varchar(255) default '';
if str_type = 1 then
set const_chars = '0123456789';
elseif str_type = 2 then
set const_chars = 'abcdefghijklmnopqrstuvwxyz';
elseif str_type = 3 then
set const_chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
elseif str_type = 4 then
set const_chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
elseif str_type = 5 then
set const_chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
else
set const_chars = '0123456789';
end if;
while counter < str_length do
set result = concat(result,substr(const_chars,ceil(rand()*(length(const_chars)-1)),1));
set counter = counter + 1;
end while;
return result;
end|
create procedure insert_t1(IN total int)
begin
declare i int default 1;
declare i2 int default 1;
declare str varchar(100) default '';
declare dup_key int default 1;
while i <= total DO
set i2 = floor(0+(rand()*100));
set str = rand_string(i2, 5);
select count(*) into dup_key from t1 where c2 = str and c1 = i;
while dup_key <> 0 do
set i2 = floor(0+(rand()*100));
set str = rand_string(i2, 5);
select count(*) into dup_key from t1 where c2 = str and c1 = i;
end while;
insert into t1 values (i, str, Point(i, i));
set i = i + 1;
end while;
end|
delimiter ;|
CALL insert_t1(10000);
check table t1;
start transaction;
CALL insert_t1(30000);
rollback;
check table t1;
# Clean up.
drop procedure insert_t1;
drop function rand_string;
drop table t1;
#********************************************************
# wl6942: Store certain GIS data type in the row rather
# than as BLOB.
#
#********************************************************
--source include/have_geometry.inc
--source include/have_innodb.inc
--echo #
--echo # Test for basic POINT operation
--echo #
CREATE TABLE gis_point(p1 POINT, p2 POINT) ENGINE=InnoDB;
INSERT INTO gis_point VALUES
(ST_PointFromText('POINT(0 0)'), ST_PointFromText('POINT(0 0)')),
(ST_PointFromText('POINT(10 -20)'), ST_PointFromText('POINT(10 -20)')),
(ST_PointFromText('POINT(3.1415926 3.535897)'), ST_PointFromText('POINT(-3.932626 -3.488272)')),
(ST_PointFromText('POINT(-111.9876 234.1357)'), ST_PointFromText('POINT(-957.1914 958.1919)'));
SELECT ST_X(p1), ST_Y(p2) FROM gis_point;
DROP TABLE gis_point;
--echo #
--echo # Test when POINT is not on any indexes
--echo #
CREATE TABLE gis_point(p1 POINT, p2 POINT) ENGINE=InnoDB;
INSERT INTO gis_point VALUES
(ST_PointFromText('POINT(100.32374832 101.23741821)'), ST_PointFromText('POINT(100.32374832 101.23741821)')),
(ST_PointFromText('POINT(105.34523342 103.18492302)'), ST_PointFromText('POINT(100.32374832 101.23741821)')),
(ST_PointFromText('POINT(100.32374832 101.23741821)'), ST_PointFromText('POINT(200.32247328 101.86728201)')),
(ST_PointFromText('POINT(100.32374832 101.23741821)'), ST_PointFromText('POINT(100.32374832 101.98527111)'));
--replace_column 10 #
EXPLAIN SELECT ST_AsText(p1), ST_AsText(p2) FROM gis_point GROUP BY p1, p2;
SELECT ST_AsText(p1), ST_AsText(p2) FROM gis_point GROUP BY p1, p2;
SELECT ST_AsText(p1) FROM gis_point WHERE p1 = p2;
SELECT ST_AsText(p1), ST_AsText(p2) FROM gis_point WHERE p1 = ST_PointFromText('POINT(100.32374832 101.23741821)');
SELECT ST_AsText(p1), ST_AsText(p2) FROM gis_point WHERE p2 = ST_PointFromText('POINT(200.32247328 101.86728201)');
DROP TABLE gis_point;
--echo #
--echo # Test some ALTER TABLE operations on POINT tables
--echo #
CREATE TABLE t1 (
p POINT NOT NULL,
g GEOMETRY NOT NULL
) ENGINE=InnoDB;
INSERT INTO t1 VALUES(ST_PointFromText('POINT(0 1)'), ST_PointFromText('POINT(10 11)'));
INSERT INTO t1 VALUES(ST_PointFromText('POINT(1 1)'), ST_PointFromText('POINT(10 12)'));
INSERT INTO t1 VALUES(ST_PointFromText('POINT(1 0)'), ST_PointFromText('POINT(10 13)'));
INSERT INTO t1 VALUES(ST_PointFromText('POINT(0 0)'), ST_PointFromText('POINT(10 14)'));
SELECT ST_AsText(p), ST_AsText(g) FROM t1;
SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE name = 'p' OR name = 'g';
ALTER TABLE t1 ADD COLUMN p1 POINT, ADD COLUMN p2 POINT, ADD KEY(p);
SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE name = 'p' OR name = 'g' OR name = 'p1' OR name = 'p2';
--echo # NOT NULL POINT will use ''
SELECT count(*) AS `Expect 4` FROM t1 WHERE p1 = '';
SELECT count(*) AS `Expect 4` FROM t1 WHERE p2 = '';
SELECT ST_AsText(p), ST_AsText(p1) FROM t1 WHERE p = p1;
SELECT ST_AsText(p), ST_AsText(p1) FROM t1 WHERE p = p2;
ALTER TABLE t1 DROP COLUMN p2;
--echo # NULLABLE POINT will use NULL
ALTER TABLE t1 ADD COLUMN p2 POINT, ADD KEY(p2);
SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE name = 'p' OR name = 'g' OR name = 'p1' OR name = 'p2';
SELECT count(*) AS `Expect 4` FROM t1 WHERE p2 IS NULL;
UPDATE t1 SET p2 = ST_PointFromText('POINT(10 20)');
UPDATE t1 SET p1 = ST_PointFromText('POINT(10 20)');
ALTER TABLE t1 DROP COLUMN p2;
SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE name = 'p' OR name = 'g' OR name = 'p1';
SELECT ST_AsText(p), ST_AsText(p1) FROM t1 WHERE p = p1;
INSERT INTO t1 VALUES (ST_PointFromText('POINT(0.5 0.5)'), ST_PointFromText('POINT(0 1)'), ST_PointFromText('POINT(10 19)'));
SELECT ST_AsText(p1) FROM t1;
DELETE FROM t1 WHERE p1 = ST_PointFromText('POINT(10 19)');
SELECT ST_AsText(p1) FROM t1;
--echo # Add spatial keys on the table
--error ER_SPATIAL_CANT_HAVE_NULL
ALTER TABLE t1 ADD SPATIAL(p), ADD SPATIAL(p1);
SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE name = 'p' OR name = 'g' OR name = 'p1';
SELECT ST_AsText(p), ST_AsText(p1) FROM t1 WHERE p1 = ST_PointFromText('POINT(10 30)');
SELECT ST_AsText(p), ST_AsText(p1) FROM t1 WHERE p1 = ST_PointFromText('POINT(10 20)');
SELECT ST_AsText(p), ST_AsText(p1) FROM t1 WHERE MBRWithin(p1, ST_GeomFromText('POLYGON((5 5, 20 5, 20 21, 5 21, 5 5))'));
SELECT ST_AsText(p), ST_AsText(p1) FROM t1 WHERE MBRWithin(p, ST_GeomFromText('POLYGON((-1 0.5, -1 -0.5, 1 -0.5, 1 0.5, -1 0.5))'));
--echo # Drop spatial keys on the table
--error ER_CANT_DROP_FIELD_OR_KEY
ALTER TABLE t1 DROP KEY p, DROP KEY p1;
SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE name = 'p' OR name = 'g' OR name = 'p1';
SELECT ST_AsText(p), ST_AsText(p1) FROM t1 WHERE p1 = ST_PointFromText('POINT(10 30)');
SELECT ST_AsText(p), ST_AsText(p1) FROM t1 WHERE p1 = ST_PointFromText('POINT(10 20)');
SELECT ST_AsText(p), ST_AsText(p1) FROM t1 WHERE MBRWithin(p1, ST_GeomFromText('POLYGON((5 5, 20 5, 20 21, 5 21, 5 5))'));
SELECT ST_AsText(p), ST_AsText(p1) FROM t1 WHERE MBRWithin(p, ST_GeomFromText('POLYGON((-1 0.5, -1 -0.5, 1 -0.5, 1 0.5, -1 0.5))'));
TRUNCATE t1;
ALTER TABLE t1 DROP COLUMN p, DROP COLUMN p1;
SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE name = 'p' OR name = 'g' OR name = 'p1';
ALTER TABLE t1 ADD COLUMN p POINT, ADD COLUMN p1 POINT;
SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE name = 'p' OR name = 'g' OR name = 'p1';
SHOW CREATE TABLE t1;
INSERT INTO t1 VALUES(ST_PointFromText('POINT(0.5 0.5)'), ST_PointFromText('POINT(0 1)'), ST_PointFromText('POINT(10 19)'));
INSERT INTO t1 VALUES(ST_PointFromText('POINT(0.6 0.6)'), ST_PointFromText('POINT(1 1)'), ST_PointFromText('POINT(10 20)'));
INSERT INTO t1 VALUES(ST_PointFromText('POINT(0.7 0.7)'), ST_PointFromText('POINT(1 0)'), ST_PointFromText('POINT(10 21)'));
INSERT INTO t1 VALUES(ST_PointFromText('POINT(0.8 0.8)'), ST_PointFromText('POINT(0 0)'), ST_PointFromText('POINT(10 22)'));
SELECT ST_AsText(p), ST_AsText(p1) FROM t1 WHERE p1 = ST_PointFromText('POINT(10 30)');
SELECT ST_AsText(p), ST_AsText(p1) FROM t1 WHERE p1 = ST_PointFromText('POINT(10 20)');
SELECT ST_AsText(p), ST_AsText(p1) FROM t1 WHERE MBRWithin(p1, ST_GeomFromText('POLYGON((5 5, 20 5, 20 21, 5 21, 5 5))'));
SELECT ST_AsText(p), ST_AsText(p1) FROM t1 WHERE MBRWithin(p, ST_GeomFromText('POLYGON((-1 0.5, -1 -0.5, 1 -0.5, 1 0.5, -1 0.5))'));
ALTER TABLE t1 DROP COLUMN p1, ADD COLUMN p1 POINT, CHANGE COLUMN p pp POINT AFTER p1;
SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE name = 'pp' OR name = 'g' OR name = 'p1';
UPDATE t1 SET p1 = ST_PointFromText('POINT(5 5)');
SELECT ST_AsText(pp), ST_AsText(p1) FROM t1;
--error ER_SPATIAL_CANT_HAVE_NULL
ALTER TABLE t1 ADD SPATIAL(p1), ADD SPATIAL(pp), ALGORITHM = COPY;
SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE name = 'pp' OR name = 'g' OR name = 'p1';
SELECT ST_AsText(pp), ST_AsText(p1) FROM t1 WHERE p1 = ST_PointFromText('POINT(10 30)');
SELECT ST_AsText(pp), ST_AsText(p1) FROM t1 WHERE p1 = ST_PointFromText('POINT(10 20)');
SELECT ST_AsText(pp), ST_AsText(p1) FROM t1 WHERE MBRWithin(p1, ST_GeomFromText('POLYGON((5 5, 20 5, 20 21, 5 21, 5 5))')) ORDER BY pp;
SELECT ST_AsText(pp), ST_AsText(p1) FROM t1 WHERE MBRWithin(pp, ST_GeomFromText('POLYGON((-1 0.5, -1 -0.5, 1 -0.5, 1 0.5, -1 0.5))')) ORDER BY pp;
DROP TABLE t1;
--echo #
--echo # Test when the POINT is on B-TREE
--echo #
CREATE TABLE gis_point(fid INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT, p POINT, KEY(p)) ENGINE=InnoDB;
INSERT INTO gis_point VALUES
(101, ST_PointFromText('POINT(10 10)')),
(102, ST_PointFromText('POINT(20 10)')),
(103, ST_PointFromText('POINT(20 20)')),
(104, ST_PointFromWKB(ST_AsWKB(ST_PointFromText('POINT(10 20)'))));
SELECT ST_AsText(p) FROM gis_point;
SELECT ST_AsText(p) FROM gis_point WHERE p = ST_PointFromText('POINT(20 20)');
INSERT INTO gis_point VALUES
(201, ST_PointFromText('POINT(100.32374832 101.23741821)')),
(202, ST_PointFromText('POINT(102.43287328 100.23489233)')),
(203, ST_PointFromText('POINT(101.43284962 100.45892392)')),
(204, ST_PointFromWKB(ST_AsWKB(ST_PointFromText('POINT(103.43718640 105.248206478)')))),
(205, ST_PointFromText('POINT(101.43284962 100.45892392)')),
(206, ST_PointFromWKB(ST_AsWKB(ST_PointFromText('POINT(103.43718640 105.248206478)'))));
-- echo 'The ORDER BY will use filesort'
--replace_column 10 #
EXPLAIN SELECT ST_AsText(p) FROM gis_point ORDER BY p;
SELECT ST_AsText(p) FROM gis_point ORDER BY p;
SELECT ST_AsText(p), COUNT(*) FROM gis_point GROUP BY p;
TRUNCATE gis_point;
INSERT INTO gis_point VALUES
(101, ST_PointFromText('POINT(10 10)')),
(102, ST_PointFromText('POINT(20 10)')),
(103, ST_PointFromText('POINT(20 20)')),
(104, ST_PointFromWKB(ST_AsWKB(ST_PointFromText('POINT(10 20)'))));
--echo # Check if we can create prefix index on POINT
ALTER TABLE gis_point ADD COLUMN g POINT, ADD KEY(g(8));
INSERT INTO gis_point VALUES
(105, ST_PointFromText('POINT(25 15)'), ST_PointFromText('POINT(100 100)')),
(106, ST_PointFromText('POINT(25 25)'), ST_PointFromText('POINT(110 110)'));
SELECT ST_AsText(p) FROM gis_point;
SELECT ST_AsText(p), ST_AsText(g) FROM gis_point WHERE g IS NULL;
UPDATE gis_point SET g = ST_PointFromText('POINT(200 200)') WHERE g IS NULL OR g = ST_PointFromText('POINT(110 110)');
SELECT ST_AsText(g) FROM gis_point WHERE g IS NULL OR g = ST_PointFromText('POINT(200 200)');
--echo # Check the information schema tables
SELECT table_name, column_name, data_type, column_type FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name='gis_point' AND (column_name = 'p' OR column_name = 'g');
SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE name = 'p' OR name = 'g';
SELECT length(p) FROM gis_point;
ALTER TABLE gis_point DROP COLUMN g, ALGORITHM = COPY;
TRUNCATE gis_point;
INSERT INTO gis_point VALUES
(101, ST_PointFromText('POINT(10 10)')),
(102, ST_PointFromText('POINT(20 10)')),
(103, ST_PointFromText('POINT(20 20)')),
(104, ST_PointFromWKB(ST_AsWKB(ST_PointFromText('POINT(10 20)'))));
--echo # Check if we can create prefix index on POINT
ALTER TABLE gis_point ADD COLUMN g POINT, ADD KEY(g(8));
INSERT INTO gis_point VALUES
(105, ST_PointFromText('POINT(25 15)'), ST_PointFromText('POINT(100 100)')),
(106, ST_PointFromText('POINT(25 25)'), ST_PointFromText('POINT(110 110)'));
SELECT ST_AsText(p) FROM gis_point;
SELECT ST_AsText(p), ST_AsText(g) FROM gis_point WHERE g IS NULL;
UPDATE gis_point SET g = ST_PointFromText('POINT(200 200)') WHERE g IS NULL OR g = ST_PointFromText('POINT(110 110)');
SELECT ST_AsText(g) FROM gis_point WHERE g IS NULL OR g = ST_PointFromText('POINT(200 200)');
CHECK TABLE gis_point;
SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE name = 'p' OR name = 'g';
DROP TABLE gis_point;
--echo #
--echo # Check the mtype of other geometry data types should be 15
--echo #
CREATE TABLE g (
geom GEOMETRY NOT NULL,
l LINESTRING NOT NULL,
poly POLYGON NOT NULL,
mp MULTIPOINT NOT NULL,
ml MULTILINESTRING NOT NULL,
mpoly MULTIPOLYGON NOT NULL,
gc GEOMETRYCOLLECTION NOT NULL
) ENGINE=InnoDB;
SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE name = 'p' OR name = 'g' OR name = 'geom' OR name = 'l' OR name = 'poly' OR name = 'mp' OR name = 'ml' OR name = 'mpoly' OR name = 'gc';
DROP TABLE g;
--echo #
--echo # check the mtype and len with CREATE TABLE AS
--echo #
CREATE TABLE t1 (
p POINT NOT NULL,
g GEOMETRY NOT NULL
) ENGINE=InnoDB;
INSERT INTO t1 VALUES(ST_PointFromText('POINT(10 10)'),ST_GeomFromText('POLYGON((30 30,40 40,50 50,30 50,30 40,30 30))'));
# Check the mtype and len of the table
SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE name = 'p' OR name = 'g' AND name='t1';
CREATE TABLE t2 AS SELECT * FROM t1;
# Cleanup
DROP TABLE t1;
# Check the mtype and len of the table, should be 14,25
SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE name = 'p' OR name = 'g' AND name='t2';
# Cleanup
DROP table t2;
--echo #
--echo # Test when POINT is used in spatial index
--echo #
SET @ls1 = ST_GeomFromText('LINESTRING(0 20, 10 0)');
SET @ls2 = ST_GeomFromText('LINESTRING(0 0, 10 20)');
SET @ls3 = ST_GeomFromText('LINESTRING(20 -40, 21 -42)');
SET @ls4 = ST_GeomFromText('LINESTRING(20 -42, 21 -40)');
SET @poly1 = ST_GeomFromText('POLYGON((2 2, 2 10, 10 10, 10 2, 2 2))');
SET @poly2 = ST_GeomFromText('POLYGON((0 0, -5 0, -4 -1, -6 -15, -3 -15, 0 0))');
SET @poly3 = ST_GeomFromText('POLYGON((10.0 10.0, 20.5 20, 20.5 50, 32.0 64.0, 32.3 64.6, 5 60, 10 10))');
SET @poly4 = ST_GeomFromText('POLYGON((0 10, -10 10, -10 -10, 0 -10, 0 10))');
SET @p1 = ST_PointFromText('POINT(0 0)');
SET @mpoly = ST_GeomFromText('MULTIPOLYGON(((3 3, 3 16, 16 16, 16 3, 3 3)), ((10 10, 10 50, 50 50, 50 10, 10 10)))');
CREATE TABLE gis_point (p1 POINT NOT NULL, p2 POINT NOT NULL, SPATIAL KEY k1 (p1), SPATIAL KEY k2 (p2)) ENGINE=InnoDB;
INSERT INTO gis_point VALUES
(ST_PointFromText('POINT(1 2)'), ST_PointFromText('POINT(-1 -3)')),
(ST_PointFromText('POINT(2 4)'), ST_PointFromText('POINT(-2 -6)')),
(ST_PointFromText('POINT(3 6)'), ST_PointFromText('POINT(-3 -9)')),
(ST_PointFromText('POINT(4 8)'), ST_PointFromText('POINT(-4 -12)')),
(ST_PointFromText('POINT(5 10)'), ST_PointFromText('POINT(-5 -15)')),
(ST_PointFromText('POINT(6 12)'), ST_PointFromText('POINT(-6 -18)')),
(ST_PointFromText('POINT(7 14)'), ST_PointFromText('POINT(-7 -21)')),
(ST_PointFromText('POINT(8 16)'), ST_PointFromText('POINT(0 0)')),
(ST_PointFromText('POINT(9 18)'), ST_PointFromText('POINT(-4 2)')),
(ST_PointFromText('POINT(10 21)'), ST_PointFromText('POINT(-6 3)')),
(ST_PointFromText('POINT(20.5 41)'), ST_PointFromText('POINT(-8 4)')),
(ST_PointFromText('POINT(26.25 57)'), ST_PointFromText('POINT(1 2)')),
(ST_PointFromText('POINT(32.1234 64.2468)'), ST_PointFromText('POINT(-1 -1)'));
CREATE TABLE gis_point1 SELECT * FROM gis_point;
SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE name = 'p1' OR name = 'p2';
SELECT ST_AsText(p1), ST_AsText(p2) FROM gis_point1;
SELECT ST_AsText(p1) FROM gis_point1 WHERE ST_Intersection(@ls1, @ls2) = p1;
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRWithin(p1, @poly1);
SELECT ST_AsText(p2) FROM gis_point1 WHERE ST_Contains(@poly2, p2);
SELECT ST_AsText(p2) FROM gis_point1 WHERE ST_Equals(p2, @p1);
SELECT ST_AsText(p1) FROM gis_point1 WHERE ST_Touches(@poly3, p1) AND MBRWithin(p2, @poly4);
SELECT ST_AsText(p1) FROM gis_point1 WHERE ST_Contains(@mpoly, p1);
SELECT ST_AsText(p1) FROM gis_point1 WHERE ST_Contains(@mpoly, p1) AND NOT MBRWithin(p1, @mpoly);
--echo # Check functions that use MBR, with line type data
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRIntersects(p1, @ls1);
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRWithin(p1, @ls1);
SELECT ST_AsText(p1) FROM gis_point1 WHERE ST_Touches(p1, @ls1);
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRDisjoint(p1, @ls1);
--echo # No matching records
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBREquals(p1, @ls1);
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRContains(p1, @ls1);
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBROverlaps(p1, @ls3);
SELECT ST_AsText(p1) FROM gis_point1 WHERE ST_Crosses(p1, @ls1);
--echo # Check functions that use MBR, with polygon type data
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRIntersects(p1, @poly1);
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRWithin(p1, @poly1);
SELECT ST_AsText(p1) FROM gis_point1 WHERE ST_Touches(p1, @poly1);
SELECT ST_AsText(p1) FROM gis_point1 WHERE ST_Crosses(p1, @poly1);
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRDisjoint(p1, @poly1);
--echo # No matching records
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBREquals(p1, @poly1);
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRContains(p1, @poly1);
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBROverlaps(p1, @poly1);
--echo # Check functions that use MBR, with point type data
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRIntersects(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRWithin(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point1 WHERE ST_Touches(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBREquals(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRContains(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRDisjoint(p1, @p1);
--echo # No matching records
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBROverlaps(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point1 WHERE ST_Crosses(p1, @p1);
--echo # Check with MBR functions point type data
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRIntersects(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRWithin(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point1 WHERE ST_Touches(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRContains(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRDisjoint(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRequals(p1, @p1);
--echo # No matching records
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBROverlaps(p1, @p1);
--echo # Check with MBR functions point polygon data
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRIntersects(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRWithin(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point1 WHERE ST_Touches(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRContains(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRDisjoint(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRequals(p1, @p1);
--echo # No matching records
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBROverlaps(p1, @p1);
--echo # Check with MBR functions polygon type data
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRIntersects(p1, @poly1);
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRWithin(p1, @poly1);
SELECT ST_AsText(p1) FROM gis_point1 WHERE ST_Touches(p1, @poly1);
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRDisjoint(p1, @poly1);
--echo # No matching records
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBROverlaps(p1, @poly1);
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRContains(p1, @poly1);
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRequals(p1, @poly1);
--echo # Check with MBR functions line type data
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRIntersects(p1, @ls1);
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRWithin(p1, @ls1);
SELECT ST_AsText(p1) FROM gis_point1 WHERE ST_Touches(p1, @ls1);
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRDisjoint(p1, @ls1);
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRequals(p1, @ls1);
--echo # No matching records
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBROverlaps(p1, @ls1);
SELECT ST_AsText(p1) FROM gis_point1 WHERE MBRContains(p1, @ls1);
DROP TABLE gis_point1;
SELECT ST_AsText(p1), ST_AsText(p2) FROM gis_point;
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Intersection(@ls1, @ls2) = p1;
SELECT ST_AsText(p1) FROM gis_point WHERE MBRWithin(p1, @poly1);
SELECT ST_AsText(p2) FROM gis_point WHERE ST_Contains(@poly2, p2);
SELECT ST_AsText(p2) FROM gis_point WHERE ST_Equals(p2, @p1);
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Touches(@poly3, p1) AND MBRWithin(p2, @poly4);
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Contains(@mpoly, p1);
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Contains(@mpoly, p1) AND NOT MBRWithin(p1, @mpoly);
--echo # Check functions that use MBR, with line type data
SELECT ST_AsText(p1) FROM gis_point WHERE MBRIntersects(p1, @ls1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRWithin(p1, @ls1);
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Touches(p1, @ls1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRDisjoint(p1, @ls1);
--echo # No matching records
SELECT ST_AsText(p1) FROM gis_point WHERE MBREquals(p1, @ls1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRContains(p1, @ls1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBROverlaps(p1, @ls3);
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Crosses(p1, @ls1);
--echo # Check functions that use MBR, with polygon type data
SELECT ST_AsText(p1) FROM gis_point WHERE MBRIntersects(p1, @poly1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRWithin(p1, @poly1);
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Touches(p1, @poly1);
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Crosses(p1, @poly1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRDisjoint(p1, @poly1);
--echo # No matching records
SELECT ST_AsText(p1) FROM gis_point WHERE MBREquals(p1, @poly1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRContains(p1, @poly1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBROverlaps(p1, @poly1);
--echo # Check functions that use MBR, with point type data
SELECT ST_AsText(p1) FROM gis_point WHERE MBRIntersects(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRWithin(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Touches(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBREquals(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRContains(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRDisjoint(p1, @p1);
--echo # No matching records
SELECT ST_AsText(p1) FROM gis_point WHERE MBROverlaps(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Crosses(p1, @p1);
--echo # Check with MBR functions point type data
SELECT ST_AsText(p1) FROM gis_point WHERE MBRIntersects(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRWithin(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Touches(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRContains(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRDisjoint(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRequals(p1, @p1);
--echo # No matching records
SELECT ST_AsText(p1) FROM gis_point WHERE MBROverlaps(p1, @p1);
--echo # Check with MBR functions point polygon data
SELECT ST_AsText(p1) FROM gis_point WHERE MBRIntersects(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRWithin(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Touches(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRContains(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRDisjoint(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRequals(p1, @p1);
--echo # No matching records
SELECT ST_AsText(p1) FROM gis_point WHERE MBROverlaps(p1, @p1);
--echo # Check with MBR functions polygon type data
SELECT ST_AsText(p1) FROM gis_point WHERE MBRIntersects(p1, @poly1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRWithin(p1, @poly1);
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Touches(p1, @poly1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRDisjoint(p1, @poly1);
--echo # No matching records
SELECT ST_AsText(p1) FROM gis_point WHERE MBROverlaps(p1, @poly1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRContains(p1, @poly1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRequals(p1, @poly1);
--echo # Check with MBR functions line type data
SELECT ST_AsText(p1) FROM gis_point WHERE MBRIntersects(p1, @ls1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRWithin(p1, @ls1);
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Touches(p1, @ls1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRDisjoint(p1, @ls1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRequals(p1, @ls1);
--echo # No matching records
SELECT ST_AsText(p1) FROM gis_point WHERE MBROverlaps(p1, @ls1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRContains(p1, @ls1);
--echo # Modify the storage engine to Myisam, Check the spatial functions
ALTER TABLE gis_point ENGINE Myisam;
--echo # Check functions that use MBR, with line type data
SELECT ST_AsText(p1) FROM gis_point WHERE MBRIntersects(p1, @ls1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRWithin(p1, @ls1);
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Touches(p1, @ls1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRDisjoint(p1, @ls1);
--echo # No matching records
SELECT ST_AsText(p1) FROM gis_point WHERE MBREquals(p1, @ls1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRContains(p1, @ls1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBROverlaps(p1, @ls3);
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Crosses(p1, @ls1);
--echo # Check functions that use MBR, with polygon type data
SELECT ST_AsText(p1) FROM gis_point WHERE MBRIntersects(p1, @poly1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRWithin(p1, @poly1);
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Touches(p1, @poly1);
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Crosses(p1, @poly1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRDisjoint(p1, @poly1);
--echo # No matching records
SELECT ST_AsText(p1) FROM gis_point WHERE MBREquals(p1, @poly1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRContains(p1, @poly1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBROverlaps(p1, @poly1);
--echo # Check functions that use MBR, with point type data
SELECT ST_AsText(p1) FROM gis_point WHERE MBRIntersects(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRWithin(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Touches(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBREquals(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRContains(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRDisjoint(p1, @p1);
--echo # No matching records
SELECT ST_AsText(p1) FROM gis_point WHERE MBROverlaps(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Crosses(p1, @p1);
--echo # Check with MBR functions point type data
SELECT ST_AsText(p1) FROM gis_point WHERE MBRIntersects(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRWithin(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Touches(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRContains(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRDisjoint(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRequals(p1, @p1);
--echo # No matching records
SELECT ST_AsText(p1) FROM gis_point WHERE MBROverlaps(p1, @p1);
--echo # Check with MBR functions point polygon data
SELECT ST_AsText(p1) FROM gis_point WHERE MBRIntersects(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRWithin(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Touches(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRContains(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRDisjoint(p1, @p1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRequals(p1, @p1);
--echo # No matching records
SELECT ST_AsText(p1) FROM gis_point WHERE MBROverlaps(p1, @p1);
--echo # Check with MBR functions polygon type data
SELECT ST_AsText(p1) FROM gis_point WHERE MBRIntersects(p1, @poly1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRWithin(p1, @poly1);
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Touches(p1, @poly1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRDisjoint(p1, @poly1);
--echo # No matching records
SELECT ST_AsText(p1) FROM gis_point WHERE MBROverlaps(p1, @poly1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRContains(p1, @poly1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRequals(p1, @poly1);
--echo # Check with MBR functions line type data
SELECT ST_AsText(p1) FROM gis_point WHERE MBRIntersects(p1, @ls1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRWithin(p1, @ls1);
SELECT ST_AsText(p1) FROM gis_point WHERE ST_Touches(p1, @ls1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRDisjoint(p1, @ls1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRequals(p1, @ls1);
--echo # No matching records
SELECT ST_AsText(p1) FROM gis_point WHERE MBROverlaps(p1, @ls1);
SELECT ST_AsText(p1) FROM gis_point WHERE MBRContains(p1, @ls1);
--echo # Modify the storage engine to InnoDB again, do following testing
ALTER TABLE gis_point ENGINE InnoDB;
CHECK TABLE gis_point;
-- echo The ORDER BY for spatial index will use filesort
--replace_column 10 #
EXPLAIN SELECT ST_AsText(p1), ST_AsText(p2) FROM gis_point ORDER BY p1, p2;
SELECT ST_AsText(p1), ST_AsText(p2) FROM gis_point ORDER BY p1, p2;
-- echo Try to do IDU on the table and verify the result
DELETE FROM gis_point WHERE ST_Equals(p2, ST_PointFromText('POINT(-8 4)'));
INSERT INTO gis_point VALUES(ST_PointFromText('POINT(20.5 -41)'), ST_PointFromText('POINT(8 -4)'));
SELECT ST_AsText(p1) AS 'Expect (32.1234 64.2468)' FROM gis_point WHERE ST_Touches(@poly3, p1) AND MBRWithin(p2, @poly4);
UPDATE gis_point SET p1 = ST_PointFromText('POINT(20.5 41)'), p2 = ST_PointFromText('POINT(-8 4)') WHERE ST_Intersection(@ls3, @ls4) = p1;
SELECT ST_AsText(p1) AS 'Expect (32.1234 64.2468) AND (20.5 41)' FROM gis_point WHERE ST_Touches(@poly3, p1) AND MBRWithin(p2, @poly4);
CHECK TABLE gis_point;
-- echo Use a trx to test the IDU on the table and verify the result
START TRANSACTION;
DELETE FROM gis_point WHERE ST_Equals(p2, ST_PointFromText('POINT(-8 4)'));
INSERT INTO gis_point VALUES(ST_PointFromText('POINT(20.5 -41)'), ST_PointFromText('POINT(8 -4)'));
SELECT ST_AsText(p1) AS 'Expect (32.1234 64.2468)' FROM gis_point WHERE ST_Touches(@poly3, p1) AND MBRWithin(p2, @poly4);
UPDATE gis_point SET p1 = ST_PointFromText('POINT(20.5 49)'), p2 = ST_PointFromText('POINT(-8 4)') WHERE ST_Intersection(@ls3, @ls4) = p1;
SELECT ST_AsText(p1) AS 'Expect (32.1234 64.2468) AND (20.5 49)' FROM gis_point WHERE ST_Touches(@poly3, p1) AND MBRWithin(p2, @poly4);
ROLLBACK;
SELECT ST_AsText(p1) AS 'Expect (32.1234 64.2468) AND (20.5 41)' FROM gis_point WHERE ST_Touches(@poly3, p1) AND MBRWithin(p2, @poly4);
CHECK TABLE gis_point;
DROP TABLE gis_point;
--echo #
--echo # Test inserting/updating different type data into POINT field
--echo #
CREATE TABLE gis_point (i INT, p POINT) ENGINE=InnoDB;
CREATE TABLE geom (i INT, g GEOMETRY NOT NULL, SPATIAL KEY(g)) ENGINE=InnoDB;
INSERT INTO gis_point VALUES(0, ST_PointFromText('POINT(1 1)'));
INSERT INTO gis_point VALUES(1, ST_PointFromText('POINT(2 2)'));
INSERT INTO gis_point VALUES(2, NULL);
ALTER TABLE gis_point ADD COLUMN j INT, ALGORITHM = COPY;
SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE name = 'p';
SELECT name, mtype, prtype, len FROM INFORMATION_SCHEMA.INNODB_SYS_COLUMNS WHERE name = 'p';
SELECT i, ST_AsText(p) FROM gis_point;
UPDATE gis_point SET p = NULL WHERE p = ST_PointFromText('POINT(1 1)');
UPDATE gis_point SET p = ST_PointFromText('POINT(1 2)') WHERE p = ST_PointFromText('POINT(2 2)');
UPDATE gis_point SET p = ST_PointFromText('POINT(1 1)') WHERE p IS NULL;
SELECT i, ST_AsText(p) FROM gis_point;
INSERT INTO geom VALUES(0, ST_PointFromText('POINT(0 0)'));
INSERT INTO geom VALUES(1, ST_PointFromText('POINT(10 10)'));
INSERT INTO geom VALUES(2, ST_GeomFromText('POLYGON((7 1,6 2,6 3,10 3,10 1,7 1))'));
SELECT ST_AsText(g) FROM geom;
SELECT ST_AsText(p) FROM gis_point;
DELETE FROM geom WHERE g = ST_GeomFromText('POLYGON((7 1,6 2,6 3,10 3,10 1,7 1))');
--echo From GEOMETRY to POINT, now ALL the data are POINT
ALTER TABLE geom MODIFY g POINT NOT NULL;
SHOW CREATE TABLE geom;
SELECT ST_AsText(g) FROM geom;
--echo From POINT to GEOMETRY, all data are POINT
ALTER TABLE geom MODIFY g GEOMETRY NOT NULL;
SHOW CREATE TABLE geom;
TRUNCATE TABLE geom;
--echo From GEOMETRY to POINT, the table is empty
ALTER TABLE geom MODIFY g POINT NOT NULL;
SHOW CREATE TABLE geom;
SELECT ST_AsText(g) FROM geom;
CHECK TABLE gis_point;
CHECK TABLE geom;
DROP TABLE gis_point, geom;
--echo #
--echo # Test when a geom field, such as POINT, is also a primary key
--echo #
CREATE TABLE t1 (
a INT NOT NULL,
p POINT NOT NULL,
l LINESTRING NOT NULL,
g GEOMETRY NOT NULL,
PRIMARY KEY(p),
SPATIAL KEY `idx2` (p),
SPATIAL KEY `idx3` (l),
SPATIAL KEY `idx4` (g)
) ENGINE=InnoDB;
INSERT INTO t1 VALUES(
1, ST_GeomFromText('POINT(10 10)'),
ST_GeomFromText('LINESTRING(1 1, 5 5, 10 10)'),
ST_GeomFromText('POLYGON((30 30, 40 40, 50 50, 30 50, 30 40, 30 30))'));
INSERT INTO t1 VALUES(
2, ST_GeomFromText('POINT(20 20)'),
ST_GeomFromText('LINESTRING(2 3, 7 8, 9 10, 15 16)'),
ST_GeomFromText('POLYGON((10 30, 30 40, 40 50, 40 30, 30 20, 10 30))'));
SELECT a, ST_AsText(p), ST_AsText(l), ST_AsText(g) FROM t1;
--replace_column 10 #
EXPLAIN UPDATE t1 SET p = ST_GeomFromText('POINT(30 30)') WHERE p = ST_GeomFromText('POINT(20 20)');
UPDATE t1 SET p = ST_GeomFromText('POINT(30 30)') WHERE p = ST_GeomFromText('POINT(20 20)');
# Once Bug 18265942 - GIS: INNODB WOULD GET POSSIBLE WRONG FIND_FLAG FOR SELECT FROM SERVER is fixed, we can test all the following statements commented out.
#SELECT ST_AsText(p) FROM t1 WHERE MBRWithin(p, ST_GeomFromText('POLYGON((25 25, 25 35, 35 35, 35 25, 25 25))'));
#UPDATE t1 SET p = ST_GeomFromText('POINT(15 15)') WHERE MBRWithin(p, ST_GeomFromText('POLYGON((25 25, 25 35, 35 35, 35 25, 25 25))'));
#DELETE FROM t1 WHERE MBRWithin(p, ST_GeomFromText('LINESTRING(15 15, 15 25, 25 25, 35 15, 15 15)'));
#SELECT a, ST_AsText(p), ST_AsText(l), ST_AsText(g) FROM t1;
#INSERT INTO t1 VALUES(
#3, ST_GeomFromText('POINT(25 25)'),
#ST_GeomFromText('LINESTRING(2 3, 7 8, 9 10, 15 16)'),
#ST_GeomFromText('POLYGON((10 30, 30 40, 40 50, 40 30, 30 20, 10 30))'));
#UPDATE t1 SET p = ST_GeomFromText('POINT(50 50)'), l = ST_GeomFromText('LINESTRING(20 20, 21 21, 22 22, 23 23)') WHERE MBRWithin(g, ST_GeomFromText('LINESTRING(25 25, 25 50, 50 50, 50 25, 25 25)'));
SELECT a, ST_AsText(p), ST_AsText(l), ST_AsText(g) FROM t1;
ALTER TABLE t1 DROP PRIMARY KEY;
ALTER TABLE t1 ADD PRIMARY KEY(a);
SELECT a, ST_AsText(p), ST_AsText(l), ST_AsText(g) FROM t1;
ALTER TABLE t1 DROP PRIMARY KEY;
ALTER TABLE t1 ADD PRIMARY KEY(p);
SELECT a, ST_AsText(p), ST_AsText(l), ST_AsText(g) FROM t1;
SHOW CREATE TABLE t1;
# Also waiting for Bug 18265942
#UPDATE t1 SET p = ST_PointFromText('POINT(20 20)') WHERE ST_Equals(p, ST_PointFromText('POINT(30 30)'));
#INSERT INTO t1 VALUES(
#3, ST_GeomFromText('POINT(25 25)'),
#ST_GeomFromText('LINESTRING(2 3, 7 8, 9 10, 15 16)'),
#ST_GeomFromText('POLYGON((10 30, 30 40, 40 50, 40 30, 30 20, 10 30))'));
SELECT a, ST_AsText(p), ST_AsText(l), ST_AsText(g) FROM t1;
ALTER TABLE t1 DROP PRIMARY KEY;
ALTER TABLE t1 ADD PRIMARY KEY(p);
--replace_column 10 #
EXPLAIN SELECT a, ST_AsText(p) FROM t1 WHERE a = 2 AND p = ST_GeomFromText('POINT(30 30)');
SELECT a, ST_AsText(p) FROM t1 WHERE a = 2 AND p = ST_GeomFromText('POINT(30 30)');
SELECT a, ST_AsText(p), ST_AsText(l), ST_AsText(g) FROM t1;
CHECK TABLE t1;
DROP TABLE t1;
--echo #
--echo # Test for foreign keys.
--echo #
CREATE TABLE parent(p POINT, PRIMARY KEY(p)) ENGINE=InnoDB;
CREATE TABLE child(p POINT NOT NULL) ENGINE=InnoDB;
ALTER TABLE parent ADD SPATIAL INDEX idx1(p ASC);
ALTER TABLE child ADD SPATIAL INDEX idx2(p ASC);
SHOW CREATE TABLE parent;
SHOW CREATE TABLE child;
--error ER_CANNOT_ADD_FOREIGN
ALTER TABLE child ADD FOREIGN KEY(p) REFERENCES parent(p);
ALTER TABLE parent DROP INDEX idx1;
--error ER_CANNOT_ADD_FOREIGN
ALTER TABLE child ADD FOREIGN KEY(p) REFERENCES parent(p);
ALTER TABLE child DROP INDEX idx2;
--error ER_CANNOT_ADD_FOREIGN
ALTER TABLE child ADD FOREIGN KEY(p) REFERENCES parent(p);
DROP TABLE child, parent;
--echo #
--echo # Bug#28763: Selecting geometry fields in UNION caused server crash.
--echo #
CREATE TABLE t1(f1 GEOMETRY, f2 POINT, f3 GEOMETRY) ENGINE=InnoDB;
SELECT f1 FROM t1 UNION SELECT f1 FROM t1;
INSERT INTO t1 (f2,f3) VALUES (ST_GeomFromText('POINT(1 1)'),
ST_GeomFromText('POINT(2 2)'));
SELECT ST_AsText(f2),ST_AsText(f3) FROM t1;
SELECT ST_AsText(a) FROM (SELECT f2 AS a FROM t1 UNION SELECT f3 FROM t1) t;
CREATE TABLE t2 AS SELECT f2 AS a FROM t1 UNION SELECT f3 FROM t1;
DESC t2;
SELECT ST_AsText(a) FROM t2;
DROP TABLE t1, t2;
#********************************************************
# wl6942: Store certain GIS data type in the row rather
# than as BLOB.
#
#********************************************************
--source include/have_geometry.inc
--source include/have_innodb.inc
--source include/not_embedded.inc
--source include/big_test.inc
--source include/not_valgrind.inc
--echo #
--echo # Test when the POINT is on B-TREE
--echo #
CREATE TABLE t1(fid INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT, p POINT, KEY(p)) ENGINE=InnoDB;
INSERT INTO t1 VALUES
(101, ST_PointFromText('POINT(10 10)')),
(102, ST_PointFromText('POINT(20 10)')),
(103, ST_PointFromText('POINT(20 20)')),
(104, ST_PointFromWKB(ST_AsWKB(ST_PointFromText('POINT(10 20)'))));
SELECT ST_AsText(p) FROM t1;
SELECT ST_AsText(p) FROM t1 WHERE p = ST_PointFromText('POINT(20 20)');
INSERT INTO t1 VALUES
(201, ST_PointFromText('POINT(100.32374832 101.23741821)')),
(202, ST_PointFromText('POINT(102.43287328 100.23489233)')),
(203, ST_PointFromText('POINT(101.43284962 100.45892392)')),
(204, ST_PointFromWKB(ST_AsWKB(ST_PointFromText('POINT(103.43718640 105.248206478)')))),
(205, ST_PointFromText('POINT(101.43284962 100.45892392)')),
(206, ST_PointFromWKB(ST_AsWKB(ST_PointFromText('POINT(103.43718640 105.248206478)'))));
SELECT ST_AsText(p), COUNT(*) FROM t1 GROUP BY p;
TRUNCATE t1;
SELECT * FROM t1;
INSERT INTO t1(p) VALUES(ST_PointFromText('POINT(10 10)')),
(ST_PointFromText('POINT(10 20)')),
(ST_PointFromText('POINT(10 40)')),
(ST_PointFromText('POINT(10 60)')),
(ST_PointFromText('POINT(20 15)')),
(ST_PointFromText('POINT(30 10)')),
(ST_PointFromText('POINT(40 10)')),
(ST_PointFromText('POINT(50 10)')),
(ST_PointFromText('POINT(60 5)')),
(ST_PointFromText('POINT(60 10)')),
(ST_PointFromText('POINT(60 20)')),
(ST_PointFromText('POINT(60 100)')),
(ST_PointFromText('POINT(100 100)')),
(ST_PointFromText('POINT(80 60)')),
(ST_PointFromText('POINT(81 50)')),
(ST_PointFromText('POINT(82 70)')),
(ST_PointFromText('POINT(83 30)')),
(ST_PointFromText('POINT(20 100)')),
(ST_PointFromText('POINT(150 2000)')),
(ST_PointFromText('POINT(109 230)')),
(ST_PointFromText('POINT(280 250)')),
(ST_PointFromText('POINT(176 175)')),
(ST_PointFromText('POINT(200 10)')),
(NULL),
(NULL);
SELECT ST_AsText(p) FROM t1;
SELECT COUNT(*) FROM t1;
SELECT ST_AsText(p) FROM t1;
SELECT COUNT(*) FROM t1;
INSERT INTO t1(p) SELECT p FROM t1;
INSERT INTO t1(p) SELECT p FROM t1;
INSERT INTO t1(p) SELECT p FROM t1;
INSERT INTO t1(p) SELECT p FROM t1;
INSERT INTO t1(p) SELECT p FROM t1;
INSERT INTO t1(p) SELECT p FROM t1;
INSERT INTO t1(p) SELECT p FROM t1;
INSERT INTO t1(p) SELECT p FROM t1;
INSERT INTO t1(p) SELECT p FROM t1;
INSERT INTO t1(p) SELECT p FROM t1;
INSERT INTO t1(p) SELECT p FROM t1;
INSERT INTO t1(p) SELECT p FROM t1;
CHECK TABLE t1;
SELECT COUNT(*) FROM t1;
SELECT ST_AsText(p), COUNT(*) FROM t1 GROUP BY p;
SELECT COUNT(*) FROM t1 WHERE p = ST_PointFromText('POINT(280 250)');
DELETE FROM t1 WHERE p = ST_PointFromText('POINT(280 250)');
SELECT COUNT(*) FROM t1 WHERE p = ST_PointFromText('POINT(280 250)');
SELECT COUNT(*) FROM t1 WHERE p = ST_PointFromText('POINT(60 5)');
DELETE FROM t1 WHERE P = ST_PointFromText('POINT(60 5)');
SELECT COUNT(*) FROM t1 WHERE p = ST_PointFromText('POINT(60 5)');
SELECT ST_AsText(p), COUNT(*) FROM t1 WHERE p = ST_PointFromText('POINT(60 10)') OR p = ST_PointFromText('POINT(60 20)') OR p = ST_PointFromText('POINT(60 30)') GROUP BY p;
UPDATE t1 SET p = ST_PointFromText('POINT(101 102)') WHERE p = ST_PointFromText('POINT(60 10)') OR p = ST_PointFromText('POINT(60 20)') OR p = ST_PointFromText('POINT(60 30)');
SELECT ST_AsText(p), COUNT(*) FROM t1 WHERE p = ST_PointFromText('POINT(60 10)') OR p = ST_PointFromText('POINT(60 20)') OR p = ST_PointFromText('POINT(60 30)') GROUP BY p;
SELECT COUNT(*) FROM t1 WHERE p = ST_PointFromText('POINT(101 102)');
SELECT COUNT(*) FROM t1 WHERE p IS NULL;
UPDATE t1 SET p = ST_PointFromText('POINT(160 160)') WHERE p IS NULL;
SELECT COUNT(*) FROM t1 WHERE p IS NULL;
SELECT COUNT(*) FROM t1 WHERE p = ST_PointFromText('POINT(160 160)');
SELECT ST_AsText(p), COUNT(*) FROM t1 GROUP BY p;
SELECT COUNT(*) FROM t1;
CHECK TABLE t1;
DROP TABLE t1;
--echo #
--echo # Test when POINT is used in spatial index
--echo #
SET @ls1 = ST_GeomFromText('LINESTRING(0 20, 10 0)');
SET @ls2 = ST_GeomFromText('LINESTRING(0 0, 10 20)');
SET @ls3 = ST_GeomFromText('LINESTRING(20 -40, 21 -42)');
SET @ls4 = ST_GeomFromText('LINESTRING(20 -42, 21 -40)');
SET @poly1 = ST_GeomFromText('POLYGON((2 2, 2 10, 10 10, 10 2, 2 2))');
SET @poly2 = ST_GeomFromText('POLYGON((0 0, -5 0, -4 -1, -6 -15, -3 -15, 0 0))');
SET @poly3 = ST_GeomFromText('POLYGON((10.0 10.0, 20.5 20, 20.5 50, 32.0 64.0, 32.3 64.6, 5 60, 10 10))');
SET @poly4 = ST_GeomFromText('POLYGON((0 10, -10 10, -10 -10, 0 -10, 0 10))');
SET @p1 = ST_PointFromText('POINT(0 0)');
SET @mpoly = ST_GeomFromText('MULTIPOLYGON(((3 3, 3 16, 16 16, 16 3, 3 3)), ((10 10, 10 50, 50 50, 50 10, 10 10)))');
CREATE TABLE gis_point (p1 POINT NOT NULL, p2 POINT NOT NULL, SPATIAL KEY k1 (p1), SPATIAL KEY k2 (p2)) ENGINE=InnoDB;
INSERT INTO gis_point VALUES
(ST_PointFromText('POINT(1 2)'), ST_PointFromText('POINT(-1 -3)')),
(ST_PointFromText('POINT(2 4)'), ST_PointFromText('POINT(-2 -6)')),
(ST_PointFromText('POINT(3 6)'), ST_PointFromText('POINT(-3 -9)')),
(ST_PointFromText('POINT(4 8)'), ST_PointFromText('POINT(-4 -12)')),
(ST_PointFromText('POINT(5 10)'), ST_PointFromText('POINT(-5 -15)')),
(ST_PointFromText('POINT(6 12)'), ST_PointFromText('POINT(-6 -18)')),
(ST_PointFromText('POINT(7 14)'), ST_PointFromText('POINT(-7 -21)')),
(ST_PointFromText('POINT(8 16)'), ST_PointFromText('POINT(0 0)')),
(ST_PointFromText('POINT(9 18)'), ST_PointFromText('POINT(-4 2)')),
(ST_PointFromText('POINT(10 21)'), ST_PointFromText('POINT(-6 3)')),
(ST_PointFromText('POINT(20.5 41)'), ST_PointFromText('POINT(-8 4)')),
(ST_PointFromText('POINT(26.25 57)'), ST_PointFromText('POINT(1 2)')),
(ST_PointFromText('POINT(32.1234 64.2468)'), ST_PointFromText('POINT(-1 -1)'));
-- echo 'The ORDER BY for spatial index will use filesort'
--replace_column 10 #
EXPLAIN SELECT ST_AsText(p1), ST_AsText(p2) FROM gis_point ORDER BY p1, p2;
SELECT ST_AsText(p1), ST_AsText(p2) FROM gis_point ORDER BY p1, p2;
-- echo 'Try to do IDU on the table and verify the result'
DELETE FROM gis_point WHERE ST_Equals(p2, ST_PointFromText('POINT(-8 4)'));
INSERT INTO gis_point VALUES(ST_PointFromText('POINT(20.5 -41)'), ST_PointFromText('POINT(8 -4)'));
SELECT ST_AsText(p1) AS 'Expect (32.1234 64.2468)' FROM gis_point WHERE ST_TOUCHES(@poly3, p1) AND MBRWithin(p2, @poly4);
UPDATE gis_point SET p1 = ST_PointFromText('POINT(20.5 41)'), p2 = ST_PointFromText('POINT(-8 4)') WHERE ST_Intersection(@ls3, @ls4) = p1;
SELECT ST_AsText(p1) AS 'Expect (32.1234 64.2468) AND (20.5 41)' FROM gis_point WHERE ST_TOUCHES(@poly3, p1) AND MBRWithin(p2, @poly4);
CHECK TABLE gis_point;
-- echo ============================================================
-- echo Use a trx to test the IDU on the table and verify the result
-- echo ============================================================
START TRANSACTION;
DELETE FROM gis_point WHERE ST_Equals(p2, ST_PointFromText('POINT(-8 4)'));
INSERT INTO gis_point VALUES(ST_PointFromText('POINT(20.5 -41)'), ST_PointFromText('POINT(8 -4)'));
SELECT ST_AsText(p1) AS 'Expect (32.1234 64.2468)' FROM gis_point WHERE ST_TOUCHES(@poly3, p1) AND MBRWithin(p2, @poly4);
UPDATE gis_point SET p1 = ST_PointFromText('POINT(20.5 49)'), p2 = ST_PointFromText('POINT(-8 4)') WHERE ST_Intersection(@ls3, @ls4) = p1;
SELECT ST_AsText(p1) AS 'Expect (32.1234 64.2468) AND (20.5 49)' FROM gis_point WHERE ST_TOUCHES(@poly3, p1) AND MBRWithin(p2, @poly4);
ROLLBACK;
SELECT ST_AsText(p1) AS 'Expect (32.1234 64.2468) AND (20.5 41)' FROM gis_point WHERE ST_TOUCHES(@poly3, p1) AND MBRWithin(p2, @poly4);
CHECK TABLE gis_point;
-- echo =======================================================
-- echo Enlarge the table by inserting the same data and verify
-- echo =======================================================
INSERT INTO gis_point SELECT * FROM gis_point;
INSERT INTO gis_point SELECT * FROM gis_point;
INSERT INTO gis_point SELECT * FROM gis_point;
INSERT INTO gis_point SELECT * FROM gis_point;
INSERT INTO gis_point SELECT * FROM gis_point;
INSERT INTO gis_point SELECT * FROM gis_point;
INSERT INTO gis_point SELECT * FROM gis_point;
INSERT INTO gis_point SELECT * FROM gis_point;
INSERT INTO gis_point SELECT * FROM gis_point;
INSERT INTO gis_point SELECT * FROM gis_point;
CHECK TABLE gis_point;
SELECT COUNT(*), ST_AsText(p1), ST_AsText(p2) FROM gis_point GROUP BY p1, p2;
SELECT COUNT(*), ST_AsText(p1) FROM gis_point WHERE ST_Intersection(@ls1, @ls2) = p1 GROUP BY p1;
SELECT COUNT(*), ST_AsText(p1) FROM gis_point WHERE MBRWithin(p1, @poly1) GROUP BY p1;
SELECT COUNT(*), ST_AsText(p2) FROM gis_point WHERE ST_Contains(@poly2, p2) GROUP BY p2;
SELECT COUNT(*), ST_AsText(p2) FROM gis_point WHERE ST_Equals(p2, @p1) GROUP BY p2;
SELECT COUNT(*), ST_AsText(p1) FROM gis_point WHERE ST_TOUCHES(@poly3, p1) AND MBRWithin(p2, @poly4) GROUP BY p1;
SELECT COUNT(*), ST_AsText(p1), ST_AsText(p2) FROM gis_point WHERE ST_Contains(@mpoly, p1) GROUP BY p1, p2;
SELECT COUNT(*), ST_AsText(p1), ST_AsText(p2) FROM gis_point WHERE ST_Contains(@mpoly, p1) AND NOT MBRWithin(p1, @mpoly) GROUP BY p1, p2;
-- echo ======================================================================
-- echo Build another new table with the same schema, will insert data from this table to the orignal one
-- echo ======================================================================
CREATE TABLE p(p1 POINT NOT NULL, p2 POINT NOT NULL, SPATIAL INDEX k1(p2)) ENGINE=InnoDB;
INSERT INTO p VALUES(ST_PointFromText('POINT(1000 -1000)'), ST_PointFromText('POINT(-201 203.56)'));
INSERT INTO p VALUES(ST_PointFromText('POINT(20.5 43.9832)'), ST_PointFromText('POINT(-0 0)'));
INSERT INTO p VALUES(ST_PointFromText('POINT(-4.2 -6.98)'), ST_PointFromText('POINT(-120.5 343.9832)'));
INSERT INTO p SELECT * FROM p WHERE MBRWithin(p1, ST_GeomFromText('POLYGON((0 0, 0 2000, 2000 2000, 2000 -2000, 0 -2000, 0 0))'));
INSERT INTO p SELECT * FROM p WHERE MBRWithin(p1, ST_GeomFromText('POLYGON((0 0, -10 0, -100 -100, 0 -50, 0 0))'));
SELECT COUNT(*), ST_AsText(p1), ST_AsText(p2) FROM p GROUP BY p1, p2;
INSERT INTO gis_point SELECT * FROM p;
INSERT INTO gis_point SELECT * FROM p;
INSERT INTO gis_point SELECT * FROM p;
INSERT INTO gis_point SELECT * FROM p;
INSERT INTO gis_point SELECT * FROM p;
INSERT INTO gis_point SELECT * FROM p;
INSERT INTO gis_point SELECT * FROM p;
CHECK TABLE gis_point;
SELECT COUNT(*), ST_AsText(p1), ST_AsText(p2) FROM gis_point GROUP BY p1, p2;
SELECT COUNT(*), ST_AsText(p1) FROM gis_point WHERE ST_TOUCHES(@poly3, p1) AND MBRWithin(p2, @poly4) GROUP BY p1;
SELECT COUNT(*), ST_AsText(p2) FROM gis_point WHERE MBRWithin(p2, @poly2) GROUP BY p2;
DROP TABLE p;
-- echo ================================
-- echo Use a trx to test IUD and verify
-- echo ================================
# Temporarily disabled the following test case, since the ROLLBACK and
# some other DML would cost too much of time. We could test them until
# we have optimized the UNDO, etc.
#START TRANSACTION;
#-- echo 'To remove (-2 -6), (-1 -3)'
#DELETE FROM gis_point WHERE ST_Contains(ST_GeomFromText('POLYGON((-8 -8, 4 -7, 1 1, 0 -1, -2 -2, -8 -8))') , p2);
#SELECT COUNT(*), ST_AsText(p2) FROM gis_point WHERE ST_Contains(@poly2, p2) GROUP BY p2;
#-- echo 'To set (-1 -1) to (-5.12 -10.84)'
#UPDATE gis_point SET p2 = ST_PointFromText('POINT(-5.12 -10.84)') WHERE ST_Intersection(ST_GeomFromText('LINESTRING(-3 4, -2 0, 0.5 -2.5, 5 0)'), ST_GeomFromText('LINESTRING(0.6 0.6, -10 -10)')) = p2;
#SELECT COUNT(*), ST_AsText(p2) FROM gis_point WHERE MBRWithin(p2, @poly2) GROUP BY p2;
#-- echo 'To insert several (-3.6 -4.05) (-1 -1)
#INSERT INTO gis_point VALUES
#(ST_PointFromText('POINT(10.1 2.6)'), ST_PointFromText('POINT(-1 -1)')),
#(ST_PointFromText('POINT(100.99 -2.53)'), ST_PointFromText('POINT(-3.6 -4.05)')),
#(ST_PointFromText('POINT(13.62 3.87)'), ST_PointFromText('POINT(-1 -1)')),
#(ST_PointFromText('POINT(-36.3 0.34)'), ST_PointFromText('POINT(-1 -1)')),
#(ST_PointFromText('POINT(1.04 25.6)'), ST_PointFromText('POINT(-3.6 -4.05)'));
#SELECT COUNT(*), ST_AsText(p2) FROM gis_point WHERE MBRWithin(p2, @poly2) GROUP BY p2;
#SELECT COUNT(*), ST_AsText(p2) FROM gis_point WHERE ST_Contains(ST_GeomFromText('POLYGON((-0.999 -0.999, -6 -1, -6 -7, -0.99999 -0.99999, -0.999 -0.999))'), p2) GROUP BY p2;
#ROLLBACK;
#CHECK TABLE gis_point;
-- echo =============================================
-- echo Delete those rows selected from another table
-- echo =============================================
SELECT COUNT(*), ST_AsText(p1), ST_AsText(p2) FROM gis_point GROUP BY p1, p2;
UPDATE gis_point SET p2 = ST_PointFromText('POINT(2000 2000)') WHERE ST_Contains(ST_GeomFromText('POLYGON((-100 100, -400 100, -400 400, -100 400, -100 100))'), p2) OR ST_Contains(ST_GeomFromText('POLYGON((-0.0001 -0.0002, -0.0001 0.00002, 0.00000005 0.000001, 0.0000025 -0.001, -0.0001 -0.0002))'), p2);
CHECK TABLE gis_point;
-- echo 'To remove all the just updated rows'
DELETE FROM gis_point WHERE ST_Intersection(ST_GeomFromText('LINESTRING(1800 1900, 2200 2100)'), ST_GeomFromText('LINESTRING(0 0, 2001 2001)')) = p2;
INSERT INTO gis_point VALUES
(ST_PointFromText('POINT(8 16)'), ST_PointFromText('POINT(0 0)')),
(ST_PointFromText('POINT(8 16)'), ST_PointFromText('POINT(0 0)'));
-- echo ======================================================================
-- echo Following results should be almost the same with those at the beginning
-- echo ======================================================================
SELECT COUNT(*), ST_AsText(p1), ST_AsText(p2) FROM gis_point GROUP BY p1, p2;
SELECT COUNT(*), ST_AsText(p1), ST_AsText(p2)
FROM gis_point
WHERE ST_Contains(ST_GeomFromText('POLYGON((-1000 -1000, -1000 1000, 1000 1000, 1001 -1001, -1000 -1000))'), p1)
GROUP BY p1, p2;
SELECT ST_AsText(p1), ST_AsText(p2) FROM gis_point GROUP BY p1, p2;
SELECT COUNT(*), ST_AsText(p1) FROM gis_point WHERE ST_Intersection(@ls1, @ls2) = p1 GROUP BY p1;
SELECT COUNT(*), ST_AsText(p1) FROM gis_point WHERE MBRWithin(p1, @poly1) GROUP BY p1;
SELECT COUNT(*), ST_AsText(p2) FROM gis_point WHERE ST_Contains(@poly2, p2) GROUP BY p2;
SELECT COUNT(*), ST_AsText(p2) FROM gis_point WHERE ST_Equals(p2, @p1) GROUP BY p2;
SELECT COUNT(*), ST_AsText(p1) FROM gis_point WHERE ST_TOUCHES(@poly3, p1) AND MBRWithin(p2, @poly4) GROUP BY p1;
SELECT COUNT(*), ST_AsText(p1), ST_AsText(p2) FROM gis_point WHERE ST_Contains(@mpoly, p1) GROUP BY p1, p2;
SELECT COUNT(*), ST_AsText(p1), ST_AsText(p2) FROM gis_point WHERE ST_Contains(@mpoly, p1) AND NOT MBRWithin(p1, @mpoly) GROUP BY p1, p2;
CHECK TABLE gis_point;
DROP TABLE gis_point;
# *****************************************************************
# Test spatial index with isolation level Repeatable Read on DML
# This will also test the no phantom rows happens
# Check the COUNT(*) and SELECT results before & after COMMIT in
# the last con1 statment
# Test at con1: Global Repeatable Read con2 : Sess Read Committed
# Test at con1: Sess Repeatable Read con2 : Sess Read Committed
# *****************************************************************
--source include/have_innodb.inc
--source include/have_geometry.inc
--source include/not_embedded.inc
# Test Repeatable Read & Read committed at Global, Session levels
CREATE TABLE tab(c1 int NOT NULL PRIMARY KEY,c2 POINT NOT NULL,
c3 LINESTRING NOT NULL,c4 POLYGON NOT NULL,c5 GEOMETRY NOT NULL)
ENGINE=InnoDB;
ALTER TABLE tab ADD SPATIAL INDEX idx2(c2 ASC);
ALTER TABLE tab ADD SPATIAL KEY idx3(c3 DESC);
ALTER TABLE tab ADD SPATIAL INDEX idx4(c4 ASC) COMMENT 'testing spatial index on Polygon';
ALTER TABLE tab ADD SPATIAL KEY idx5(c5 ASC) COMMENT 'testing spatial index on Geometry';
INSERT INTO tab(c1,c2,c3,c4,c5)
VALUES(1,ST_GeomFromText('POINT(10 10)'),ST_GeomFromText('LINESTRING(5 5,20 20,30 30)'),
ST_GeomFromText('POLYGON((30 30,40 40,50 50,30 50,30 40,30 30))'),
ST_GeomFromText('POLYGON((30 30,40 40,50 50,30 50,30 40,30 30))'));
# 1 record is expected
SELECT c1,ST_AsText(c2),ST_AsText(c3),ST_AsText(c4),ST_AsText(c5) FROM tab;
# Record count should be 1
SELECT COUNT(*) FROM tab;
--echo "In connection 1"
connect (con1,localhost,root,,);
connection con1;
SET GLOBAL TRANSACTION ISOLATION LEVEL REPEATABLE READ;
SELECT @@tx_isolation;
# Record count should be 1
SELECT COUNT(*) FROM tab;
# 1 record is expected
SELECT c1,ST_AsText(c2),ST_AsText(c3),ST_AsText(c4),ST_AsText(c5) FROM tab;
--echo "In connection 2"
connect (con2,localhost,root,,);
connection con2;
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
SELECT @@tx_isolation;
START TRANSACTION;
INSERT INTO tab(c1,c2,c3,c4,c5)
VALUES(2,ST_GeomFromText('POINT(20 20)'),ST_GeomFromText('LINESTRING(20 20,30 30,40 40)'),
ST_GeomFromText('POLYGON((40 50,40 70,50 100,70 100,80 80,70 50,40 50))'),
ST_GeomFromText('POLYGON((40 50,40 70,50 100,70 100,80 80,70 50,40 50))'));
SET @g1 = ST_GeomFromText('POLYGON((30 30,40 40,50 50,30 50,30 40,30 30))');
SET @g2 = ST_GeomFromText('POINT(10 10)');
# Record should be updated
UPDATE tab SET C5 = ST_GeomFromText('POLYGON((300 300,400 400,500 500,300 500,300 400,300 300))')
WHERE MBREquals(tab.c4, @g1) AND MBREquals(tab.c2, @g2);
--echo "In connection 1"
connection con1;
SET @g3 = ST_GeomFromText('POLYGON((40 50,40 70,50 100,70 100,80 80,70 50,40 50))');
# No record is expected (No phantom row)
SELECT c1,ST_AsText(c2),ST_AsText(c4),ST_AsText(c5) FROM tab WHERE MBREquals(tab.c5, @g3);
# Record count should be 1
SELECT COUNT(*) FROM tab;
START TRANSACTION;
# Record count should be 1
SELECT COUNT(*) FROM tab;
--echo "In connection 2"
connection con2;
# Record count should be 2
SELECT COUNT(*) FROM tab;
COMMIT;
disconnect con2;
--source include/wait_until_disconnected.inc
--echo "In connection 1"
connection con1;
# Record count should be 1
SELECT COUNT(*) FROM tab;
SET @g4 = ST_GeomFromText('POLYGON((300 300,400 400,500 500,300 500,300 400,300 300))');
# No records are expected (No phantom row)
SELECT ST_AsText(c5) FROM tab WHERE MBREquals(tab.c5, @g4);
COMMIT;
# The updated record is expected
SELECT ST_AsText(c5) FROM tab WHERE MBREquals(tab.c5, @g4);
# Record count should be 2
SELECT COUNT(*) FROM tab;
# 2 records are expected
SELECT c1,ST_AsText(c2),ST_AsText(c4),ST_AsText(c5) FROM tab;
disconnect con1;
--source include/wait_until_disconnected.inc
--connection default
DROP TABLE tab;
# Test Repeatable Read & Read committed at Session levels
CREATE TABLE tab(c1 int NOT NULL PRIMARY KEY,c2 POINT NOT NULL,
c3 LINESTRING NOT NULL,c4 POLYGON NOT NULL,c5 GEOMETRY NOT NULL)
ENGINE=InnoDB;
ALTER TABLE tab ADD SPATIAL INDEX idx2(c2 ASC);
ALTER TABLE tab ADD SPATIAL KEY idx3(c3 DESC);
ALTER TABLE tab ADD SPATIAL INDEX idx4(c4 ASC) COMMENT 'testing spatial index on Polygon';
ALTER TABLE tab ADD SPATIAL KEY idx5(c5 ASC) COMMENT 'testing spatial index on Geometry';
INSERT INTO tab(c1,c2,c3,c4,c5)
VALUES(1,ST_GeomFromText('POINT(10 10)'),ST_GeomFromText('LINESTRING(5 5,20 20,30 30)'),
ST_GeomFromText('POLYGON((30 30,40 40,50 50,30 50,30 40,30 30))'),
ST_GeomFromText('POLYGON((30 30,40 40,50 50,30 50,30 40,30 30))'));
# 1 record is expected
SELECT c1,ST_AsText(c2),ST_AsText(c3),ST_AsText(c4),ST_AsText(c5) FROM tab;
# Record count should be 1
SELECT COUNT(*) FROM tab;
--echo "In connection 1"
connect (con1,localhost,root,,);
connection con1;
SET SESSION TRANSACTION ISOLATION LEVEL REPEATABLE READ;
SELECT @@tx_isolation;
# Record count should be 1
SELECT COUNT(*) FROM tab;
# 1 record is expected
SELECT c1,ST_AsText(c2),ST_AsText(c3),ST_AsText(c4),ST_AsText(c5) FROM tab;
--echo "In connection 2"
connect (con2,localhost,root,,);
connection con2;
SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
SELECT @@tx_isolation;
START TRANSACTION;
INSERT INTO tab(c1,c2,c3,c4,c5)
VALUES(2,ST_GeomFromText('POINT(20 20)'),ST_GeomFromText('LINESTRING(20 20,30 30,40 40)'),
ST_GeomFromText('POLYGON((40 50,40 70,50 100,70 100,80 80,70 50,40 50))'),
ST_GeomFromText('POLYGON((40 50,40 70,50 100,70 100,80 80,70 50,40 50))'));
SET @g1 = ST_GeomFromText('POLYGON((30 30,40 40,50 50,30 50,30 40,30 30))');
SET @g2 = ST_GeomFromText('POINT(10 10)');
# Record should be updated
UPDATE tab SET C5 = ST_GeomFromText('POLYGON((300 300,400 400,500 500,300 500,300 400,300 300))')
WHERE MBREquals(tab.c4, @g1) AND MBREquals(tab.c2, @g2);
--echo "In connection 1"
connection con1;
SET @g3 = ST_GeomFromText('POLYGON((40 50,40 70,50 100,70 100,80 80,70 50,40 50))');
# No record is expected (No phantom row)
SELECT c1,ST_AsText(c2),ST_AsText(c4),ST_AsText(c5) FROM tab WHERE MBREquals(tab.c5, @g3);
# Record count should be 1
SELECT COUNT(*) FROM tab;
START TRANSACTION;
# Record count should be 1
SELECT COUNT(*) FROM tab;
--echo "In connection 2"
connection con2;
# Record count should be 2
SELECT COUNT(*) FROM tab;
COMMIT;
disconnect con2;
--source include/wait_until_disconnected.inc
--echo "In connection 1"
connection con1;
# Record count should be 1
SELECT COUNT(*) FROM tab;
SET @g4 = ST_GeomFromText('POLYGON((300 300,400 400,500 500,300 500,300 400,300 300))');
# No records are expected (No phantom row)
SELECT ST_AsText(c5) FROM tab WHERE MBREquals(tab.c5, @g4);
COMMIT;
# The updated record is expected
SELECT ST_AsText(c5) FROM tab WHERE MBREquals(tab.c5, @g4);
# Record count should be 2
SELECT COUNT(*) FROM tab;
# 2 records are expected
SELECT c1,ST_AsText(c2),ST_AsText(c4),ST_AsText(c5) FROM tab;
disconnect con1;
--source include/wait_until_disconnected.inc
--connection default
DROP TABLE tab;
This source diff could not be displayed because it is too large. You can view the blob instead.
--source include/not_embedded.inc
--source include/have_innodb.inc
--source include/have_innodb_zip.inc
# Test the redundant format
LET $file_per_table='off';
LET $file_format='Antelope';
LET $row_format=REDUNDANT;
--source include/innodb_gis_row_format_basic.inc
# Test the compressed format
LET $file_per_table='on';
LET $file_format='Barracuda';
LET $row_format=COMPRESSED;
--source include/innodb_gis_row_format_basic.inc
# Test the dynamic format
LET $file_per_table='on';
LET $file_format='Barracuda';
LET $row_format=DYNAMIC;
--source include/innodb_gis_row_format_basic.inc
# Test the compact format
LET $file_per_table='off';
LET $file_format='Antelope';
LET $row_format=COMPACT;
--source include/innodb_gis_row_format_basic.inc
# WL#6745 InnoDB R-tree support
# This test case will test R-tree split.
# Not supported in embedded
--source include/not_embedded.inc
--source include/have_innodb.inc
--source include/have_innodb_zip.inc
--source include/have_debug.inc
--source include/big_test.inc
# Valgrind takes too much time on PB2 even in the --big-test runs.
--source include/not_valgrind.inc
# Create table with R-tree index.
SET GLOBAL innodb_file_per_table=1;
#Create table with R-tree index.
create table t1 (c1 int, c2 geometry not null, spatial index (c2))engine=innodb ROW_FORMAT=COMPRESSED;
# Insert enough values to let R-tree split.
insert into t1 values(1, Point(1,1));
insert into t1 values(2, Point(2,2));
insert into t1 values(3, Point(3,3));
insert into t1 values(4, Point(4,4));
insert into t1 values(5, Point(5,5));
insert into t1 values(6, Point(6,6));
insert into t1 values(7, Point(7,7));
insert into t1 values(8, Point(8,8));
insert into t1 values(9, Point(9,9));
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
start transaction;
insert into t1 select * from t1;
select count(*) from t1;
rollback;
check table t1;
select count(*) from t1;
set @g1 = ST_GeomFromText('Polygon((0 0,0 100,100 100,100 0,0 0))');
select count(*) from t1 where MBRWithin(t1.c2, @g1);
set @g1 = ST_GeomFromText('Polygon((10 10,10 800,800 800,800 10,10 10))');
select count(*) from t1 where MBRWithin(t1.c2, @g1);
SET DEBUG='+d,page_copy_rec_list_start_compress_fail';
delete from t1;
SET DEBUG='-d,page_copy_rec_list_start_compress_fail';
select count(*) from t1 where MBRWithin(t1.c2, @g1);
# Clean up.
drop table t1;
# WL#6745 InnoDB R-tree support
# This test case will test R-tree multi level split.
# Restarting is not supported in embedded
--source include/not_embedded.inc
--source include/have_innodb.inc
--source include/have_innodb_zip.inc
--source include/big_test.inc
# Valgrind takes too much time on PB2 even in the --big-test runs.
--source include/not_valgrind.inc
SET GLOBAL innodb_file_per_table=1;
# Create table with R-tree index.
create table t1 (c1 int, c2 geometry not null, spatial index (c2))engine=innodb ROW_FORMAT=COMPRESSED;
# Insert enough values to let R-tree split.
delimiter |;
create procedure insert_t1(IN total int)
begin
declare i int default 1;
while (i <= total) DO
insert into t1 values (i, Point(i, i));
set i = i + 1;
end while;
end|
delimiter ;|
# Test level 3 rtree.
CALL insert_t1(70000);
select count(*) from t1;
# Check table.
check table t1;
truncate table t1;
# Test crash recovery.
#
#
call mtr.add_suppression("InnoDB: page [0-9]+ in the doublewrite buffer is not within space bounds.*");
# Test rtree enlarge recovery.
START TRANSACTION;
CALL insert_t1(5000);
#select count(*) from t1;
# Check table.
#check table t1;
COMMIT;
--source include/kill_and_restart_mysqld.inc
# Clean up.
drop procedure insert_t1;
drop table t1;
# WL#6745 InnoDB R-tree support
# This test case will test R-tree split.
# Not supported in embedded
--source include/not_embedded.inc
--source include/have_innodb.inc
--source include/have_debug.inc
--source include/have_debug_sync.inc
--source include/big_test.inc
# Create table with R-tree index.
create table t1 (c1 int, c2 geometry not null, spatial index (c2))engine=innodb;
# Insert enough values to let R-tree split.
insert into t1 values(1, Point(1,1));
insert into t1 values(2, Point(2,2));
insert into t1 values(3, Point(3,3));
insert into t1 values(4, Point(4,4));
insert into t1 values(5, Point(5,5));
insert into t1 values(6, Point(6,6));
insert into t1 values(7, Point(7,7));
insert into t1 values(8, Point(8,8));
insert into t1 values(9, Point(9,9));
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
connect (a,localhost,root,,);
connection a;
SET SESSION debug="+d,rtr_pcur_move_to_next_return";
set session transaction isolation level serializable;
set @g1 = ST_GeomFromText('Polygon((0 0,0 100,100 100,100 0,0 0))');
SET DEBUG_SYNC = 'RESET';
SET DEBUG_SYNC = 'row_search_for_mysql_before_return SIGNAL started WAIT_FOR go_ahead';
--send select count(*) from t1 where MBRWithin(t1.c2, @g1);
--echo # Establish session con1 (user=root)
connect (con1,localhost,root,,);
connection con1;
set session transaction isolation level serializable;
SET DEBUG_SYNC = 'now WAIT_FOR started';
insert into t1 select * from t1;
SET DEBUG_SYNC = 'now SIGNAL go_ahead';
connection a;
reap;
select count(*) from t1 where MBRWithin(t1.c2, @g1);
connection default;
insert into t1 select * from t1;
insert into t1 select * from t1;
set @g1 = ST_GeomFromText('Polygon((0 0,0 100,100 100,100 0,0 0))');
select count(*) from t1 where MBRWithin(t1.c2, @g1);
set @g1 = ST_GeomFromText('Polygon((10 10,10 800,800 800,800 10,10 10))');
select count(*) from t1 where MBRWithin(t1.c2, @g1);
set session transaction isolation level serializable;
truncate t1;
# Test on predicate locking
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(2 2, 150 150)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(3 3, 160 160)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(4 4, 170 170)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(5 5, 180 180)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(6 6, 190 190)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(7 7, 200 200)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(8 8, 210 210)'));
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
# Connection 'a' will place predicate lock on almost all pages
connection a;
set session transaction isolation level serializable;
select @@tx_isolation;
start transaction;
set @g1 = ST_GeomFromText('Polygon((100 100, 100 110, 110 110, 110 100, 100 100))');
select count(*) from t1 where MBRwithin(t1.c2, @g1);
# The split will replicate locks across pages
connect (b,localhost,root,,);
connection b;
set session transaction isolation level serializable;
set session innodb_lock_wait_timeout = 1;
select @@tx_isolation;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
# FIXME: Put this back once we sort out the shrink business
#insert into t1 select * from t1;
connection a;
commit;
connection default;
select count(*) from t1;
# Insert a record that would be in the search range
insert into t1 values (105, Point(105, 105));
# Connection 'a' will place predicate lock on almost all pages
connection a;
start transaction;
set @g1 = ST_GeomFromText('Polygon((100 100, 100 110, 110 110, 110 100, 100 100))');
select count(*) from t1 where MBRwithin(t1.c2, @g1);
connection b;
select @@innodb_lock_wait_timeout;
select @@tx_isolation;
--error ER_LOCK_WAIT_TIMEOUT
insert into t1 select * from t1;
select count(*) from t1;
connection a;
select sleep(2);
commit;
#==================Test predicates on "MBRIntersects"==========================
connection default;
truncate t1;
# Test on predicate locking
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(2 2, 150 150)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(3 3, 160 160)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(4 4, 170 170)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(5 5, 180 180)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(6 6, 190 190)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(7 7, 200 200)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(8 8, 210 210)'));
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
# Connection 'a' will place predicate lock on almost all pages
connection a;
set session transaction isolation level serializable;
select @@tx_isolation;
start transaction;
set @g1 = ST_GeomFromText('Polygon((100 100, 100 110, 110 110, 110 100, 100 100))');
select count(*) from t1 where MBRwithin(t1.c2, @g1);
# The split will replicate locks across pages
connection b;
set session transaction isolation level serializable;
set session innodb_lock_wait_timeout = 1;
select @@tx_isolation;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
connection a;
commit;
connection default;
select count(*) from t1;
# Insert a record that would be in the search range
insert into t1 values (105, Point(105, 105));
# Connection 'a' will place predicate lock on almost all pages
connection a;
start transaction;
set @g1 = ST_GeomFromText('Polygon((100 100, 100 110, 110 110, 110 100, 100 100))');
select count(*) from t1 where MBRwithin(t1.c2, @g1);
select count(*) from t1 where MBRIntersects(t1.c2, @g1);
connection b;
select @@innodb_lock_wait_timeout;
select @@tx_isolation;
# this should conflict with the "MBRIntersects" predicate lock in session "a"
--error ER_LOCK_WAIT_TIMEOUT
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(8 105, 200 105)'));
select count(*) from t1;
connection a;
select sleep(2);
commit;
#==================Test predicate lock on "delete"==========================
connection default;
truncate t1;
# Test on predicate locking
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(2 2, 150 150)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(3 3, 160 160)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(5 5, 180 180)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(6 6, 190 190)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(7 7, 200 200)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(8 8, 210 210)'));
# Connection default will place predicate lock on follow range
set @g1 = ST_GeomFromText('Polygon((3 3, 3 5, 5 5, 5 3, 3 3))');
start transaction;
delete from t1 where MBRWithin(t1.c2, @g1);
connection a;
set session innodb_lock_wait_timeout = 1;
select @@innodb_lock_wait_timeout;
--error ER_LOCK_WAIT_TIMEOUT
insert into t1 values(4, Point(4,4));
connection default;
rollback;
#==================Test predicate lock on "select for update"==================
connection default;
truncate t1;
# Test on predicate locking
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(2 2, 150 150)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(3 3, 160 160)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(5 5, 180 180)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(6 6, 190 190)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(7 7, 200 200)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(8 8, 210 210)'));
# Connection default will place predicate lock on follow range
set @g1 = ST_GeomFromText('Polygon((3 3, 3 5, 5 5, 5 3, 3 3))');
start transaction;
select count(*) from t1 where MBRWithin(t1.c2, @g1) for update;
connection a;
set session innodb_lock_wait_timeout = 1;
select @@innodb_lock_wait_timeout;
--error ER_LOCK_WAIT_TIMEOUT
insert into t1 values(4, Point(4,4));
connection default;
rollback;
#==================Test predicates replicate through split =================
connection default;
truncate t1;
delimiter |;
create procedure insert_t1(IN start int, IN total int)
begin
declare i int default 1;
set i = start;
while (i <= total) DO
insert into t1 values (i, Point(i, i));
set i = i + 1;
end while;
end|
delimiter ;|
CALL insert_t1(0, 1000);
# Connection 'a' will place predicate lock on root and last leaf page
connection a;
set session transaction isolation level serializable;
select @@tx_isolation;
start transaction;
set @g1 = ST_GeomFromText('Polygon((800 800, 800 1000, 1000 1000, 1000 800, 800 800))');
select count(*) from t1 where MBRwithin(t1.c2, @g1);
# Connection 'b' will split the last leaf page, so the predicate
# lock should replicate
connection b;
CALL insert_t1(1001, 2000);
# This insert goes to the new page after split, it should be blocked
set session transaction isolation level serializable;
set session innodb_lock_wait_timeout = 1;
# Insert a record that would be in the search range
--error ER_LOCK_WAIT_TIMEOUT
insert into t1 values (1200, Point(950, 950));
connection a;
select sleep(2);
commit;
connection a;
SET SESSION debug="-d,rtr_pcur_move_to_next_return";
disconnect a;
--source include/wait_until_disconnected.inc
connection b;
disconnect b;
--source include/wait_until_disconnected.inc
# Clean up.
connection default;
drop table t1;
drop procedure insert_t1;
#============ Test row locks =======================
create table t1 (c1 int, c2 geometry not null, spatial index (c2))engine=innodb;
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(2 2, 150 150)'));
INSERT INTO t1 VALUES (2, ST_GeomFromText('LineString(3 3, 160 160)'));
INSERT INTO t1 VALUES (2, ST_GeomFromText('LineString(4 4, 170 170)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(5 5, 180 180)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(6 6, 190 190)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(7 7, 200 200)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(8 8, 210 210)'));
connect (a,localhost,root,,);
connection a;
SET SESSION debug="+d,rtr_pcur_move_to_next_return";
set transaction isolation level serializable;
start transaction;
set @g1 = ST_GeomFromText('Polygon((100 100, 100 110, 110 110, 110 100, 100 100))');
select count(*) from t1 where MBRwithin(t1.c2, @g1);
connect (b,localhost,root,,);
connection b;
# This should be successful
delete from t1 where c1 = 1;
connection a;
commit;
set transaction isolation level serializable;
start transaction;
set @g1 = ST_GeomFromText('Polygon((0 0, 0 300, 300 300, 300 0, 0 0))');
select count(*) from t1 where MBRwithin(t1.c2, @g1);
connection b;
set session innodb_lock_wait_timeout = 1;
--error ER_LOCK_WAIT_TIMEOUT
delete from t1 where c1 = 2;
# Clean up.
connection a;
commit;
connection default;
drop table t1;
SET DEBUG_SYNC= 'RESET';
# Test btr_discard_page adjust concurrent search path
create table t1 (c1 int, c2 geometry not null, spatial index (c2))engine=innodb;
start transaction;
insert into t1 values(1, Point(1,1));
insert into t1 values(2, Point(2,2));
insert into t1 values(3, Point(3,3));
insert into t1 values(4, Point(4,4));
insert into t1 values(5, Point(5,5));
insert into t1 values(6, Point(6,6));
insert into t1 values(7, Point(7,7));
insert into t1 values(8, Point(8,8));
insert into t1 values(9, Point(9,9));
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
select count(*) from t1;
connection b;
set @g1 = ST_GeomFromText('Polygon((0 0,0 100,100 100,100 0,0 0))');
set transaction isolation level read uncommitted;
SET DEBUG_SYNC= 'row_search_for_mysql_before_return SIGNAL siga WAIT_FOR sigb';
send select count(*) from t1 where MBRWithin(t1.c2, @g1);
connection default;
SET DEBUG_SYNC= 'now WAIT_FOR siga';
rollback;
SET DEBUG_SYNC= 'now SIGNAL sigb';
connection b;
--reap
select count(*) from t1 where MBRWithin(t1.c2, @g1);
connection default;
DROP TABLE t1;
SET DEBUG_SYNC = 'RESET';
create table t1 (c1 int, c2 geometry not null, spatial index (c2))engine=innodb;
delimiter |;
create procedure insert_t1(IN total int)
begin
declare i int default 1;
while (i <= total) DO
insert into t1 values (i, Point(i, i));
set i = i + 1;
end while;
end|
delimiter ;|
start transaction;
CALL insert_t1(100);
connection a;
set @g1 = ST_GeomFromText('Polygon((0 0,0 1000,1000 1000,1000 0,0 0))');
SET DEBUG_SYNC= 'rtr_pcur_move_to_next_return SIGNAL siga WAIT_FOR sigb';
--send select count(*) from t1 where MBRWithin(t1.c2, @g1);
connection default;
SET DEBUG_SYNC= 'now WAIT_FOR siga';
rollback;
SET DEBUG_SYNC= 'now SIGNAL sigb';
connection a;
--reap;
connection default;
drop procedure insert_t1;
DROP TABLE t1;
connection a;
SET SESSION debug="-d,rtr_pcur_move_to_next_return";
disconnect a;
--source include/wait_until_disconnected.inc
connection b;
disconnect b;
--source include/wait_until_disconnected.inc
connection default;
SET DEBUG_SYNC = 'RESET';
# This is to test create GIS index with algorithm=inplace.
--source include/have_innodb.inc
--source include/have_debug.inc
--source include/no_valgrind_without_big.inc
# Create table with geometry column
CREATE TABLE t1 (c1 INT, c2 GEOMETRY NOT NULL, c3 GEOMETRY NOT NULL) ENGINE=INNODB;
# Insert enough values
INSERT INTO t1 VALUES(1, Point(1,1), ST_GeomFromText('POLYGON (( 0 -1, 0 1, 2 1, 2 -1, 0 -1))'));
INSERT INTO t1 VALUES(2, Point(2,2), ST_GeomFromText('POLYGON (( 0 -3, 0 -1, 2 -1, 2 -3, 0 -3))'));
INSERT INTO t1 VALUES(3, Point(3,3), ST_GeomFromText('POLYGON (( 1 0, 1 2, 3 2, 3 0, 1 0))'));
INSERT INTO t1 VALUES(4, Point(4,4), ST_GeomFromText('POLYGON (( -3 0, -3 2, -1 2, -1 0, -3 0))'));
INSERT INTO t1 VALUES(5, Point(5,5), ST_GeomFromText('POLYGON (( 0 0, 0 1, 1 1, 1 0, 0 0))'));
INSERT INTO t1 VALUES(6, Point(6,6), ST_GeomFromText('POLYGON (( 2 0, 2 2, 4 2, 4 0, 2 0))'));
INSERT INTO t1 VALUES(7, Point(7,7), ST_GeomFromText('POLYGON (( 0 3, 0 5, 2 5, 2 3, 0 3))'));
INSERT INTO t1 VALUES(8, Point(8,8), ST_GeomFromText('POLYGON (( 0 1, 0 3, 2 3, 2 1, 0 1))'));
INSERT INTO t1 VALUES(9, Point(9,9), ST_GeomFromText('POLYGON (( 0 0, 0 3, 3 3, 3 0, 0 0))'));
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
# create spatial index
CREATE SPATIAL INDEX idx ON t1(c2);
SELECT COUNT(*) FROM t1;
SET @g1 = ST_GeomFromText('Polygon((0 0,0 100,100 100,100 0,0 0))');
SELECT COUNT(*) FROM t1 WHERE MBRWithin(t1.c2, @g1);
SET @g1 = ST_GeomFromText('Polygon((10 10,10 800,800 800,800 10,10 10))');
SELECT COUNT(*) FROM t1 WHERE MBRWithin(t1.c2, @g1);
ALTER TABLE t1 DROP INDEX idx, ADD SPATIAL INDEX idx3(c2);
SET SESSION debug="+d,row_merge_instrument_log_check_flush";
ALTER TABLE t1 DROP INDEX idx3, ADD SPATIAL INDEX idx4(c2), ADD SPATIAL INDEX idx5(c3);
# Clean up.
DROP TABLE t1;
# WL#6745 InnoDB R-tree support
# This test case will test R-tree multi level split.
--source include/have_innodb.inc
--source include/big_test.inc
--source include/not_valgrind.inc
--source include/have_debug.inc
# Create table with R-tree index.
create table t1 (c1 int, c2 geometry not null, spatial index (c2))engine=innodb;
# Insert enough values to let R-tree split.
delimiter |;
create procedure insert_t1(IN total int)
begin
declare i int default 1;
while (i <= total) DO
insert into t1 values
(i, Point(i, i)),
(i + 1, Point(i + 1, i + 1)),
(i + 2, Point(i + 2, i + 2)),
(i + 3, Point(i + 3, i + 3)),
(i + 4, Point(i + 4, i + 4)),
(i + 5, Point(i + 5, i + 5)),
(i + 6, Point(i + 6, i + 6)),
(i + 7, Point(i + 7, i + 7)),
(i + 8, Point(i + 8, i + 8)),
(i + 9, Point(i + 9, i + 9));
set i = i + 10;
end while;
end|
delimiter ;|
# Test level 1 rtree.
CALL insert_t1(5000);
select count(*) from t1;
# Check table.
check table t1;
# Test level 2 rtree.
truncate table t1;
CALL insert_t1(10000);
select count(*) from t1;
drop index c2 on t1;
create spatial index idx on t1(c2);
show create table t1;
SET DEBUG='+d,row_merge_ins_spatial_fail';
--error ER_GET_ERRNO
create spatial index idx2 on t1(c2);
SET DEBUG='-d,row_merge_ins_spatial_fail';
show create table t1;
# Check table.
check table t1;
# Test level 3 rtree.
truncate table t1;
CALL insert_t1(100000);
select count(*) from t1;
# Check table.
check table t1;
truncate table t1;
# Clean up.
drop procedure insert_t1;
drop table t1;
This source diff could not be displayed because it is too large. You can view the blob instead.
#
# BUG#21245805 HA_INNOBASE::RECORDS_IN_RANGE() RETURNS CONSTANT FOR SPATIAL INDEXES
#
--source include/have_innodb.inc
--source include/have_debug.inc
CREATE TABLE t1 (
g GEOMETRY NOT NULL
) ENGINE=InnoDB;
ALTER TABLE t1 ADD SPATIAL(g);
SET @g1 = ST_GeomFromText('POINT(10 10)');
SET @g2 = ST_GeomFromText('POLYGON((5 5, 20 5, 20 21, 5 21, 5 5))');
SET @g3 = ST_GeomFromText('POLYGON((1.79769e+308 1.79769e+308, 20 5, -1.79769e+308 -1.79769e+308, 1.79769e+308 1.79769e+308))');
# Test empty table
EXPLAIN SELECT ST_AsText(g) FROM t1 WHERE MBRContains(g, @g1);
SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g1);
# Insert gis data
INSERT INTO t1 VALUES(@g1);
INSERT INTO t1 VALUES(@g2);
INSERT INTO t1 VALUES(@g3);
SELECT ST_AsText(g) FROM t1;
ANALYZE TABLE t1;
# Test g1
EXPLAIN SELECT ST_AsText(g) FROM t1 WHERE MBRContains(g, @g1);
SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g1);
EXPLAIN SELECT ST_AsText(g) FROM t1 WHERE MBRDisjoint(g, @g1);
SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g1);
EXPLAIN SELECT ST_AsText(g) FROM t1 WHERE MBREquals(g, @g1);
SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g1);
EXPLAIN SELECT ST_AsText(g) FROM t1 WHERE MBRIntersects(g, @g1);
SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g1);
EXPLAIN SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g1);
SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g1);
# Test g2
EXPLAIN SELECT ST_AsText(g) FROM t1 WHERE MBRContains(g, @g2);
SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g2);
EXPLAIN SELECT ST_AsText(g) FROM t1 WHERE MBRDisjoint(g, @g2);
SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g2);
EXPLAIN SELECT ST_AsText(g) FROM t1 WHERE MBREquals(g, @g2);
SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g2);
EXPLAIN SELECT ST_AsText(g) FROM t1 WHERE MBRIntersects(g, @g2);
SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g2);
EXPLAIN SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g2);
SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g2);
# Test g3
EXPLAIN SELECT ST_AsText(g) FROM t1 WHERE MBRContains(g, @g3);
SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g3);
EXPLAIN SELECT ST_AsText(g) FROM t1 WHERE MBRDisjoint(g, @g3);
SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g3);
EXPLAIN SELECT ST_AsText(g) FROM t1 WHERE MBREquals(g, @g3);
SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g3);
EXPLAIN SELECT ST_AsText(g) FROM t1 WHERE MBRIntersects(g, @g3);
SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g3);
EXPLAIN SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g3);
SELECT ST_AsText(g) FROM t1 WHERE MBRWithin(g, @g3);
DROP TABLE t1;
# WL#6745 InnoDB R-tree support
# This test case will test basic R-tree support features.
--source include/have_innodb.inc
# Create table with R-tree index.
create table t1 (i int, i2 char(10), g geometry not null, primary key (i, i2), spatial index (g))engine=innodb;
# Insert values.
insert into t1 values (1, "111", POINT(1,1));
insert into t1 values (2, "222", POINT(1.5,1.5));
insert into t1 values (3, "333", POINT(3,3));
insert into t1 values (4, "444", POINT(3.1,3.1));
insert into t1 values (5, "555", POINT(5,5));
analyze table t1;
# Select by R-tree index.
set @g1 = ST_GeomFromText('Polygon((0 0,0 3,3 3,3 0,0 0))');
explain select ST_astext(t1.g) from t1 where MBRWithin(t1.g, @g1);
select ST_astext(t1.g) from t1 where MBRWithin(t1.g, @g1);
# Delete values.
set @g1 = ST_GeomFromText('Polygon((0 0,0 3,3 3,3 0,0 0))');
delete from t1 where MBRWithin(t1.g, @g1);
check table t1;
select ST_astext(t1.g) from t1;
# Update values.
set @g1 = ST_GeomFromText('Polygon((5 5,5 5,5 5,5 5,5 5))');
update t1 set g = POINT(2,2) where MBRWithin(t1.g, @g1);
check table t1;
select ST_astext(t1.g) from t1;
# Show index.
--replace_column 7 #
show indexes from t1;
# Cleanup.
drop table t1;
# Test functions.
create table t1 (name VARCHAR(100), square GEOMETRY not null, spatial index (square))engine=innodb;
INSERT INTO t1 VALUES("small", ST_GeomFromText('POLYGON (( 0 0, 0 1, 1 1, 1 0, 0 0))'));
INSERT INTO t1 VALUES("big", ST_GeomFromText('POLYGON (( 0 0, 0 3, 3 3, 3 0, 0 0))'));
INSERT INTO t1 VALUES("up", ST_GeomFromText('POLYGON (( 0 1, 0 3, 2 3, 2 1, 0 1))'));
INSERT INTO t1 VALUES("up2", ST_GeomFromText('POLYGON (( 0 2, 0 4, 2 4, 2 2, 0 2))'));
INSERT INTO t1 VALUES("up3", ST_GeomFromText('POLYGON (( 0 3, 0 5, 2 5, 2 3, 0 3))'));
INSERT INTO t1 VALUES("down", ST_GeomFromText('POLYGON (( 0 -1, 0 1, 2 1, 2 -1, 0 -1))'));
INSERT INTO t1 VALUES("down2", ST_GeomFromText('POLYGON (( 0 -2, 0 0, 2 0, 2 -2, 0 -2))'));
INSERT INTO t1 VALUES("down3", ST_GeomFromText('POLYGON (( 0 -3, 0 -1, 2 -1, 2 -3, 0 -3))'));
INSERT INTO t1 VALUES("right", ST_GeomFromText('POLYGON (( 1 0, 1 2, 3 2, 3 0, 1 0))'));
INSERT INTO t1 VALUES("right2", ST_GeomFromText('POLYGON (( 2 0, 2 2, 4 2, 4 0, 2 0))'));
INSERT INTO t1 VALUES("right3", ST_GeomFromText('POLYGON (( 3 0, 3 2, 5 2, 5 0, 3 0))'));
INSERT INTO t1 VALUES("left", ST_GeomFromText('POLYGON (( -1 0, -1 2, 1 2, 1 0, -1 0))'));
INSERT INTO t1 VALUES("left2", ST_GeomFromText('POLYGON (( -2 0, -2 2, 0 2, 0 0, -2 0))'));
INSERT INTO t1 VALUES("left3", ST_GeomFromText('POLYGON (( -3 0, -3 2, -1 2, -1 0, -3 0))'));
SET @p = ST_GeomFromText('POLYGON (( 0 0, 0 2, 2 2, 2 0, 0 0))');
SELECT name, ST_AsText(square) from t1 where MBRContains(@p, square);
SELECT name, ST_AsText(square) from t1 where MBRDisjoint(@p, square);
SELECT name, ST_AsText(square) from t1 where MBREquals(@p, square);
SELECT name, ST_AsText(square) from t1 where MBRIntersects(@p, square);
SELECT name, ST_AsText(square) from t1 where MBROverlaps(@p, square);
SELECT name, ST_AsText(square) from t1 where MBRTouches(@p, square);
SELECT name, ST_AsText(square) from t1 where MBRWithin(@p, square);
# MBROverlaps needs a few more tests, with point and line dimensions
--error ER_GIS_INVALID_DATA
SET @vert1 = ST_GeomFromText('POLYGON ((0 -2, 0 2, 0 -2))');
--error ER_GIS_INVALID_DATA
SET @horiz1 = ST_GeomFromText('POLYGON ((-2 0, 2 0, -2 0))');
--error ER_GIS_INVALID_DATA
SET @horiz2 = ST_GeomFromText('POLYGON ((-1 0, 3 0, -1 0))');
--error ER_GIS_INVALID_DATA
SET @horiz3 = ST_GeomFromText('POLYGON ((2 0, 3 0, 2 0))');
--error ER_GIS_INVALID_DATA
SET @point1 = ST_GeomFromText('POLYGON ((0 0))');
--error ER_GIS_INVALID_DATA
SET @point2 = ST_GeomFromText('POLYGON ((-2 0))');
SELECT GROUP_CONCAT(a1.name ORDER BY a1.name) AS MBRoverlaps FROM t1 a1 WHERE MBROverlaps(a1.square, @vert1) GROUP BY a1.name;
SELECT GROUP_CONCAT(a1.name ORDER BY a1.name) AS MBRoverlaps FROM t1 a1 WHERE MBROverlaps(a1.square, @horiz1) GROUP BY a1.name;
SELECT MBROverlaps(@horiz1, @vert1) FROM DUAL;
SELECT MBROverlaps(@horiz1, @horiz2) FROM DUAL;
SELECT MBROverlaps(@horiz1, @horiz3) FROM DUAL;
SELECT MBROverlaps(@horiz1, @point1) FROM DUAL;
SELECT MBROverlaps(@horiz1, @point2) FROM DUAL;
DROP TABLE t1;
# Inplace create spatial index is not supported
create table t1 (i int not null, g geometry not null)engine=innodb;
# Insert values.
insert into t1 values (1, POINT(1,1));
insert into t1 values (2, POINT(1.5,1.5));
insert into t1 values (3, POINT(3,3));
insert into t1 values (4, POINT(3.1,3.1));
insert into t1 values (5, POINT(5,5));
alter table t1 add primary key(i), algorithm=inplace;
alter table t1 drop primary key;
create spatial index idx on t1(g) algorithm=inplace;
create spatial index idx2 on t1(g);
alter table t1 add primary key(i), algorithm=inplace;
show create table t1;
drop index idx on t1;
drop table t1;
# This is a testcase ported from mysql-test/t/gis-rtree.test
-- source include/have_geometry.inc
#
# test of rtree (using with spatial data)
#
--disable_warnings
DROP TABLE IF EXISTS t1, t2;
--enable_warnings
CREATE TABLE t1 (
fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
g GEOMETRY NOT NULL,
SPATIAL KEY(g)
) ENGINE=InnoDB;
SHOW CREATE TABLE t1;
let $1=150;
let $2=150;
while ($1)
{
eval INSERT INTO t1 (g) VALUES (ST_GeomFromText('LineString($1 $1, $2 $2)'));
dec $1;
inc $2;
}
SELECT count(*) FROM t1;
SELECT fid, ST_AsText(g) FROM t1 WHERE MBRWithin(g, ST_GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))')) ORDER BY fid;
DROP TABLE t1;
CREATE TABLE t2 (
fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
g GEOMETRY NOT NULL
) ENGINE=InnoDB;
let $1=10;
while ($1)
{
let $2=10;
while ($2)
{
eval INSERT INTO t2 (g) VALUES (LineString(Point($1 * 10 - 9, $2 * 10 - 9), Point($1 * 10, $2 * 10)));
dec $2;
}
dec $1;
}
ALTER TABLE t2 ADD SPATIAL KEY(g);
SHOW CREATE TABLE t2;
SELECT count(*) FROM t2;
SELECT fid, ST_AsText(g) FROM t2 WHERE MBRWithin(g,
ST_GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))')) ORDER BY fid;
let $1=10;
while ($1)
{
let $2=10;
while ($2)
{
eval DELETE FROM t2 WHERE MBRWithin(g, ST_Envelope(ST_GeometryFromWKB(Point($1 * 10 - 9, $2 * 10 - 9), Point($1 * 10, $2 * 10))));
SELECT count(*) FROM t2;
dec $2;
}
dec $1;
}
DROP TABLE t2;
drop table if exists t1;
CREATE TABLE t1 (a geometry NOT NULL, SPATIAL (a));
INSERT INTO t1 VALUES (ST_GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (ST_GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (ST_GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (ST_GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (ST_GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (ST_GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (ST_GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (ST_GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (ST_GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (ST_GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (ST_GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (ST_GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (ST_GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (ST_GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (ST_GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (ST_GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (ST_GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (ST_GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (ST_GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (ST_GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (ST_GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (ST_GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (ST_GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (ST_GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (ST_GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (ST_GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (ST_GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (ST_GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
INSERT INTO t1 VALUES (ST_GeomFromText("LINESTRING(100 100, 200 200, 300 300)"));
check table t1;
analyze table t1;
drop table t1;
#
# The following crashed gis
#
CREATE TABLE t1 (
fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
g GEOMETRY NOT NULL,
SPATIAL KEY(g)
) ENGINE=InnoDB;
INSERT INTO t1 (g) VALUES (ST_GeomFromText('LineString(1 2, 2 3)')),(ST_GeomFromText('LineString(1 2, 2 4)'));
#select * from t1 where g<ST_GeomFromText('LineString(1 2, 2 3)');
drop table t1;
CREATE TABLE t1 (
line LINESTRING NOT NULL,
kind ENUM('po', 'pp', 'rr', 'dr', 'rd', 'ts', 'cl') NOT NULL DEFAULT 'po',
name VARCHAR(32),
SPATIAL KEY (line)
) engine=InnoDB;
ALTER TABLE t1 DISABLE KEYS;
--error ER_CANT_CREATE_GEOMETRY_OBJECT
INSERT INTO t1 (name, kind, line) VALUES
("Aadaouane", "pp", ST_GeomFromText("POINT(32.816667 35.983333)")),
("Aadassiye", "pp", ST_GeomFromText("POINT(35.816667 36.216667)")),
("Aadbel", "pp", ST_GeomFromText("POINT(34.533333 36.100000)")),
("Aadchit", "pp", ST_GeomFromText("POINT(33.347222 35.423611)")),
("Aadchite", "pp", ST_GeomFromText("POINT(33.347222 35.423611)")),
("Aadchit el Qoussair", "pp", ST_GeomFromText("POINT(33.283333 35.483333)")),
("Aaddaye", "pp", ST_GeomFromText("POINT(36.716667 40.833333)")),
("'Aadeissa", "pp", ST_GeomFromText("POINT(32.823889 35.698889)")),
("Aaderup", "pp", ST_GeomFromText("POINT(55.216667 11.766667)")),
("Qalaat Aades", "pp", ST_GeomFromText("POINT(33.503333 35.377500)")),
("A ad'ino", "pp", ST_GeomFromText("POINT(54.812222 38.209167)")),
("Aadi Noia", "pp", ST_GeomFromText("POINT(13.800000 39.833333)")),
("Aad La Macta", "pp", ST_GeomFromText("POINT(35.779444 -0.129167)")),
("Aadland", "pp", ST_GeomFromText("POINT(60.366667 5.483333)")),
("Aadliye", "pp", ST_GeomFromText("POINT(33.366667 36.333333)")),
("Aadloun", "pp", ST_GeomFromText("POINT(33.403889 35.273889)")),
("Aadma", "pp", ST_GeomFromText("POINT(58.798333 22.663889)")),
("Aadma Asundus", "pp", ST_GeomFromText("POINT(58.798333 22.663889)")),
("Aadmoun", "pp", ST_GeomFromText("POINT(34.150000 35.650000)")),
("Aadneram", "pp", ST_GeomFromText("POINT(59.016667 6.933333)")),
("Aadneskaar", "pp", ST_GeomFromText("POINT(58.083333 6.983333)")),
("Aadorf", "pp", ST_GeomFromText("POINT(47.483333 8.900000)")),
("Aadorp", "pp", ST_GeomFromText("POINT(52.366667 6.633333)")),
("Aadouane", "pp", ST_GeomFromText("POINT(32.816667 35.983333)")),
("Aadoui", "pp", ST_GeomFromText("POINT(34.450000 35.983333)")),
("Aadouiye", "pp", ST_GeomFromText("POINT(34.583333 36.183333)")),
("Aadouss", "pp", ST_GeomFromText("POINT(33.512500 35.601389)")),
("Aadra", "pp", ST_GeomFromText("POINT(33.616667 36.500000)")),
("Aadzi", "pp", ST_GeomFromText("POINT(38.100000 64.850000)"));
ALTER TABLE t1 ENABLE KEYS;
INSERT INTO t1 (name, kind, line) VALUES ("austria", "pp", ST_GeomFromText('LINESTRING(14.9906 48.9887,14.9946 48.9904,14.9947 48.9916)'));
drop table t1;
CREATE TABLE t1 (st varchar(100));
INSERT INTO t1 VALUES ("Fake string");
CREATE TABLE t2 (geom GEOMETRY NOT NULL, SPATIAL KEY gk(geom));
--error ER_GIS_INVALID_DATA
INSERT INTO t2 SELECT ST_GeomFromText(st) FROM t1;
drop table t1, t2;
SET sql_mode = 'NO_ENGINE_SUBSTITUTION';
CREATE TABLE t1 (`geometry` geometry NOT NULL default '',SPATIAL KEY `gndx` (`geometry`)) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO t1 (geometry) VALUES
(ST_PolygonFromText('POLYGON((-18.6086111000 -66.9327777000, -18.6055555000
-66.8158332999, -18.7186111000 -66.8102777000, -18.7211111000 -66.9269443999,
-18.6086111000 -66.9327777000))'));
INSERT INTO t1 (geometry) VALUES
(ST_PolygonFromText('POLYGON((-65.7402776999 -96.6686111000, -65.7372222000
-96.5516666000, -65.8502777000 -96.5461111000, -65.8527777000 -96.6627777000,
-65.7402776999 -96.6686111000))'));
check table t1 extended;
drop table t1;
CREATE TABLE t1 (`geometry` geometry NOT NULL default '',SPATIAL KEY `gndx` (`geometry`)) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO t1 (geometry) VALUES
(ST_PolygonFromText('POLYGON((2 2, 2 8, 10 8, 10 2, 2 2))'));
INSERT INTO t1 (geometry) VALUES
(ST_PolygonFromText('POLYGON((2 12, 15 12, 15 18, 2 18, 2 12))'));
INSERT INTO t1 (geometry) VALUES
(ST_PolygonFromText('POLYGON((3 5, 3 18, 10 18, 10 5, 3 5))'));
INSERT INTO t1 (geometry) VALUES
(ST_PolygonFromText('POLYGON((4 6, 4 8, 10 8, 10 4, 4 6))'));
set @g1 = ST_GeomFromText('Polygon((0 0,0 1000,1000 1000,1000 0,0 0))');
select count(*) from t1 where MBRWithin(t1.geometry, @g1);
start transaction;
INSERT INTO t1 (geometry) VALUES
(ST_PolygonFromText('POLYGON((4 6, 4 8, 10 8, 10 4, 4 6))'));
select count(*) from t1 where MBRWithin(t1.geometry, @g1);
rollback;
select count(*) from t1 where MBRWithin(t1.geometry, @g1);
set @g2 = ST_GeomFromText('POINT(2 2)');
select count(*) from t1 where MBRcontains(t1.geometry, @g2);
select count(*) from t1 where MBRintersects(t1.geometry, @g2);
set @g3 = ST_GeomFromText('LINESTRING(2 2, 2 12)');
select count(*) from t1 where MBRintersects(t1.geometry, @g3);
DROP TABLE t1;
#
# Bug#17877 - Corrupted spatial index
#
CREATE TABLE t1 (
c1 geometry NOT NULL default '',
SPATIAL KEY i1 (c1)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO t1 (c1) VALUES (
ST_PolygonFromText('POLYGON((-18.6086111000 -66.9327777000,
-18.6055555000 -66.8158332999,
-18.7186111000 -66.8102777000,
-18.7211111000 -66.9269443999,
-18.6086111000 -66.9327777000))'));
# This showed a missing key.
CHECK TABLE t1 EXTENDED;
DROP TABLE t1;
#
CREATE TABLE t1 (
c1 geometry NOT NULL default '',
SPATIAL KEY i1 (c1)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO t1 (c1) VALUES (
ST_PolygonFromText('POLYGON((-18.6086111000 -66.9327777000,
-18.6055555000 -66.8158332999,
-18.7186111000 -66.8102777000,
-18.7211111000 -66.9269443999,
-18.6086111000 -66.9327777000))'));
INSERT INTO t1 (c1) VALUES (
ST_PolygonFromText('POLYGON((-65.7402776999 -96.6686111000,
-65.7372222000 -96.5516666000,
-65.8502777000 -96.5461111000,
-65.8527777000 -96.6627777000,
-65.7402776999 -96.6686111000))'));
# This is the same as the first insert to get a non-unique key.
INSERT INTO t1 (c1) VALUES (
ST_PolygonFromText('POLYGON((-18.6086111000 -66.9327777000,
-18.6055555000 -66.8158332999,
-18.7186111000 -66.8102777000,
-18.7211111000 -66.9269443999,
-18.6086111000 -66.9327777000))'));
# This showed (and still shows) OK.
CHECK TABLE t1 EXTENDED;
DROP TABLE t1;
SET sql_mode = default;
#
# Bug #21888: Query on GEOMETRY field using PointFromWKB() results in lost connection
#
CREATE TABLE t1 (foo GEOMETRY NOT NULL, SPATIAL INDEX(foo) );
INSERT INTO t1 (foo) VALUES (POINT(1,1));
INSERT INTO t1 (foo) VALUES (POINT(1,0));
INSERT INTO t1 (foo) VALUES (POINT(0,1));
INSERT INTO t1 (foo) VALUES (POINT(0,0));
SELECT 1 FROM t1 WHERE foo != POINT(0,0);
DROP TABLE t1;
#
# Bug#25673 - spatial index corruption, error 126 incorrect key file for table
#
CREATE TABLE t1 (id bigint(12) unsigned NOT NULL auto_increment,
c2 varchar(15) collate utf8_bin default NULL,
c1 varchar(15) collate utf8_bin default NULL,
c3 varchar(10) collate utf8_bin default NULL,
spatial_point point NOT NULL,
PRIMARY KEY(id),
SPATIAL KEY (spatial_point)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
#
INSERT INTO t1 (c2, c1, c3, spatial_point) VALUES
('y', 's', 'j', ST_GeomFromText('POINT(167 74)')),
('r', 'n', 'd', ST_GeomFromText('POINT(215 118)')),
('g', 'n', 'e', ST_GeomFromText('POINT(203 98)')),
('h', 'd', 'd', ST_GeomFromText('POINT(54 193)')),
('r', 'x', 'y', ST_GeomFromText('POINT(47 69)')),
('t', 'q', 'r', ST_GeomFromText('POINT(109 42)')),
('a', 'z', 'd', ST_GeomFromText('POINT(0 154)')),
('x', 'v', 'o', ST_GeomFromText('POINT(174 131)')),
('b', 'r', 'a', ST_GeomFromText('POINT(114 253)')),
('x', 'z', 'i', ST_GeomFromText('POINT(163 21)')),
('w', 'p', 'i', ST_GeomFromText('POINT(42 102)')),
('g', 'j', 'j', ST_GeomFromText('POINT(170 133)')),
('m', 'g', 'n', ST_GeomFromText('POINT(28 22)')),
('b', 'z', 'h', ST_GeomFromText('POINT(174 28)')),
('q', 'k', 'f', ST_GeomFromText('POINT(233 73)')),
('w', 'w', 'a', ST_GeomFromText('POINT(124 200)')),
('t', 'j', 'w', ST_GeomFromText('POINT(252 101)')),
('d', 'r', 'd', ST_GeomFromText('POINT(98 18)')),
('w', 'o', 'y', ST_GeomFromText('POINT(165 31)')),
('y', 'h', 't', ST_GeomFromText('POINT(14 220)')),
('d', 'p', 'u', ST_GeomFromText('POINT(223 196)')),
('g', 'y', 'g', ST_GeomFromText('POINT(207 96)')),
('x', 'm', 'n', ST_GeomFromText('POINT(214 3)')),
('g', 'v', 'e', ST_GeomFromText('POINT(140 205)')),
('g', 'm', 'm', ST_GeomFromText('POINT(10 236)')),
('i', 'r', 'j', ST_GeomFromText('POINT(137 228)')),
('w', 's', 'p', ST_GeomFromText('POINT(115 6)')),
('o', 'n', 'k', ST_GeomFromText('POINT(158 129)')),
('j', 'h', 'l', ST_GeomFromText('POINT(129 72)')),
('f', 'x', 'l', ST_GeomFromText('POINT(139 207)')),
('u', 'd', 'n', ST_GeomFromText('POINT(125 109)')),
('b', 'a', 'z', ST_GeomFromText('POINT(30 32)')),
('m', 'h', 'o', ST_GeomFromText('POINT(251 251)')),
('f', 'r', 'd', ST_GeomFromText('POINT(243 211)')),
('b', 'd', 'r', ST_GeomFromText('POINT(232 80)')),
('g', 'k', 'v', ST_GeomFromText('POINT(15 100)')),
('i', 'f', 'c', ST_GeomFromText('POINT(109 66)')),
('r', 't', 'j', ST_GeomFromText('POINT(178 6)')),
('y', 'n', 'f', ST_GeomFromText('POINT(233 211)')),
('f', 'y', 'm', ST_GeomFromText('POINT(99 16)')),
('z', 'q', 'l', ST_GeomFromText('POINT(39 49)')),
('j', 'c', 'r', ST_GeomFromText('POINT(75 187)')),
('c', 'y', 'y', ST_GeomFromText('POINT(246 253)')),
('w', 'u', 'd', ST_GeomFromText('POINT(56 190)')),
('n', 'q', 'm', ST_GeomFromText('POINT(73 149)')),
('d', 'y', 'a', ST_GeomFromText('POINT(134 6)')),
('z', 's', 'w', ST_GeomFromText('POINT(216 225)')),
('d', 'u', 'k', ST_GeomFromText('POINT(132 70)')),
('f', 'v', 't', ST_GeomFromText('POINT(187 141)')),
('r', 'r', 'a', ST_GeomFromText('POINT(152 39)')),
('y', 'p', 'o', ST_GeomFromText('POINT(45 27)')),
('p', 'n', 'm', ST_GeomFromText('POINT(228 148)')),
('e', 'g', 'e', ST_GeomFromText('POINT(88 81)')),
('m', 'a', 'h', ST_GeomFromText('POINT(35 29)')),
('m', 'h', 'f', ST_GeomFromText('POINT(30 71)')),
('h', 'k', 'i', ST_GeomFromText('POINT(244 78)')),
('z', 'v', 'd', ST_GeomFromText('POINT(241 38)')),
('q', 'l', 'j', ST_GeomFromText('POINT(13 71)')),
('s', 'p', 'g', ST_GeomFromText('POINT(108 38)')),
('q', 's', 'j', ST_GeomFromText('POINT(92 101)')),
('l', 'h', 'g', ST_GeomFromText('POINT(120 78)')),
('w', 't', 'b', ST_GeomFromText('POINT(193 109)')),
('b', 's', 's', ST_GeomFromText('POINT(223 211)')),
('w', 'w', 'y', ST_GeomFromText('POINT(122 42)')),
('q', 'c', 'c', ST_GeomFromText('POINT(104 102)')),
('w', 'g', 'n', ST_GeomFromText('POINT(213 120)')),
('p', 'q', 'a', ST_GeomFromText('POINT(247 148)')),
('c', 'z', 'e', ST_GeomFromText('POINT(18 106)')),
('z', 'u', 'n', ST_GeomFromText('POINT(70 133)')),
('j', 'n', 'x', ST_GeomFromText('POINT(232 13)')),
('e', 'h', 'f', ST_GeomFromText('POINT(22 135)')),
('w', 'l', 'f', ST_GeomFromText('POINT(9 180)')),
('a', 'v', 'q', ST_GeomFromText('POINT(163 228)')),
('i', 'z', 'o', ST_GeomFromText('POINT(180 100)')),
('e', 'c', 'l', ST_GeomFromText('POINT(182 231)')),
('c', 'k', 'o', ST_GeomFromText('POINT(19 60)')),
('q', 'f', 'p', ST_GeomFromText('POINT(79 95)')),
('m', 'd', 'r', ST_GeomFromText('POINT(3 127)')),
('m', 'e', 't', ST_GeomFromText('POINT(136 154)')),
('w', 'w', 'w', ST_GeomFromText('POINT(102 15)')),
('l', 'n', 'q', ST_GeomFromText('POINT(71 196)')),
('p', 'k', 'c', ST_GeomFromText('POINT(47 139)')),
('j', 'o', 'r', ST_GeomFromText('POINT(177 128)')),
('j', 'q', 'a', ST_GeomFromText('POINT(170 6)')),
('b', 'a', 'o', ST_GeomFromText('POINT(63 211)')),
('g', 's', 'o', ST_GeomFromText('POINT(144 251)')),
('w', 'u', 'w', ST_GeomFromText('POINT(221 214)')),
('g', 'a', 'm', ST_GeomFromText('POINT(14 102)')),
('u', 'q', 'z', ST_GeomFromText('POINT(86 200)')),
('k', 'a', 'm', ST_GeomFromText('POINT(144 222)')),
('j', 'u', 'r', ST_GeomFromText('POINT(216 142)')),
('q', 'k', 'v', ST_GeomFromText('POINT(121 236)')),
('p', 'o', 'r', ST_GeomFromText('POINT(108 102)')),
('b', 'd', 'x', ST_GeomFromText('POINT(127 198)')),
('k', 's', 'a', ST_GeomFromText('POINT(2 150)')),
('f', 'm', 'f', ST_GeomFromText('POINT(160 191)')),
('q', 'y', 'x', ST_GeomFromText('POINT(98 111)')),
('o', 'f', 'm', ST_GeomFromText('POINT(232 218)')),
('c', 'w', 'j', ST_GeomFromText('POINT(156 165)')),
('s', 'q', 'v', ST_GeomFromText('POINT(98 161)'));
SET @@RAND_SEED1=692635050, @@RAND_SEED2=297339954;
DELETE FROM t1 ORDER BY RAND() LIMIT 10;
SET @@RAND_SEED1=159925977, @@RAND_SEED2=942570618;
DELETE FROM t1 ORDER BY RAND() LIMIT 10;
SET @@RAND_SEED1=328169745, @@RAND_SEED2=410451954;
DELETE FROM t1 ORDER BY RAND() LIMIT 10;
SET @@RAND_SEED1=178507359, @@RAND_SEED2=332493072;
DELETE FROM t1 ORDER BY RAND() LIMIT 10;
SET @@RAND_SEED1=1034033013, @@RAND_SEED2=558966507;
DELETE FROM t1 ORDER BY RAND() LIMIT 10;
UPDATE t1 set spatial_point=ST_GeomFromText('POINT(230 9)') where c1 like 'y%';
UPDATE t1 set spatial_point=ST_GeomFromText('POINT(95 35)') where c1 like 'j%';
UPDATE t1 set spatial_point=ST_GeomFromText('POINT(93 99)') where c1 like 'a%';
UPDATE t1 set spatial_point=ST_GeomFromText('POINT(19 81)') where c1 like 'r%';
UPDATE t1 set spatial_point=ST_GeomFromText('POINT(20 177)') where c1 like 'h%';
UPDATE t1 set spatial_point=ST_GeomFromText('POINT(221 193)') where c1 like 'u%';
UPDATE t1 set spatial_point=ST_GeomFromText('POINT(195 205)') where c1 like 'd%';
UPDATE t1 set spatial_point=ST_GeomFromText('POINT(15 213)') where c1 like 'u%';
UPDATE t1 set spatial_point=ST_GeomFromText('POINT(214 63)') where c1 like 'n%';
UPDATE t1 set spatial_point=ST_GeomFromText('POINT(243 171)') where c1 like 'c%';
UPDATE t1 set spatial_point=ST_GeomFromText('POINT(198 82)') where c1 like 'y%';
INSERT INTO t1 (c2, c1, c3, spatial_point) VALUES
('f', 'y', 'p', ST_GeomFromText('POINT(109 235)')),
('b', 'e', 'v', ST_GeomFromText('POINT(20 48)')),
('i', 'u', 'f', ST_GeomFromText('POINT(15 55)')),
('o', 'r', 'z', ST_GeomFromText('POINT(105 64)')),
('a', 'p', 'a', ST_GeomFromText('POINT(142 236)')),
('g', 'i', 'k', ST_GeomFromText('POINT(10 49)')),
('x', 'z', 'x', ST_GeomFromText('POINT(192 200)')),
('c', 'v', 'r', ST_GeomFromText('POINT(94 168)')),
('y', 'z', 'e', ST_GeomFromText('POINT(141 51)')),
('h', 'm', 'd', ST_GeomFromText('POINT(35 251)')),
('v', 'm', 'q', ST_GeomFromText('POINT(44 90)')),
('j', 'l', 'z', ST_GeomFromText('POINT(67 237)')),
('i', 'v', 'a', ST_GeomFromText('POINT(75 14)')),
('b', 'q', 't', ST_GeomFromText('POINT(153 33)')),
('e', 'm', 'a', ST_GeomFromText('POINT(247 49)')),
('l', 'y', 'g', ST_GeomFromText('POINT(56 203)')),
('v', 'o', 'r', ST_GeomFromText('POINT(90 54)')),
('r', 'n', 'd', ST_GeomFromText('POINT(135 83)')),
('j', 't', 'u', ST_GeomFromText('POINT(174 239)')),
('u', 'n', 'g', ST_GeomFromText('POINT(104 191)')),
('p', 'q', 'y', ST_GeomFromText('POINT(63 171)')),
('o', 'q', 'p', ST_GeomFromText('POINT(192 103)')),
('f', 'x', 'e', ST_GeomFromText('POINT(244 30)')),
('n', 'x', 'c', ST_GeomFromText('POINT(92 103)')),
('r', 'q', 'z', ST_GeomFromText('POINT(166 20)')),
('s', 'a', 'j', ST_GeomFromText('POINT(137 205)')),
('z', 't', 't', ST_GeomFromText('POINT(99 134)')),
('o', 'm', 'j', ST_GeomFromText('POINT(217 3)')),
('n', 'h', 'j', ST_GeomFromText('POINT(211 17)')),
('v', 'v', 'a', ST_GeomFromText('POINT(41 137)')),
('q', 'o', 'j', ST_GeomFromText('POINT(5 92)')),
('z', 'y', 'e', ST_GeomFromText('POINT(175 212)')),
('j', 'z', 'h', ST_GeomFromText('POINT(224 194)')),
('a', 'g', 'm', ST_GeomFromText('POINT(31 119)')),
('p', 'c', 'f', ST_GeomFromText('POINT(17 221)')),
('t', 'h', 'k', ST_GeomFromText('POINT(26 203)')),
('u', 'w', 'p', ST_GeomFromText('POINT(47 185)')),
('z', 'a', 'c', ST_GeomFromText('POINT(61 133)')),
('u', 'k', 'a', ST_GeomFromText('POINT(210 115)')),
('k', 'f', 'h', ST_GeomFromText('POINT(125 113)')),
('t', 'v', 'y', ST_GeomFromText('POINT(12 239)')),
('u', 'v', 'd', ST_GeomFromText('POINT(90 24)')),
('m', 'y', 'w', ST_GeomFromText('POINT(25 243)')),
('d', 'n', 'g', ST_GeomFromText('POINT(122 92)')),
('z', 'm', 'f', ST_GeomFromText('POINT(235 110)')),
('q', 'd', 'f', ST_GeomFromText('POINT(233 217)')),
('a', 'v', 'u', ST_GeomFromText('POINT(69 59)')),
('x', 'k', 'p', ST_GeomFromText('POINT(240 14)')),
('i', 'v', 'r', ST_GeomFromText('POINT(154 42)')),
('w', 'h', 'l', ST_GeomFromText('POINT(178 156)')),
('d', 'h', 'n', ST_GeomFromText('POINT(65 157)')),
('c', 'k', 'z', ST_GeomFromText('POINT(62 33)')),
('e', 'l', 'w', ST_GeomFromText('POINT(162 1)')),
('r', 'f', 'i', ST_GeomFromText('POINT(127 71)')),
('q', 'm', 'c', ST_GeomFromText('POINT(63 118)')),
('c', 'h', 'u', ST_GeomFromText('POINT(205 203)')),
('d', 't', 'p', ST_GeomFromText('POINT(234 87)')),
('s', 'g', 'h', ST_GeomFromText('POINT(149 34)')),
('o', 'b', 'q', ST_GeomFromText('POINT(159 179)')),
('k', 'u', 'f', ST_GeomFromText('POINT(202 254)')),
('u', 'f', 'g', ST_GeomFromText('POINT(70 15)')),
('x', 's', 'b', ST_GeomFromText('POINT(25 181)')),
('s', 'c', 'g', ST_GeomFromText('POINT(252 17)')),
('a', 'c', 'f', ST_GeomFromText('POINT(89 67)')),
('r', 'e', 'q', ST_GeomFromText('POINT(55 54)')),
('f', 'i', 'k', ST_GeomFromText('POINT(178 230)')),
('p', 'e', 'l', ST_GeomFromText('POINT(198 28)')),
('w', 'o', 'd', ST_GeomFromText('POINT(204 189)')),
('c', 'a', 'g', ST_GeomFromText('POINT(230 178)')),
('r', 'o', 'e', ST_GeomFromText('POINT(61 116)')),
('w', 'a', 'a', ST_GeomFromText('POINT(178 237)')),
('v', 'd', 'e', ST_GeomFromText('POINT(70 85)')),
('k', 'c', 'e', ST_GeomFromText('POINT(147 118)')),
('d', 'q', 't', ST_GeomFromText('POINT(218 77)')),
('k', 'g', 'f', ST_GeomFromText('POINT(192 113)')),
('w', 'n', 'e', ST_GeomFromText('POINT(92 124)')),
('r', 'm', 'q', ST_GeomFromText('POINT(130 65)')),
('o', 'r', 'r', ST_GeomFromText('POINT(174 233)')),
('k', 'n', 't', ST_GeomFromText('POINT(175 147)')),
('q', 'm', 'r', ST_GeomFromText('POINT(18 208)')),
('l', 'd', 'i', ST_GeomFromText('POINT(13 104)')),
('w', 'o', 'y', ST_GeomFromText('POINT(207 39)')),
('p', 'u', 'o', ST_GeomFromText('POINT(114 31)')),
('y', 'a', 'p', ST_GeomFromText('POINT(106 59)')),
('a', 'x', 'z', ST_GeomFromText('POINT(17 57)')),
('v', 'h', 'x', ST_GeomFromText('POINT(170 13)')),
('t', 's', 'u', ST_GeomFromText('POINT(84 18)')),
('z', 'z', 'f', ST_GeomFromText('POINT(250 197)')),
('l', 'z', 't', ST_GeomFromText('POINT(59 80)')),
('j', 'g', 's', ST_GeomFromText('POINT(54 26)')),
('g', 'v', 'm', ST_GeomFromText('POINT(89 98)')),
('q', 'v', 'b', ST_GeomFromText('POINT(39 240)')),
('x', 'k', 'v', ST_GeomFromText('POINT(246 207)')),
('k', 'u', 'i', ST_GeomFromText('POINT(105 111)')),
('w', 'z', 's', ST_GeomFromText('POINT(235 8)')),
('d', 'd', 'd', ST_GeomFromText('POINT(105 4)')),
('c', 'z', 'q', ST_GeomFromText('POINT(13 140)')),
('m', 'k', 'i', ST_GeomFromText('POINT(208 120)')),
('g', 'a', 'g', ST_GeomFromText('POINT(9 182)')),
('z', 'j', 'r', ST_GeomFromText('POINT(149 153)')),
('h', 'f', 'g', ST_GeomFromText('POINT(81 236)')),
('m', 'e', 'q', ST_GeomFromText('POINT(209 215)')),
('c', 'h', 'y', ST_GeomFromText('POINT(235 70)')),
('i', 'e', 'g', ST_GeomFromText('POINT(138 26)')),
('m', 't', 'u', ST_GeomFromText('POINT(119 237)')),
('o', 'w', 's', ST_GeomFromText('POINT(193 166)')),
('f', 'm', 'q', ST_GeomFromText('POINT(85 96)')),
('x', 'l', 'x', ST_GeomFromText('POINT(58 115)')),
('x', 'q', 'u', ST_GeomFromText('POINT(108 210)')),
('b', 'h', 'i', ST_GeomFromText('POINT(250 139)')),
('y', 'd', 'x', ST_GeomFromText('POINT(199 135)')),
('w', 'h', 'p', ST_GeomFromText('POINT(247 233)')),
('p', 'z', 't', ST_GeomFromText('POINT(148 249)')),
('q', 'a', 'u', ST_GeomFromText('POINT(174 78)')),
('v', 't', 'm', ST_GeomFromText('POINT(70 228)')),
('t', 'n', 'f', ST_GeomFromText('POINT(123 2)')),
('x', 't', 'b', ST_GeomFromText('POINT(35 50)')),
('r', 'j', 'f', ST_GeomFromText('POINT(200 51)')),
('s', 'q', 'o', ST_GeomFromText('POINT(23 184)')),
('u', 'v', 'z', ST_GeomFromText('POINT(7 113)')),
('v', 'u', 'l', ST_GeomFromText('POINT(145 190)')),
('o', 'k', 'i', ST_GeomFromText('POINT(161 122)')),
('l', 'y', 'e', ST_GeomFromText('POINT(17 232)')),
('t', 'b', 'e', ST_GeomFromText('POINT(120 50)')),
('e', 's', 'u', ST_GeomFromText('POINT(254 1)')),
('d', 'd', 'u', ST_GeomFromText('POINT(167 140)')),
('o', 'b', 'x', ST_GeomFromText('POINT(186 237)')),
('m', 's', 's', ST_GeomFromText('POINT(172 149)')),
('t', 'y', 'a', ST_GeomFromText('POINT(149 85)')),
('x', 't', 'r', ST_GeomFromText('POINT(10 165)')),
('g', 'c', 'e', ST_GeomFromText('POINT(95 165)')),
('e', 'e', 'z', ST_GeomFromText('POINT(98 65)')),
('f', 'v', 'i', ST_GeomFromText('POINT(149 144)')),
('o', 'p', 'm', ST_GeomFromText('POINT(233 67)')),
('t', 'u', 'b', ST_GeomFromText('POINT(109 215)')),
('o', 'o', 'b', ST_GeomFromText('POINT(130 48)')),
('e', 'm', 'h', ST_GeomFromText('POINT(88 189)')),
('e', 'v', 'y', ST_GeomFromText('POINT(55 29)')),
('e', 't', 'm', ST_GeomFromText('POINT(129 55)')),
('p', 'p', 'i', ST_GeomFromText('POINT(126 222)')),
('c', 'i', 'c', ST_GeomFromText('POINT(19 158)')),
('c', 'b', 's', ST_GeomFromText('POINT(13 19)')),
('u', 'y', 'a', ST_GeomFromText('POINT(114 5)')),
('a', 'o', 'f', ST_GeomFromText('POINT(227 232)')),
('t', 'c', 'z', ST_GeomFromText('POINT(63 62)')),
('d', 'o', 'k', ST_GeomFromText('POINT(48 228)')),
('x', 'c', 'e', ST_GeomFromText('POINT(204 2)')),
('e', 'e', 'g', ST_GeomFromText('POINT(125 43)')),
('o', 'r', 'f', ST_GeomFromText('POINT(171 140)'));
UPDATE t1 set spatial_point=ST_GeomFromText('POINT(163 157)') where c1 like 'w%';
UPDATE t1 set spatial_point=ST_GeomFromText('POINT(53 151)') where c1 like 'd%';
UPDATE t1 set spatial_point=ST_GeomFromText('POINT(96 183)') where c1 like 'r%';
UPDATE t1 set spatial_point=ST_GeomFromText('POINT(57 91)') where c1 like 'q%';
UPDATE t1 set spatial_point=ST_GeomFromText('POINT(202 110)') where c1 like 'c%';
UPDATE t1 set spatial_point=ST_GeomFromText('POINT(120 137)') where c1 like 'w%';
UPDATE t1 set spatial_point=ST_GeomFromText('POINT(207 147)') where c1 like 'c%';
UPDATE t1 set spatial_point=ST_GeomFromText('POINT(31 125)') where c1 like 'e%';
UPDATE t1 set spatial_point=ST_GeomFromText('POINT(27 36)') where c1 like 'r%';
INSERT INTO t1 (c2, c1, c3, spatial_point) VALUES
('b', 'c', 'e', ST_GeomFromText('POINT(41 137)')),
('p', 'y', 'k', ST_GeomFromText('POINT(50 22)')),
('s', 'c', 'h', ST_GeomFromText('POINT(208 173)')),
('x', 'u', 'l', ST_GeomFromText('POINT(199 175)')),
('s', 'r', 'h', ST_GeomFromText('POINT(85 192)')),
('j', 'k', 'u', ST_GeomFromText('POINT(18 25)')),
('p', 'w', 'h', ST_GeomFromText('POINT(152 197)')),
('e', 'd', 'c', ST_GeomFromText('POINT(229 3)')),
('o', 'x', 'k', ST_GeomFromText('POINT(187 155)')),
('o', 'b', 'k', ST_GeomFromText('POINT(208 150)')),
('d', 'a', 'j', ST_GeomFromText('POINT(70 87)')),
('f', 'e', 'k', ST_GeomFromText('POINT(156 96)')),
('u', 'y', 'p', ST_GeomFromText('POINT(239 193)')),
('n', 'v', 'p', ST_GeomFromText('POINT(223 98)')),
('z', 'j', 'r', ST_GeomFromText('POINT(87 89)')),
('h', 'x', 'x', ST_GeomFromText('POINT(92 0)')),
('r', 'v', 'r', ST_GeomFromText('POINT(159 139)')),
('v', 'g', 'g', ST_GeomFromText('POINT(16 229)')),
('z', 'k', 'u', ST_GeomFromText('POINT(99 52)')),
('p', 'p', 'o', ST_GeomFromText('POINT(105 125)')),
('w', 'h', 'y', ST_GeomFromText('POINT(105 154)')),
('v', 'y', 'z', ST_GeomFromText('POINT(134 238)')),
('x', 'o', 'o', ST_GeomFromText('POINT(178 88)')),
('z', 'w', 'd', ST_GeomFromText('POINT(123 60)')),
('q', 'f', 'u', ST_GeomFromText('POINT(64 90)')),
('s', 'n', 't', ST_GeomFromText('POINT(50 138)')),
('v', 'p', 't', ST_GeomFromText('POINT(114 91)')),
('a', 'o', 'n', ST_GeomFromText('POINT(78 43)')),
('k', 'u', 'd', ST_GeomFromText('POINT(185 161)')),
('w', 'd', 'n', ST_GeomFromText('POINT(25 92)')),
('k', 'w', 'a', ST_GeomFromText('POINT(59 238)')),
('t', 'c', 'f', ST_GeomFromText('POINT(65 87)')),
('g', 's', 'p', ST_GeomFromText('POINT(238 126)')),
('d', 'n', 'y', ST_GeomFromText('POINT(107 173)')),
('l', 'a', 'w', ST_GeomFromText('POINT(125 152)')),
('m', 'd', 'j', ST_GeomFromText('POINT(146 53)')),
('q', 'm', 'c', ST_GeomFromText('POINT(217 187)')),
('i', 'r', 'r', ST_GeomFromText('POINT(6 113)')),
('e', 'j', 'b', ST_GeomFromText('POINT(37 83)')),
('w', 'w', 'h', ST_GeomFromText('POINT(83 199)')),
('k', 'b', 's', ST_GeomFromText('POINT(170 64)')),
('s', 'b', 'c', ST_GeomFromText('POINT(163 130)')),
('c', 'h', 'a', ST_GeomFromText('POINT(141 3)')),
('k', 'j', 'u', ST_GeomFromText('POINT(143 76)')),
('r', 'h', 'o', ST_GeomFromText('POINT(243 92)')),
('i', 'd', 'b', ST_GeomFromText('POINT(205 13)')),
('r', 'y', 'q', ST_GeomFromText('POINT(138 8)')),
('m', 'o', 'i', ST_GeomFromText('POINT(36 45)')),
('v', 'g', 'm', ST_GeomFromText('POINT(0 40)')),
('f', 'e', 'i', ST_GeomFromText('POINT(76 6)')),
('c', 'q', 'q', ST_GeomFromText('POINT(115 248)')),
('x', 'c', 'i', ST_GeomFromText('POINT(29 74)')),
('l', 's', 't', ST_GeomFromText('POINT(83 18)')),
('t', 't', 'a', ST_GeomFromText('POINT(26 168)')),
('u', 'n', 'x', ST_GeomFromText('POINT(200 110)')),
('j', 'b', 'd', ST_GeomFromText('POINT(216 136)')),
('s', 'p', 'w', ST_GeomFromText('POINT(38 156)')),
('f', 'b', 'v', ST_GeomFromText('POINT(29 186)')),
('v', 'e', 'r', ST_GeomFromText('POINT(149 40)')),
('v', 't', 'm', ST_GeomFromText('POINT(184 24)')),
('y', 'g', 'a', ST_GeomFromText('POINT(219 105)')),
('s', 'f', 'i', ST_GeomFromText('POINT(114 130)')),
('e', 'q', 'h', ST_GeomFromText('POINT(203 135)')),
('h', 'g', 'b', ST_GeomFromText('POINT(9 208)')),
('o', 'l', 'r', ST_GeomFromText('POINT(245 79)')),
('s', 's', 'v', ST_GeomFromText('POINT(238 198)')),
('w', 'w', 'z', ST_GeomFromText('POINT(209 232)')),
('v', 'd', 'n', ST_GeomFromText('POINT(30 193)')),
('q', 'w', 'k', ST_GeomFromText('POINT(133 18)')),
('o', 'h', 'o', ST_GeomFromText('POINT(42 140)')),
('f', 'f', 'h', ST_GeomFromText('POINT(145 1)')),
('u', 's', 'r', ST_GeomFromText('POINT(70 62)')),
('x', 'n', 'q', ST_GeomFromText('POINT(33 86)')),
('u', 'p', 'v', ST_GeomFromText('POINT(232 220)')),
('z', 'e', 'a', ST_GeomFromText('POINT(130 69)')),
('r', 'u', 'z', ST_GeomFromText('POINT(243 241)')),
('b', 'n', 't', ST_GeomFromText('POINT(120 12)')),
('u', 'f', 's', ST_GeomFromText('POINT(190 212)')),
('a', 'd', 'q', ST_GeomFromText('POINT(235 191)')),
('f', 'q', 'm', ST_GeomFromText('POINT(176 2)')),
('n', 'c', 's', ST_GeomFromText('POINT(218 163)')),
('e', 'm', 'h', ST_GeomFromText('POINT(163 108)')),
('c', 'f', 'l', ST_GeomFromText('POINT(220 115)')),
('c', 'v', 'q', ST_GeomFromText('POINT(66 45)')),
('w', 'v', 'x', ST_GeomFromText('POINT(251 220)')),
('f', 'w', 'z', ST_GeomFromText('POINT(146 149)')),
('h', 'n', 'h', ST_GeomFromText('POINT(148 128)')),
('y', 'k', 'v', ST_GeomFromText('POINT(28 110)')),
('c', 'x', 'q', ST_GeomFromText('POINT(13 13)')),
('e', 'd', 's', ST_GeomFromText('POINT(91 190)')),
('c', 'w', 'c', ST_GeomFromText('POINT(10 231)')),
('u', 'j', 'n', ST_GeomFromText('POINT(250 21)')),
('w', 'n', 'x', ST_GeomFromText('POINT(141 69)')),
('f', 'p', 'y', ST_GeomFromText('POINT(228 246)')),
('d', 'q', 'f', ST_GeomFromText('POINT(194 22)')),
('d', 'z', 'l', ST_GeomFromText('POINT(233 181)')),
('c', 'a', 'q', ST_GeomFromText('POINT(183 96)')),
('m', 'i', 'd', ST_GeomFromText('POINT(117 226)')),
('z', 'y', 'y', ST_GeomFromText('POINT(62 81)')),
('g', 'v', 'm', ST_GeomFromText('POINT(66 158)'));
SET @@RAND_SEED1=481064922, @@RAND_SEED2=438133497;
DELETE FROM t1 ORDER BY RAND() LIMIT 10;
SET @@RAND_SEED1=280535103, @@RAND_SEED2=444518646;
DELETE FROM t1 ORDER BY RAND() LIMIT 10;
SET @@RAND_SEED1=1072017234, @@RAND_SEED2=484203885;
DELETE FROM t1 ORDER BY RAND() LIMIT 10;
SET @@RAND_SEED1=358851897, @@RAND_SEED2=358495224;
DELETE FROM t1 ORDER BY RAND() LIMIT 10;
SET @@RAND_SEED1=509031459, @@RAND_SEED2=675962925;
DELETE FROM t1 ORDER BY RAND() LIMIT 10;
#UPDATE t1 set spatial_point=ST_GeomFromText('POINT(61 203)') where c1 like 'y%';
UPDATE t1 set spatial_point=ST_GeomFromText('POINT(202 194)') where c1 like 'f%';
UPDATE t1 set spatial_point=ST_GeomFromText('POINT(228 18)') where c1 like 'h%';
UPDATE t1 set spatial_point=ST_GeomFromText('POINT(88 18)') where c1 like 'l%';
UPDATE t1 set spatial_point=ST_GeomFromText('POINT(176 94)') where c1 like 'e%';
UPDATE t1 set spatial_point=ST_GeomFromText('POINT(44 47)') where c1 like 'g%';
UPDATE t1 set spatial_point=ST_GeomFromText('POINT(95 191)') where c1 like 'b%';
UPDATE t1 set spatial_point=ST_GeomFromText('POINT(179 218)') where c1 like 'y%';
UPDATE t1 set spatial_point=ST_GeomFromText('POINT(239 40)') where c1 like 'g%';
UPDATE t1 set spatial_point=ST_GeomFromText('POINT(248 41)') where c1 like 'q%';
UPDATE t1 set spatial_point=ST_GeomFromText('POINT(167 82)') where c1 like 't%';
UPDATE t1 set spatial_point=ST_GeomFromText('POINT(13 104)') where c1 like 'u%';
UPDATE t1 set spatial_point=ST_GeomFromText('POINT(139 84)') where c1 like 'a%';
UPDATE t1 set spatial_point=ST_GeomFromText('POINT(145 108)') where c1 like 'p%';
UPDATE t1 set spatial_point=ST_GeomFromText('POINT(147 57)') where c1 like 't%';
UPDATE t1 set spatial_point=ST_GeomFromText('POINT(217 144)') where c1 like 'n%';
UPDATE t1 set spatial_point=ST_GeomFromText('POINT(160 224)') where c1 like 'w%';
UPDATE t1 set spatial_point=ST_GeomFromText('POINT(38 28)') where c1 like 'j%';
UPDATE t1 set spatial_point=ST_GeomFromText('POINT(104 114)') where c1 like 'q%';
UPDATE t1 set spatial_point=ST_GeomFromText('POINT(88 19)') where c1 like 'c%';
INSERT INTO t1 (c2, c1, c3, spatial_point) VALUES
('f', 'x', 'p', ST_GeomFromText('POINT(92 181)')),
('s', 'i', 'c', ST_GeomFromText('POINT(49 60)')),
('c', 'c', 'i', ST_GeomFromText('POINT(7 57)')),
('n', 'g', 'k', ST_GeomFromText('POINT(252 105)')),
('g', 'b', 'm', ST_GeomFromText('POINT(180 11)')),
('u', 'l', 'r', ST_GeomFromText('POINT(32 90)')),
('c', 'x', 'e', ST_GeomFromText('POINT(143 24)')),
('x', 'u', 'a', ST_GeomFromText('POINT(123 92)')),
('s', 'b', 'h', ST_GeomFromText('POINT(190 108)')),
('c', 'x', 'b', ST_GeomFromText('POINT(104 100)')),
('i', 'd', 't', ST_GeomFromText('POINT(214 104)')),
('r', 'w', 'g', ST_GeomFromText('POINT(29 67)')),
('b', 'f', 'g', ST_GeomFromText('POINT(149 46)')),
('r', 'r', 'd', ST_GeomFromText('POINT(242 196)')),
('j', 'l', 'a', ST_GeomFromText('POINT(90 196)')),
('e', 't', 'b', ST_GeomFromText('POINT(190 64)')),
('l', 'x', 'w', ST_GeomFromText('POINT(250 73)')),
('q', 'y', 'r', ST_GeomFromText('POINT(120 182)')),
('s', 'j', 'a', ST_GeomFromText('POINT(180 175)')),
('n', 'i', 'y', ST_GeomFromText('POINT(124 136)')),
('s', 'x', 's', ST_GeomFromText('POINT(176 209)')),
('u', 'f', 's', ST_GeomFromText('POINT(215 173)')),
('m', 'j', 'x', ST_GeomFromText('POINT(44 140)')),
('v', 'g', 'x', ST_GeomFromText('POINT(177 233)')),
('u', 't', 'b', ST_GeomFromText('POINT(136 197)')),
('f', 'g', 'b', ST_GeomFromText('POINT(10 8)')),
('v', 'c', 'j', ST_GeomFromText('POINT(13 81)')),
('d', 's', 'q', ST_GeomFromText('POINT(200 100)')),
('a', 'p', 'j', ST_GeomFromText('POINT(33 40)')),
('i', 'c', 'g', ST_GeomFromText('POINT(168 204)')),
('k', 'h', 'i', ST_GeomFromText('POINT(93 243)')),
('s', 'b', 's', ST_GeomFromText('POINT(157 13)')),
('v', 'l', 'l', ST_GeomFromText('POINT(103 6)')),
('r', 'b', 'k', ST_GeomFromText('POINT(244 137)')),
('l', 'd', 'r', ST_GeomFromText('POINT(162 254)')),
('q', 'b', 'z', ST_GeomFromText('POINT(136 246)')),
('x', 'x', 'p', ST_GeomFromText('POINT(120 37)')),
('m', 'e', 'z', ST_GeomFromText('POINT(203 167)')),
('q', 'n', 'p', ST_GeomFromText('POINT(94 119)')),
('b', 'g', 'u', ST_GeomFromText('POINT(93 248)')),
('r', 'v', 'v', ST_GeomFromText('POINT(53 88)')),
('y', 'a', 'i', ST_GeomFromText('POINT(98 219)')),
('a', 's', 'g', ST_GeomFromText('POINT(173 138)')),
('c', 'a', 't', ST_GeomFromText('POINT(235 135)')),
('q', 'm', 'd', ST_GeomFromText('POINT(224 208)')),
('e', 'p', 'k', ST_GeomFromText('POINT(161 238)')),
('n', 'g', 'q', ST_GeomFromText('POINT(35 204)')),
('t', 't', 'x', ST_GeomFromText('POINT(230 178)')),
('w', 'f', 'a', ST_GeomFromText('POINT(150 221)')),
('z', 'm', 'z', ST_GeomFromText('POINT(119 42)')),
('l', 'j', 's', ST_GeomFromText('POINT(97 96)')),
('f', 'z', 'x', ST_GeomFromText('POINT(208 65)')),
('i', 'v', 'c', ST_GeomFromText('POINT(145 79)')),
('l', 'f', 'k', ST_GeomFromText('POINT(83 234)')),
('u', 'a', 's', ST_GeomFromText('POINT(250 49)')),
('o', 'k', 'p', ST_GeomFromText('POINT(46 50)')),
('d', 'e', 'z', ST_GeomFromText('POINT(30 198)')),
('r', 'r', 'l', ST_GeomFromText('POINT(78 189)')),
('y', 'l', 'f', ST_GeomFromText('POINT(188 132)')),
('d', 'q', 'm', ST_GeomFromText('POINT(247 107)')),
('p', 'j', 'n', ST_GeomFromText('POINT(148 227)')),
('b', 'o', 'i', ST_GeomFromText('POINT(172 25)')),
('e', 'v', 'd', ST_GeomFromText('POINT(94 248)')),
('q', 'd', 'f', ST_GeomFromText('POINT(15 29)')),
('w', 'b', 'b', ST_GeomFromText('POINT(74 111)')),
('g', 'q', 'f', ST_GeomFromText('POINT(107 215)')),
('o', 'h', 'r', ST_GeomFromText('POINT(25 168)')),
('u', 't', 'w', ST_GeomFromText('POINT(251 188)')),
('h', 's', 'w', ST_GeomFromText('POINT(254 247)')),
('f', 'f', 'b', ST_GeomFromText('POINT(166 103)'));
SET @@RAND_SEED1=866613816, @@RAND_SEED2=92289615;
INSERT INTO t1 (c2, c1, c3, spatial_point) VALUES
('l', 'c', 'l', ST_GeomFromText('POINT(202 98)')),
('k', 'c', 'b', ST_GeomFromText('POINT(46 206)')),
('r', 'y', 'm', ST_GeomFromText('POINT(74 140)')),
('y', 'z', 'd', ST_GeomFromText('POINT(200 160)')),
('s', 'y', 's', ST_GeomFromText('POINT(156 205)')),
('u', 'v', 'p', ST_GeomFromText('POINT(86 82)')),
('j', 's', 's', ST_GeomFromText('POINT(91 233)')),
('x', 'j', 'f', ST_GeomFromText('POINT(3 14)')),
('l', 'z', 'v', ST_GeomFromText('POINT(123 156)')),
('h', 'i', 'o', ST_GeomFromText('POINT(145 229)')),
('o', 'r', 'd', ST_GeomFromText('POINT(15 22)')),
('f', 'x', 't', ST_GeomFromText('POINT(21 60)')),
('t', 'g', 'h', ST_GeomFromText('POINT(50 153)')),
('g', 'u', 'b', ST_GeomFromText('POINT(82 85)')),
('v', 'a', 'p', ST_GeomFromText('POINT(231 178)')),
('n', 'v', 'o', ST_GeomFromText('POINT(183 25)')),
('j', 'n', 'm', ST_GeomFromText('POINT(50 144)')),
('e', 'f', 'i', ST_GeomFromText('POINT(46 16)')),
('d', 'w', 'a', ST_GeomFromText('POINT(66 6)')),
('f', 'x', 'a', ST_GeomFromText('POINT(107 197)')),
('m', 'o', 'a', ST_GeomFromText('POINT(142 80)')),
('q', 'l', 'g', ST_GeomFromText('POINT(251 23)')),
('c', 's', 's', ST_GeomFromText('POINT(158 43)')),
('y', 'd', 'o', ST_GeomFromText('POINT(196 228)')),
('d', 'p', 'l', ST_GeomFromText('POINT(107 5)')),
('h', 'a', 'b', ST_GeomFromText('POINT(183 166)')),
('m', 'w', 'p', ST_GeomFromText('POINT(19 59)')),
('b', 'y', 'o', ST_GeomFromText('POINT(178 30)')),
('x', 'w', 'i', ST_GeomFromText('POINT(168 94)')),
('t', 'k', 'z', ST_GeomFromText('POINT(171 5)')),
('r', 'm', 'a', ST_GeomFromText('POINT(222 19)')),
('u', 'v', 'e', ST_GeomFromText('POINT(224 80)')),
('q', 'r', 'k', ST_GeomFromText('POINT(212 218)')),
('d', 'p', 'j', ST_GeomFromText('POINT(169 7)')),
('d', 'r', 'v', ST_GeomFromText('POINT(193 23)')),
('n', 'y', 'y', ST_GeomFromText('POINT(130 178)')),
('m', 'z', 'r', ST_GeomFromText('POINT(81 200)')),
('j', 'e', 'w', ST_GeomFromText('POINT(145 239)')),
('v', 'h', 'x', ST_GeomFromText('POINT(24 105)')),
('z', 'm', 'a', ST_GeomFromText('POINT(175 129)')),
('b', 'c', 'v', ST_GeomFromText('POINT(213 10)')),
('t', 't', 'u', ST_GeomFromText('POINT(2 129)')),
('r', 's', 'v', ST_GeomFromText('POINT(209 192)')),
('x', 'p', 'g', ST_GeomFromText('POINT(43 63)')),
('t', 'e', 'u', ST_GeomFromText('POINT(139 210)')),
('l', 'e', 't', ST_GeomFromText('POINT(245 148)')),
('a', 'i', 'k', ST_GeomFromText('POINT(167 195)')),
('m', 'o', 'h', ST_GeomFromText('POINT(206 120)')),
('g', 'z', 's', ST_GeomFromText('POINT(169 240)')),
('z', 'u', 's', ST_GeomFromText('POINT(202 120)')),
('i', 'b', 'a', ST_GeomFromText('POINT(216 18)')),
('w', 'y', 'g', ST_GeomFromText('POINT(119 236)')),
('h', 'y', 'p', ST_GeomFromText('POINT(161 24)'));
CHECK TABLE t1 EXTENDED;
UPDATE t1 set spatial_point=ST_GeomFromText('POINT(33 100)') where c1 like 't%';
CHECK TABLE t1 EXTENDED;
UPDATE t1 set spatial_point=ST_GeomFromText('POINT(41 46)') where c1 like 'f%';
CHECK TABLE t1 EXTENDED;
DROP TABLE t1;
#
# Bug #30286 spatial index cause corruption and server crash!
#
create table t1 (a geometry not null, spatial index(a));
insert into t1 values (POINT(1.1517219314031e+164, 131072));
insert into t1 values (POINT(9.1248812352444e+192, 2.9740338169556e+284));
insert into t1 values (POINT(4.7783097267365e-299, -0));
insert into t1 values (POINT(1.49166814624e-154, 2.0880974297595e-53));
insert into t1 values (POINT(4.0917382598702e+149, 1.2024538023802e+111));
insert into t1 values (POINT(2.0349165139404e+236, 2.9993936277913e-241));
insert into t1 values (POINT(2.5243548967072e-29, 1.2024538023802e+111));
insert into t1 values (POINT(0, 6.9835074892995e-251));
insert into t1 values (POINT(2.0880974297595e-53, 3.1050361846014e+231));
insert into t1 values (POINT(2.8728483499323e-188, 2.4600631144627e+260));
insert into t1 values (POINT(3.0517578125e-05, 2.0349165139404e+236));
insert into t1 values (POINT(1.1517219314031e+164, 1.1818212630766e-125));
insert into t1 values (POINT(2.481040258324e-265, 5.7766220027675e-275));
insert into t1 values (POINT(2.0880974297595e-53, 2.5243548967072e-29));
insert into t1 values (POINT(5.7766220027675e-275, 9.9464647281957e+86));
insert into t1 values (POINT(2.2181357552967e+130, 3.7857669957337e-270));
insert into t1 values (POINT(4.5767114681874e-246, 3.6893488147419e+19));
insert into t1 values (POINT(4.5767114681874e-246, 3.7537584144024e+255));
insert into t1 values (POINT(3.7857669957337e-270, 1.8033161362863e-130));
insert into t1 values (POINT(0, 5.8774717541114e-39));
insert into t1 values (POINT(1.1517219314031e+164, 2.2761049594727e-159));
insert into t1 values (POINT(6.243497100632e+144, 3.7857669957337e-270));
insert into t1 values (POINT(3.7857669957337e-270, 2.6355494858076e-82));
insert into t1 values (POINT(2.0349165139404e+236, 3.8518598887745e-34));
insert into t1 values (POINT(4.6566128730774e-10, 2.0880974297595e-53));
insert into t1 values (POINT(2.0880974297595e-53, 1.8827498946116e-183));
insert into t1 values (POINT(1.8033161362863e-130, 9.1248812352444e+192));
insert into t1 values (POINT(4.7783097267365e-299, 2.2761049594727e-159));
insert into t1 values (POINT(1.94906280228e+289, 1.2338789709327e-178));
drop table t1;
# End of 4.1 tests
#
# bug #21790 (UNKNOWN ERROR on NULLs in RTree)
#
CREATE TABLE t1(foo GEOMETRY NOT NULL, SPATIAL INDEX(foo) );
--error 1048
INSERT INTO t1(foo) VALUES (NULL);
SET sql_mode = 'NO_ENGINE_SUBSTITUTION';
--error 1416
INSERT INTO t1() VALUES ();
SET sql_mode = default;
--error 1416
INSERT INTO t1(foo) VALUES ('');
DROP TABLE t1;
#
# Bug #23578: Corruption prevents Optimize table from working properly with a
# spatial index
#
CREATE TABLE t1 (a INT AUTO_INCREMENT, b POINT NOT NULL, KEY (a), SPATIAL KEY (b));
INSERT INTO t1 (b) VALUES (ST_GeomFromText('POINT(1 2)'));
INSERT INTO t1 (b) SELECT b FROM t1;
INSERT INTO t1 (b) SELECT b FROM t1;
INSERT INTO t1 (b) SELECT b FROM t1;
INSERT INTO t1 (b) SELECT b FROM t1;
INSERT INTO t1 (b) SELECT b FROM t1;
OPTIMIZE TABLE t1;
DROP TABLE t1;
#
# Bug #29070: Error in spatial index
#
CREATE TABLE t1 (a INT, b GEOMETRY NOT NULL, SPATIAL KEY b(b));
INSERT INTO t1 VALUES (1, ST_GEOMFROMTEXT('LINESTRING(1102218.456 1,2000000 2)'));
INSERT INTO t1 VALUES (2, ST_GEOMFROMTEXT('LINESTRING(1102218.456 1,2000000 2)'));
# must return the same number as the next select
SELECT COUNT(*) FROM t1 WHERE
MBRINTERSECTS(b, ST_GEOMFROMTEXT('LINESTRING(1 1,1102219 2)') );
SELECT COUNT(*) FROM t1 IGNORE INDEX (b) WHERE
MBRINTERSECTS(b, ST_GEOMFROMTEXT('LINESTRING(1 1,1102219 2)') );
DROP TABLE t1;
--echo #
--echo # Bug #48258: Assertion failed when using a spatial index
--echo #
CREATE TABLE t1(a LINESTRING NOT NULL, SPATIAL KEY(a));
INSERT INTO t1 VALUES
(ST_GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)')),
(ST_GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)'));
EXPLAIN SELECT 1 FROM t1 WHERE a = ST_GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)');
SELECT 1 FROM t1 WHERE a = ST_GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)');
--error ER_WRONG_ARGUMENTS
EXPLAIN SELECT 1 FROM t1 WHERE a < ST_GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)');
--error ER_WRONG_ARGUMENTS
SELECT 1 FROM t1 WHERE a < ST_GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)');
--error ER_WRONG_ARGUMENTS
EXPLAIN SELECT 1 FROM t1 WHERE a <= ST_GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)');
--error ER_WRONG_ARGUMENTS
SELECT 1 FROM t1 WHERE a <= ST_GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)');
--error ER_WRONG_ARGUMENTS
EXPLAIN SELECT 1 FROM t1 WHERE a > ST_GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)');
--error ER_WRONG_ARGUMENTS
SELECT 1 FROM t1 WHERE a > ST_GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)');
--error ER_WRONG_ARGUMENTS
EXPLAIN SELECT 1 FROM t1 WHERE a >= ST_GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)');
--error ER_WRONG_ARGUMENTS
SELECT 1 FROM t1 WHERE a >= ST_GEOMFROMTEXT('LINESTRING(-1 -1, 1 -1, -1 -1, -1 1, 1 1)');
DROP TABLE t1;
--echo #
--echo # Bug #51357: crash when using handler commands on spatial indexes
--echo #
CREATE TABLE t1(a GEOMETRY NOT NULL,SPATIAL INDEX a(a));
HANDLER t1 OPEN;
HANDLER t1 READ a FIRST;
HANDLER t1 READ a NEXT;
HANDLER t1 READ a PREV;
HANDLER t1 READ a LAST;
HANDLER t1 CLOSE;
# second crash fixed when the tree has changed since the last search.
HANDLER t1 OPEN;
HANDLER t1 READ a FIRST;
INSERT INTO t1 VALUES (ST_GeomFromText('Polygon((40 40,60 40,60 60,40 60,40 40))'));
--echo # should not crash
--disable_result_log
HANDLER t1 READ a NEXT;
--enable_result_log
HANDLER t1 CLOSE;
DROP TABLE t1;
--echo End of 5.0 tests.
--echo #
--echo # Bug #57323/11764487: myisam corruption with insert ignore
--echo # and invalid spatial data
--echo #
CREATE TABLE t1(a LINESTRING NOT NULL, b GEOMETRY NOT NULL,
SPATIAL KEY(a), SPATIAL KEY(b)) ENGINE=InnoDB;
--error ER_CANT_CREATE_GEOMETRY_OBJECT
INSERT INTO t1 VALUES(ST_GEOMFROMTEXT("point (0 0)"), ST_GEOMFROMTEXT("point (1 1)"));
--error ER_CANT_CREATE_GEOMETRY_OBJECT
INSERT IGNORE INTO t1 SET a=ST_GEOMFROMTEXT("point (-6 0)"), b=ST_GEOMFROMTEXT("error");
--error ER_CANT_CREATE_GEOMETRY_OBJECT
INSERT IGNORE INTO t1 SET a=ST_GEOMFROMTEXT("point (-6 0)"), b=NULL;
SELECT ST_ASTEXT(a), ST_ASTEXT(b) FROM t1;
DROP TABLE t1;
CREATE TABLE t1(a INT NOT NULL, b GEOMETRY NOT NULL,
KEY(a), SPATIAL KEY(b)) ENGINE=InnoDB;
INSERT INTO t1 VALUES(0, ST_GEOMFROMTEXT("point (1 1)"));
--error ER_GIS_INVALID_DATA
INSERT IGNORE INTO t1 SET a=0, b=ST_GEOMFROMTEXT("error");
--error ER_CANT_CREATE_GEOMETRY_OBJECT
INSERT IGNORE INTO t1 SET a=1, b=NULL;
SELECT a, ST_ASTEXT(b) FROM t1;
DROP TABLE t1;
--echo End of 5.1 tests
# This test case will test R-tree purge.
# Not supported in embedded
--source include/not_embedded.inc
--source include/have_innodb.inc
--source include/have_innodb_zip.inc
--source include/have_debug.inc
--source include/big_test.inc
# Valgrind takes too much time on PB2 even in the --big-test runs.
--source include/not_valgrind.inc
# Temporarily disable it for 4k page size. Since it'll take too long
# time.
--disable_warnings
if (`SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE LOWER(variable_name) = 'innodb_page_size' AND variable_value = 4096`)
{
--skip Test requires InnoDB with not 4k Page size.
}
--enable_warnings
create table t (
a point not null,b point not null,c point,
d point not null,e point,f point,
spatial key (d),spatial key (b)
) engine=innodb;
delimiter |;
create procedure p(i int)
begin
declare n int default 0;
declare continue handler for sqlexception begin end;
delete from t;
repeat
set @p=point(1,1);
insert into t values(@p,@p,@p,@p,@p,@p);
insert into t values(@p,@p,@p,@p,@p,@p);
insert into t select @p,@p,@p,@p,@p,@p
from t a,t b,t c,t d,t e,t f,t g,t h,t i,t j;
delete from t;
set n:=n+1;
until n >= i end repeat;
end|
delimiter ;|
call p(200);
--source include/wait_innodb_all_purged.inc
# Clean up.
drop procedure p;
drop table t;
# WL#6745 InnoDB R-tree support
# This test case test R-tree crash/recovery.
# Restart is not supported in embedded
--source include/not_embedded.inc
--source include/have_innodb.inc
--source include/no_valgrind_without_big.inc
# Do a clean shutdown and restart so that the redo log is cleaned up from previous tests.
--source include/restart_mysqld.inc
# Create table with R-tree index.
create table t1 (c1 int, c2 geometry not null, spatial index (c2))engine=innodb;
# Insert enough values to let R-tree split.
delimiter |;
create procedure insert_t1(IN total int)
begin
declare i int default 1;
while (i <= total) DO
insert into t1 values (i, Point(i, i));
set i = i + 1;
end while;
end|
delimiter ;|
# Update values
delimiter |;
create procedure update_t1(IN total int)
begin
declare i int default 1;
while (i <= total) DO
update t1 set c2 = Point(i + 10000, i + 10000) where c2 = Point(i, i);
set i = i + 1;
end while;
end|
delimiter ;|
# Test crash recovery.
#
# Test level 1 rtree.
CALL insert_t1(367);
COMMIT;
--source include/kill_and_restart_mysqld.inc
# Check table.
check table t1;
# Clean up.
drop table t1;
# Test crash recovery on point spatial index.
create table t1 (c1 int, c2 point not null, spatial index (c2))engine=innodb;
# Some DML on point spatial index.
CALL insert_t1(367);
CALL update_t1(367);
SET @poly1 = ST_GeomFromText('POLYGON((10000 10000, 10000 10350, 10350 10350, 10350 10000, 10000 10000))');
delete from t1 where ST_Contains(@poly1, c2);
COMMIT;
--source include/kill_and_restart_mysqld.inc
# Check table.
check table t1;
select count(*) from t1;
select c1, ST_astext(c2) from t1;
# Clean up.
drop procedure insert_t1;
drop procedure update_t1;
drop table t1;
# WL#6745 InnoDB R-tree support
# This test case will test R-tree split.
# Not supported in embedded
--source include/not_embedded.inc
--source include/have_innodb.inc
--source include/big_test.inc
--source include/not_valgrind.inc
--source include/have_innodb_16k.inc
# Create table with R-tree index.
create table t1 (c1 int, c2 geometry not null, spatial index (c2))engine=innodb;
# Insert enough values to let R-tree split.
insert into t1 values(1, Point(1,1));
insert into t1 values(2, Point(2,2));
insert into t1 values(3, Point(3,3));
insert into t1 values(4, Point(4,4));
insert into t1 values(5, Point(5,5));
insert into t1 values(6, Point(6,6));
insert into t1 values(7, Point(7,7));
insert into t1 values(8, Point(8,8));
insert into t1 values(9, Point(9,9));
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
start transaction;
insert into t1 select * from t1;
select count(*) from t1;
rollback;
check table t1;
select count(*) from t1;
set @g1 = ST_GeomFromText('Polygon((0 0,0 100,100 100,100 0,0 0))');
select count(*) from t1 where MBRWithin(t1.c2, @g1);
set @g1 = ST_GeomFromText('Polygon((10 10,10 800,800 800,800 10,10 10))');
select count(*) from t1 where MBRWithin(t1.c2, @g1);
# Clean up.
drop table t1;
# WL#6745 InnoDB R-tree support
# This test case will test R-tree split.
# Not supported in embedded
--source include/not_embedded.inc
--source include/have_innodb.inc
--source include/big_test.inc
--source include/not_valgrind.inc
# Create table with R-tree index.
create table t1 (c1 int, c2 geometry not null, spatial index (c2))engine=innodb;
# Insert enough values to let R-tree split.
delimiter |;
create procedure insert_t1(IN total int)
begin
declare i int default 1;
while (i <= total) DO
insert into t1 values (i, Point(i, i));
set i = i + 1;
end while;
end|
delimiter ;|
start transaction;
CALL insert_t1(70000);
rollback;
check table t1;
# Clean up.
drop procedure insert_t1;
drop table t1;
# WL#6968 InnoDB R-tree cursor support
# Not supported in embedded
--source include/not_embedded.inc
--source include/not_valgrind.inc
--source include/have_innodb.inc
# Create table with R-tree index.
create table t1 (c1 int, c2 geometry not null, spatial index (c2))engine=innodb;
# Insert enough values to let R-tree split.
delimiter |;
create procedure insert_t1(IN total int)
begin
declare i int default 1;
while (i <= total) DO
insert into t1 values (i, Point(i, i));
set i = i + 1;
end while;
end|
delimiter ;|
# Test level 1 rtree.
CALL insert_t1(1000);
select count(*) from t1;
set @g1 = ST_GeomFromText('Polygon((0 0,0 1000,1000 1000,1000 0,0 0))');
select count(*) from t1 where MBRWithin(t1.c2, @g1);
set @g1 = ST_GeomFromText('Polygon((0 0,0 100,100 100,100 0,0 0))');
select count(*) from t1 where MBRWithin(t1.c2, @g1);
set @g1 = ST_GeomFromText('Polygon((10 10,10 800,800 800,800 10,10 10))');
select count(*) from t1 where MBRWithin(t1.c2, @g1);
set @g1 = ST_GeomFromText('Polygon((100 100,100 800,800 800,800 100,100 100))');
select count(*) from t1 where MBRWithin(t1.c2, @g1);
#SET DEBUG='+d, rtr_pessimistic_position';
#select count(*) from t1 where MBRWithin(t1.c2, @g1);
#SET DEBUG='-d, rtr_pessimistic_position';
# Equality search
set @g1 = ST_GeomFromText('Point(1 1)');
select count(*) from t1 where MBRequals(t1.c2, @g1);
# MBRDisjoint search
set @g1 = ST_GeomFromText('Polygon((0 0,0 100,100 100,100 0,0 0))');
select count(*) from t1 where MBRdisjoint(t1.c2, @g1);
# Clean up.
DROP PROCEDURE insert_t1;
truncate t1;
let $1=150;
let $2=150;
while ($1)
{
eval INSERT INTO t1 VALUES ($1, ST_GeomFromText('LineString($1 $1, $2 $2)'));
dec $1;
inc $2;
}
select count(*) from t1;
set @g1 = ST_GeomFromText('Polygon((0 0,0 1000,1000 1000,1000 0,0 0))');
select count(*) from t1 where MBRwithin(t1.c2, @g1);
truncate t1;
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(2 2, 150 150)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(3 3, 160 160)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(4 4, 170 170)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(5 5, 180 180)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(6 6, 190 190)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(7 7, 200 200)'));
INSERT INTO t1 VALUES (1, ST_GeomFromText('LineString(8 8, 210 210)'));
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
# Testing "MBRtouches"
# This is apparently now treated as "intersects"
set @g1 = ST_GeomFromText('Polygon((0 0,0 2, 2 2, 2 0, 0 0))');
select count(*) from t1 where MBRtouches(t1.c2, @g1);
set @g1 = ST_GeomFromText('Polygon((0 0,0 200,200 200,200 0,0 0))');
select count(*) from t1 where MBRWithin(t1.c2, @g1);
# Test MBRequals
set @g1 = ST_GeomFromText('LineString(2 2, 150 150)');
select count(*) from t1 where MBRequals(t1.c2, @g1);
# Test store procedure with open cursor
set @g1 = ST_GeomFromText('Polygon((0 0,0 200,200 200,200 0,0 0))');
create table t3 (a int) engine = innodb;
delimiter |;
CREATE PROCEDURE curdemo()
BEGIN
DECLARE done INT DEFAULT FALSE;
DECLARE a INT;
DECLARE cur1 CURSOR FOR SELECT c1 from t1 where MBRWithin(t1.c2, @g1);
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
OPEN cur1;
read_loop: LOOP
FETCH cur1 INTO a;
IF done THEN
LEAVE read_loop;
END IF;
INSERT INTO test.t3 VALUES (a);
END LOOP;
CLOSE cur1;
END|
delimiter ;|
call curdemo();
select count(*) from t3;
drop procedure curdemo;
drop table t3;
drop table t1;
# WL#6745 InnoDB R-tree support
# This test case will test R-tree split, mostly on duplciate records.
# Not supported in embedded
--source include/not_embedded.inc
--source include/have_innodb.inc
--source include/big_test.inc
--source include/not_valgrind.inc
--source include/have_debug.inc
# Create table with R-tree index.
create table t1 (c1 int, c2 geometry not null, spatial index (c2))engine=innodb;
# Insert enough values to let R-tree split.
insert into t1 values(1, Point(1,1));
insert into t1 values(2, Point(2,2));
insert into t1 values(3, Point(3,3));
insert into t1 values(4, Point(4,4));
insert into t1 values(5, Point(5,5));
insert into t1 values(6, Point(6,6));
insert into t1 values(7, Point(7,7));
insert into t1 values(8, Point(8,8));
insert into t1 values(9, Point(9,9));
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
#Check second round spliting.
SET SESSION debug="+d, rtr_page_need_second_split";
insert into t1 select * from t1;
SET SESSION debug="-d, rtr_page_need_second_split";
delete from t1;
insert into t1 values(1, Point(1,1));
insert into t1 values(2, Point(2,2));
insert into t1 values(3, Point(3,3));
insert into t1 values(4, Point(4,4));
insert into t1 values(5, Point(5,5));
insert into t1 values(6, Point(6,6));
insert into t1 values(7, Point(7,7));
insert into t1 values(8, Point(8,8));
insert into t1 values(9, Point(9,9));
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
start transaction;
insert into t1 select * from t1;
rollback;
check table t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
insert into t1 select * from t1;
check table t1;
select count(*) from t1;
set @g1 = ST_GeomFromText('Polygon((0 0,0 100,100 100,100 0,0 0))');
select count(*) from t1 where MBRWithin(t1.c2, @g1);
set @g1 = ST_GeomFromText('Polygon((10 10,10 800,800 800,800 10,10 10))');
select count(*) from t1 where MBRWithin(t1.c2, @g1);
drop index c2 on t1;
# Test create index with algorithm=inplace
create spatial index idx2 on t1(c2);
show create table t1;
set @g1 = ST_GeomFromText('Polygon((0 0,0 100,100 100,100 0,0 0))');
select count(*) from t1 where MBRWithin(t1.c2, @g1);
# test read only case
let $restart_parameters = restart: --innodb-read-only;
--source include/restart_mysqld.inc
set @g1 = ST_GeomFromText('Polygon((0 0,0 100,100 100,100 0,0 0))');
select count(*) from t1 where MBRWithin(t1.c2, @g1);
set @g1 = ST_GeomFromText('Polygon((2 2,2 800,800 800,800 2,2 2))');
select count(*) from t1 where MBRWithin(t1.c2, @g1);
let $restart_parameters = restart;
--source include/restart_mysqld.inc
# Clean up.
drop table t1;
#
# BUG#21340268 INNODB: BOGUS CHECK FOR MAXIMUM RECORD LENGTH WITH SPATIAL KEY
# BUG#21508582 UNDO LOG DOES NOT CONTAIN ENOUGH INFORMATION ON SPATIAL COLUMNS
#
--source include/have_innodb.inc
--source include/count_sessions.inc
connect (con1,localhost,root,,);
connection default;
let $row_format = DYNAMIC;
let $prefix_size = 767;
let $index = spatial_none;
--source include/innodb_gis_undo.inc
let $index = spatial_only;
--source include/innodb_gis_undo.inc
let $index = spatial_mixed;
--source include/innodb_gis_undo.inc
let $row_format = COMPACT;
let $prefix_size = 767;
let $index = spatial_none;
--source include/innodb_gis_undo.inc
let $index = spatial_only;
--source include/innodb_gis_undo.inc
let $index = spatial_mixed;
--source include/innodb_gis_undo.inc
disconnect con1;
--source include/wait_until_count_sessions.inc
# WL#6455 GEOMETRY datatypes support
# In order to implement GIS indexing in InnoDB,
# InnoDB needs to support GEOMETRY datatypes,
# so that InnoDB stores them properly and understands them.
# Restarting is not supported in embedded
--source include/not_embedded.inc
--source include/have_innodb.inc
--source include/have_debug.inc
# Avoid CrashReporter popup on Mac
--source include/not_crashrep.inc
# Turn on the geometry data print.
SET SESSION debug="+d,row_print_geometry_data";
# Test GEOMETRY datatype.
CREATE TABLE t_wl6455 ( i INT, g GEOMETRY NOT NULL) ENGINE=InnoDB;
SHOW CREATE TABLE t_wl6455;
# Insert Point.
INSERT INTO t_wl6455 VALUES(1, POINT(1,1));
INSERT INTO t_wl6455 VALUES(2, POINT(2,2));
# Insert MultiPoint.
SET @mp = 'MULTIPOINT(0 0, 20 20, 60 60)';
INSERT INTO t_wl6455 VALUES(3, ST_GeomFromText(@mp));
# Insert LineString.
INSERT INTO t_wl6455 VALUES(4, LINESTRING(POINT(1,1), POINT(4, 4)));
INSERT INTO t_wl6455 VALUES(5, LINESTRING(POINT(2,2), POINT(5, 5)));
# Insert MultiLineString.
SET @mls = 'MultiLineString((1 1,2 2,3 3),(4 4,5 5))';
INSERT INTO t_wl6455 VALUES(6, ST_GeomFromText(@mls));
# Insert Polygon.
SET @poly = 'Polygon((0 0,0 3,3 0,0 0),(1 1,1 2,2 1,1 1))';
INSERT INTO t_wl6455 VALUES(7, ST_GeomFromText(@poly));
# Insert MultiPolygon.
SET @mpoly = 'MultiPolygon(((0 0,0 3,3 3,3 0,0 0),(1 1,1 2,2 2,2 1,1 1)))';
INSERT INTO t_wl6455 VALUES(8, ST_GeomFromText(@mpoly));
# Insert GeometryCollection.
SET @gc = 'GeometryCollection(Point(1 1),LineString(2 2, 3 3))';
INSERT INTO t_wl6455 VALUES(9, ST_GeomFromText(@gc));
# Show result.
SELECT ST_AsText(g) FROM t_wl6455;
# Test create prefix index.
CREATE INDEX i_p ON t_wl6455 (g(10));
# Select on prefix index.
--replace_column 10 #
EXPLAIN SELECT ST_AsText(g) FROM t_wl6455 WHERE g = POINT(2,2);
SELECT ST_AsText(g) FROM t_wl6455 WHERE g = POINT(2,2);
# Test rollback/commit
SET AUTOCOMMIT = 0;
INSERT INTO t_wl6455 VALUES(10, POINT(10,10));
SELECT ST_AsText(g) FROM t_wl6455 WHERE g = POINT(10,10);
ROLLBACK;
SELECT ST_AsText(g) FROM t_wl6455 WHERE g = POINT(10,10);
INSERT INTO t_wl6455 VALUES(10, POINT(10,10));
COMMIT;
INSERT INTO t_wl6455 VALUES(11, POINT(11,11));
BEGIN;
INSERT INTO t_wl6455 VALUES(1, POINT(1,1));
--source include/kill_and_restart_mysqld.inc
CHECK TABLE t_wl6455;
SELECT ST_AsText(g) FROM t_wl6455;
# Check information_schema, the mtype of GEOMETRY datatype is 14.
SELECT sc.name, sc.pos, sc.mtype
FROM information_schema.innodb_sys_columns sc
INNER JOIN information_schema.innodb_sys_tables st
ON sc.TABLE_ID=st.TABLE_ID
WHERE st.NAME='test/t_wl6455' AND sc.NAME='g';
# Clean up
DROP TABLE t_wl6455;
# WL#6745 InnoDB R-tree support
# This test case will test R-tree multi level split.
# Not supported in embedded
--source include/not_embedded.inc
--source include/have_innodb.inc
--source include/have_debug.inc
--source include/big_test.inc
--source include/not_valgrind.inc
# Create table with R-tree index.
create table t1 (c1 int, c2 geometry not null, spatial index (c2))engine=innodb;
# Insert enough values to let R-tree split.
delimiter |;
create procedure insert_t1(IN total int)
begin
declare i int default 1;
while (i <= total) DO
insert into t1 values (i, Point(i, i));
set i = i + 1;
end while;
end|
delimiter ;|
# Test level 3 rtree.
CALL insert_t1(70000);
CALL insert_t1(90);
CALL insert_t1(90);
CALL insert_t1(83);
insert into t1 values (0, Point(0.9, 0.9));
# Check table.
check table t1;
drop procedure insert_t1;
drop table t1;
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment