mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
MDEV-11041 Innodb_gis/ tests taken from MySQL fail.
Some fixes made in innodb and item_create.cc. Adapted Innodb-GIS tests moved to MariaDB.
This commit is contained in:
@ -179,6 +179,7 @@ my @DEFAULT_SUITES= qw(
|
||||
heap-
|
||||
innodb-
|
||||
innodb_fts-
|
||||
innodb_gis-
|
||||
innodb_zip-
|
||||
maria-
|
||||
multi_source-
|
||||
|
619
mysql-test/suite/innodb_gis/r/0.result
Normal file
619
mysql-test/suite/innodb_gis/r/0.result
Normal file
@ -0,0 +1,619 @@
|
||||
SET default_storage_engine=innodb;
|
||||
DROP TABLE IF EXISTS t1, gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry;
|
||||
CREATE TABLE gis_point (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g POINT);
|
||||
CREATE TABLE gis_line (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g LINESTRING);
|
||||
CREATE TABLE gis_polygon (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g POLYGON);
|
||||
CREATE TABLE gis_multi_point (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g MULTIPOINT);
|
||||
CREATE TABLE gis_multi_line (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g MULTILINESTRING);
|
||||
CREATE TABLE gis_multi_polygon (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g MULTIPOLYGON);
|
||||
CREATE TABLE gis_geometrycollection (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g GEOMETRYCOLLECTION);
|
||||
CREATE TABLE gis_geometry (fid INTEGER PRIMARY KEY AUTO_INCREMENT, g GEOMETRY);
|
||||
SHOW CREATE TABLE gis_point;
|
||||
Table Create Table
|
||||
gis_point CREATE TABLE `gis_point` (
|
||||
`fid` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`g` point DEFAULT NULL,
|
||||
PRIMARY KEY (`fid`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
SHOW FIELDS FROM gis_point;
|
||||
Field Type Null Key Default Extra
|
||||
fid int(11) NO PRI NULL auto_increment
|
||||
g point YES NULL
|
||||
SHOW FIELDS FROM gis_line;
|
||||
Field Type Null Key Default Extra
|
||||
fid int(11) NO PRI NULL auto_increment
|
||||
g linestring YES NULL
|
||||
SHOW FIELDS FROM gis_polygon;
|
||||
Field Type Null Key Default Extra
|
||||
fid int(11) NO PRI NULL auto_increment
|
||||
g polygon YES NULL
|
||||
SHOW FIELDS FROM gis_multi_point;
|
||||
Field Type Null Key Default Extra
|
||||
fid int(11) NO PRI NULL auto_increment
|
||||
g multipoint YES NULL
|
||||
SHOW FIELDS FROM gis_multi_line;
|
||||
Field Type Null Key Default Extra
|
||||
fid int(11) NO PRI NULL auto_increment
|
||||
g multilinestring YES NULL
|
||||
SHOW FIELDS FROM gis_multi_polygon;
|
||||
Field Type Null Key Default Extra
|
||||
fid int(11) NO PRI NULL auto_increment
|
||||
g multipolygon YES NULL
|
||||
SHOW FIELDS FROM gis_geometrycollection;
|
||||
Field Type Null Key Default Extra
|
||||
fid int(11) NO PRI NULL auto_increment
|
||||
g geometrycollection YES NULL
|
||||
SHOW FIELDS FROM gis_geometry;
|
||||
Field Type Null Key Default Extra
|
||||
fid int(11) NO PRI NULL auto_increment
|
||||
g geometry YES NULL
|
||||
INSERT INTO gis_point VALUES
|
||||
(101, PointFromText('POINT(10 10)')),
|
||||
(102, PointFromText('POINT(20 10)')),
|
||||
(103, PointFromText('POINT(20 20)')),
|
||||
(104, PointFromWKB(AsWKB(PointFromText('POINT(10 20)'))));
|
||||
INSERT INTO gis_line VALUES
|
||||
(105, LineFromText('LINESTRING(0 0,0 10,10 0)')),
|
||||
(106, LineStringFromText('LINESTRING(10 10,20 10,20 20,10 20,10 10)')),
|
||||
(107, LineStringFromWKB(LineString(Point(10, 10), Point(40, 10))));
|
||||
INSERT INTO gis_polygon VALUES
|
||||
(108, PolygonFromText('POLYGON((10 10,20 10,20 20,10 20,10 10))')),
|
||||
(109, PolyFromText('POLYGON((0 0,50 0,50 50,0 50,0 0), (10 10,20 10,20 20,10 20,10 10))')),
|
||||
(110, PolyFromWKB(Polygon(LineString(Point(0, 0), Point(30, 0), Point(30, 30), Point(0, 0)))));
|
||||
INSERT INTO gis_multi_point VALUES
|
||||
(111, MultiPointFromText('MULTIPOINT(0 0,10 10,10 20,20 20)')),
|
||||
(112, MPointFromText('MULTIPOINT(1 1,11 11,11 21,21 21)')),
|
||||
(113, MPointFromWKB(MultiPoint(Point(3, 6), Point(4, 10))));
|
||||
INSERT INTO gis_multi_line VALUES
|
||||
(114, MultiLineStringFromText('MULTILINESTRING((10 48,10 21,10 0),(16 0,16 23,16 48))')),
|
||||
(115, MLineFromText('MULTILINESTRING((10 48,10 21,10 0))')),
|
||||
(116, MLineFromWKB(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, 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, 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, MPolyFromWKB(MultiPolygon(Polygon(LineString(Point(0, 3), Point(3, 3), Point(3, 0), Point(0, 3))))));
|
||||
INSERT INTO gis_geometrycollection VALUES
|
||||
(120, GeomCollFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0,10 10))')),
|
||||
(121, GeometryFromWKB(GeometryCollection(Point(44, 6), LineString(Point(3, 6), Point(7, 9)))));
|
||||
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;
|
||||
SELECT fid, AsText(g) FROM gis_point ORDER by fid;
|
||||
fid AsText(g)
|
||||
101 POINT(10 10)
|
||||
102 POINT(20 10)
|
||||
103 POINT(20 20)
|
||||
104 POINT(10 20)
|
||||
SELECT fid, AsText(g) FROM gis_line ORDER by fid;
|
||||
fid 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, AsText(g) FROM gis_polygon ORDER by fid;
|
||||
fid 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, AsText(g) FROM gis_multi_point ORDER by fid;
|
||||
fid 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, AsText(g) FROM gis_multi_line ORDER by fid;
|
||||
fid 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, AsText(g) FROM gis_multi_polygon ORDER by fid;
|
||||
fid 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, AsText(g) FROM gis_geometrycollection ORDER by fid;
|
||||
fid AsText(g)
|
||||
120 GEOMETRYCOLLECTION(POINT(0 0),LINESTRING(0 0,10 10))
|
||||
121 GEOMETRYCOLLECTION(POINT(44 6),LINESTRING(3 6,7 9))
|
||||
SELECT fid, AsText(g) FROM gis_geometry ORDER by fid;
|
||||
fid 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(44 6),LINESTRING(3 6,7 9))
|
||||
SELECT fid, Dimension(g) FROM gis_geometry ORDER by fid;
|
||||
fid 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
|
||||
SELECT fid, GeometryType(g) FROM gis_geometry ORDER by fid;
|
||||
fid 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
|
||||
SELECT fid, IsEmpty(g) FROM gis_geometry ORDER by fid;
|
||||
fid 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
|
||||
SELECT fid, AsText(Envelope(g)) FROM gis_geometry ORDER by fid;
|
||||
fid AsText(Envelope(g))
|
||||
101 POLYGON((10 10,10 10,10 10,10 10,10 10))
|
||||
102 POLYGON((20 10,20 10,20 10,20 10,20 10))
|
||||
103 POLYGON((20 20,20 20,20 20,20 20,20 20))
|
||||
104 POLYGON((10 20,10 20,10 20,10 20,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 POLYGON((10 10,40 10,40 10,10 10,10 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 POLYGON((10 0,10 0,10 48,10 48,10 0))
|
||||
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((3 6,44 6,44 9,3 9,3 6))
|
||||
explain extended select Dimension(g), GeometryType(g), IsEmpty(g), AsText(Envelope(g)) from gis_geometry;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE gis_geometry ALL NULL NULL NULL NULL 21 100.00
|
||||
Warnings:
|
||||
Note 1003 select st_dimension(`test`.`gis_geometry`.`g`) AS `Dimension(g)`,st_geometrytype(`test`.`gis_geometry`.`g`) AS `GeometryType(g)`,st_isempty(`test`.`gis_geometry`.`g`) AS `IsEmpty(g)`,st_astext(st_envelope(`test`.`gis_geometry`.`g`)) AS `AsText(Envelope(g))` from `test`.`gis_geometry`
|
||||
SELECT fid, X(g) FROM gis_point ORDER by fid;
|
||||
fid X(g)
|
||||
101 10
|
||||
102 20
|
||||
103 20
|
||||
104 10
|
||||
SELECT fid, Y(g) FROM gis_point ORDER by fid;
|
||||
fid Y(g)
|
||||
101 10
|
||||
102 10
|
||||
103 20
|
||||
104 20
|
||||
explain extended select X(g),Y(g) FROM gis_point;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE gis_point ALL NULL NULL NULL NULL 4 100.00
|
||||
Warnings:
|
||||
Note 1003 select st_x(`test`.`gis_point`.`g`) AS `X(g)`,st_y(`test`.`gis_point`.`g`) AS `Y(g)` from `test`.`gis_point`
|
||||
SELECT fid, AsText(StartPoint(g)) FROM gis_line ORDER by fid;
|
||||
fid AsText(StartPoint(g))
|
||||
105 POINT(0 0)
|
||||
106 POINT(10 10)
|
||||
107 POINT(10 10)
|
||||
SELECT fid, AsText(EndPoint(g)) FROM gis_line ORDER by fid;
|
||||
fid AsText(EndPoint(g))
|
||||
105 POINT(10 0)
|
||||
106 POINT(10 10)
|
||||
107 POINT(40 10)
|
||||
SELECT fid, GLength(g) FROM gis_line ORDER by fid;
|
||||
fid GLength(g)
|
||||
105 24.14213562373095
|
||||
106 40
|
||||
107 30
|
||||
SELECT fid, NumPoints(g) FROM gis_line ORDER by fid;
|
||||
fid NumPoints(g)
|
||||
105 3
|
||||
106 5
|
||||
107 2
|
||||
SELECT fid, AsText(PointN(g, 2)) FROM gis_line ORDER by fid;
|
||||
fid AsText(PointN(g, 2))
|
||||
105 POINT(0 10)
|
||||
106 POINT(20 10)
|
||||
107 POINT(40 10)
|
||||
SELECT fid, IsClosed(g) FROM gis_line ORDER by fid;
|
||||
fid IsClosed(g)
|
||||
105 0
|
||||
106 1
|
||||
107 0
|
||||
explain extended select AsText(StartPoint(g)),AsText(EndPoint(g)),GLength(g),NumPoints(g),AsText(PointN(g, 2)),IsClosed(g) FROM gis_line;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE gis_line ALL NULL NULL NULL NULL 3 100.00
|
||||
Warnings:
|
||||
Note 1003 select st_astext(st_startpoint(`test`.`gis_line`.`g`)) AS `AsText(StartPoint(g))`,st_astext(st_endpoint(`test`.`gis_line`.`g`)) AS `AsText(EndPoint(g))`,st_length(`test`.`gis_line`.`g`) AS `GLength(g)`,st_numpoints(`test`.`gis_line`.`g`) AS `NumPoints(g)`,st_astext(st_pointn(`test`.`gis_line`.`g`,2)) AS `AsText(PointN(g, 2))`,st_isclosed(`test`.`gis_line`.`g`) AS `IsClosed(g)` from `test`.`gis_line`
|
||||
SELECT fid, AsText(Centroid(g)) FROM gis_polygon ORDER by fid;
|
||||
fid AsText(Centroid(g))
|
||||
108 POINT(15 15)
|
||||
109 POINT(25.416666666666668 25.416666666666668)
|
||||
110 POINT(20 10)
|
||||
SELECT fid, Area(g) FROM gis_polygon ORDER by fid;
|
||||
fid Area(g)
|
||||
108 100
|
||||
109 2400
|
||||
110 450
|
||||
SELECT fid, AsText(ExteriorRing(g)) FROM gis_polygon ORDER by fid;
|
||||
fid AsText(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, NumInteriorRings(g) FROM gis_polygon ORDER by fid;
|
||||
fid NumInteriorRings(g)
|
||||
108 0
|
||||
109 1
|
||||
110 0
|
||||
SELECT fid, AsText(InteriorRingN(g, 1)) FROM gis_polygon ORDER by fid;
|
||||
fid AsText(InteriorRingN(g, 1))
|
||||
108 NULL
|
||||
109 LINESTRING(10 10,20 10,20 20,10 20,10 10)
|
||||
110 NULL
|
||||
explain extended select AsText(Centroid(g)),Area(g),AsText(ExteriorRing(g)),NumInteriorRings(g),AsText(InteriorRingN(g, 1)) FROM gis_polygon;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE gis_polygon ALL NULL NULL NULL NULL 3 100.00
|
||||
Warnings:
|
||||
Note 1003 select st_astext(st_centroid(`test`.`gis_polygon`.`g`)) AS `AsText(Centroid(g))`,st_area(`test`.`gis_polygon`.`g`) AS `Area(g)`,st_astext(st_exteriorring(`test`.`gis_polygon`.`g`)) AS `AsText(ExteriorRing(g))`,st_numinteriorrings(`test`.`gis_polygon`.`g`) AS `NumInteriorRings(g)`,st_astext(st_interiorringn(`test`.`gis_polygon`.`g`,1)) AS `AsText(InteriorRingN(g, 1))` from `test`.`gis_polygon`
|
||||
SELECT fid, IsClosed(g) FROM gis_multi_line ORDER by fid;
|
||||
fid IsClosed(g)
|
||||
114 0
|
||||
115 0
|
||||
116 0
|
||||
SELECT fid, AsText(Centroid(g)) FROM gis_multi_polygon ORDER by fid;
|
||||
fid AsText(Centroid(g))
|
||||
117 POINT(55.58852775304245 17.426536064113982)
|
||||
118 POINT(55.58852775304245 17.426536064113982)
|
||||
119 POINT(2 2)
|
||||
SELECT fid, Area(g) FROM gis_multi_polygon ORDER by fid;
|
||||
fid Area(g)
|
||||
117 1684.5
|
||||
118 1684.5
|
||||
119 4.5
|
||||
SELECT fid, NumGeometries(g) from gis_multi_point ORDER by fid;
|
||||
fid NumGeometries(g)
|
||||
111 4
|
||||
112 4
|
||||
113 2
|
||||
SELECT fid, NumGeometries(g) from gis_multi_line ORDER by fid;
|
||||
fid NumGeometries(g)
|
||||
114 2
|
||||
115 1
|
||||
116 2
|
||||
SELECT fid, NumGeometries(g) from gis_multi_polygon ORDER by fid;
|
||||
fid NumGeometries(g)
|
||||
117 2
|
||||
118 2
|
||||
119 1
|
||||
SELECT fid, NumGeometries(g) from gis_geometrycollection ORDER by fid;
|
||||
fid NumGeometries(g)
|
||||
120 2
|
||||
121 2
|
||||
explain extended SELECT fid, NumGeometries(g) from gis_multi_point;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE gis_multi_point ALL NULL NULL NULL NULL 3 100.00
|
||||
Warnings:
|
||||
Note 1003 select `test`.`gis_multi_point`.`fid` AS `fid`,st_numgeometries(`test`.`gis_multi_point`.`g`) AS `NumGeometries(g)` from `test`.`gis_multi_point`
|
||||
SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_point ORDER by fid;
|
||||
fid AsText(GeometryN(g, 2))
|
||||
111 POINT(10 10)
|
||||
112 POINT(11 11)
|
||||
113 POINT(4 10)
|
||||
SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_line ORDER by fid;
|
||||
fid AsText(GeometryN(g, 2))
|
||||
114 LINESTRING(16 0,16 23,16 48)
|
||||
115 NULL
|
||||
116 LINESTRING(2 5,5 8,21 7)
|
||||
SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_polygon ORDER by fid;
|
||||
fid AsText(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, AsText(GeometryN(g, 2)) from gis_geometrycollection ORDER by fid;
|
||||
fid AsText(GeometryN(g, 2))
|
||||
120 LINESTRING(0 0,10 10)
|
||||
121 LINESTRING(3 6,7 9)
|
||||
SELECT fid, AsText(GeometryN(g, 1)) from gis_geometrycollection ORDER by fid;
|
||||
fid AsText(GeometryN(g, 1))
|
||||
120 POINT(0 0)
|
||||
121 POINT(44 6)
|
||||
explain extended SELECT fid, AsText(GeometryN(g, 2)) from gis_multi_point;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE gis_multi_point ALL NULL NULL NULL NULL 3 100.00
|
||||
Warnings:
|
||||
Note 1003 select `test`.`gis_multi_point`.`fid` AS `fid`,st_astext(st_geometryn(`test`.`gis_multi_point`.`g`,2)) AS `AsText(GeometryN(g, 2))` from `test`.`gis_multi_point`
|
||||
SELECT g1.fid as first, g2.fid as second,
|
||||
Within(g1.g, g2.g) as w, Contains(g1.g, g2.g) as c, Overlaps(g1.g, g2.g) as o,
|
||||
Equals(g1.g, g2.g) as e, Disjoint(g1.g, g2.g) as d, Touches(g1.g, g2.g) as t,
|
||||
Intersects(g1.g, g2.g) as i, 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 1 0 0 0 1 0
|
||||
121 120 0 0 1 0 0 0 1 0
|
||||
121 121 1 1 0 1 0 0 1 0
|
||||
explain extended SELECT g1.fid as first, g2.fid as second,
|
||||
Within(g1.g, g2.g) as w, Contains(g1.g, g2.g) as c, Overlaps(g1.g, g2.g) as o,
|
||||
Equals(g1.g, g2.g) as e, Disjoint(g1.g, g2.g) as d, Touches(g1.g, g2.g) as t,
|
||||
Intersects(g1.g, g2.g) as i, Crosses(g1.g, g2.g) as r
|
||||
FROM gis_geometrycollection g1, gis_geometrycollection g2 ORDER BY first, second;
|
||||
id select_type table type possible_keys key key_len ref rows filtered Extra
|
||||
1 SIMPLE g1 ALL NULL NULL NULL NULL 2 100.00 Using temporary; Using filesort
|
||||
1 SIMPLE g2 ALL NULL NULL NULL NULL 2 100.00 Using join buffer (flat, BNL join)
|
||||
Warnings:
|
||||
Note 1003 select `test`.`g1`.`fid` AS `first`,`test`.`g2`.`fid` AS `second`,st_within(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `w`,st_contains(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `c`,mbroverlaps(`test`.`g1`.`g`,`test`.`g2`.`g`) AS `o`,st_equals(`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 `test`.`g1`.`fid`,`test`.`g2`.`fid`
|
||||
DROP TABLE gis_point, gis_line, gis_polygon, gis_multi_point, gis_multi_line, gis_multi_polygon, gis_geometrycollection, gis_geometry;
|
||||
CREATE TABLE t1 (
|
||||
a INTEGER PRIMARY KEY AUTO_INCREMENT,
|
||||
gp point,
|
||||
ln linestring,
|
||||
pg polygon,
|
||||
mp multipoint,
|
||||
mln multilinestring,
|
||||
mpg multipolygon,
|
||||
gc geometrycollection,
|
||||
gm geometry
|
||||
);
|
||||
SHOW FIELDS FROM t1;
|
||||
Field Type Null Key Default Extra
|
||||
a int(11) NO PRI NULL auto_increment
|
||||
gp point YES NULL
|
||||
ln linestring YES NULL
|
||||
pg polygon YES NULL
|
||||
mp multipoint YES NULL
|
||||
mln multilinestring YES NULL
|
||||
mpg multipolygon YES NULL
|
||||
gc geometrycollection YES NULL
|
||||
gm geometry YES NULL
|
||||
ALTER TABLE t1 ADD fid INT;
|
||||
SHOW FIELDS FROM t1;
|
||||
Field Type Null Key Default Extra
|
||||
a int(11) NO PRI NULL auto_increment
|
||||
gp point YES NULL
|
||||
ln linestring YES NULL
|
||||
pg polygon YES NULL
|
||||
mp multipoint YES NULL
|
||||
mln multilinestring YES NULL
|
||||
mpg multipolygon YES NULL
|
||||
gc geometrycollection YES NULL
|
||||
gm geometry YES NULL
|
||||
fid int(11) YES NULL
|
||||
DROP TABLE t1;
|
||||
create table t1 (pk integer primary key auto_increment, a geometry not null);
|
||||
insert into t1 (a) values (GeomFromText('Point(1 2)'));
|
||||
insert into t1 (a) values ('Garbage');
|
||||
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
|
||||
insert IGNORE into t1 (a) values ('Garbage');
|
||||
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
|
||||
drop table t1;
|
||||
create table t1 (pk integer primary key auto_increment, fl geometry not null);
|
||||
insert into t1 (fl) values (1);
|
||||
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
|
||||
insert into t1 (fl) values (1.11);
|
||||
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
|
||||
insert into t1 (fl) values ("qwerty");
|
||||
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
|
||||
insert into t1 (fl) values (pointfromtext('point(1,1)'));
|
||||
ERROR 23000: Column 'fl' cannot be null
|
||||
drop table t1;
|
||||
End of 4.1 tests
|
||||
CREATE TABLE t1 (name VARCHAR(100), square GEOMETRY);
|
||||
INSERT INTO t1 VALUES("center", GeomFromText('POLYGON (( 0 0, 0 2, 2 2, 2 0, 0 0))'));
|
||||
INSERT INTO t1 VALUES("small", GeomFromText('POLYGON (( 0 0, 0 1, 1 1, 1 0, 0 0))'));
|
||||
INSERT INTO t1 VALUES("big", GeomFromText('POLYGON (( 0 0, 0 3, 3 3, 3 0, 0 0))'));
|
||||
INSERT INTO t1 VALUES("up", GeomFromText('POLYGON (( 0 1, 0 3, 2 3, 2 1, 0 1))'));
|
||||
INSERT INTO t1 VALUES("up2", GeomFromText('POLYGON (( 0 2, 0 4, 2 4, 2 2, 0 2))'));
|
||||
INSERT INTO t1 VALUES("up3", GeomFromText('POLYGON (( 0 3, 0 5, 2 5, 2 3, 0 3))'));
|
||||
INSERT INTO t1 VALUES("down", GeomFromText('POLYGON (( 0 -1, 0 1, 2 1, 2 -1, 0 -1))'));
|
||||
INSERT INTO t1 VALUES("down2", GeomFromText('POLYGON (( 0 -2, 0 0, 2 0, 2 -2, 0 -2))'));
|
||||
INSERT INTO t1 VALUES("down3", GeomFromText('POLYGON (( 0 -3, 0 -1, 2 -1, 2 -3, 0 -3))'));
|
||||
INSERT INTO t1 VALUES("right", GeomFromText('POLYGON (( 1 0, 1 2, 3 2, 3 0, 1 0))'));
|
||||
INSERT INTO t1 VALUES("right2", GeomFromText('POLYGON (( 2 0, 2 2, 4 2, 4 0, 2 0))'));
|
||||
INSERT INTO t1 VALUES("right3", GeomFromText('POLYGON (( 3 0, 3 2, 5 2, 5 0, 3 0))'));
|
||||
INSERT INTO t1 VALUES("left", GeomFromText('POLYGON (( -1 0, -1 2, 1 2, 1 0, -1 0))'));
|
||||
INSERT INTO t1 VALUES("left2", GeomFromText('POLYGON (( -2 0, -2 2, 0 2, 0 0, -2 0))'));
|
||||
INSERT INTO t1 VALUES("left3", GeomFromText('POLYGON (( -3 0, -3 2, -1 2, -1 0, -3 0))'));
|
||||
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrcontains FROM t1 a1 JOIN t1 a2 ON MBRContains( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
|
||||
mbrcontains
|
||||
center,small
|
||||
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrdisjoint FROM t1 a1 JOIN t1 a2 ON MBRDisjoint( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
|
||||
mbrdisjoint
|
||||
down3,left3,right3,up3
|
||||
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrequal FROM t1 a1 JOIN t1 a2 ON MBREqual( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
|
||||
mbrequal
|
||||
center
|
||||
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrintersect FROM t1 a1 JOIN t1 a2 ON MBRIntersects( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
|
||||
mbrintersect
|
||||
big,center,down,down2,left,left2,right,right2,small,up,up2
|
||||
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbroverlaps FROM t1 a1 JOIN t1 a2 ON MBROverlaps( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
|
||||
mbroverlaps
|
||||
down,left,right,up
|
||||
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrtouches FROM t1 a1 JOIN t1 a2 ON MBRTouches( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
|
||||
mbrtouches
|
||||
down2,left2,right2,up2
|
||||
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS mbrwithin FROM t1 a1 JOIN t1 a2 ON MBRWithin( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
|
||||
mbrwithin
|
||||
big,center
|
||||
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS contains FROM t1 a1 JOIN t1 a2 ON Contains( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
|
||||
contains
|
||||
center,small
|
||||
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS disjoint FROM t1 a1 JOIN t1 a2 ON Disjoint( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
|
||||
disjoint
|
||||
down3,left3,right3,up3
|
||||
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS equals FROM t1 a1 JOIN t1 a2 ON Equals( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
|
||||
equals
|
||||
center
|
||||
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS intersect FROM t1 a1 JOIN t1 a2 ON Intersects( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
|
||||
intersect
|
||||
big,center,down,down2,left,left2,right,right2,small,up,up2
|
||||
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS overlaps FROM t1 a1 JOIN t1 a2 ON Overlaps( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
|
||||
overlaps
|
||||
down,left,right,up
|
||||
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS touches FROM t1 a1 JOIN t1 a2 ON Touches( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
|
||||
touches
|
||||
down2,left2,right2,up2
|
||||
SELECT GROUP_CONCAT(a2.name ORDER BY a2.name) AS within FROM t1 a1 JOIN t1 a2 ON Within( a1.square, a2.square) WHERE a1.name = "center" GROUP BY a1.name;
|
||||
within
|
||||
big,center
|
||||
SET @vert1 = GeomFromText('POLYGON ((0 -2, 0 2, 0 -2))');
|
||||
SET @horiz1 = GeomFromText('POLYGON ((-2 0, 2 0, -2 0))');
|
||||
SET @horiz2 = GeomFromText('POLYGON ((-1 0, 3 0, -1 0))');
|
||||
SET @horiz3 = GeomFromText('POLYGON ((2 0, 3 0, 2 0))');
|
||||
SET @point1 = GeomFromText('POLYGON ((0 0))');
|
||||
SET @point2 = GeomFromText('POLYGON ((-2 0))');
|
||||
SELECT GROUP_CONCAT(a1.name ORDER BY a1.name) AS overlaps FROM t1 a1 WHERE Overlaps(a1.square, @vert1) GROUP BY a1.name;
|
||||
overlaps
|
||||
SELECT GROUP_CONCAT(a1.name ORDER BY a1.name) AS overlaps FROM t1 a1 WHERE Overlaps(a1.square, @horiz1) GROUP BY a1.name;
|
||||
overlaps
|
||||
SELECT Overlaps(@horiz1, @vert1) FROM DUAL;
|
||||
Overlaps(@horiz1, @vert1)
|
||||
0
|
||||
SELECT Overlaps(@horiz1, @horiz2) FROM DUAL;
|
||||
Overlaps(@horiz1, @horiz2)
|
||||
1
|
||||
SELECT Overlaps(@horiz1, @horiz3) FROM DUAL;
|
||||
Overlaps(@horiz1, @horiz3)
|
||||
0
|
||||
SELECT Overlaps(@horiz1, @point1) FROM DUAL;
|
||||
Overlaps(@horiz1, @point1)
|
||||
0
|
||||
SELECT Overlaps(@horiz1, @point2) FROM DUAL;
|
||||
Overlaps(@horiz1, @point2)
|
||||
0
|
||||
DROP TABLE t1;
|
||||
End of 5.0 tests
|
||||
CREATE TABLE t1 (p POINT);
|
||||
CREATE TABLE t2 (p POINT, INDEX(p));
|
||||
INSERT INTO t1 VALUES (POINTFROMTEXT('POINT(1 2)'));
|
||||
INSERT INTO t2 VALUES (POINTFROMTEXT('POINT(1 2)'));
|
||||
SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)');
|
||||
COUNT(*)
|
||||
1
|
||||
EXPLAIN
|
||||
SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ref p p 28 const 1 Using where
|
||||
SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)');
|
||||
COUNT(*)
|
||||
1
|
||||
INSERT INTO t1 VALUES (POINTFROMTEXT('POINT(1 2)'));
|
||||
INSERT INTO t2 VALUES (POINTFROMTEXT('POINT(1 2)'));
|
||||
EXPLAIN
|
||||
SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using where
|
||||
SELECT COUNT(*) FROM t1 WHERE p=POINTFROMTEXT('POINT(1 2)');
|
||||
COUNT(*)
|
||||
2
|
||||
EXPLAIN
|
||||
SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ref p p 28 const # Using where
|
||||
SELECT COUNT(*) FROM t2 WHERE p=POINTFROMTEXT('POINT(1 2)');
|
||||
COUNT(*)
|
||||
2
|
||||
EXPLAIN
|
||||
SELECT COUNT(*) FROM t2 IGNORE INDEX(p) WHERE p=POINTFROMTEXT('POINT(1 2)');
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t2 ALL NULL NULL NULL NULL 2 Using where
|
||||
SELECT COUNT(*) FROM t2 IGNORE INDEX(p) WHERE p=POINTFROMTEXT('POINT(1 2)');
|
||||
COUNT(*)
|
||||
2
|
||||
DROP TABLE t1, t2;
|
||||
End of 5.0 tests
|
||||
#
|
||||
# Test for bug #58650 "Failing assertion: primary_key_no == -1 ||
|
||||
# primary_key_no == 0".
|
||||
#
|
||||
drop table if exists t1;
|
||||
# The minimal test case.
|
||||
create table t1 (a int not null, b linestring not null, unique key b (b(12)), unique key a (a));
|
||||
drop table t1;
|
||||
# The original test case.
|
||||
create table t1 (a int not null, b linestring not null, unique key b (b(12)));
|
||||
create unique index a on t1(a);
|
||||
drop table t1;
|
||||
create table t1 (g geometry not null, spatial gk(g)) engine=innodb;
|
||||
DROP TABLE t1;
|
||||
create table t1 (c1 int, c2 geometry not null, spatial index (c2))engine=innodb;
|
||||
connect a,localhost,root,,;
|
||||
connection a;
|
||||
start transaction;
|
||||
insert into t1 values(1, Point(1,1));
|
||||
connect con1,localhost,root,,;
|
||||
connection con1;
|
||||
set @g1 = ST_GeomFromText('Polygon((0 0,0 100,100 100,100 0,0 0))');
|
||||
set transaction isolation level read uncommitted;
|
||||
select count(*) from t1 where ST_Within(t1.c2, @g1);
|
||||
count(*)
|
||||
0
|
||||
disconnect con1;
|
||||
connection a;
|
||||
commit;
|
||||
disconnect a;
|
||||
connection default;
|
||||
drop table t1;
|
1499
mysql-test/suite/innodb_gis/r/1.result
Normal file
1499
mysql-test/suite/innodb_gis/r/1.result
Normal file
File diff suppressed because it is too large
Load Diff
671
mysql-test/suite/innodb_gis/r/alter_spatial_index.result
Normal file
671
mysql-test/suite/innodb_gis/r/alter_spatial_index.result
Normal file
@ -0,0 +1,671 @@
|
||||
CALL mtr.add_suppression("but MySQL is asking statistics for 2 columns. Have you mixed");
|
||||
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;
|
||||
CREATE TABLE tab1(c1 int NOT NULL PRIMARY KEY,c2 MULTIPOINT NOT NULL,
|
||||
c3 MULTILINESTRING NOT NULL,c4 MULTIPOLYGON NOT NULL,c5 GEOMETRY NOT NULL)
|
||||
ENGINE=InnoDB;
|
||||
INSERT INTO tab1 SELECT * FROM tab;
|
||||
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))'));
|
||||
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))'));
|
||||
INSERT INTO tab(c1,c2,c3,c4,c5)
|
||||
VALUES(3,ST_GeomFromText('POINT(4 4)'),ST_GeomFromText('LINESTRING(130 130,140 140,150 150)'),
|
||||
ST_GeomFromText('POLYGON((7 1,6 2,6 3,10 3,10 1,7 1))'),
|
||||
ST_GeomFromText('POLYGON((4 -2,5 -4,6 -5,7 -4,7 2,4 -2))'));
|
||||
INSERT INTO tab(c1,c2,c3,c4,c5)
|
||||
VALUES(4,ST_GeomFromText('POINT(50 50)'),ST_GeomFromText('LINESTRING(200 200,300 300,400 400)'),
|
||||
ST_GeomFromText('POLYGON((300 300,400 400,500 500,300 500,300 400,300 300))'),
|
||||
ST_GeomFromText('POLYGON((300 300,400 400,500 500,300 500,300 400,300 300))'));
|
||||
INSERT INTO tab(c1,c2,c3,c4,c5)
|
||||
VALUES(5,ST_GeomFromText('POINT(3 3)'),ST_GeomFromText('LINESTRING(400 400,500 500,600 700)'),
|
||||
ST_GeomFromText('POLYGON((1010 1010,1020 1020,1030 1030,1040 1030,1020 1010,1010 1010))'),
|
||||
ST_GeomFromText('POLYGON((1010 1010,1020 1020,1030 1030,1040 1030,1020 1010,1010 1010))'));
|
||||
INSERT INTO tab(c1,c2,c3,c4,c5)
|
||||
VALUES(6,ST_GeomFromText('POINT(3 3)'),ST_GeomFromText('LINESTRING(40 40,50 50,60 70)'),
|
||||
ST_GeomFromText('POLYGON((2010 2010,2020 2020,2030 2030,2040 2030,2020 2010,2010 2010))'),
|
||||
ST_GeomFromText('POLYGON((2010 2010,2020 2020,2030 2030,2040 2030,2020 2010,2010 2010))'));
|
||||
INSERT INTO tab(c1,c2,c3,c4,c5)
|
||||
VALUES(7,ST_GeomFromText('POINT(60 70)'),ST_GeomFromText('LINESTRING(40 40,50 50,60 70)'),
|
||||
ST_GeomFromText('POLYGON((3010 3010,3020 3020,3030 3030,3040 3030,3020 3010,3010 3010))'),
|
||||
ST_GeomFromText('POLYGON((3010 3010,3020 3020,3030 3030,3040 3030,3020 3010,3010 3010))'));
|
||||
INSERT INTO tab(c1,c2,c3,c4,c5)
|
||||
VALUES(8,ST_GeomFromText('POINT(0 0)'),ST_GeomFromText('LINESTRING(40 40,50 50,60 70)'),
|
||||
ST_GeomFromText('POLYGON((3010 3010,3020 3020,3030 3030,3040 3030,3020 3010,3010 3010))'),
|
||||
ST_GeomFromText('POLYGON((3010 3010,3020 3020,3030 3030,3040 3030,3020 3010,3010 3010))'));
|
||||
INSERT INTO tab(c1,c2,c3,c4,c5)
|
||||
VALUES(9,ST_GeomFromText('POINT(120 120)'),ST_GeomFromText('LINESTRING(100 100,110 110,120 120)'),
|
||||
ST_GeomFromText('POLYGON((4010 4010,4020 4020,4030 4030,4040 4030,4020 4010,4010 4010))'),
|
||||
ST_GeomFromText('POLYGON((4010 4010,4020 4020,4030 4030,4040 4030,4020 4010,4010 4010))'));
|
||||
INSERT INTO tab(c1,c2,c3,c4,c5)
|
||||
VALUES(10,ST_GeomFromText('POINT(160 160)'),ST_GeomFromText('LINESTRING(140 140,150 150,160 160)'),
|
||||
ST_GeomFromText('POLYGON((5010 5010,5020 5020,5030 5030,5040 5030,5020 5010,5010 5010))'),
|
||||
ST_GeomFromText('POLYGON((5010 5010,5020 5020,5030 5030,5040 5030,5020 5010,5010 5010))'));
|
||||
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';
|
||||
ALTER TABLE tab ADD INDEX idx6(c4(10)) USING BTREE;
|
||||
SET @g1 = ST_GeomFromText( 'POLYGON((7 1,6 2,6 3,10 3,10 1,7 1))');
|
||||
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE MBRContains(tab.c4, @g1);
|
||||
c1 ST_Astext(c2) ST_Astext(c4)
|
||||
3 POINT(4 4) POLYGON((7 1,6 2,6 3,10 3,10 1,7 1))
|
||||
UPDATE tab SET C2 = ST_GeomFromText('POINT(0 0)')
|
||||
WHERE MBRContains(tab.c4, @g1);
|
||||
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE MBRContains(tab.c4, @g1);
|
||||
c1 ST_Astext(c2) ST_Astext(c4)
|
||||
3 POINT(0 0) POLYGON((7 1,6 2,6 3,10 3,10 1,7 1))
|
||||
DELETE FROM tab WHERE MBRContains(tab.c4, @g1);
|
||||
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE MBRContains(tab.c4, @g1);
|
||||
c1 ST_Astext(c2) ST_Astext(c4)
|
||||
SET @g1 = ST_GeomFromText('LINESTRING( 300 300,400 400)');
|
||||
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE MBRContains(tab.c4, @g1);
|
||||
c1 ST_Astext(c2) ST_Astext(c4)
|
||||
UPDATE tab SET C2 = ST_GeomFromText('POINT(100 100)')
|
||||
WHERE MBRContains(tab.c4, @g1);
|
||||
DELETE FROM tab WHERE MBRContains(tab.c4, @g1);
|
||||
SET @g1 = ST_GeomFromText( 'POLYGON((1010 1010,1020 1020,1030 1030,1040 1030,1020 1010,1010 1010))');
|
||||
SELECT c1,ST_AsText(c2),ST_Astext(c4) FROM tab WHERE MBRWithin(tab.c4, @g1);
|
||||
c1 ST_AsText(c2) ST_Astext(c4)
|
||||
5 POINT(3 3) POLYGON((1010 1010,1020 1020,1030 1030,1040 1030,1020 1010,1010 1010))
|
||||
UPDATE tab SET C2 = ST_GeomFromText('POINT(200 200)')
|
||||
WHERE MBRWithin(tab.c4, @g1);
|
||||
SELECT c1,ST_AsText(c2),ST_AsText(c4) FROM tab WHERE MBRWithin(tab.c4, @g1);
|
||||
c1 ST_AsText(c2) ST_AsText(c4)
|
||||
5 POINT(200 200) POLYGON((1010 1010,1020 1020,1030 1030,1040 1030,1020 1010,1010 1010))
|
||||
DELETE FROM tab WHERE MBRWithin(tab.c4, @g1);
|
||||
ALTER TABLE tab MODIFY COLUMN c2 MULTIPOINT;
|
||||
ERROR 42000: All parts of a SPATIAL index must be NOT NULL
|
||||
ALTER TABLE tab MODIFY COLUMN c3 MULTILINESTRING;
|
||||
ERROR 42000: All parts of a SPATIAL index must be NOT NULL
|
||||
ALTER TABLE tab MODIFY COLUMN c4 MULTIPOLYGON;
|
||||
ERROR 42000: All parts of a SPATIAL index must be NOT NULL
|
||||
ALTER TABLE tab MODIFY COLUMN c3 MULTILINESTRING NULL;
|
||||
ERROR 42000: All parts of a SPATIAL index must be NOT NULL
|
||||
ALTER TABLE tab MODIFY COLUMN c4 MULTIPOLYGON NULL;
|
||||
ERROR 42000: All parts of a SPATIAL index must be NOT NULL
|
||||
ALTER TABLE tab MODIFY COLUMN c4 Geometry NULL;
|
||||
ERROR 42000: All parts of a SPATIAL index must be NOT NULL
|
||||
ALTER TABLE tab CHANGE COLUMN c2 c22 POINT;
|
||||
ERROR 42000: All parts of a SPATIAL index must be NOT NULL
|
||||
ALTER TABLE tab CHANGE COLUMN c3 c33 LINESTRING;
|
||||
ERROR 42000: All parts of a SPATIAL index must be NOT NULL
|
||||
ALTER TABLE tab CHANGE COLUMN c4 c44 POLYGON;
|
||||
ERROR 42000: All parts of a SPATIAL index must be NOT NULL
|
||||
ALTER TABLE tab add SPATIAL INDEX idx1(c1);
|
||||
ERROR HY000: Incorrect arguments to SPATIAL INDEX
|
||||
ALTER TABLE tab ADD SPATIAL INDEX idx6(c2 ASC) USING BTREE;
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'USING BTREE' at line 1
|
||||
ALTER TABLE tab ADD SPATIAL INDEX idx6(c2 ASC) USING HASH;
|
||||
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'USING HASH' at line 1
|
||||
SHOW CREATE TABLE tab;
|
||||
Table Create Table
|
||||
tab CREATE TABLE `tab` (
|
||||
`c1` int(11) NOT NULL,
|
||||
`c2` point NOT NULL,
|
||||
`c3` linestring NOT NULL,
|
||||
`c4` geometry NOT NULL,
|
||||
`c5` geometry NOT NULL,
|
||||
PRIMARY KEY (`c1`),
|
||||
SPATIAL KEY `idx2` (`c2`),
|
||||
SPATIAL KEY `idx3` (`c3`),
|
||||
SPATIAL KEY `idx4` (`c4`) COMMENT 'testing spatial index on Polygon',
|
||||
SPATIAL KEY `idx5` (`c5`) COMMENT 'testing spatial index on Geometry',
|
||||
KEY `idx6` (`c4`(10)) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
SHOW INDEX FROM tab;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
tab 0 PRIMARY 1 c1 A # NULL NULL BTREE
|
||||
tab 1 idx2 1 c2 A # 32 NULL SPATIAL
|
||||
tab 1 idx3 1 c3 A # 32 NULL SPATIAL
|
||||
tab 1 idx4 1 c4 A # 32 NULL SPATIAL testing spatial index on Polygon
|
||||
tab 1 idx5 1 c5 A # 32 NULL SPATIAL testing spatial index on Geometry
|
||||
tab 1 idx6 1 c4 A # 10 NULL BTREE
|
||||
SET @g1 = ST_GeomFromText('POLYGON((20 20,30 30,40 40,50 50,40 50,30 40,30 30,20 20))');
|
||||
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE ST_Crosses(tab.c4, @g1);
|
||||
c1 ST_Astext(c2) ST_Astext(c4)
|
||||
2 POINT(20 20) POLYGON((40 50,40 70,50 100,70 100,80 80,70 50,40 50))
|
||||
1 POINT(10 10) POLYGON((30 30,40 40,50 50,30 50,30 40,30 30))
|
||||
UPDATE tab SET C2 = ST_GeomFromText('POINT(1000 1000)')
|
||||
WHERE ST_Crosses(tab.c4, @g1);
|
||||
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE ST_Crosses(tab.c4, @g1);
|
||||
c1 ST_Astext(c2) ST_Astext(c4)
|
||||
2 POINT(1000 1000) POLYGON((40 50,40 70,50 100,70 100,80 80,70 50,40 50))
|
||||
1 POINT(1000 1000) POLYGON((30 30,40 40,50 50,30 50,30 40,30 30))
|
||||
DELETE FROM tab WHERE ST_Crosses(tab.c4, @g1);
|
||||
ALTER TABLE tab CHANGE COLUMN c2 c22 POINT NOT NULL;
|
||||
ALTER TABLE tab CHANGE COLUMN c3 c33 LINESTRING NOT NULL;
|
||||
ALTER TABLE tab CHANGE COLUMN c4 c44 POLYGON NOT NULL;
|
||||
SHOW CREATE TABLE tab;
|
||||
Table Create Table
|
||||
tab CREATE TABLE `tab` (
|
||||
`c1` int(11) NOT NULL,
|
||||
`c22` point NOT NULL,
|
||||
`c33` linestring NOT NULL,
|
||||
`c44` polygon NOT NULL,
|
||||
`c5` geometry NOT NULL,
|
||||
PRIMARY KEY (`c1`),
|
||||
SPATIAL KEY `idx2` (`c22`),
|
||||
SPATIAL KEY `idx3` (`c33`),
|
||||
SPATIAL KEY `idx4` (`c44`) COMMENT 'testing spatial index on Polygon',
|
||||
SPATIAL KEY `idx5` (`c5`) COMMENT 'testing spatial index on Geometry',
|
||||
KEY `idx6` (`c44`(10)) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
SHOW INDEX FROM tab;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
tab 0 PRIMARY 1 c1 A # NULL NULL BTREE
|
||||
tab 1 idx2 1 c22 A # 32 NULL SPATIAL
|
||||
tab 1 idx3 1 c33 A # 32 NULL SPATIAL
|
||||
tab 1 idx4 1 c44 A # 32 NULL SPATIAL testing spatial index on Polygon
|
||||
tab 1 idx5 1 c5 A # 32 NULL SPATIAL testing spatial index on Geometry
|
||||
tab 1 idx6 1 c44 A # 10 NULL BTREE
|
||||
ALTER TABLE tab CHANGE COLUMN c22 c2 POINT NOT NULL;
|
||||
ALTER TABLE tab CHANGE COLUMN c33 c3 LINESTRING NOT NULL;
|
||||
ALTER TABLE tab CHANGE COLUMN c44 c4 POLYGON NOT NULL;
|
||||
SHOW CREATE TABLE tab;
|
||||
Table Create Table
|
||||
tab CREATE TABLE `tab` (
|
||||
`c1` int(11) NOT NULL,
|
||||
`c2` point NOT NULL,
|
||||
`c3` linestring NOT NULL,
|
||||
`c4` polygon NOT NULL,
|
||||
`c5` geometry NOT NULL,
|
||||
PRIMARY KEY (`c1`),
|
||||
SPATIAL KEY `idx2` (`c2`),
|
||||
SPATIAL KEY `idx3` (`c3`),
|
||||
SPATIAL KEY `idx4` (`c4`) COMMENT 'testing spatial index on Polygon',
|
||||
SPATIAL KEY `idx5` (`c5`) COMMENT 'testing spatial index on Geometry',
|
||||
KEY `idx6` (`c4`(10)) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
SHOW INDEX FROM tab;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
tab 0 PRIMARY 1 c1 A # NULL NULL BTREE
|
||||
tab 1 idx2 1 c2 A # 32 NULL SPATIAL
|
||||
tab 1 idx3 1 c3 A # 32 NULL SPATIAL
|
||||
tab 1 idx4 1 c4 A # 32 NULL SPATIAL testing spatial index on Polygon
|
||||
tab 1 idx5 1 c5 A # 32 NULL SPATIAL testing spatial index on Geometry
|
||||
tab 1 idx6 1 c4 A # 10 NULL BTREE
|
||||
ALTER TABLE tab DISABLE KEYS;
|
||||
Warnings:
|
||||
Note 1031 Storage engine InnoDB of the table `test`.`tab` doesn't have this option
|
||||
SHOW WARNINGS;
|
||||
Level Code Message
|
||||
Note 1031 Storage engine InnoDB of the table `test`.`tab` doesn't have this option
|
||||
SET @g1 = ST_GeomFromText('POLYGON((5010 5010,5020 5020,5030 5030,5040 5030,5020 5010,5010 5010))');
|
||||
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE MBREquals(tab.c4, @g1);
|
||||
c1 ST_Astext(c2) ST_Astext(c4)
|
||||
10 POINT(160 160) POLYGON((5010 5010,5020 5020,5030 5030,5040 5030,5020 5010,5010 5010))
|
||||
UPDATE tab SET C2 = ST_GeomFromText('POINT(2000 2000)')
|
||||
WHERE MBREquals(tab.c4, @g1);
|
||||
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE MBREquals(tab.c4, @g1);
|
||||
c1 ST_Astext(c2) ST_Astext(c4)
|
||||
10 POINT(2000 2000) POLYGON((5010 5010,5020 5020,5030 5030,5040 5030,5020 5010,5010 5010))
|
||||
DELETE FROM tab WHERE MBREquals(tab.c4, @g1);
|
||||
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE MBREquals(tab.c4, @g1);
|
||||
c1 ST_Astext(c2) ST_Astext(c4)
|
||||
ALTER TABLE tab DROP PRIMARY KEY;
|
||||
ALTER TABLE tab ADD PRIMARY KEY(c2) ;
|
||||
SET @g1 = ST_GeomFromText( 'POLYGON((0 0,0 30,30 40,40 50,50 30,0 0))');
|
||||
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE ST_Touches(tab.c4, @g1);
|
||||
c1 ST_Astext(c2) ST_Astext(c4)
|
||||
UPDATE tab SET C2 = ST_GeomFromText('POINT(3000 3000)')
|
||||
WHERE ST_Touches(tab.c4, @g1);
|
||||
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE ST_Touches(tab.c4, @g1);
|
||||
c1 ST_Astext(c2) ST_Astext(c4)
|
||||
DELETE FROM tab WHERE ST_Touches(tab.c4, @g1);
|
||||
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE ST_Touches(tab.c4, @g1);
|
||||
c1 ST_Astext(c2) ST_Astext(c4)
|
||||
FLUSH TABLE tab FOR EXPORT;
|
||||
UNLOCK TABLES;
|
||||
ALTER TABLE tab DISCARD TABLESPACE;
|
||||
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab;
|
||||
ERROR HY000: Tablespace has been discarded for table `tab`
|
||||
CHECK TABLE tab;
|
||||
Table Op Msg_type Msg_text
|
||||
test.tab check status OK
|
||||
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab ORDER BY c1;
|
||||
c1 ST_Astext(c2) ST_Astext(c4)
|
||||
4 POINT(50 50) POLYGON((300 300,400 400,500 500,300 500,300 400,300 300))
|
||||
6 POINT(3 3) POLYGON((2010 2010,2020 2020,2030 2030,2040 2030,2020 2010,2010 2010))
|
||||
7 POINT(60 70) POLYGON((3010 3010,3020 3020,3030 3030,3040 3030,3020 3010,3010 3010))
|
||||
8 POINT(0 0) POLYGON((3010 3010,3020 3020,3030 3030,3040 3030,3020 3010,3010 3010))
|
||||
9 POINT(120 120) POLYGON((4010 4010,4020 4020,4030 4030,4040 4030,4020 4010,4010 4010))
|
||||
SET @g1 = ST_GeomFromText('LINESTRING( 3010 3010,4010 4010,5010 5010)');
|
||||
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE MBRIntersects(tab.c4, @g1) order by c1;
|
||||
c1 ST_Astext(c2) ST_Astext(c4)
|
||||
7 POINT(60 70) POLYGON((3010 3010,3020 3020,3030 3030,3040 3030,3020 3010,3010 3010))
|
||||
8 POINT(0 0) POLYGON((3010 3010,3020 3020,3030 3030,3040 3030,3020 3010,3010 3010))
|
||||
9 POINT(120 120) POLYGON((4010 4010,4020 4020,4030 4030,4040 4030,4020 4010,4010 4010))
|
||||
UPDATE tab SET c2 = ST_GeomFromText('POINT(4000 4000)')
|
||||
WHERE MBRIntersects(tab.c4, @g1);
|
||||
ERROR 23000: Duplicate entry '\x00\x00\x00\x00\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00@\xAF@\x' for key 'PRIMARY'
|
||||
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE MBRIntersects(tab.c4, @g1) ORDER BY c1;
|
||||
c1 ST_Astext(c2) ST_Astext(c4)
|
||||
7 POINT(60 70) POLYGON((3010 3010,3020 3020,3030 3030,3040 3030,3020 3010,3010 3010))
|
||||
8 POINT(0 0) POLYGON((3010 3010,3020 3020,3030 3030,3040 3030,3020 3010,3010 3010))
|
||||
9 POINT(120 120) POLYGON((4010 4010,4020 4020,4030 4030,4040 4030,4020 4010,4010 4010))
|
||||
DELETE FROM tab WHERE MBRIntersects(tab.c4, @g1);
|
||||
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE MBROverlaps(tab.c4, @g1) ORDER BY c1;
|
||||
c1 ST_Astext(c2) ST_Astext(c4)
|
||||
INSERT INTO tab SELECT * FROM tab1;
|
||||
ALTER TABLE tab DROP PRIMARY KEY;
|
||||
ALTER TABLE tab DROP INDEX idx2;
|
||||
CREATE TEMPORARY TABLE temp_tab AS SELECT * FROM tab where c1 = c2;
|
||||
INSERT INTO temp_tab SELECT * FROM tab;
|
||||
CREATE SPATIAL INDEX idx2 ON temp_tab(c2);
|
||||
CREATE SPATIAL INDEX idx3 ON temp_tab(c3);
|
||||
CREATE SPATIAL INDEX idx4 ON temp_tab(c4);
|
||||
CREATE SPATIAL INDEX idx5 ON temp_tab(c5);
|
||||
SHOW CREATE TABLE temp_tab;
|
||||
Table Create Table
|
||||
temp_tab CREATE TEMPORARY TABLE `temp_tab` (
|
||||
`c1` int(11) NOT NULL,
|
||||
`c2` point NOT NULL,
|
||||
`c3` linestring NOT NULL,
|
||||
`c4` geometry NOT NULL,
|
||||
`c5` geometry NOT NULL,
|
||||
SPATIAL KEY `idx2` (`c2`),
|
||||
SPATIAL KEY `idx3` (`c3`),
|
||||
SPATIAL KEY `idx4` (`c4`),
|
||||
SPATIAL KEY `idx5` (`c5`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
SET @g1 = ST_GeomFromText( 'POLYGON((7 1,6 2,6 3,10 3,10 1,7 1))');
|
||||
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM temp_tab WHERE MBRContains(temp_tab.c4, @g1) ORDER BY c1;
|
||||
c1 ST_Astext(c2) ST_Astext(c4)
|
||||
UPDATE temp_tab SET C2 = ST_GeomFromText('POINT(1000 1000)')
|
||||
WHERE MBRContains(temp_tab.c4, @g1);
|
||||
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM temp_tab WHERE MBRContains(temp_tab.c4, @g1);
|
||||
c1 ST_Astext(c2) ST_Astext(c4)
|
||||
DELETE FROM temp_tab WHERE MBRContains(temp_tab.c4, @g1);
|
||||
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM temp_tab WHERE MBRContains(temp_tab.c4, @g1) ORDER BY c1;
|
||||
c1 ST_Astext(c2) ST_Astext(c4)
|
||||
SHOW CREATE TABLE tab;
|
||||
Table Create Table
|
||||
tab CREATE TABLE `tab` (
|
||||
`c1` int(11) NOT NULL,
|
||||
`c2` point NOT NULL,
|
||||
`c3` linestring NOT NULL,
|
||||
`c4` geometry NOT NULL,
|
||||
`c5` geometry NOT NULL,
|
||||
SPATIAL KEY `idx3` (`c3`),
|
||||
SPATIAL KEY `idx4` (`c4`) COMMENT 'testing spatial index on Polygon',
|
||||
SPATIAL KEY `idx5` (`c5`) COMMENT 'testing spatial index on Geometry',
|
||||
KEY `idx6` (`c4`(10)) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
SHOW INDEX FROM tab;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
tab 1 idx3 1 c3 A # 32 NULL SPATIAL
|
||||
tab 1 idx4 1 c4 A # 32 NULL SPATIAL testing spatial index on Polygon
|
||||
tab 1 idx5 1 c5 A # 32 NULL SPATIAL testing spatial index on Geometry
|
||||
tab 1 idx6 1 c4 A # 10 NULL BTREE
|
||||
DELETE FROM tab;
|
||||
ALTER TABLE tab ADD PRIMARY KEY(c2);
|
||||
CREATE SPATIAL INDEX idx2 ON tab(c2 ASC);
|
||||
ALTER TABLE tab ADD CONSTRAINT const_1 UNIQUE(c2);
|
||||
SHOW CREATE TABLE tab;
|
||||
Table Create Table
|
||||
tab CREATE TABLE `tab` (
|
||||
`c1` int(11) NOT NULL,
|
||||
`c2` point NOT NULL,
|
||||
`c3` linestring NOT NULL,
|
||||
`c4` geometry NOT NULL,
|
||||
`c5` geometry NOT NULL,
|
||||
PRIMARY KEY (`c2`(25)),
|
||||
UNIQUE KEY `const_1` (`c2`(25)),
|
||||
SPATIAL KEY `idx3` (`c3`),
|
||||
SPATIAL KEY `idx4` (`c4`) COMMENT 'testing spatial index on Polygon',
|
||||
SPATIAL KEY `idx5` (`c5`) COMMENT 'testing spatial index on Geometry',
|
||||
KEY `idx6` (`c4`(10)) USING BTREE,
|
||||
SPATIAL KEY `idx2` (`c2`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
SHOW INDEX FROM tab;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
tab 0 PRIMARY 1 c2 A # 25 NULL BTREE
|
||||
tab 0 const_1 1 c2 A # 25 NULL BTREE
|
||||
tab 1 idx3 1 c3 A # 32 NULL SPATIAL
|
||||
tab 1 idx4 1 c4 A # 32 NULL SPATIAL testing spatial index on Polygon
|
||||
tab 1 idx5 1 c5 A # 32 NULL SPATIAL testing spatial index on Geometry
|
||||
tab 1 idx6 1 c4 A # 10 NULL BTREE
|
||||
tab 1 idx2 1 c2 A # 32 NULL SPATIAL
|
||||
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))'));
|
||||
DELETE FROM tab;
|
||||
ALTER TABLE tab DROP PRIMARY KEY ;
|
||||
ALTER TABLE tab DROP KEY const_1;
|
||||
ALTER TABLE tab ADD PRIMARY KEY(c5(10));
|
||||
ALTER TABLE tab ADD CONSTRAINT const_1 UNIQUE(c5(10));
|
||||
SHOW CREATE TABLE tab;
|
||||
Table Create Table
|
||||
tab CREATE TABLE `tab` (
|
||||
`c1` int(11) NOT NULL,
|
||||
`c2` point NOT NULL,
|
||||
`c3` linestring NOT NULL,
|
||||
`c4` geometry NOT NULL,
|
||||
`c5` geometry NOT NULL,
|
||||
PRIMARY KEY (`c5`(10)),
|
||||
UNIQUE KEY `const_1` (`c5`(10)),
|
||||
SPATIAL KEY `idx3` (`c3`),
|
||||
SPATIAL KEY `idx4` (`c4`) COMMENT 'testing spatial index on Polygon',
|
||||
SPATIAL KEY `idx5` (`c5`) COMMENT 'testing spatial index on Geometry',
|
||||
KEY `idx6` (`c4`(10)) USING BTREE,
|
||||
SPATIAL KEY `idx2` (`c2`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
SHOW INDEX FROM tab;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
tab 0 PRIMARY 1 c5 A # 10 NULL BTREE
|
||||
tab 0 const_1 1 c5 A # 10 NULL BTREE
|
||||
tab 1 idx3 1 c3 A # 32 NULL SPATIAL
|
||||
tab 1 idx4 1 c4 A # 32 NULL SPATIAL testing spatial index on Polygon
|
||||
tab 1 idx5 1 c5 A # 32 NULL SPATIAL testing spatial index on Geometry
|
||||
tab 1 idx6 1 c4 A # 10 NULL BTREE
|
||||
tab 1 idx2 1 c2 A # 32 NULL SPATIAL
|
||||
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))'));
|
||||
DROP TABLE tab,tab1,temp_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;
|
||||
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))'));
|
||||
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))'));
|
||||
INSERT INTO tab(c1,c2,c3,c4,c5)
|
||||
VALUES(3,ST_GeomFromText('POINT(4 4)'),ST_GeomFromText('LINESTRING(130 130,140 140,150 150)'),
|
||||
ST_GeomFromText('POLYGON((7 1,6 2,6 3,10 3,10 1,7 1))'),
|
||||
ST_GeomFromText('POLYGON((4 -2,5 -4,6 -5,7 -4,7 2,4 -2))'));
|
||||
INSERT INTO tab(c1,c2,c3,c4,c5)
|
||||
VALUES(4,ST_GeomFromText('POINT(50 50)'),ST_GeomFromText('LINESTRING(200 200,300 300,400 400)'),
|
||||
ST_GeomFromText('POLYGON((300 300,400 400,500 500,300 500,300 400,300 300))'),
|
||||
ST_GeomFromText('POLYGON((300 300,400 400,500 500,300 500,300 400,300 300))'));
|
||||
INSERT INTO tab(c1,c2,c3,c4,c5)
|
||||
VALUES(5,ST_GeomFromText('POINT(3 3)'),ST_GeomFromText('LINESTRING(400 400,500 500,600 700)'),
|
||||
ST_GeomFromText('POLYGON((1010 1010,1020 1020,1030 1030,1040 1030,1020 1010,1010 1010))'),
|
||||
ST_GeomFromText('POLYGON((1010 1010,1020 1020,1030 1030,1040 1030,1020 1010,1010 1010))'));
|
||||
INSERT INTO tab(c1,c2,c3,c4,c5)
|
||||
VALUES(6,ST_GeomFromText('POINT(3 3)'),ST_GeomFromText('LINESTRING(40 40,50 50,60 70)'),
|
||||
ST_GeomFromText('POLYGON((2010 2010,2020 2020,2030 2030,2040 2030,2020 2010,2010 2010))'),
|
||||
ST_GeomFromText('POLYGON((2010 2010,2020 2020,2030 2030,2040 2030,2020 2010,2010 2010))'));
|
||||
INSERT INTO tab(c1,c2,c3,c4,c5)
|
||||
VALUES(7,ST_GeomFromText('POINT(60 70)'),ST_GeomFromText('LINESTRING(40 40,50 50,60 70)'),
|
||||
ST_GeomFromText('POLYGON((3010 3010,3020 3020,3030 3030,3040 3030,3020 3010,3010 3010))'),
|
||||
ST_GeomFromText('POLYGON((3010 3010,3020 3020,3030 3030,3040 3030,3020 3010,3010 3010))'));
|
||||
INSERT INTO tab(c1,c2,c3,c4,c5)
|
||||
VALUES(8,ST_GeomFromText('POINT(0 0)'),ST_GeomFromText('LINESTRING(40 40,50 50,60 70)'),
|
||||
ST_GeomFromText('POLYGON((3010 3010,3020 3020,3030 3030,3040 3030,3020 3010,3010 3010))'),
|
||||
ST_GeomFromText('POLYGON((3010 3010,3020 3020,3030 3030,3040 3030,3020 3010,3010 3010))'));
|
||||
INSERT INTO tab(c1,c2,c3,c4,c5)
|
||||
VALUES(9,ST_GeomFromText('POINT(120 120)'),ST_GeomFromText('LINESTRING(100 100,110 110,120 120)'),
|
||||
ST_GeomFromText('POLYGON((4010 4010,4020 4020,4030 4030,4040 4030,4020 4010,4010 4010))'),
|
||||
ST_GeomFromText('POLYGON((4010 4010,4020 4020,4030 4030,4040 4030,4020 4010,4010 4010))'));
|
||||
INSERT INTO tab(c1,c2,c3,c4,c5)
|
||||
VALUES(10,ST_GeomFromText('POINT(160 160)'),ST_GeomFromText('LINESTRING(140 140,150 150,160 160)'),
|
||||
ST_GeomFromText('POLYGON((5010 5010,5020 5020,5030 5030,5040 5030,5020 5010,5010 5010))'),
|
||||
ST_GeomFromText('POLYGON((5010 5010,5020 5020,5030 5030,5040 5030,5020 5010,5010 5010))'));
|
||||
ANALYZE TABLE tab;
|
||||
Table Op Msg_type Msg_text
|
||||
test.tab analyze status OK
|
||||
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';
|
||||
ALTER TABLE tab ADD INDEX idx6(c4(10)) USING BTREE;
|
||||
ALTER TABLE tab MODIFY COLUMN c2 GEOMETRY NOT NULL;
|
||||
ALTER TABLE tab add COLUMN c8 POINT NOT NULL, ALGORITHM = INPLACE, LOCK=NONE;
|
||||
ERROR 0A000: ALGORITHM=INPLACE is not supported. Reason: InnoDB presently supports one FULLTEXT index creation at a time. Try ALGORITHM=COPY
|
||||
SHOW CREATE TABLE tab;
|
||||
Table Create Table
|
||||
tab CREATE TABLE `tab` (
|
||||
`c1` int(11) NOT NULL,
|
||||
`c2` geometry NOT NULL,
|
||||
`c3` linestring NOT NULL,
|
||||
`c4` polygon NOT NULL,
|
||||
`c5` geometry NOT NULL,
|
||||
PRIMARY KEY (`c1`),
|
||||
SPATIAL KEY `idx2` (`c2`),
|
||||
SPATIAL KEY `idx3` (`c3`),
|
||||
SPATIAL KEY `idx4` (`c4`) COMMENT 'testing spatial index on Polygon',
|
||||
SPATIAL KEY `idx5` (`c5`) COMMENT 'testing spatial index on Geometry',
|
||||
KEY `idx6` (`c4`(10)) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
SHOW INDEX FROM tab;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
tab 0 PRIMARY 1 c1 A # NULL NULL BTREE
|
||||
tab 1 idx2 1 c2 A # 32 NULL SPATIAL
|
||||
tab 1 idx3 1 c3 A # 32 NULL SPATIAL
|
||||
tab 1 idx4 1 c4 A # 32 NULL SPATIAL testing spatial index on Polygon
|
||||
tab 1 idx5 1 c5 A # 32 NULL SPATIAL testing spatial index on Geometry
|
||||
tab 1 idx6 1 c4 A # 10 NULL BTREE
|
||||
SET @g1 = ST_GeomFromText( 'POLYGON((7 1,6 2,6 3,10 3,10 1,7 1))');
|
||||
UPDATE tab SET C2 = ST_GeomFromText('POINT(1000 1000)')
|
||||
WHERE MBRContains(tab.c4, @g1);
|
||||
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE MBRContains(tab.c4, @g1) ORDER BY c1;
|
||||
c1 ST_Astext(c2) ST_Astext(c4)
|
||||
3 POINT(1000 1000) POLYGON((7 1,6 2,6 3,10 3,10 1,7 1))
|
||||
DELETE FROM tab WHERE MBRContains(tab.c4, @g1);
|
||||
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE MBRContains(tab.c4, @g1) ORDER BY c1;
|
||||
c1 ST_Astext(c2) ST_Astext(c4)
|
||||
ALTER TABLE tab MODIFY COLUMN c4 GEOMETRY NOT NULL;
|
||||
SHOW CREATE TABLE tab;
|
||||
Table Create Table
|
||||
tab CREATE TABLE `tab` (
|
||||
`c1` int(11) NOT NULL,
|
||||
`c2` geometry NOT NULL,
|
||||
`c3` linestring NOT NULL,
|
||||
`c4` geometry NOT NULL,
|
||||
`c5` geometry NOT NULL,
|
||||
PRIMARY KEY (`c1`),
|
||||
SPATIAL KEY `idx2` (`c2`),
|
||||
SPATIAL KEY `idx3` (`c3`),
|
||||
SPATIAL KEY `idx4` (`c4`) COMMENT 'testing spatial index on Polygon',
|
||||
SPATIAL KEY `idx5` (`c5`) COMMENT 'testing spatial index on Geometry',
|
||||
KEY `idx6` (`c4`(10)) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
SHOW INDEX FROM tab;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
tab 0 PRIMARY 1 c1 A # NULL NULL BTREE
|
||||
tab 1 idx2 1 c2 A # 32 NULL SPATIAL
|
||||
tab 1 idx3 1 c3 A # 32 NULL SPATIAL
|
||||
tab 1 idx4 1 c4 A # 32 NULL SPATIAL testing spatial index on Polygon
|
||||
tab 1 idx5 1 c5 A # 32 NULL SPATIAL testing spatial index on Geometry
|
||||
tab 1 idx6 1 c4 A # 10 NULL BTREE
|
||||
ANALYZE TABLE tab;
|
||||
Table Op Msg_type Msg_text
|
||||
test.tab analyze status OK
|
||||
SET @g1 = ST_GeomFromText('POLYGON((5010 5010,5020 5020,5030 5030,5040 5030,5020 5010,5010 5010))');
|
||||
SET @g2 = ST_GeomFromText('LINESTRING(140 140,150 150,160 160)');
|
||||
SELECT c1,ST_Astext(c2),ST_AsText(c3),ST_Astext(c4) FROM tab WHERE MBREquals(tab.c4, @g1)
|
||||
AND MBREquals(tab.c3,@g2) ORDER BY c1;
|
||||
c1 ST_Astext(c2) ST_AsText(c3) ST_Astext(c4)
|
||||
10 POINT(160 160) LINESTRING(140 140,150 150,160 160) POLYGON((5010 5010,5020 5020,5030 5030,5040 5030,5020 5010,5010 5010))
|
||||
UPDATE tab SET C2 = ST_GeomFromText('POINT(2000 2000)')
|
||||
WHERE MBREquals(tab.c4, @g1) AND MBREquals(tab.c3,@g2);
|
||||
SELECT c1,ST_Astext(c2),ST_AsText(c3),ST_Astext(c4) FROM tab WHERE MBREquals(tab.c4, @g1)
|
||||
AND MBREquals(tab.c3,@g2) ORDER BY c1;
|
||||
c1 ST_Astext(c2) ST_AsText(c3) ST_Astext(c4)
|
||||
10 POINT(2000 2000) LINESTRING(140 140,150 150,160 160) POLYGON((5010 5010,5020 5020,5030 5030,5040 5030,5020 5010,5010 5010))
|
||||
DELETE FROM tab WHERE MBREquals(tab.c4, @g1) AND MBREquals(tab.c3,@g2);
|
||||
SELECT c1,ST_Astext(c2),ST_AsText(c3),ST_Astext(c4) FROM tab WHERE MBREquals(tab.c4, @g1)
|
||||
AND MBREquals(tab.c3,@g2) ORDER BY c1;
|
||||
c1 ST_Astext(c2) ST_AsText(c3) ST_Astext(c4)
|
||||
ANALYZE TABLE tab;
|
||||
Table Op Msg_type Msg_text
|
||||
test.tab analyze status OK
|
||||
SET @g1 = ST_GeomFromText('POLYGON((4010 4010,4020 4020,4030 4030,4040 4030,4020 4010,4010 4010))');
|
||||
SET @g2 = ST_GeomFromText('LINESTRING(1 1,2 2,3 3)');
|
||||
ALTER TABLE tab MODIFY COLUMN c2 POINT NOT NULL;
|
||||
ALTER TABLE tab MODIFY COLUMN c3 LINESTRING NOT NULL;
|
||||
ALTER TABLE tab MODIFY COLUMN c4 POLYGON NOT NULL;
|
||||
SHOW CREATE TABLE tab;
|
||||
Table Create Table
|
||||
tab CREATE TABLE `tab` (
|
||||
`c1` int(11) NOT NULL,
|
||||
`c2` point NOT NULL,
|
||||
`c3` linestring NOT NULL,
|
||||
`c4` polygon NOT NULL,
|
||||
`c5` geometry NOT NULL,
|
||||
PRIMARY KEY (`c1`),
|
||||
SPATIAL KEY `idx2` (`c2`),
|
||||
SPATIAL KEY `idx3` (`c3`),
|
||||
SPATIAL KEY `idx4` (`c4`) COMMENT 'testing spatial index on Polygon',
|
||||
SPATIAL KEY `idx5` (`c5`) COMMENT 'testing spatial index on Geometry',
|
||||
KEY `idx6` (`c4`(10)) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
SHOW INDEX FROM tab;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
tab 0 PRIMARY 1 c1 A # NULL NULL BTREE
|
||||
tab 1 idx2 1 c2 A # 32 NULL SPATIAL
|
||||
tab 1 idx3 1 c3 A # 32 NULL SPATIAL
|
||||
tab 1 idx4 1 c4 A # 32 NULL SPATIAL testing spatial index on Polygon
|
||||
tab 1 idx5 1 c5 A # 32 NULL SPATIAL testing spatial index on Geometry
|
||||
tab 1 idx6 1 c4 A # 10 NULL BTREE
|
||||
ANALYZE TABLE tab;
|
||||
Table Op Msg_type Msg_text
|
||||
test.tab analyze status OK
|
||||
SET @g1 = ST_GeomFromText( 'POLYGON((0 0,0 30,30 40,40 50,50 30,0 0))');
|
||||
SET @g2 = ST_GeomFromText('LINESTRING(1 1,2 2,3 3)');
|
||||
SELECT c1,ST_Astext(c2),ST_AsText(c3),ST_Astext(c4) FROM tab WHERE ST_Touches(tab.c4, @g1)
|
||||
AND ST_Touches(tab.c3,@g2);
|
||||
c1 ST_Astext(c2) ST_AsText(c3) ST_Astext(c4)
|
||||
UPDATE tab SET C2 = ST_GeomFromText('POINT(2000 2000)')
|
||||
WHERE ST_Touches(tab.c4, @g1) AND ST_Touches(tab.c3,@g2);
|
||||
DELETE FROM tab WHERE ST_Touches(tab.c4, @g1) AND ST_Touches(tab.c3,@g2);
|
||||
SELECT c1,ST_Astext(c2),ST_AsText(c3),ST_Astext(c4) FROM tab WHERE ST_Touches(tab.c4, @g1)
|
||||
AND ST_Touches(tab.c3,@g2);
|
||||
c1 ST_Astext(c2) ST_AsText(c3) ST_Astext(c4)
|
||||
SELECT c1,ST_Astext(c2),ST_AsText(c3),ST_Astext(c4) FROM tab WHERE ST_Touches(tab.c4, @g1)
|
||||
OR ST_Touches(tab.c3,@g2);
|
||||
c1 ST_Astext(c2) ST_AsText(c3) ST_Astext(c4)
|
||||
2 POINT(20 20) LINESTRING(20 20,30 30,40 40) POLYGON((40 50,40 70,50 100,70 100,80 80,70 50,40 50))
|
||||
UPDATE tab SET C2 = ST_GeomFromText('POINT(2000 2000)')
|
||||
WHERE ST_Touches(tab.c4, @g1) OR ST_Touches(tab.c3,@g2);
|
||||
SELECT c1,ST_Astext(c2),ST_AsText(c3),ST_Astext(c4) FROM tab WHERE ST_Touches(tab.c4, @g1)
|
||||
OR ST_Touches(tab.c3,@g2);
|
||||
c1 ST_Astext(c2) ST_AsText(c3) ST_Astext(c4)
|
||||
2 POINT(2000 2000) LINESTRING(20 20,30 30,40 40) POLYGON((40 50,40 70,50 100,70 100,80 80,70 50,40 50))
|
||||
DELETE FROM tab WHERE ST_Touches(tab.c4, @g1) OR ST_Touches(tab.c3,@g2);
|
||||
SELECT c1,ST_Astext(c2),ST_AsText(c3),ST_Astext(c4) FROM tab WHERE ST_Touches(tab.c4, @g1)
|
||||
OR ST_Touches(tab.c3,@g2);
|
||||
c1 ST_Astext(c2) ST_AsText(c3) ST_Astext(c4)
|
||||
ALTER TABLE tab MODIFY COLUMN c4 INT NOT NULL;
|
||||
ERROR HY000: Incorrect arguments to SPATIAL INDEX
|
||||
ALTER TABLE tab MODIFY COLUMN c4 BLOB NOT NULL;
|
||||
ERROR HY000: Incorrect arguments to SPATIAL INDEX
|
||||
ALTER TABLE tab ENGINE Myisam;
|
||||
ALTER TABLE tab ENGINE InnoDB;
|
||||
ANALYZE TABLE tab;
|
||||
Table Op Msg_type Msg_text
|
||||
test.tab analyze status OK
|
||||
SET @g1 = ST_GeomFromText('POLYGON((1010 1010,1020 1020,1030 1030,1040 1030,1020 1010,1010 1010))');
|
||||
SET @g2 = ST_GeomFromText('LINESTRING(400 400,500 500,600 700)');
|
||||
SELECT c1,ST_AsText(c2),ST_AsText(c3),ST_Astext(c4) FROM tab WHERE MBRWithin(tab.c4, @g1) AND MBRWithin(tab.c3, @g2);
|
||||
c1 ST_AsText(c2) ST_AsText(c3) ST_Astext(c4)
|
||||
5 POINT(3 3) LINESTRING(400 400,500 500,600 700) POLYGON((1010 1010,1020 1020,1030 1030,1040 1030,1020 1010,1010 1010))
|
||||
SET @g1 = ST_GeomFromText('POINT(2000 2000)');
|
||||
SET @g2 = ST_GeomFromText('POINT(2000 2000)');
|
||||
SELECT c1,ST_AsText(c2),ST_AsText(c3),ST_Astext(c4) FROM tab WHERE MBRWithin(tab.c2, @g1) AND MBRWithin(tab.c3, @g2);
|
||||
c1 ST_AsText(c2) ST_AsText(c3) ST_Astext(c4)
|
||||
DELETE FROM tab WHERE MBRWithin(tab.c2, @g1) AND MBRWithin(tab.c3, @g2);
|
||||
SELECT c1,ST_AsText(c2),ST_AsText(c3),ST_Astext(c4) FROM tab WHERE MBRWithin(tab.c2, @g1) AND MBRWithin(tab.c3, @g2);
|
||||
c1 ST_AsText(c2) ST_AsText(c3) ST_Astext(c4)
|
||||
DROP TABLE tab;
|
||||
CREATE TABLE parent (id POINT, PRIMARY KEY(id)) ENGINE=InnoDB;
|
||||
CREATE TABLE child (id GEOMETRY NOT NULL, parent_id POINT NOT NULL) ENGINE=InnoDB;
|
||||
ALTER TABLE parent ADD SPATIAL INDEX idx1(id ASC);
|
||||
ALTER TABLE child ADD SPATIAL INDEX idx2(parent_id ASC);
|
||||
SHOW CREATE TABLE parent;
|
||||
Table Create Table
|
||||
parent CREATE TABLE `parent` (
|
||||
`id` point NOT NULL,
|
||||
PRIMARY KEY (`id`(25)),
|
||||
SPATIAL KEY `idx1` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
SHOW CREATE TABLE child;
|
||||
Table Create Table
|
||||
child CREATE TABLE `child` (
|
||||
`id` geometry NOT NULL,
|
||||
`parent_id` point NOT NULL,
|
||||
SPATIAL KEY `idx2` (`parent_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
SHOW INDEX FROM parent;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
parent 0 PRIMARY 1 id A 0 25 NULL BTREE
|
||||
parent 1 idx1 1 id A NULL 32 NULL SPATIAL
|
||||
SHOW INDEX FROM child;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
child 1 idx2 1 parent_id A # 32 NULL SPATIAL
|
||||
ALTER TABLE child ADD FOREIGN KEY(parent_id) REFERENCES parent(id) ;
|
||||
ALTER TABLE child ADD FOREIGN KEY(parent_id) REFERENCES parent(id) ON DELETE CASCADE ;
|
||||
DROP table child,parent;
|
||||
CREATE TABLE parent (id GEOMETRY, PRIMARY KEY(id(10))) ENGINE=InnoDB;
|
||||
CREATE TABLE child (id GEOMETRY NOT NULL, parent_id GEOMETRY NOT NULL) ENGINE=InnoDB;
|
||||
ALTER TABLE parent ADD SPATIAL INDEX idx1(id ASC) ;
|
||||
ALTER TABLE child ADD SPATIAL INDEX idx2(parent_id ASC);
|
||||
SHOW CREATE TABLE parent;
|
||||
Table Create Table
|
||||
parent CREATE TABLE `parent` (
|
||||
`id` geometry NOT NULL,
|
||||
PRIMARY KEY (`id`(10)),
|
||||
SPATIAL KEY `idx1` (`id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
SHOW CREATE TABLE child;
|
||||
Table Create Table
|
||||
child CREATE TABLE `child` (
|
||||
`id` geometry NOT NULL,
|
||||
`parent_id` geometry NOT NULL,
|
||||
SPATIAL KEY `idx2` (`parent_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
SHOW INDEX FROM parent;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
parent 0 PRIMARY 1 id A 0 10 NULL BTREE
|
||||
parent 1 idx1 1 id A NULL 32 NULL SPATIAL
|
||||
SHOW INDEX FROM child;
|
||||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment
|
||||
child 1 idx2 1 parent_id A NULL 32 NULL SPATIAL
|
||||
ALTER TABLE child ADD FOREIGN KEY(parent_id) REFERENCES parent(id) ;
|
||||
DROP table child,parent;
|
||||
create table t1 (c1 int) engine=innodb;
|
||||
insert into t1 values(NULL);
|
||||
alter table t1 add b geometry, add spatial index(b), algorithm=inplace;
|
||||
ERROR 42000: All parts of a SPATIAL index must be NOT NULL
|
||||
alter table t1 add b geometry, algorithm=inplace;
|
||||
update t1 set b = st_geomfromtext('point(0 0)');
|
||||
alter table t1 add spatial index(b), algorithm=inplace;
|
||||
ERROR 42000: All parts of a SPATIAL index must be NOT NULL
|
||||
delete from t1;
|
||||
DROP table t1;
|
||||
create table t1 (c1 int) engine=innodb;
|
||||
insert into t1 values(NULL);
|
||||
alter table t1 add b geometry, add spatial index(b), algorithm=copy;
|
||||
ERROR 42000: All parts of a SPATIAL index must be NOT NULL
|
||||
alter table t1 add b geometry not null, add spatial index(b), algorithm=copy;
|
||||
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
|
||||
update t1 set b = st_geomfromtext('point(0 0)');
|
||||
ERROR 42S22: Unknown column 'b' in 'field list'
|
||||
alter table t1 add spatial index(b), algorithm=copy;
|
||||
ERROR 42000: Key column 'b' doesn't exist in table
|
||||
delete from t1;
|
||||
DROP table t1;
|
||||
#
|
||||
# BUG#20111575 ALTER TABLE...ADD SPATIAL INDEX...LOCK NONE IS REFUSED
|
||||
# WITHOUT STATING A REASON
|
||||
#
|
||||
CREATE TABLE t1(p point NOT NULL) ENGINE=innodb;
|
||||
ALTER TABLE t1 ADD SPATIAL INDEX(p), LOCK=NONE;
|
||||
ERROR 0A000: LOCK=NONE is not supported. Reason: InnoDB presently supports one FULLTEXT index creation at a time. Try LOCK=SHARED
|
||||
ALTER TABLE t1 ADD SPATIAL INDEX(p);
|
||||
ALTER TABLE t1 FORCE, LOCK=NONE;
|
||||
ERROR 0A000: LOCK=NONE is not supported. Reason: InnoDB presently supports one FULLTEXT index creation at a time. Try LOCK=SHARED
|
||||
DROP TABLE t1;
|
15
mysql-test/suite/innodb_gis/r/check_rtree.result
Normal file
15
mysql-test/suite/innodb_gis/r/check_rtree.result
Normal file
@ -0,0 +1,15 @@
|
||||
create table t1 (i int, g geometry not null, spatial index (g))engine=innodb;
|
||||
SET SESSION debug="+d,rtree_test_check_count";
|
||||
Warnings:
|
||||
Warning 1287 '@@debug' is deprecated and will be removed in a future release. Please use '@@debug_dbug' instead
|
||||
insert into t1 values (1, POINT(1,1));
|
||||
insert into t1 values (1, POINT(1.5,1.5));
|
||||
insert into t1 values (1, POINT(3,3));
|
||||
insert into t1 values (1, POINT(3.1,3.1));
|
||||
insert into t1 values (1, POINT(5,5));
|
||||
CALL mtr.add_suppression("InnoDB: Flagged corruption of `g` in table `test`.`t1` in CHECK TABLE; Wrong count");
|
||||
check table t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check Warning InnoDB: Index 'g' contains 0 entries, should be 5.
|
||||
test.t1 check error Corrupt
|
||||
drop table t1;
|
1290
mysql-test/suite/innodb_gis/r/create_spatial_index.result
Normal file
1290
mysql-test/suite/innodb_gis/r/create_spatial_index.result
Normal file
File diff suppressed because it is too large
Load Diff
1491
mysql-test/suite/innodb_gis/r/gis.result
Normal file
1491
mysql-test/suite/innodb_gis/r/gis.result
Normal file
File diff suppressed because it is too large
Load Diff
515
mysql-test/suite/innodb_gis/r/precise.result
Normal file
515
mysql-test/suite/innodb_gis/r/precise.result
Normal file
@ -0,0 +1,515 @@
|
||||
DROP TABLE IF EXISTS t1;
|
||||
select 1, ST_Intersects(ST_GeomFromText('POLYGON((0 0,20 0,20 20,0 20,0 0))'), ST_GeomFromText('POLYGON((10 10,30 10,30 30,10 30,10 10))'));
|
||||
1 ST_Intersects(ST_GeomFromText('POLYGON((0 0,20 0,20 20,0 20,0 0))'), ST_GeomFromText('POLYGON((10 10,30 10,30 30,10 30,10 10))'))
|
||||
1 1
|
||||
select 0, ST_Intersects(ST_GeomFromText('POLYGON((0 0,20 10,10 30, 0 0))'), ST_GeomFromText('POLYGON((10 40, 40 50, 20 70, 10 40))'));
|
||||
0 ST_Intersects(ST_GeomFromText('POLYGON((0 0,20 10,10 30, 0 0))'), ST_GeomFromText('POLYGON((10 40, 40 50, 20 70, 10 40))'))
|
||||
0 0
|
||||
select 1, ST_Intersects(ST_GeomFromText('POLYGON((0 0,20 10,10 30, 0 0))'), ST_GeomFromText('POINT(10 10)'));
|
||||
1 ST_Intersects(ST_GeomFromText('POLYGON((0 0,20 10,10 30, 0 0))'), ST_GeomFromText('POINT(10 10)'))
|
||||
1 1
|
||||
select 1, ST_Intersects(ST_GeomFromText('POLYGON((0 0,20 10,10 30, 0 0))'), ST_GeomFromText('POLYGON((10 10,30 20,20 40, 10 10))'));
|
||||
1 ST_Intersects(ST_GeomFromText('POLYGON((0 0,20 10,10 30, 0 0))'), ST_GeomFromText('POLYGON((10 10,30 20,20 40, 10 10))'))
|
||||
1 1
|
||||
select 0, ST_Within(ST_GeomFromText('POLYGON((0 0,20 10,10 30, 0 0))'), ST_GeomFromText('POLYGON((10 10,30 20,20 40, 10 10))'));
|
||||
0 ST_Within(ST_GeomFromText('POLYGON((0 0,20 10,10 30, 0 0))'), ST_GeomFromText('POLYGON((10 10,30 20,20 40, 10 10))'))
|
||||
0 0
|
||||
select 1, ST_Within(ST_GeomFromText('POLYGON((1 1,20 10,10 30, 1 1))'), ST_GeomFromText('POLYGON((0 0,30 5,10 40, 0 0))'));
|
||||
1 ST_Within(ST_GeomFromText('POLYGON((1 1,20 10,10 30, 1 1))'), ST_GeomFromText('POLYGON((0 0,30 5,10 40, 0 0))'))
|
||||
1 1
|
||||
create table t1 (g point)engine=innodb;
|
||||
insert into t1 values
|
||||
(ST_GeomFromText('POINT(2 2)')), (ST_GeomFromText('POINT(2 4)')), (ST_GeomFromText('POINT(2 6)')), (ST_GeomFromText('POINT(2 8)')),
|
||||
(ST_GeomFromText('POINT(4 2)')), (ST_GeomFromText('POINT(4 4)')), (ST_GeomFromText('POINT(4 6)')), (ST_GeomFromText('POINT(4 8)')),
|
||||
(ST_GeomFromText('POINT(6 2)')), (ST_GeomFromText('POINT(6 4)')), (ST_GeomFromText('POINT(6 6)')), (ST_GeomFromText('POINT(6 8)')),
|
||||
(ST_GeomFromText('POINT(8 2)')), (ST_GeomFromText('POINT(8 4)')), (ST_GeomFromText('POINT(8 6)')), (ST_GeomFromText('POINT(8 8)'));
|
||||
select ST_astext(g) from t1 where ST_Within(g, ST_GeomFromText('POLYGON((5 1, 7 1, 7 7, 5 7, 3 3, 5 3, 5 1))'));
|
||||
ST_astext(g)
|
||||
POINT(4 4)
|
||||
POINT(6 2)
|
||||
POINT(6 4)
|
||||
POINT(6 6)
|
||||
select 'Contains';
|
||||
Contains
|
||||
Contains
|
||||
select ST_astext(g) from t1 where ST_Contains(ST_GeomFromText('POLYGON((5 1, 7 1, 7 7, 5 7, 3 3, 5 3, 5 1))'), g);
|
||||
ST_astext(g)
|
||||
POINT(4 4)
|
||||
POINT(6 2)
|
||||
POINT(6 4)
|
||||
POINT(6 6)
|
||||
select 'Intersects';
|
||||
Intersects
|
||||
Intersects
|
||||
select ST_astext(g) from t1 where ST_Intersects(ST_GeomFromText('POLYGON((5 1, 7 1, 7 7, 5 7, 3 3, 5 3, 5 1))'), g);
|
||||
ST_astext(g)
|
||||
POINT(4 4)
|
||||
POINT(6 2)
|
||||
POINT(6 4)
|
||||
POINT(6 6)
|
||||
select 'Contains';
|
||||
Contains
|
||||
Contains
|
||||
select ST_astext(g) from t1 where ST_Contains(ST_GeomFromText('POLYGON((5 1, 7 1, 7 7, 5 7, 3 3, 5 3, 5 1))'), g);
|
||||
ST_astext(g)
|
||||
POINT(4 4)
|
||||
POINT(6 2)
|
||||
POINT(6 4)
|
||||
POINT(6 6)
|
||||
select 'Contains2';
|
||||
Contains2
|
||||
Contains2
|
||||
select ST_astext(g) from t1 where ST_Contains(ST_GeomFromText('POLYGON((5 1, 7 1, 7 7, 5 7, 3 3, 5 3, 5 1), (5.01 3.01, 6 5, 9 5, 8 3, 5.01 3.01))'), g);
|
||||
ST_astext(g)
|
||||
POINT(4 4)
|
||||
POINT(6 2)
|
||||
POINT(6 6)
|
||||
POINT(8 4)
|
||||
DROP TABLE t1;
|
||||
select 0, ST_Within(ST_GeomFromText('LINESTRING(15 15, 50 50, 60 60)'), ST_GeomFromText('POLYGON((10 10,30 20,20 40, 10 10))'));
|
||||
0 ST_Within(ST_GeomFromText('LINESTRING(15 15, 50 50, 60 60)'), ST_GeomFromText('POLYGON((10 10,30 20,20 40, 10 10))'))
|
||||
0 0
|
||||
select 1, ST_Within(ST_GeomFromText('LINESTRING(15 15, 16 16)'), ST_GeomFromText('POLYGON((10 10,30 20,20 40, 10 10))'));
|
||||
1 ST_Within(ST_GeomFromText('LINESTRING(15 15, 16 16)'), ST_GeomFromText('POLYGON((10 10,30 20,20 40, 10 10))'))
|
||||
1 1
|
||||
select 1, ST_Intersects(ST_GeomFromText('LINESTRING(15 15, 50 50)'), ST_GeomFromText('LINESTRING(50 15, 15 50)'));
|
||||
1 ST_Intersects(ST_GeomFromText('LINESTRING(15 15, 50 50)'), ST_GeomFromText('LINESTRING(50 15, 15 50)'))
|
||||
1 1
|
||||
select 1, ST_Intersects(ST_GeomFromText('LINESTRING(15 15, 50 50)'), ST_GeomFromText('LINESTRING(16 16, 51 51)'));
|
||||
1 ST_Intersects(ST_GeomFromText('LINESTRING(15 15, 50 50)'), ST_GeomFromText('LINESTRING(16 16, 51 51)'))
|
||||
1 1
|
||||
select 1, ST_Intersects(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('POLYGON((50 5, 55 10, 0 45, 50 5))'));
|
||||
1 ST_Intersects(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('POLYGON((50 5, 55 10, 0 45, 50 5))'))
|
||||
1 1
|
||||
select ST_astext(ST_Union(ST_geometryfromtext('point(1 1)'), ST_geometryfromtext('polygon((0 0, 2 0, 1 2, 0 0))')));
|
||||
ST_astext(ST_Union(ST_geometryfromtext('point(1 1)'), ST_geometryfromtext('polygon((0 0, 2 0, 1 2, 0 0))')))
|
||||
POLYGON((0 0,1 2,2 0,0 0))
|
||||
select ST_astext(ST_Intersection(ST_geometryfromtext('point(1 1)'), ST_geometryfromtext('polygon((0 0, 2 0, 1 2, 0 0))')));
|
||||
ST_astext(ST_Intersection(ST_geometryfromtext('point(1 1)'), ST_geometryfromtext('polygon((0 0, 2 0, 1 2, 0 0))')))
|
||||
POINT(1 1)
|
||||
select ST_Intersects(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('POLYGON((50 5, 55 10, 0 45, 50 5))'));
|
||||
ST_Intersects(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('POLYGON((50 5, 55 10, 0 45, 50 5))'))
|
||||
1
|
||||
select ST_contains(ST_GeomFromText('MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)), ((6 6, 6 11, 11 11, 11 6, 6 6)))'), ST_GeomFromText('POINT(5 10)'));
|
||||
ST_contains(ST_GeomFromText('MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)), ((6 6, 6 11, 11 11, 11 6, 6 6)))'), ST_GeomFromText('POINT(5 10)'))
|
||||
0
|
||||
select ST_Disjoint(ST_GeomFromText('POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))'), ST_GeomFromText('POLYGON((10 10, 10 15, 15 15, 15 10, 10 10))'));
|
||||
ST_Disjoint(ST_GeomFromText('POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))'), ST_GeomFromText('POLYGON((10 10, 10 15, 15 15, 15 10, 10 10))'))
|
||||
1
|
||||
select ST_Disjoint(ST_GeomFromText('POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))'), ST_GeomFromText('POLYGON((10 10, 10 4, 4 4, 4 10, 10 10))'));
|
||||
ST_Disjoint(ST_GeomFromText('POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))'), ST_GeomFromText('POLYGON((10 10, 10 4, 4 4, 4 10, 10 10))'))
|
||||
0
|
||||
select ST_Overlaps(ST_GeomFromText('POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))'), ST_GeomFromText('POLYGON((10 10, 10 4, 4 4, 4 10, 10 10))'));
|
||||
ST_Overlaps(ST_GeomFromText('POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))'), ST_GeomFromText('POLYGON((10 10, 10 4, 4 4, 4 10, 10 10))'))
|
||||
1
|
||||
select ST_Overlaps(ST_GeomFromText('POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))'), ST_GeomFromText('POLYGON((1 1, 1 4, 4 4, 4 1, 1 1))'));
|
||||
ST_Overlaps(ST_GeomFromText('POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))'), ST_GeomFromText('POLYGON((1 1, 1 4, 4 4, 4 1, 1 1))'))
|
||||
0
|
||||
select ST_DISTANCE(ST_geomfromtext('polygon((0 0, 1 2, 2 1, 0 0))'), ST_geomfromtext('polygon((2 2, 3 4, 4 3, 2 2))'));
|
||||
ST_DISTANCE(ST_geomfromtext('polygon((0 0, 1 2, 2 1, 0 0))'), ST_geomfromtext('polygon((2 2, 3 4, 4 3, 2 2))'))
|
||||
0.7071067811865475
|
||||
select ST_DISTANCE(ST_geomfromtext('polygon((0 0, 1 2, 2 1, 0 0))'), ST_geomfromtext('linestring(0 1, 1 0)'));
|
||||
ST_DISTANCE(ST_geomfromtext('polygon((0 0, 1 2, 2 1, 0 0))'), ST_geomfromtext('linestring(0 1, 1 0)'))
|
||||
0
|
||||
select ST_DISTANCE(ST_geomfromtext('polygon((0 0, 3 6, 6 3, 0 0))'), ST_geomfromtext('polygon((2 2, 3 4, 4 3, 2 2))'));
|
||||
ST_DISTANCE(ST_geomfromtext('polygon((0 0, 3 6, 6 3, 0 0))'), ST_geomfromtext('polygon((2 2, 3 4, 4 3, 2 2))'))
|
||||
0
|
||||
select ST_DISTANCE(ST_geomfromtext('polygon((0 0, 3 6, 6 3, 0 0),(2 2, 3 4, 4 3, 2 2))'), ST_geomfromtext('point(3 3)'));
|
||||
ST_DISTANCE(ST_geomfromtext('polygon((0 0, 3 6, 6 3, 0 0),(2 2, 3 4, 4 3, 2 2))'), ST_geomfromtext('point(3 3)'))
|
||||
0.4472135954999579
|
||||
select ST_DISTANCE(ST_geomfromtext('linestring(0 0, 3 6, 6 3, 0 0)'), ST_geomfromtext('polygon((2 2, 3 4, 4 3, 2 2))'));
|
||||
ST_DISTANCE(ST_geomfromtext('linestring(0 0, 3 6, 6 3, 0 0)'), ST_geomfromtext('polygon((2 2, 3 4, 4 3, 2 2))'))
|
||||
0.8944271909999159
|
||||
select ST_astext(ST_Intersection(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('POLYGON((50 5, 55 10, 0 45, 50 5))')));
|
||||
ST_astext(ST_Intersection(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('POLYGON((50 5, 55 10, 0 45, 50 5))')))
|
||||
POLYGON((26.47058823529412 23.823529411764707,21.951219512195124 27.439024390243905,23.855421686746986 29.819277108433734,29.289940828402365 26.36094674556213,26.47058823529412 23.823529411764707))
|
||||
select ST_astext(ST_Intersection(ST_GeomFromText('LINESTRING(0 0, 50 45, 40 50, 0 0)'), ST_GeomFromText('LINESTRING(50 5, 55 10, 0 45, 50 5)')));
|
||||
ST_astext(ST_Intersection(ST_GeomFromText('LINESTRING(0 0, 50 45, 40 50, 0 0)'), ST_GeomFromText('LINESTRING(50 5, 55 10, 0 45, 50 5)')))
|
||||
MULTIPOINT(26.47058823529412 23.823529411764707,29.289940828402365 26.36094674556213,21.951219512195124 27.439024390243905,23.855421686746986 29.819277108433734)
|
||||
select ST_astext(ST_Intersection(ST_GeomFromText('LINESTRING(0 0, 50 45, 40 50)'), ST_GeomFromText('LINESTRING(50 5, 55 10, 0 45)')));
|
||||
ST_astext(ST_Intersection(ST_GeomFromText('LINESTRING(0 0, 50 45, 40 50)'), ST_GeomFromText('LINESTRING(50 5, 55 10, 0 45)')))
|
||||
POINT(29.289940828402365 26.36094674556213)
|
||||
select ST_astext(ST_Intersection(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('POINT(20 20)')));
|
||||
ST_astext(ST_Intersection(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('POINT(20 20)')))
|
||||
POINT(20 20)
|
||||
select ST_astext(ST_Intersection(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('LINESTRING(-10 -10, 200 200)')));
|
||||
ST_astext(ST_Intersection(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('LINESTRING(-10 -10, 200 200)')))
|
||||
LINESTRING(0 0,46.666666666666664 46.666666666666664)
|
||||
select ST_astext(ST_Intersection(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('LINESTRING(-10 -10, 200 200, 199 201, -11 -9)')));
|
||||
ST_astext(ST_Intersection(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('LINESTRING(-10 -10, 200 200, 199 201, -11 -9)')))
|
||||
MULTILINESTRING((0 0,46.666666666666664 46.666666666666664),(8 10,45.33333333333333 47.33333333333333))
|
||||
select ST_astext(ST_UNION(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('LINESTRING(-10 -10, 200 200, 199 201, -11 -9)')));
|
||||
ST_astext(ST_UNION(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('LINESTRING(-10 -10, 200 200, 199 201, -11 -9)')))
|
||||
GEOMETRYCOLLECTION(LINESTRING(-10 -10,0 0),LINESTRING(-11 -9,8 10),POLYGON((0 0,40 50,50 45,0 0)),LINESTRING(46.666666666666664 46.666666666666664,200 200,199 201,45.33333333333333 47.33333333333333))
|
||||
select ST_astext(ST_intersection(ST_geomfromtext('polygon((0 0, 1 0, 0 1, 0 0))'), ST_geomfromtext('polygon((0 0, 1 1, 0 2, 0 0))')));
|
||||
ST_astext(ST_intersection(ST_geomfromtext('polygon((0 0, 1 0, 0 1, 0 0))'), ST_geomfromtext('polygon((0 0, 1 1, 0 2, 0 0))')))
|
||||
POLYGON((0 0,0 1,0.5 0.5,0 0))
|
||||
select ST_astext(ST_symdifference(ST_geomfromtext('polygon((0 0, 1 0, 0 1, 0 0))'), ST_geomfromtext('polygon((0 0, 1 1, 0 2, 0 0))')));
|
||||
ST_astext(ST_symdifference(ST_geomfromtext('polygon((0 0, 1 0, 0 1, 0 0))'), ST_geomfromtext('polygon((0 0, 1 1, 0 2, 0 0))')))
|
||||
MULTIPOLYGON(((0 0,0.5 0.5,1 0,0 0)),((0.5 0.5,0 1,0 2,1 1,0.5 0.5)))
|
||||
select ST_astext(ST_UNION(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('LINESTRING(-10 -10, 200 200, 199 201, -11 -9)')));
|
||||
ST_astext(ST_UNION(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('LINESTRING(-10 -10, 200 200, 199 201, -11 -9)')))
|
||||
GEOMETRYCOLLECTION(LINESTRING(-10 -10,0 0),LINESTRING(-11 -9,8 10),POLYGON((0 0,40 50,50 45,0 0)),LINESTRING(46.666666666666664 46.666666666666664,200 200,199 201,45.33333333333333 47.33333333333333))
|
||||
select ST_astext(ST_buffer(ST_geometryfromtext('point(1 1)'), 1));
|
||||
ST_astext(ST_buffer(ST_geometryfromtext('point(1 1)'), 1))
|
||||
POLYGON((1 0,0.9509 0.0012,0.9019 0.0048,0.8532 0.0108,0.8049 0.0192,0.7570 0.0299,0.7097 0.0430,0.6631 0.0584,0.6173 0.0761,0.5724 0.0960,0.5286 0.1180,0.4858 0.1422,0.4444 0.1685,0.4043 0.1967,0.3656 0.2269,0.3284 0.2590,0.2928 0.2928,0.2590 0.3284,0.2269 0.3656,0.1967 0.4043,0.1685 0.4444,0.1422 0.4858,0.1180 0.5286,0.0960 0.5724,0.0761 0.6173,0.0584 0.6631,0.0430 0.7097,0.0299 0.7570,0.0192 0.8049,0.0108 0.8532,0.0048 0.9019,0.0012 0.9509,0 1,0.0048 1.0980,0.0108 1.1467,0.0192 1.1950,0.0299 1.2429,0.0430 1.2902,0.0584 1.3368,0.0761 1.3826,0.0960 1.4275,0.1180 1.4713,0.1422 1.5141,0.1685 1.5555,0.1967 1.5956,0.2269 1.6343,0.2590 1.6715,0.2928 1.7071,0.3284 1.7409,0.3656 1.7730,0.4043 1.8032,0.4444 1.8314,0.4858 1.8577,0.5286 1.8819,0.5724 1.9039,0.6173 1.9238,0.6631 1.9415,0.7097 1.9569,0.7570 1.9700,0.8049 1.9807,0.8532 1.9891,0.9019 1.9951,0.9509 1.9987,1 2,1.0490 1.9987,1.0980 1.9951,1.1467 1.9891,1.1950 1.9807,1.2429 1.9700,1.2902 1.9569,1.3368 1.9415,1.3826 1.9238,1.4275 1.9039,1.4713 1.8819,1.5141 1.8577,1.5555 1.8314,1.5956 1.8032,1.6343 1.7730,1.6715 1.7409,1.7071 1.7071,1.7409 1.6715,1.7730 1.6343,1.8032 1.5956,1.8314 1.5555,1.8577 1.5141,1.8819 1.4713,1.9039 1.4275,1.9238 1.3826,1.9415 1.3368,1.9569 1.2902,1.9700 1.2429,1.9807 1.1950,1.9891 1.1467,1.9951 1.0980,1.9987 1.0490,2 1,1.9951 0.9019,1.9891 0.8532,1.9807 0.8049,1.9700 0.7570,1.9569 0.7097,1.9415 0.6631,1.9238 0.6173,1.9039 0.5724,1.8819 0.5286,1.8577 0.4858,1.8314 0.4444,1.8032 0.4043,1.7730 0.3656,1.7409 0.3284,1.7071 0.2928,1.6715 0.2590,1.6343 0.2269,1.5956 0.1967,1.5555 0.1685,1.5141 0.1422,1.4713 0.1180,1.4275 0.0960,1.3826 0.0761,1.3368 0.0584,1.2902 0.0430,1.2429 0.0299,1.1950 0.0192,1.1467 0.0108,1.0980 0.0048,1.0490 0.0012,1 0))
|
||||
create table t1(geom geometrycollection)engine=innodb;
|
||||
select ST_astext(geom), ST_area(geom),ST_area(ST_buffer(geom,2)) from t1;
|
||||
ST_astext(geom) ST_area(geom) ST_area(ST_buffer(geom,2))
|
||||
select ST_NUMPOINTS(ST_EXTERIORRING(ST_buffer(geom,2))) from t1;
|
||||
ST_NUMPOINTS(ST_EXTERIORRING(ST_buffer(geom,2)))
|
||||
set @geom=ST_geomfromtext('LINESTRING(2 1, 4 2, 2 3, 2 5)');
|
||||
set @buff=ST_buffer(@geom,1);
|
||||
select ST_NUMPOINTS(ST_EXTERIORRING(@buff)) from t1;
|
||||
ST_NUMPOINTS(ST_EXTERIORRING(@buff))
|
||||
DROP TABLE t1;
|
||||
select st_touches(ST_geomfromtext('point(0 0)'), ST_geomfromtext('point(1 1)'));
|
||||
st_touches(ST_geomfromtext('point(0 0)'), ST_geomfromtext('point(1 1)'))
|
||||
0
|
||||
select st_touches(ST_geomfromtext('point(1 1)'), ST_geomfromtext('point(1 1)'));
|
||||
st_touches(ST_geomfromtext('point(1 1)'), ST_geomfromtext('point(1 1)'))
|
||||
0
|
||||
select st_touches(ST_geomfromtext('polygon((0 0, 2 2, 0 4, 0 0))'), ST_geomfromtext('point(1 1)'));
|
||||
st_touches(ST_geomfromtext('polygon((0 0, 2 2, 0 4, 0 0))'), ST_geomfromtext('point(1 1)'))
|
||||
1
|
||||
select st_touches(ST_geomfromtext('polygon((0 0, 2 2, 0 4, 0 0))'), ST_geomfromtext('point(1 0)'));
|
||||
st_touches(ST_geomfromtext('polygon((0 0, 2 2, 0 4, 0 0))'), ST_geomfromtext('point(1 0)'))
|
||||
0
|
||||
select st_touches(ST_geomfromtext('polygon((0 0, 2 2, 0 4, 0 0))'), ST_geomfromtext('point(1 2)'));
|
||||
st_touches(ST_geomfromtext('polygon((0 0, 2 2, 0 4, 0 0))'), ST_geomfromtext('point(1 2)'))
|
||||
0
|
||||
select st_touches(ST_geomfromtext('polygon((0 0, 2 2, 0 4, 0 0))'), ST_geomfromtext('polygon((1 1.2, 1 0, 2 0, 1 1.2))'));
|
||||
st_touches(ST_geomfromtext('polygon((0 0, 2 2, 0 4, 0 0))'), ST_geomfromtext('polygon((1 1.2, 1 0, 2 0, 1 1.2))'))
|
||||
0
|
||||
select st_touches(ST_geomfromtext('polygon((0 0, 2 2, 0 4, 0 0))'), ST_geomfromtext('polygon((1 1, 1 0, 2 0, 1 1))'));
|
||||
st_touches(ST_geomfromtext('polygon((0 0, 2 2, 0 4, 0 0))'), ST_geomfromtext('polygon((1 1, 1 0, 2 0, 1 1))'))
|
||||
1
|
||||
SELECT ST_Equals(ST_PolyFromText('POLYGON((67 13, 67 18, 67 18, 59 18, 59 13, 67 13) )'),ST_PolyFromText('POLYGON((67 13, 67 18, 59 19, 59 13, 59 13, 67 13) )')) as result;
|
||||
result
|
||||
0
|
||||
SELECT ST_Equals(ST_PolyFromText('POLYGON((67 13, 67 18, 67 18, 59 18, 59 13, 67 13) )'),ST_PolyFromText('POLYGON((67 13, 67 18, 59 18, 59 13, 59 13, 67 13) )')) as result;
|
||||
result
|
||||
1
|
||||
SELECT ST_Equals(ST_PointFromText('POINT (12 13)'),ST_PointFromText('POINT (12 13)')) as result;
|
||||
result
|
||||
1
|
||||
#
|
||||
# BUG#11755628/47429: INTERSECTION FUNCTION CRASHED MYSQLD
|
||||
# BUG#11759650/51979: UNION/INTERSECTION OF POLYGONS CRASHES MYSQL
|
||||
#
|
||||
SELECT ST_ASTEXT(ST_UNION(ST_GEOMFROMTEXT('POLYGON((525000 183300,525400
|
||||
183300,525400 18370, 525000 183700,525000 183300))'),
|
||||
ST_geomfromtext('POLYGON((525298.67 183511.53,525296.57
|
||||
183510.39,525296.42 183510.31,525289.11 183506.62,525283.17
|
||||
183503.47,525280.98 183502.26,525278.63 183500.97,525278.39
|
||||
183500.84,525276.79 183500,525260.7 183491.55,525263.95
|
||||
183484.75,525265.58 183481.95,525278.97 183488.73,525276.5
|
||||
183493.45,525275.5 183495.7,525280.35 183498.2,525282.3
|
||||
183499.1,525282.2 183499.3,525283.55 183500,525301.75
|
||||
183509.35,525304.45 183504.25,525307.85 183504.95,525304.5
|
||||
183510.83,525302.81 183513.8,525298.67 183511.53),(525275.06
|
||||
183489.89,525272.06 183488.37,525268.94 183494.51,525271.94
|
||||
183496.03,525275.06 183489.89),(525263.26 183491.55,525266.15
|
||||
183493.04,525269.88 183485.82,525266.99 183484.33,525263.26
|
||||
183491.55))'))) st_u;
|
||||
st_u
|
||||
MULTIPOLYGON(((525400 18370,525000.9677614468 183300,525400 183300,525400 18370)),((525000 183300,525000 183700,525000.9677614468 183300,525000 183300)),((525265.58 183481.95,525263.95 183484.75,525260.7 183491.55,525276.79 183500,525278.39 183500.84,525278.63 183500.97,525280.98 183502.26,525283.17 183503.47,525289.11 183506.62,525296.42 183510.31,525296.57 183510.39,525298.67 183511.53,525302.81 183513.8,525304.5 183510.83,525307.85 183504.95,525304.45 183504.25,525301.75 183509.35,525283.55 183500,525282.2 183499.3,525282.3 183499.1,525280.35 183498.2,525275.5 183495.7,525276.5 183493.45,525278.97 183488.73,525265.58 183481.95),(525266.99 183484.33,525263.26 183491.55,525266.15 183493.04,525269.88 183485.82,525266.99 183484.33),(525272.06 183488.37,525268.94 183494.51,525271.94 183496.03,525275.06 183489.89,525272.06 183488.37)))
|
||||
SET @a=0x0000000001030000000200000005000000000000000000000000000000000000000000000000002440000000000000000000000000000024400000000000002440000000000000000000000000000024400000000000000000000000000000000000000000000000000000F03F000000000000F03F0000000000000040000000000000F03F00000000000000400000000000000040000000000000F03F0000000000000040000000000000F03F000000000000F03F;
|
||||
SELECT ST_ASTEXT(ST_TOUCHES(@a, ST_GEOMFROMTEXT('point(0 0)'))) t;
|
||||
t
|
||||
NULL
|
||||
DROP TABLE IF EXISTS p1;
|
||||
CREATE PROCEDURE p1(dist DOUBLE, geom TEXT)
|
||||
BEGIN
|
||||
DECLARE g GEOMETRY;
|
||||
SET g=GeomFromText(geom);
|
||||
SELECT geom AS `-----`;
|
||||
SELECT dist, GeometryType(@buf:=ST_Buffer(g, dist)) AS `buffer`, ROUND(ST_AREA(@buf),2) AS buf_area;
|
||||
END|
|
||||
#
|
||||
# Testing ST_BUFFER with positive distance
|
||||
#
|
||||
-----
|
||||
POINT(0 0))
|
||||
dist buffer buf_area
|
||||
1 POLYGON 3.14
|
||||
-----
|
||||
LineString(0 1, 1 1))
|
||||
dist buffer buf_area
|
||||
1 POLYGON 5.14
|
||||
-----
|
||||
LineString(9 9,8 1,1 5,0 0)
|
||||
dist buffer buf_area
|
||||
1 POLYGON 44.63
|
||||
-----
|
||||
Polygon((2 2,2 8,8 8,8 2,2 2))
|
||||
dist buffer buf_area
|
||||
1 POLYGON 63.14
|
||||
-----
|
||||
Polygon((0 0,0 8,8 8,8 0,0 0),(2 2,6 2,6 6,2 6,2 2))
|
||||
dist buffer buf_area
|
||||
1 POLYGON 95.14
|
||||
-----
|
||||
Polygon((0 0, 0 8, 8 8, 8 10, -10 10, -10 0, 0 0))
|
||||
dist buffer buf_area
|
||||
1 POLYGON 174.93
|
||||
-----
|
||||
MultiPoint(9 9,8 1,1 5)
|
||||
dist buffer buf_area
|
||||
1 MULTIPOLYGON 9.42
|
||||
-----
|
||||
MultiLineString((0 0,2 2))
|
||||
dist buffer buf_area
|
||||
1 POLYGON 8.80
|
||||
-----
|
||||
MultiLineString((0 0,2 2,0 4))
|
||||
dist buffer buf_area
|
||||
1 POLYGON 14.24
|
||||
-----
|
||||
MultiLineString((0 0,2 2),(0 2,2 0))
|
||||
dist buffer buf_area
|
||||
1 POLYGON 13.59
|
||||
-----
|
||||
MultiLineString((2 2,2 8,-2 8),(-6 -6, 6 6),(10 10, 14 14))
|
||||
dist buffer buf_area
|
||||
1 MULTIPOLYGON 70.06
|
||||
-----
|
||||
MultiPolygon(((2 2,2 8,8 8,8 2,2 2)), ((9 9,8 1,1 5,9 9)))
|
||||
dist buffer buf_area
|
||||
1 POLYGON 73.18
|
||||
-----
|
||||
MultiPolygon(((2 2,2 8,8 8,8 2,2 2), (4 4,4 6,6 6,6 4,4 4)),((9 9,8 1,1 5,9 9)))
|
||||
dist buffer buf_area
|
||||
1 POLYGON 73.18
|
||||
-----
|
||||
GeometryCollection(Point(0 0))
|
||||
dist buffer buf_area
|
||||
1 POLYGON 3.14
|
||||
-----
|
||||
GeometryCollection(LineString(0 0, 2 2)))
|
||||
dist buffer buf_area
|
||||
1 POLYGON 8.80
|
||||
-----
|
||||
GeometryCollection(Polygon((2 2,2 8,8 8,8 2,2 2))))
|
||||
dist buffer buf_area
|
||||
1 POLYGON 63.14
|
||||
-----
|
||||
GeometryCollection(MultiPoint(9 9,8 1,1 5))
|
||||
dist buffer buf_area
|
||||
1 MULTIPOLYGON 9.42
|
||||
-----
|
||||
GeometryCollection(MultiLineString((0 0,0 1),(3 0,3 1)))
|
||||
dist buffer buf_area
|
||||
1 MULTIPOLYGON 10.28
|
||||
-----
|
||||
GeometryCollection(MultiPolygon(((0 0, 3 0, 3 3, 0 3, 0 0)),((6 6,6 9,9 9,9 6,6 6))))
|
||||
dist buffer buf_area
|
||||
1 MULTIPOLYGON 48.28
|
||||
-----
|
||||
GeometryCollection(Point(9 9),LineString(1 5,0 0),Polygon((2 2,2 8,8 8,8 2,2 2)))
|
||||
dist buffer buf_area
|
||||
1 POLYGON 75.92
|
||||
#
|
||||
# Testing ST_BUFFER with zero distance
|
||||
#
|
||||
-----
|
||||
POINT(0 0))
|
||||
dist buffer buf_area
|
||||
0 POINT 0.00
|
||||
-----
|
||||
LineString(0 1, 1 1))
|
||||
dist buffer buf_area
|
||||
0 LINESTRING 0.00
|
||||
-----
|
||||
LineString(9 9,8 1,1 5,0 0)
|
||||
dist buffer buf_area
|
||||
0 LINESTRING 0.00
|
||||
-----
|
||||
Polygon((2 2,2 8,8 8,8 2,2 2))
|
||||
dist buffer buf_area
|
||||
0 POLYGON 36.00
|
||||
-----
|
||||
Polygon((0 0,0 8,8 8,8 0,0 0),(2 2,6 2,6 6,2 6,2 2))
|
||||
dist buffer buf_area
|
||||
0 POLYGON 48.00
|
||||
-----
|
||||
Polygon((0 0, 0 8, 8 8, 8 10, -10 10, -10 0, 0 0))
|
||||
dist buffer buf_area
|
||||
0 POLYGON 116.00
|
||||
-----
|
||||
MultiPoint(9 9,8 1,1 5)
|
||||
dist buffer buf_area
|
||||
0 MULTIPOINT NULL
|
||||
-----
|
||||
MultiLineString((0 0,2 2))
|
||||
dist buffer buf_area
|
||||
0 MULTILINESTRING NULL
|
||||
-----
|
||||
MultiLineString((0 0,2 2,0 4))
|
||||
dist buffer buf_area
|
||||
0 MULTILINESTRING NULL
|
||||
-----
|
||||
MultiLineString((0 0,2 2),(0 2,2 0))
|
||||
dist buffer buf_area
|
||||
0 MULTILINESTRING NULL
|
||||
-----
|
||||
MultiLineString((2 2,2 8,-2 8),(-6 -6, 6 6),(10 10, 14 14))
|
||||
dist buffer buf_area
|
||||
0 MULTILINESTRING NULL
|
||||
-----
|
||||
MultiPolygon(((2 2,2 8,8 8,8 2,2 2)), ((9 9,8 1,1 5,9 9)))
|
||||
dist buffer buf_area
|
||||
0 MULTIPOLYGON 66.00
|
||||
-----
|
||||
MultiPolygon(((2 2,2 8,8 8,8 2,2 2), (4 4,4 6,6 6,6 4,4 4)),((9 9,8 1,1 5,9 9)))
|
||||
dist buffer buf_area
|
||||
0 MULTIPOLYGON 62.00
|
||||
-----
|
||||
GeometryCollection(Point(0 0))
|
||||
dist buffer buf_area
|
||||
0 GEOMETRYCOLLECTION 0.00
|
||||
-----
|
||||
GeometryCollection(LineString(0 0, 2 2)))
|
||||
dist buffer buf_area
|
||||
0 GEOMETRYCOLLECTION 0.00
|
||||
-----
|
||||
GeometryCollection(Polygon((2 2,2 8,8 8,8 2,2 2))))
|
||||
dist buffer buf_area
|
||||
0 GEOMETRYCOLLECTION 36.00
|
||||
-----
|
||||
GeometryCollection(MultiPoint(9 9,8 1,1 5))
|
||||
dist buffer buf_area
|
||||
0 GEOMETRYCOLLECTION NULL
|
||||
-----
|
||||
GeometryCollection(MultiLineString((0 0,0 1),(3 0,3 1)))
|
||||
dist buffer buf_area
|
||||
0 GEOMETRYCOLLECTION NULL
|
||||
-----
|
||||
GeometryCollection(MultiPolygon(((0 0, 3 0, 3 3, 0 3, 0 0)),((6 6,6 9,9 9,9 6,6 6))))
|
||||
dist buffer buf_area
|
||||
0 GEOMETRYCOLLECTION 18.00
|
||||
-----
|
||||
GeometryCollection(Point(9 9),LineString(1 5,0 0),Polygon((2 2,2 8,8 8,8 2,2 2)))
|
||||
dist buffer buf_area
|
||||
0 GEOMETRYCOLLECTION 36.00
|
||||
#
|
||||
# Testing ST_BUFFER with negative distance
|
||||
#
|
||||
-----
|
||||
POINT(0 0))
|
||||
dist buffer buf_area
|
||||
-1 GEOMETRYCOLLECTION 0.00
|
||||
-----
|
||||
LineString(0 1, 1 1))
|
||||
dist buffer buf_area
|
||||
-1 GEOMETRYCOLLECTION 0.00
|
||||
-----
|
||||
LineString(9 9,8 1,1 5,0 0)
|
||||
dist buffer buf_area
|
||||
-1 GEOMETRYCOLLECTION 0.00
|
||||
-----
|
||||
Polygon((2 2,2 8,8 8,8 2,2 2))
|
||||
dist buffer buf_area
|
||||
-1 POLYGON 16.00
|
||||
-----
|
||||
MultiPoint(9 9,8 1,1 5)
|
||||
dist buffer buf_area
|
||||
-1 GEOMETRYCOLLECTION 0.00
|
||||
-----
|
||||
MultiLineString((0 0,2 2))
|
||||
dist buffer buf_area
|
||||
-1 GEOMETRYCOLLECTION 0.00
|
||||
-----
|
||||
MultiLineString((0 0,2 2,0 4))
|
||||
dist buffer buf_area
|
||||
-1 GEOMETRYCOLLECTION 0.00
|
||||
-----
|
||||
MultiLineString((0 0,2 2),(0 2,2 0))
|
||||
dist buffer buf_area
|
||||
-1 GEOMETRYCOLLECTION 0.00
|
||||
-----
|
||||
MultiLineString((2 2,2 8,-2 8),(-6 -6, 6 6),(10 10, 14 14))
|
||||
dist buffer buf_area
|
||||
-1 GEOMETRYCOLLECTION 0.00
|
||||
-----
|
||||
GeometryCollection(Point(0 0))
|
||||
dist buffer buf_area
|
||||
-1 GEOMETRYCOLLECTION 0.00
|
||||
-----
|
||||
GeometryCollection(LineString(0 0, 2 2)))
|
||||
dist buffer buf_area
|
||||
-1 GEOMETRYCOLLECTION 0.00
|
||||
-----
|
||||
GeometryCollection(Polygon((2 2,2 8,8 8,8 2,2 2))))
|
||||
dist buffer buf_area
|
||||
-1 POLYGON 16.00
|
||||
-----
|
||||
GeometryCollection(MultiPoint(9 9,8 1,1 5))
|
||||
dist buffer buf_area
|
||||
-1 GEOMETRYCOLLECTION 0.00
|
||||
-----
|
||||
GeometryCollection(MultiLineString((0 0,0 1),(3 0,3 1)))
|
||||
dist buffer buf_area
|
||||
-1 GEOMETRYCOLLECTION 0.00
|
||||
-----
|
||||
GeometryCollection(Point(9 9),LineString(1 5,0 0),Polygon((2 2,2 8,8 8,8 2,2 2)))
|
||||
dist buffer buf_area
|
||||
-1 POLYGON 16.00
|
||||
SELECT ST_CONTAINS(
|
||||
GeomFromText('MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)),((6 6, 6 11, 11 11, 11 6, 6 6)))'),
|
||||
GeomFromText('POINT(5 10)'));
|
||||
ST_CONTAINS(
|
||||
GeomFromText('MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)),((6 6, 6 11, 11 11, 11 6, 6 6)))'),
|
||||
GeomFromText('POINT(5 10)'))
|
||||
0
|
||||
SELECT AsText(ST_UNION(
|
||||
GeomFromText('MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)),((6 6, 6 11, 11 11, 11 6, 6 6)))'),
|
||||
GeomFromText('POINT(5 10)')));
|
||||
AsText(ST_UNION(
|
||||
GeomFromText('MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)),((6 6, 6 11, 11 11, 11 6, 6 6)))'),
|
||||
GeomFromText('POINT(5 10)')))
|
||||
GEOMETRYCOLLECTION(POLYGON((0 0,0 5,5 5,5 0,0 0)),POLYGON((6 6,6 11,11 11,11 6,6 6)),POINT(5 10))
|
||||
DROP PROCEDURE p1;
|
||||
#
|
||||
# Bug #13833019 ASSERTION `T1->RESULT_RANGE' FAILED IN GCALC_OPERATION_REDUCER::END_COUPLE
|
||||
#
|
||||
SELECT GeometryType(ST_BUFFER(MULTIPOLYGONFROMTEXT('MULTIPOLYGON(((0 0,9 4,3 3,0 0)),((2 2,2 2,8 8,2 3,2 2)))'), 3));
|
||||
GeometryType(ST_BUFFER(MULTIPOLYGONFROMTEXT('MULTIPOLYGON(((0 0,9 4,3 3,0 0)),((2 2,2 2,8 8,2 3,2 2)))'), 3))
|
||||
POLYGON
|
||||
#
|
||||
# Bug #13832749 HANDLE_FATAL_SIGNAL IN GCALC_FUNCTION::COUNT_INTERNAL
|
||||
#
|
||||
SELECT GeometryType(ST_BUFFER(MULTIPOLYGONFROMTEXT('MULTIPOLYGON(((3 5,2 5,2 4,3 4,3 5)),((2 2,2 8,8 8,8 2,2 2), (4 4,4 6,6 6,6 4,4 4)), ((9 9,8 1,1 5,9 9)))'),1));
|
||||
GeometryType(ST_BUFFER(MULTIPOLYGONFROMTEXT('MULTIPOLYGON(((3 5,2 5,2 4,3 4,3 5)),((2 2,2 8,8 8,8 2,2 2), (4 4,4 6,6 6,6 4,4 4)), ((9 9,8 1,1 5,9 9)))'),1))
|
||||
POLYGON
|
||||
#
|
||||
# Bug#13358363 - ASSERTION: N > 0 && N < SINUSES_CALCULATED*2+1 | GET_N_SINCOS/ADD_EDGE_BUFFER
|
||||
#
|
||||
DO ST_BUFFER(ST_GEOMCOLLFROMTEXT('linestring(1 1,2 2)'),'');
|
||||
Warnings:
|
||||
Warning 1292 Truncated incorrect DOUBLE value: ''
|
||||
SELECT ST_WITHIN(
|
||||
LINESTRINGFROMTEXT(' LINESTRING(3 8,9 2,3 8,3 3,7 6,4 7,4 7,8 1) '),
|
||||
ST_BUFFER(MULTIPOLYGONFROMTEXT(' MULTIPOLYGON(((3 5,2 5,2 4,3 4,3 5)),((2 2,2 8,8 8,8 2,2 2),(4 4,4 6,6 6,6 4,4 4)),((0 5,3 5,3 2,1 2,1 1,3 1,3 0,0 0,0 3,2 3,2 4,0 4,0 5))) '),
|
||||
ST_NUMINTERIORRINGS(POLYGONFROMTEXT('POLYGON((3 5,2 4,2 5,3 5)) '))));
|
||||
ST_WITHIN(
|
||||
LINESTRINGFROMTEXT(' LINESTRING(3 8,9 2,3 8,3 3,7 6,4 7,4 7,8 1) '),
|
||||
ST_BUFFER(MULTIPOLYGONFROMTEXT(' MULTIPOLYGON(((3 5,2 5,2 4,3 4,3 5)),((2 2,2 8,8 8,8 2,2 2),(4 4,4 6,6 6,6 4,4 4)),((0 5,3 5,3 2,1 2,1 1,3 1,3 0,0 0,0 3,2 3,2 4,0 4,0 5))) ')
|
||||
0
|
||||
SELECT ST_DIMENSION(ST_BUFFER(POLYGONFROMTEXT(' POLYGON((3 5,2 5,2 4,3 4,3 5)) '),
|
||||
ST_NUMINTERIORRINGS(POLYGONFROMTEXT(' POLYGON((0 0,9 3,4 2,0 0))'))));
|
||||
ST_DIMENSION(ST_BUFFER(POLYGONFROMTEXT(' POLYGON((3 5,2 5,2 4,3 4,3 5)) '),
|
||||
ST_NUMINTERIORRINGS(POLYGONFROMTEXT(' POLYGON((0 0,9 3,4 2,0 0))'))))
|
||||
2
|
||||
SELECT ST_NUMINTERIORRINGS(
|
||||
ST_ENVELOPE(ST_BUFFER(MULTIPOLYGONFROMTEXT('MULTIPOLYGON(((3 5,2 5,2 4,3 4,3 5))) '),
|
||||
SRID(MULTILINESTRINGFROMTEXT('MULTILINESTRING((2 2,4 2,1 2,2 4,2 2)) ')))));
|
||||
ST_NUMINTERIORRINGS(
|
||||
ST_ENVELOPE(ST_BUFFER(MULTIPOLYGONFROMTEXT('MULTIPOLYGON(((3 5,2 5,2 4,3 4,3 5))) '),
|
||||
SRID(MULTILINESTRINGFROMTEXT('MULTILINESTRING((2 2,4 2,1 2,2 4,2 2)) ')))))
|
||||
0
|
||||
SELECT ASTEXT(ST_BUFFER(POLYGONFROMTEXT(' POLYGON((9 9,5 2,4 5,9 9))'),
|
||||
SRID(GEOMETRYFROMTEXT(' MULTIPOINT(8 4,5 0,7 8,6 9,3 4,7 3,5 5) '))));
|
||||
ASTEXT(ST_BUFFER(POLYGONFROMTEXT(' POLYGON((9 9,5 2,4 5,9 9))'),
|
||||
SRID(GEOMETRYFROMTEXT(' MULTIPOINT(8 4,5 0,7 8,6 9,3 4,7 3,5 5) '))))
|
||||
POLYGON((9 9,5 2,4 5,9 9))
|
59
mysql-test/suite/innodb_gis/r/rt_precise.result
Normal file
59
mysql-test/suite/innodb_gis/r/rt_precise.result
Normal file
@ -0,0 +1,59 @@
|
||||
SET default_storage_engine=InnoDB;
|
||||
DROP TABLE IF EXISTS t1;
|
||||
CREATE TABLE t1 (
|
||||
fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
g GEOMETRY NOT NULL,
|
||||
KEY gis_key(g(5))
|
||||
) ENGINE=InnoDB;
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`fid` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`g` geometry NOT NULL,
|
||||
PRIMARY KEY (`fid`),
|
||||
KEY `gis_key` (`g`(5))
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1
|
||||
SELECT count(*) FROM t1;
|
||||
count(*)
|
||||
150
|
||||
ANALYZE TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 analyze status OK
|
||||
EXPLAIN SELECT fid, ST_AsText(g) FROM t1 WHERE ST_Within(g, ST_GeomFromText('Polygon((140 140,160 140,160 160,140 140))'));
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 ALL gis_key NULL NULL NULL 150 #
|
||||
SELECT fid, ST_AsText(g) FROM t1 WHERE ST_Within(g, ST_GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))')) ORDER BY fid;
|
||||
fid ST_AsText(g)
|
||||
1 LINESTRING(150 150,150 150)
|
||||
2 LINESTRING(149 149,151 151)
|
||||
3 LINESTRING(148 148,152 152)
|
||||
4 LINESTRING(147 147,153 153)
|
||||
5 LINESTRING(146 146,154 154)
|
||||
6 LINESTRING(145 145,155 155)
|
||||
7 LINESTRING(144 144,156 156)
|
||||
8 LINESTRING(143 143,157 157)
|
||||
9 LINESTRING(142 142,158 158)
|
||||
10 LINESTRING(141 141,159 159)
|
||||
11 LINESTRING(140 140,160 160)
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1 (
|
||||
fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
g GEOMETRY NOT NULL
|
||||
) ENGINE=InnoDB;
|
||||
ALTER TABLE t1 ADD SPATIAL KEY(g);
|
||||
SHOW CREATE TABLE t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`fid` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`g` geometry NOT NULL,
|
||||
PRIMARY KEY (`fid`),
|
||||
SPATIAL KEY `g` (`g`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=101 DEFAULT CHARSET=latin1
|
||||
SELECT count(*) FROM t1;
|
||||
count(*)
|
||||
100
|
||||
SELECT fid, ST_AsText(g) FROM t1 WHERE ST_Within(g,
|
||||
ST_GeomFromText('Polygon((40 40,60 40,60 60,40 40))')) ORDER BY fid;
|
||||
fid ST_AsText(g)
|
||||
DROP TABLE t1;
|
||||
End of 5.5 tests.
|
251
mysql-test/suite/innodb_gis/r/rtree.result
Normal file
251
mysql-test/suite/innodb_gis/r/rtree.result
Normal file
@ -0,0 +1,251 @@
|
||||
create table t1 (i int, g geometry not null, spatial index (g))engine=innodb;
|
||||
insert into t1 values (1, POINT(1,1));
|
||||
insert into t1 values (1, POINT(1.5,1.5));
|
||||
insert into t1 values (1, POINT(3,3));
|
||||
insert into t1 values (1, POINT(3.1,3.1));
|
||||
insert into t1 values (1, 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 type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range g g 34 NULL 1 Using where
|
||||
select ST_astext(t1.g) from t1 where MBRWithin(t1.g, @g1);
|
||||
ST_astext(t1.g)
|
||||
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(1 1)
|
||||
POINT(1.5 1.5)
|
||||
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(1 1)
|
||||
POINT(1.5 1.5)
|
||||
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 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))');
|
||||
SET @horiz1 = ST_GeomFromText('POLYGON ((-2 0, 2 0, -2 0))');
|
||||
SET @horiz2 = ST_GeomFromText('POLYGON ((-1 0, 3 0, -1 0))');
|
||||
SET @horiz3 = ST_GeomFromText('POLYGON ((2 0, 3 0, 2 0))');
|
||||
SET @point1 = ST_GeomFromText('POLYGON ((0 0))');
|
||||
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;
|
||||
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)
|
||||
0
|
||||
SELECT MBROverlaps(@horiz1, @horiz2) FROM DUAL;
|
||||
MBROverlaps(@horiz1, @horiz2)
|
||||
1
|
||||
SELECT MBROverlaps(@horiz1, @horiz3) FROM DUAL;
|
||||
MBROverlaps(@horiz1, @horiz3)
|
||||
0
|
||||
SELECT MBROverlaps(@horiz1, @point1) FROM DUAL;
|
||||
MBROverlaps(@horiz1, @point1)
|
||||
0
|
||||
SELECT MBROverlaps(@horiz1, @point2) FROM DUAL;
|
||||
MBROverlaps(@horiz1, @point2)
|
||||
0
|
||||
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);
|
||||
alter table t1 drop primary key;
|
||||
create spatial index idx on t1(g);
|
||||
create spatial index idx2 on t1(g);
|
||||
Warnings:
|
||||
Note 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);
|
||||
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;
|
||||
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 type possible_keys key key_len ref rows Extra
|
||||
1 SIMPLE t1 range g g 34 NULL 1 Using where
|
||||
select ST_astext(t1.g) from t1 where MBRWithin(t1.g, @g1);
|
||||
ST_astext(t1.g)
|
||||
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(1 1)
|
||||
POINT(1.5 1.5)
|
||||
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(1 1)
|
||||
POINT(1.5 1.5)
|
||||
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` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`way` geometry NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
SPATIAL KEY `way` (`way`)
|
||||
) ENGINE=InnoDB;
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(1 1)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(1 2)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(1 3)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(1 4)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(1 5)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(2 1)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(2 2)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(2 3)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(2 4)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(2 5)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(3 1)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(3 2)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(3 3)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(3 4)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(3 5)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(4 1)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(4 2)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(4 3)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(4 4)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(4 5)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(5 1)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(5 2)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(5 3)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(5 4)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(5 5)');
|
||||
SELECT COUNT(*)
|
||||
FROM t1
|
||||
WHERE ST_CONTAINS(ST_GeomFromText('POLYGON((2 2,4 2, 4 4, 2 4, 2 2))'),way);
|
||||
COUNT(*)
|
||||
9
|
||||
OPTIMIZE TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 optimize note Table does not support optimize, doing recreate + analyze instead
|
||||
test.t1 optimize status OK
|
||||
SELECT COUNT(*)
|
||||
FROM t1
|
||||
WHERE ST_CONTAINS(ST_GeomFromText('POLYGON((2 2,4 2, 4 4, 2 4, 2 2))'),way);
|
||||
COUNT(*)
|
||||
9
|
||||
DROP TABLE t1;
|
||||
CREATE TABLE t1( i INT, g GEOMETRY NOT NULL, SPATIAL INDEX (g)) ENGINE=InnoDB;
|
||||
INSERT INTO t1 VALUES(1, LINESTRING(POINT(1,1), POINT(4, 4)));
|
||||
INSERT INTO t1 VALUES(2, LINESTRING(POINT(2,2), POINT(5, 5)));
|
||||
UPDATE t1 SET g = LINESTRING(POINT(1,1), POINT(2,2), POINT(3,3), POINT(4,4))
|
||||
WHERE i = 1;
|
||||
UPDATE t1 SET g = LINESTRING(POINT(1,1), POINT(2,2), POINT(3,3), POINT(8,8))
|
||||
WHERE i = 2;
|
||||
CHECK TABLE t1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.t1 check status OK
|
||||
DELETE FROM t1
|
||||
WHERE ST_CONTAINS(ST_GeomFromText('POLYGON((0 0,4 0, 4 4, 0 4, 0 0))'),g);
|
||||
DROP TABLE t1;
|
42
mysql-test/suite/innodb_gis/t/0.test
Normal file
42
mysql-test/suite/innodb_gis/t/0.test
Normal file
@ -0,0 +1,42 @@
|
||||
--source include/have_innodb.inc
|
||||
SET default_storage_engine=innodb;
|
||||
--source include/gis_generic.inc
|
||||
--source include/gis_keys.inc
|
||||
|
||||
#
|
||||
# Bug #15680 (SPATIAL key in innodb)
|
||||
#
|
||||
#--error ER_TABLE_CANT_HANDLE_SPKEYS
|
||||
create table t1 (g geometry not null, spatial gk(g)) engine=innodb;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
# Test read uncommitted
|
||||
create table t1 (c1 int, c2 geometry not null, spatial index (c2))engine=innodb;
|
||||
|
||||
connect (a,localhost,root,,);
|
||||
connection a;
|
||||
|
||||
start transaction;
|
||||
insert into t1 values(1, Point(1,1));
|
||||
|
||||
|
||||
connect (con1,localhost,root,,);
|
||||
connection con1;
|
||||
set @g1 = ST_GeomFromText('Polygon((0 0,0 100,100 100,100 0,0 0))');
|
||||
set transaction isolation level read uncommitted;
|
||||
select count(*) from t1 where ST_Within(t1.c2, @g1);
|
||||
disconnect con1;
|
||||
|
||||
--source include/wait_until_disconnected.inc
|
||||
|
||||
connection a;
|
||||
commit;
|
||||
disconnect a;
|
||||
--source include/wait_until_disconnected.inc
|
||||
|
||||
connection default;
|
||||
drop table t1;
|
||||
|
||||
|
||||
|
1451
mysql-test/suite/innodb_gis/t/1.test
Normal file
1451
mysql-test/suite/innodb_gis/t/1.test
Normal file
File diff suppressed because it is too large
Load Diff
753
mysql-test/suite/innodb_gis/t/alter_spatial_index.test
Normal file
753
mysql-test/suite/innodb_gis/t/alter_spatial_index.test
Normal file
@ -0,0 +1,753 @@
|
||||
# ******************************************************************
|
||||
# Test Alter table add spatial idex asc/desc comments
|
||||
# Test error Alter table modify column with No not null option
|
||||
# Test error Alter table modify column with null option
|
||||
# Test table column having both indexes spatial and Btree
|
||||
# Test error Alter table spatial index using hash/Btree
|
||||
# Test modify column from point to multipoint,line to multiline
|
||||
# Test modify column from mutipoint to point,multiline to line
|
||||
# Test discard & import tablepsace
|
||||
# spatial index on temp tables
|
||||
# Unique constraint on spatial index column Geometry
|
||||
# Unique constraint on spatial index column POINT
|
||||
# Modify Engine Innodb to Myisam to InnoDB
|
||||
# Check Foreign Key constraint on Point column
|
||||
# Check Foreign Key constraint on Geometry column
|
||||
# ******************************************************************
|
||||
|
||||
CALL mtr.add_suppression("but MySQL is asking statistics for 2 columns. Have you mixed");
|
||||
|
||||
--source include/have_innodb.inc
|
||||
--source include/have_geometry.inc
|
||||
|
||||
let MYSQLD_DATADIR= `select @@datadir`;
|
||||
|
||||
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;
|
||||
|
||||
CREATE TABLE tab1(c1 int NOT NULL PRIMARY KEY,c2 MULTIPOINT NOT NULL,
|
||||
c3 MULTILINESTRING NOT NULL,c4 MULTIPOLYGON NOT NULL,c5 GEOMETRY NOT NULL)
|
||||
ENGINE=InnoDB;
|
||||
|
||||
INSERT INTO tab1 SELECT * FROM tab;
|
||||
|
||||
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))'));
|
||||
|
||||
|
||||
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))'));
|
||||
|
||||
INSERT INTO tab(c1,c2,c3,c4,c5)
|
||||
VALUES(3,ST_GeomFromText('POINT(4 4)'),ST_GeomFromText('LINESTRING(130 130,140 140,150 150)'),
|
||||
ST_GeomFromText('POLYGON((7 1,6 2,6 3,10 3,10 1,7 1))'),
|
||||
ST_GeomFromText('POLYGON((4 -2,5 -4,6 -5,7 -4,7 2,4 -2))'));
|
||||
|
||||
INSERT INTO tab(c1,c2,c3,c4,c5)
|
||||
VALUES(4,ST_GeomFromText('POINT(50 50)'),ST_GeomFromText('LINESTRING(200 200,300 300,400 400)'),
|
||||
ST_GeomFromText('POLYGON((300 300,400 400,500 500,300 500,300 400,300 300))'),
|
||||
ST_GeomFromText('POLYGON((300 300,400 400,500 500,300 500,300 400,300 300))'));
|
||||
|
||||
INSERT INTO tab(c1,c2,c3,c4,c5)
|
||||
VALUES(5,ST_GeomFromText('POINT(3 3)'),ST_GeomFromText('LINESTRING(400 400,500 500,600 700)'),
|
||||
ST_GeomFromText('POLYGON((1010 1010,1020 1020,1030 1030,1040 1030,1020 1010,1010 1010))'),
|
||||
ST_GeomFromText('POLYGON((1010 1010,1020 1020,1030 1030,1040 1030,1020 1010,1010 1010))'));
|
||||
|
||||
INSERT INTO tab(c1,c2,c3,c4,c5)
|
||||
VALUES(6,ST_GeomFromText('POINT(3 3)'),ST_GeomFromText('LINESTRING(40 40,50 50,60 70)'),
|
||||
ST_GeomFromText('POLYGON((2010 2010,2020 2020,2030 2030,2040 2030,2020 2010,2010 2010))'),
|
||||
ST_GeomFromText('POLYGON((2010 2010,2020 2020,2030 2030,2040 2030,2020 2010,2010 2010))'));
|
||||
|
||||
INSERT INTO tab(c1,c2,c3,c4,c5)
|
||||
VALUES(7,ST_GeomFromText('POINT(60 70)'),ST_GeomFromText('LINESTRING(40 40,50 50,60 70)'),
|
||||
ST_GeomFromText('POLYGON((3010 3010,3020 3020,3030 3030,3040 3030,3020 3010,3010 3010))'),
|
||||
ST_GeomFromText('POLYGON((3010 3010,3020 3020,3030 3030,3040 3030,3020 3010,3010 3010))'));
|
||||
|
||||
INSERT INTO tab(c1,c2,c3,c4,c5)
|
||||
VALUES(8,ST_GeomFromText('POINT(0 0)'),ST_GeomFromText('LINESTRING(40 40,50 50,60 70)'),
|
||||
ST_GeomFromText('POLYGON((3010 3010,3020 3020,3030 3030,3040 3030,3020 3010,3010 3010))'),
|
||||
ST_GeomFromText('POLYGON((3010 3010,3020 3020,3030 3030,3040 3030,3020 3010,3010 3010))'));
|
||||
|
||||
|
||||
INSERT INTO tab(c1,c2,c3,c4,c5)
|
||||
VALUES(9,ST_GeomFromText('POINT(120 120)'),ST_GeomFromText('LINESTRING(100 100,110 110,120 120)'),
|
||||
ST_GeomFromText('POLYGON((4010 4010,4020 4020,4030 4030,4040 4030,4020 4010,4010 4010))'),
|
||||
ST_GeomFromText('POLYGON((4010 4010,4020 4020,4030 4030,4040 4030,4020 4010,4010 4010))'));
|
||||
|
||||
|
||||
INSERT INTO tab(c1,c2,c3,c4,c5)
|
||||
VALUES(10,ST_GeomFromText('POINT(160 160)'),ST_GeomFromText('LINESTRING(140 140,150 150,160 160)'),
|
||||
ST_GeomFromText('POLYGON((5010 5010,5020 5020,5030 5030,5040 5030,5020 5010,5010 5010))'),
|
||||
ST_GeomFromText('POLYGON((5010 5010,5020 5020,5030 5030,5040 5030,5020 5010,5010 5010))'));
|
||||
|
||||
|
||||
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';
|
||||
|
||||
ALTER TABLE tab ADD INDEX idx6(c4(10)) USING BTREE;
|
||||
|
||||
|
||||
# Test the MBRContains
|
||||
SET @g1 = ST_GeomFromText( 'POLYGON((7 1,6 2,6 3,10 3,10 1,7 1))');
|
||||
|
||||
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE MBRContains(tab.c4, @g1);
|
||||
|
||||
UPDATE tab SET C2 = ST_GeomFromText('POINT(0 0)')
|
||||
WHERE MBRContains(tab.c4, @g1);
|
||||
|
||||
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE MBRContains(tab.c4, @g1);
|
||||
|
||||
DELETE FROM tab WHERE MBRContains(tab.c4, @g1);
|
||||
|
||||
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE MBRContains(tab.c4, @g1);
|
||||
|
||||
|
||||
SET @g1 = ST_GeomFromText('LINESTRING( 300 300,400 400)');
|
||||
|
||||
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE MBRContains(tab.c4, @g1);
|
||||
|
||||
UPDATE tab SET C2 = ST_GeomFromText('POINT(100 100)')
|
||||
WHERE MBRContains(tab.c4, @g1);
|
||||
|
||||
DELETE FROM tab WHERE MBRContains(tab.c4, @g1);
|
||||
|
||||
# Test the MBRWithin
|
||||
SET @g1 = ST_GeomFromText( 'POLYGON((1010 1010,1020 1020,1030 1030,1040 1030,1020 1010,1010 1010))');
|
||||
|
||||
SELECT c1,ST_AsText(c2),ST_Astext(c4) FROM tab WHERE MBRWithin(tab.c4, @g1);
|
||||
|
||||
UPDATE tab SET C2 = ST_GeomFromText('POINT(200 200)')
|
||||
WHERE MBRWithin(tab.c4, @g1);
|
||||
|
||||
SELECT c1,ST_AsText(c2),ST_AsText(c4) FROM tab WHERE MBRWithin(tab.c4, @g1);
|
||||
|
||||
DELETE FROM tab WHERE MBRWithin(tab.c4, @g1);
|
||||
|
||||
--error ER_SPATIAL_CANT_HAVE_NULL
|
||||
ALTER TABLE tab MODIFY COLUMN c2 MULTIPOINT;
|
||||
|
||||
--error ER_SPATIAL_CANT_HAVE_NULL
|
||||
ALTER TABLE tab MODIFY COLUMN c3 MULTILINESTRING;
|
||||
|
||||
--error ER_SPATIAL_CANT_HAVE_NULL
|
||||
ALTER TABLE tab MODIFY COLUMN c4 MULTIPOLYGON;
|
||||
|
||||
--error ER_SPATIAL_CANT_HAVE_NULL
|
||||
ALTER TABLE tab MODIFY COLUMN c3 MULTILINESTRING NULL;
|
||||
|
||||
--error ER_SPATIAL_CANT_HAVE_NULL
|
||||
ALTER TABLE tab MODIFY COLUMN c4 MULTIPOLYGON NULL;
|
||||
|
||||
--error ER_SPATIAL_CANT_HAVE_NULL
|
||||
ALTER TABLE tab MODIFY COLUMN c4 Geometry NULL;
|
||||
|
||||
--error ER_SPATIAL_CANT_HAVE_NULL
|
||||
ALTER TABLE tab CHANGE COLUMN c2 c22 POINT;
|
||||
|
||||
--error ER_SPATIAL_CANT_HAVE_NULL
|
||||
ALTER TABLE tab CHANGE COLUMN c3 c33 LINESTRING;
|
||||
|
||||
--error ER_SPATIAL_CANT_HAVE_NULL
|
||||
ALTER TABLE tab CHANGE COLUMN c4 c44 POLYGON;
|
||||
|
||||
# --error ER_SPATIAL_MUST_HAVE_GEOM_COL
|
||||
--error ER_WRONG_ARGUMENTS
|
||||
ALTER TABLE tab add SPATIAL INDEX idx1(c1);
|
||||
|
||||
--error ER_PARSE_ERROR
|
||||
ALTER TABLE tab ADD SPATIAL INDEX idx6(c2 ASC) USING BTREE;
|
||||
|
||||
--error ER_PARSE_ERROR
|
||||
ALTER TABLE tab ADD SPATIAL INDEX idx6(c2 ASC) USING HASH;
|
||||
|
||||
# --error ER_INVALID_USE_OF_NULL
|
||||
# ALTER TABLE tab CHANGE c2 c2 MULTIPOINT NOT NULL FIRST, ALGORITHM=COPY;
|
||||
|
||||
# --error ER_CANT_CREATE_GEOMETRY_OBJECT
|
||||
# ALTER TABLE tab MODIFY COLUMN c3 MULTILINESTRING NOT NULL,ALGORITHM=COPY;
|
||||
|
||||
# --error ER_CANT_CREATE_GEOMETRY_OBJECT
|
||||
# ALTER TABLE tab MODIFY COLUMN c4 MULTIPOLYGON NOT NULL;
|
||||
|
||||
SHOW CREATE TABLE tab;
|
||||
|
||||
--replace_column 7 #
|
||||
SHOW INDEX FROM tab;
|
||||
|
||||
SET @g1 = ST_GeomFromText('POLYGON((20 20,30 30,40 40,50 50,40 50,30 40,30 30,20 20))');
|
||||
|
||||
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE ST_Crosses(tab.c4, @g1);
|
||||
|
||||
UPDATE tab SET C2 = ST_GeomFromText('POINT(1000 1000)')
|
||||
WHERE ST_Crosses(tab.c4, @g1);
|
||||
|
||||
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE ST_Crosses(tab.c4, @g1);
|
||||
|
||||
DELETE FROM tab WHERE ST_Crosses(tab.c4, @g1);
|
||||
|
||||
ALTER TABLE tab CHANGE COLUMN c2 c22 POINT NOT NULL;
|
||||
|
||||
ALTER TABLE tab CHANGE COLUMN c3 c33 LINESTRING NOT NULL;
|
||||
|
||||
ALTER TABLE tab CHANGE COLUMN c4 c44 POLYGON NOT NULL;
|
||||
|
||||
SHOW CREATE TABLE tab;
|
||||
|
||||
--replace_column 7 #
|
||||
SHOW INDEX FROM tab;
|
||||
|
||||
ALTER TABLE tab CHANGE COLUMN c22 c2 POINT NOT NULL;
|
||||
|
||||
ALTER TABLE tab CHANGE COLUMN c33 c3 LINESTRING NOT NULL;
|
||||
|
||||
ALTER TABLE tab CHANGE COLUMN c44 c4 POLYGON NOT NULL;
|
||||
|
||||
SHOW CREATE TABLE tab;
|
||||
|
||||
--replace_column 7 #
|
||||
SHOW INDEX FROM tab;
|
||||
|
||||
ALTER TABLE tab DISABLE KEYS;
|
||||
|
||||
SHOW WARNINGS;
|
||||
|
||||
SET @g1 = ST_GeomFromText('POLYGON((5010 5010,5020 5020,5030 5030,5040 5030,5020 5010,5010 5010))');
|
||||
|
||||
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE MBREquals(tab.c4, @g1);
|
||||
|
||||
UPDATE tab SET C2 = ST_GeomFromText('POINT(2000 2000)')
|
||||
WHERE MBREquals(tab.c4, @g1);
|
||||
|
||||
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE MBREquals(tab.c4, @g1);
|
||||
|
||||
DELETE FROM tab WHERE MBREquals(tab.c4, @g1);
|
||||
|
||||
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE MBREquals(tab.c4, @g1);
|
||||
|
||||
ALTER TABLE tab DROP PRIMARY KEY;
|
||||
|
||||
ALTER TABLE tab ADD PRIMARY KEY(c2) ;
|
||||
|
||||
SET @g1 = ST_GeomFromText( 'POLYGON((0 0,0 30,30 40,40 50,50 30,0 0))');
|
||||
|
||||
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE ST_Touches(tab.c4, @g1);
|
||||
|
||||
UPDATE tab SET C2 = ST_GeomFromText('POINT(3000 3000)')
|
||||
WHERE ST_Touches(tab.c4, @g1);
|
||||
|
||||
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE ST_Touches(tab.c4, @g1);
|
||||
|
||||
DELETE FROM tab WHERE ST_Touches(tab.c4, @g1);
|
||||
|
||||
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE ST_Touches(tab.c4, @g1);
|
||||
|
||||
FLUSH TABLE tab FOR EXPORT;
|
||||
|
||||
--copy_file $MYSQLD_DATADIR/test/tab.ibd $MYSQLD_DATADIR/test/tab.ibd.bk
|
||||
|
||||
UNLOCK TABLES;
|
||||
|
||||
ALTER TABLE tab DISCARD TABLESPACE;
|
||||
|
||||
--disable_warnings
|
||||
|
||||
--error ER_TABLESPACE_DISCARDED
|
||||
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab;
|
||||
|
||||
--copy_file $MYSQLD_DATADIR/test/tab.ibd.bk $MYSQLD_DATADIR/test/tab.ibd
|
||||
|
||||
--remove_file $MYSQLD_DATADIR/test/tab.ibd.bk
|
||||
|
||||
--disable_query_log
|
||||
|
||||
ALTER TABLE tab IMPORT TABLESPACE;
|
||||
|
||||
--enable_query_log
|
||||
|
||||
CHECK TABLE tab;
|
||||
|
||||
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab ORDER BY c1;
|
||||
|
||||
SET @g1 = ST_GeomFromText('LINESTRING( 3010 3010,4010 4010,5010 5010)');
|
||||
|
||||
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE MBRIntersects(tab.c4, @g1) order by c1;
|
||||
|
||||
--error ER_DUP_ENTRY
|
||||
UPDATE tab SET c2 = ST_GeomFromText('POINT(4000 4000)')
|
||||
WHERE MBRIntersects(tab.c4, @g1);
|
||||
|
||||
# --error ER_CANT_CREATE_GEOMETRY_OBJECT
|
||||
# UPDATE tab SET c4 = ST_GeomFromText('POINT(4000 4000)')
|
||||
# WHERE MBRIntersects(tab.c4, @g1);
|
||||
|
||||
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE MBRIntersects(tab.c4, @g1) ORDER BY c1;
|
||||
|
||||
DELETE FROM tab WHERE MBRIntersects(tab.c4, @g1);
|
||||
|
||||
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE MBROverlaps(tab.c4, @g1) ORDER BY c1;
|
||||
|
||||
INSERT INTO tab SELECT * FROM tab1;
|
||||
|
||||
ALTER TABLE tab DROP PRIMARY KEY;
|
||||
|
||||
ALTER TABLE tab DROP INDEX idx2;
|
||||
|
||||
# Check spatial index on temp tables
|
||||
|
||||
CREATE TEMPORARY TABLE temp_tab AS SELECT * FROM tab where c1 = c2;
|
||||
|
||||
INSERT INTO temp_tab SELECT * FROM tab;
|
||||
|
||||
CREATE SPATIAL INDEX idx2 ON temp_tab(c2);
|
||||
|
||||
CREATE SPATIAL INDEX idx3 ON temp_tab(c3);
|
||||
|
||||
CREATE SPATIAL INDEX idx4 ON temp_tab(c4);
|
||||
|
||||
CREATE SPATIAL INDEX idx5 ON temp_tab(c5);
|
||||
|
||||
SHOW CREATE TABLE temp_tab;
|
||||
|
||||
SET @g1 = ST_GeomFromText( 'POLYGON((7 1,6 2,6 3,10 3,10 1,7 1))');
|
||||
|
||||
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM temp_tab WHERE MBRContains(temp_tab.c4, @g1) ORDER BY c1;
|
||||
|
||||
# The following comments will be removed once the patch is available
|
||||
UPDATE temp_tab SET C2 = ST_GeomFromText('POINT(1000 1000)')
|
||||
WHERE MBRContains(temp_tab.c4, @g1);
|
||||
|
||||
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM temp_tab WHERE MBRContains(temp_tab.c4, @g1);
|
||||
|
||||
# Sever crashes Here so commented, will be removed later
|
||||
DELETE FROM temp_tab WHERE MBRContains(temp_tab.c4, @g1);
|
||||
|
||||
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM temp_tab WHERE MBRContains(temp_tab.c4, @g1) ORDER BY c1;
|
||||
|
||||
# Check Unique constraint on spatial index column POINT
|
||||
|
||||
SHOW CREATE TABLE tab;
|
||||
|
||||
--replace_column 7 #
|
||||
SHOW INDEX FROM tab;
|
||||
|
||||
DELETE FROM tab;
|
||||
|
||||
ALTER TABLE tab ADD PRIMARY KEY(c2);
|
||||
|
||||
CREATE SPATIAL INDEX idx2 ON tab(c2 ASC);
|
||||
|
||||
ALTER TABLE tab ADD CONSTRAINT const_1 UNIQUE(c2);
|
||||
|
||||
SHOW CREATE TABLE tab;
|
||||
|
||||
--replace_column 7 #
|
||||
SHOW INDEX FROM tab;
|
||||
|
||||
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))'));
|
||||
|
||||
# Check Unique constraint on spatial index column Geometry
|
||||
|
||||
DELETE FROM tab;
|
||||
|
||||
ALTER TABLE tab DROP PRIMARY KEY ;
|
||||
|
||||
ALTER TABLE tab DROP KEY const_1;
|
||||
|
||||
ALTER TABLE tab ADD PRIMARY KEY(c5(10));
|
||||
|
||||
ALTER TABLE tab ADD CONSTRAINT const_1 UNIQUE(c5(10));
|
||||
|
||||
SHOW CREATE TABLE tab;
|
||||
|
||||
--replace_column 7 #
|
||||
SHOW INDEX FROM tab;
|
||||
|
||||
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))'));
|
||||
|
||||
#cleanup
|
||||
DROP TABLE tab,tab1,temp_tab;
|
||||
|
||||
--enable_warnings
|
||||
|
||||
# Check Modify POINT to GEOMETRY and GEOMETRY to 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;
|
||||
|
||||
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))'));
|
||||
|
||||
|
||||
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))'));
|
||||
|
||||
INSERT INTO tab(c1,c2,c3,c4,c5)
|
||||
VALUES(3,ST_GeomFromText('POINT(4 4)'),ST_GeomFromText('LINESTRING(130 130,140 140,150 150)'),
|
||||
ST_GeomFromText('POLYGON((7 1,6 2,6 3,10 3,10 1,7 1))'),
|
||||
ST_GeomFromText('POLYGON((4 -2,5 -4,6 -5,7 -4,7 2,4 -2))'));
|
||||
|
||||
INSERT INTO tab(c1,c2,c3,c4,c5)
|
||||
VALUES(4,ST_GeomFromText('POINT(50 50)'),ST_GeomFromText('LINESTRING(200 200,300 300,400 400)'),
|
||||
ST_GeomFromText('POLYGON((300 300,400 400,500 500,300 500,300 400,300 300))'),
|
||||
ST_GeomFromText('POLYGON((300 300,400 400,500 500,300 500,300 400,300 300))'));
|
||||
|
||||
INSERT INTO tab(c1,c2,c3,c4,c5)
|
||||
VALUES(5,ST_GeomFromText('POINT(3 3)'),ST_GeomFromText('LINESTRING(400 400,500 500,600 700)'),
|
||||
ST_GeomFromText('POLYGON((1010 1010,1020 1020,1030 1030,1040 1030,1020 1010,1010 1010))'),
|
||||
ST_GeomFromText('POLYGON((1010 1010,1020 1020,1030 1030,1040 1030,1020 1010,1010 1010))'));
|
||||
|
||||
INSERT INTO tab(c1,c2,c3,c4,c5)
|
||||
VALUES(6,ST_GeomFromText('POINT(3 3)'),ST_GeomFromText('LINESTRING(40 40,50 50,60 70)'),
|
||||
ST_GeomFromText('POLYGON((2010 2010,2020 2020,2030 2030,2040 2030,2020 2010,2010 2010))'),
|
||||
ST_GeomFromText('POLYGON((2010 2010,2020 2020,2030 2030,2040 2030,2020 2010,2010 2010))'));
|
||||
|
||||
INSERT INTO tab(c1,c2,c3,c4,c5)
|
||||
VALUES(7,ST_GeomFromText('POINT(60 70)'),ST_GeomFromText('LINESTRING(40 40,50 50,60 70)'),
|
||||
ST_GeomFromText('POLYGON((3010 3010,3020 3020,3030 3030,3040 3030,3020 3010,3010 3010))'),
|
||||
ST_GeomFromText('POLYGON((3010 3010,3020 3020,3030 3030,3040 3030,3020 3010,3010 3010))'));
|
||||
|
||||
INSERT INTO tab(c1,c2,c3,c4,c5)
|
||||
VALUES(8,ST_GeomFromText('POINT(0 0)'),ST_GeomFromText('LINESTRING(40 40,50 50,60 70)'),
|
||||
ST_GeomFromText('POLYGON((3010 3010,3020 3020,3030 3030,3040 3030,3020 3010,3010 3010))'),
|
||||
ST_GeomFromText('POLYGON((3010 3010,3020 3020,3030 3030,3040 3030,3020 3010,3010 3010))'));
|
||||
|
||||
|
||||
INSERT INTO tab(c1,c2,c3,c4,c5)
|
||||
VALUES(9,ST_GeomFromText('POINT(120 120)'),ST_GeomFromText('LINESTRING(100 100,110 110,120 120)'),
|
||||
ST_GeomFromText('POLYGON((4010 4010,4020 4020,4030 4030,4040 4030,4020 4010,4010 4010))'),
|
||||
ST_GeomFromText('POLYGON((4010 4010,4020 4020,4030 4030,4040 4030,4020 4010,4010 4010))'));
|
||||
|
||||
|
||||
INSERT INTO tab(c1,c2,c3,c4,c5)
|
||||
VALUES(10,ST_GeomFromText('POINT(160 160)'),ST_GeomFromText('LINESTRING(140 140,150 150,160 160)'),
|
||||
ST_GeomFromText('POLYGON((5010 5010,5020 5020,5030 5030,5040 5030,5020 5010,5010 5010))'),
|
||||
ST_GeomFromText('POLYGON((5010 5010,5020 5020,5030 5030,5040 5030,5020 5010,5010 5010))'));
|
||||
|
||||
ANALYZE TABLE tab;
|
||||
|
||||
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';
|
||||
|
||||
ALTER TABLE tab ADD INDEX idx6(c4(10)) USING BTREE;
|
||||
|
||||
|
||||
ALTER TABLE tab MODIFY COLUMN c2 GEOMETRY NOT NULL;
|
||||
|
||||
# --error ER_CANT_CREATE_GEOMETRY_OBJECT
|
||||
# ALTER TABLE tab MODIFY COLUMN c3 POLYGON NOT NULL;
|
||||
|
||||
# --error ER_INVALID_USE_OF_NULL
|
||||
# ALTER TABLE tab add COLUMN c7 POINT NOT NULL;
|
||||
|
||||
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
|
||||
ALTER TABLE tab add COLUMN c8 POINT NOT NULL, ALGORITHM = INPLACE, LOCK=NONE;
|
||||
|
||||
SHOW CREATE TABLE tab;
|
||||
|
||||
--replace_column 7 #
|
||||
SHOW INDEX FROM tab;
|
||||
|
||||
SET @g1 = ST_GeomFromText( 'POLYGON((7 1,6 2,6 3,10 3,10 1,7 1))');
|
||||
|
||||
UPDATE tab SET C2 = ST_GeomFromText('POINT(1000 1000)')
|
||||
WHERE MBRContains(tab.c4, @g1);
|
||||
|
||||
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE MBRContains(tab.c4, @g1) ORDER BY c1;
|
||||
|
||||
DELETE FROM tab WHERE MBRContains(tab.c4, @g1);
|
||||
|
||||
SELECT c1,ST_Astext(c2),ST_Astext(c4) FROM tab WHERE MBRContains(tab.c4, @g1) ORDER BY c1;
|
||||
|
||||
# --error ER_CANT_CREATE_GEOMETRY_OBJECT
|
||||
# ALTER TABLE tab MODIFY COLUMN c2 POLYGON NOT NULL;
|
||||
|
||||
ALTER TABLE tab MODIFY COLUMN c4 GEOMETRY NOT NULL;
|
||||
|
||||
SHOW CREATE TABLE tab;
|
||||
|
||||
--replace_column 7 #
|
||||
SHOW INDEX FROM tab;
|
||||
|
||||
ANALYZE TABLE tab;
|
||||
|
||||
SET @g1 = ST_GeomFromText('POLYGON((5010 5010,5020 5020,5030 5030,5040 5030,5020 5010,5010 5010))');
|
||||
|
||||
SET @g2 = ST_GeomFromText('LINESTRING(140 140,150 150,160 160)');
|
||||
|
||||
SELECT c1,ST_Astext(c2),ST_AsText(c3),ST_Astext(c4) FROM tab WHERE MBREquals(tab.c4, @g1)
|
||||
AND MBREquals(tab.c3,@g2) ORDER BY c1;
|
||||
|
||||
UPDATE tab SET C2 = ST_GeomFromText('POINT(2000 2000)')
|
||||
WHERE MBREquals(tab.c4, @g1) AND MBREquals(tab.c3,@g2);
|
||||
|
||||
SELECT c1,ST_Astext(c2),ST_AsText(c3),ST_Astext(c4) FROM tab WHERE MBREquals(tab.c4, @g1)
|
||||
AND MBREquals(tab.c3,@g2) ORDER BY c1;
|
||||
|
||||
DELETE FROM tab WHERE MBREquals(tab.c4, @g1) AND MBREquals(tab.c3,@g2);
|
||||
|
||||
SELECT c1,ST_Astext(c2),ST_AsText(c3),ST_Astext(c4) FROM tab WHERE MBREquals(tab.c4, @g1)
|
||||
AND MBREquals(tab.c3,@g2) ORDER BY c1;
|
||||
|
||||
ANALYZE TABLE tab;
|
||||
|
||||
SET @g1 = ST_GeomFromText('POLYGON((4010 4010,4020 4020,4030 4030,4040 4030,4020 4010,4010 4010))');
|
||||
|
||||
SET @g2 = ST_GeomFromText('LINESTRING(1 1,2 2,3 3)');
|
||||
|
||||
# When Point type data exist in the column allow DDL operation
|
||||
ALTER TABLE tab MODIFY COLUMN c2 POINT NOT NULL;
|
||||
|
||||
ALTER TABLE tab MODIFY COLUMN c3 LINESTRING NOT NULL;
|
||||
|
||||
ALTER TABLE tab MODIFY COLUMN c4 POLYGON NOT NULL;
|
||||
|
||||
SHOW CREATE TABLE tab;
|
||||
|
||||
--replace_column 7 #
|
||||
SHOW INDEX FROM tab;
|
||||
|
||||
ANALYZE TABLE tab;
|
||||
|
||||
SET @g1 = ST_GeomFromText( 'POLYGON((0 0,0 30,30 40,40 50,50 30,0 0))');
|
||||
|
||||
SET @g2 = ST_GeomFromText('LINESTRING(1 1,2 2,3 3)');
|
||||
|
||||
# Should be 0 rows affected
|
||||
SELECT c1,ST_Astext(c2),ST_AsText(c3),ST_Astext(c4) FROM tab WHERE ST_Touches(tab.c4, @g1)
|
||||
AND ST_Touches(tab.c3,@g2);
|
||||
|
||||
# Should be 0 rows affected
|
||||
UPDATE tab SET C2 = ST_GeomFromText('POINT(2000 2000)')
|
||||
WHERE ST_Touches(tab.c4, @g1) AND ST_Touches(tab.c3,@g2);
|
||||
|
||||
# Should be 0 rows affected
|
||||
DELETE FROM tab WHERE ST_Touches(tab.c4, @g1) AND ST_Touches(tab.c3,@g2);
|
||||
|
||||
# Should be 0 rows affected
|
||||
SELECT c1,ST_Astext(c2),ST_AsText(c3),ST_Astext(c4) FROM tab WHERE ST_Touches(tab.c4, @g1)
|
||||
AND ST_Touches(tab.c3,@g2);
|
||||
|
||||
# should be 1 row affected
|
||||
SELECT c1,ST_Astext(c2),ST_AsText(c3),ST_Astext(c4) FROM tab WHERE ST_Touches(tab.c4, @g1)
|
||||
OR ST_Touches(tab.c3,@g2);
|
||||
|
||||
# should be 1 row affected
|
||||
UPDATE tab SET C2 = ST_GeomFromText('POINT(2000 2000)')
|
||||
WHERE ST_Touches(tab.c4, @g1) OR ST_Touches(tab.c3,@g2);
|
||||
|
||||
# should be 1 row affected
|
||||
SELECT c1,ST_Astext(c2),ST_AsText(c3),ST_Astext(c4) FROM tab WHERE ST_Touches(tab.c4, @g1)
|
||||
OR ST_Touches(tab.c3,@g2);
|
||||
|
||||
# should be 1 row affected
|
||||
DELETE FROM tab WHERE ST_Touches(tab.c4, @g1) OR ST_Touches(tab.c3,@g2);
|
||||
|
||||
# Should be Empty set
|
||||
SELECT c1,ST_Astext(c2),ST_AsText(c3),ST_Astext(c4) FROM tab WHERE ST_Touches(tab.c4, @g1)
|
||||
OR ST_Touches(tab.c3,@g2);
|
||||
|
||||
# --error ER_SPATIAL_MUST_HAVE_GEOM_COL
|
||||
--error ER_WRONG_ARGUMENTS
|
||||
ALTER TABLE tab MODIFY COLUMN c4 INT NOT NULL;
|
||||
|
||||
# --error ER_SPATIAL_MUST_HAVE_GEOM_COL
|
||||
--error ER_WRONG_ARGUMENTS
|
||||
ALTER TABLE tab MODIFY COLUMN c4 BLOB NOT NULL;
|
||||
|
||||
# Test InnoDB to Myisam to InnoDB
|
||||
ALTER TABLE tab ENGINE Myisam;
|
||||
|
||||
ALTER TABLE tab ENGINE InnoDB;
|
||||
|
||||
ANALYZE TABLE tab;
|
||||
|
||||
SET @g1 = ST_GeomFromText('POLYGON((1010 1010,1020 1020,1030 1030,1040 1030,1020 1010,1010 1010))');
|
||||
|
||||
SET @g2 = ST_GeomFromText('LINESTRING(400 400,500 500,600 700)');
|
||||
|
||||
SELECT c1,ST_AsText(c2),ST_AsText(c3),ST_Astext(c4) FROM tab WHERE MBRWithin(tab.c4, @g1) AND MBRWithin(tab.c3, @g2);
|
||||
|
||||
# --error ER_CANT_CREATE_GEOMETRY_OBJECT
|
||||
# UPDATE tab SET c2 = ST_GeomFromText('POINT(2000 2000)'),
|
||||
# c3=ST_GeomFromText('POINT(2000 2000)')
|
||||
# WHERE MBRWithin(tab.c4, @g1) AND MBRWithin(tab.c3, @g2);
|
||||
|
||||
SET @g1 = ST_GeomFromText('POINT(2000 2000)');
|
||||
|
||||
SET @g2 = ST_GeomFromText('POINT(2000 2000)');
|
||||
|
||||
SELECT c1,ST_AsText(c2),ST_AsText(c3),ST_Astext(c4) FROM tab WHERE MBRWithin(tab.c2, @g1) AND MBRWithin(tab.c3, @g2);
|
||||
|
||||
DELETE FROM tab WHERE MBRWithin(tab.c2, @g1) AND MBRWithin(tab.c3, @g2);
|
||||
|
||||
SELECT c1,ST_AsText(c2),ST_AsText(c3),ST_Astext(c4) FROM tab WHERE MBRWithin(tab.c2, @g1) AND MBRWithin(tab.c3, @g2);
|
||||
|
||||
#cleanup
|
||||
DROP TABLE tab;
|
||||
|
||||
# Check Foreign Key constraint on Point column
|
||||
CREATE TABLE parent (id POINT, PRIMARY KEY(id)) ENGINE=InnoDB;
|
||||
|
||||
CREATE TABLE child (id GEOMETRY NOT NULL, parent_id POINT NOT NULL) ENGINE=InnoDB;
|
||||
|
||||
ALTER TABLE parent ADD SPATIAL INDEX idx1(id ASC);
|
||||
|
||||
ALTER TABLE child ADD SPATIAL INDEX idx2(parent_id ASC);
|
||||
|
||||
SHOW CREATE TABLE parent;
|
||||
|
||||
SHOW CREATE TABLE child;
|
||||
|
||||
SHOW INDEX FROM parent;
|
||||
|
||||
--replace_column 7 #
|
||||
SHOW INDEX FROM child;
|
||||
|
||||
# --error ER_CANNOT_ADD_FOREIGN
|
||||
--disable_result_log
|
||||
--error ER_CANT_CREATE_TABLE
|
||||
ALTER TABLE child ADD FOREIGN KEY(parent_id) REFERENCES parent(id) ;
|
||||
|
||||
# --error ER_CANNOT_ADD_FOREIGN
|
||||
--error ER_CANT_CREATE_TABLE
|
||||
ALTER TABLE child ADD FOREIGN KEY(parent_id) REFERENCES parent(id) ON DELETE CASCADE ;
|
||||
--enable_result_log
|
||||
|
||||
#cleanup
|
||||
DROP table child,parent;
|
||||
|
||||
# Check Foreign Key constraint on Geometry column
|
||||
CREATE TABLE parent (id GEOMETRY, PRIMARY KEY(id(10))) ENGINE=InnoDB;
|
||||
|
||||
CREATE TABLE child (id GEOMETRY NOT NULL, parent_id GEOMETRY NOT NULL) ENGINE=InnoDB;
|
||||
|
||||
ALTER TABLE parent ADD SPATIAL INDEX idx1(id ASC) ;
|
||||
|
||||
ALTER TABLE child ADD SPATIAL INDEX idx2(parent_id ASC);
|
||||
|
||||
SHOW CREATE TABLE parent;
|
||||
|
||||
SHOW CREATE TABLE child;
|
||||
|
||||
SHOW INDEX FROM parent;
|
||||
|
||||
SHOW INDEX FROM child;
|
||||
|
||||
--disable_result_log
|
||||
# --error ER_BLOB_KEY_WITHOUT_LENGTH
|
||||
--error ER_CANT_CREATE_TABLE
|
||||
ALTER TABLE child ADD FOREIGN KEY(parent_id) REFERENCES parent(id) ;
|
||||
--enable_result_log
|
||||
|
||||
#cleanup
|
||||
DROP table child,parent;
|
||||
|
||||
# Check add spatial index when table already has rows (inplace).
|
||||
create table t1 (c1 int) engine=innodb;
|
||||
insert into t1 values(NULL);
|
||||
|
||||
# Add spatial index fail, since geometry column can't be null.
|
||||
--error ER_SPATIAL_CANT_HAVE_NULL
|
||||
alter table t1 add b geometry, add spatial index(b), algorithm=inplace;
|
||||
|
||||
# Add spatial index fail, since there's invalid geo data.
|
||||
# The case has to be commented because it no longer fails and following cases
|
||||
# don't expect the effect of such a statement.
|
||||
#--error ER_CANT_CREATE_GEOMETRY_OBJECT
|
||||
# alter table t1 add b geometry not null, add spatial index(b), algorithm=inplace;
|
||||
|
||||
# Add a geometry column.
|
||||
alter table t1 add b geometry, algorithm=inplace;
|
||||
|
||||
# Add spatial index fail, since there's a NULL or invalid geo data.
|
||||
# The case has to be commented because it no longer fails and following cases
|
||||
# don't expect the effect of such a statement.
|
||||
#--error ER_CANT_CREATE_GEOMETRY_OBJECT
|
||||
#alter table t1 add spatial index(b), algorithm=inplace;
|
||||
|
||||
# Update invalide geo data to point(0 0).
|
||||
update t1 set b = st_geomfromtext('point(0 0)');
|
||||
|
||||
# Add spatial index success.
|
||||
--error ER_SPATIAL_CANT_HAVE_NULL
|
||||
alter table t1 add spatial index(b), algorithm=inplace;
|
||||
|
||||
# Delete rows.
|
||||
delete from t1;
|
||||
|
||||
#cleanup
|
||||
DROP table t1;
|
||||
|
||||
# Check add spatial index when table already has rows (copy).
|
||||
create table t1 (c1 int) engine=innodb;
|
||||
insert into t1 values(NULL);
|
||||
|
||||
# Add spatial index fail, since geometry column can't be null.
|
||||
--error ER_SPATIAL_CANT_HAVE_NULL
|
||||
alter table t1 add b geometry, add spatial index(b), algorithm=copy;
|
||||
|
||||
# Add spatial index fail, since there's a NULL or invalid geo data.
|
||||
# --error ER_INVALID_USE_OF_NULL
|
||||
--error ER_CANT_CREATE_GEOMETRY_OBJECT
|
||||
alter table t1 add b geometry not null, add spatial index(b), algorithm=copy;
|
||||
|
||||
# Add a geometry column.
|
||||
# --error ER_INVALID_USE_OF_NULL
|
||||
# alter table t1 add b geometry not null, algorithm=copy;
|
||||
|
||||
# Add spatial index.
|
||||
# The case has to be commented because it no longer fails and following cases
|
||||
# don't expect the effect of such a statement.
|
||||
#--error ER_CANT_CREATE_GEOMETRY_OBJECT
|
||||
#alter table t1 add spatial index(b), algorithm=copy;
|
||||
|
||||
# Update invalide geo data to point(0 0).
|
||||
--error ER_BAD_FIELD_ERROR
|
||||
update t1 set b = st_geomfromtext('point(0 0)');
|
||||
|
||||
# Add spatial index success.
|
||||
--error ER_KEY_COLUMN_DOES_NOT_EXITS
|
||||
alter table t1 add spatial index(b), algorithm=copy;
|
||||
|
||||
# Delete rows.
|
||||
delete from t1;
|
||||
|
||||
#cleanup
|
||||
DROP table t1;
|
||||
|
||||
--echo #
|
||||
--echo # BUG#20111575 ALTER TABLE...ADD SPATIAL INDEX...LOCK NONE IS REFUSED
|
||||
--echo # WITHOUT STATING A REASON
|
||||
--echo #
|
||||
CREATE TABLE t1(p point NOT NULL) ENGINE=innodb;
|
||||
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
|
||||
ALTER TABLE t1 ADD SPATIAL INDEX(p), LOCK=NONE;
|
||||
ALTER TABLE t1 ADD SPATIAL INDEX(p);
|
||||
--error ER_ALTER_OPERATION_NOT_SUPPORTED_REASON
|
||||
ALTER TABLE t1 FORCE, LOCK=NONE;
|
||||
DROP TABLE t1;
|
27
mysql-test/suite/innodb_gis/t/check_rtree.test
Normal file
27
mysql-test/suite/innodb_gis/t/check_rtree.test
Normal file
@ -0,0 +1,27 @@
|
||||
# This test case will test checking R-tree features.
|
||||
|
||||
# Not supported in embedded
|
||||
--source include/not_embedded.inc
|
||||
--source include/have_debug.inc
|
||||
--source include/have_innodb.inc
|
||||
|
||||
# Create table with R-tree index.
|
||||
create table t1 (i int, g geometry not null, spatial index (g))engine=innodb;
|
||||
|
||||
# Turn on the geometry data print.
|
||||
SET SESSION debug="+d,rtree_test_check_count";
|
||||
|
||||
# Insert values.
|
||||
insert into t1 values (1, POINT(1,1));
|
||||
insert into t1 values (1, POINT(1.5,1.5));
|
||||
insert into t1 values (1, POINT(3,3));
|
||||
insert into t1 values (1, POINT(3.1,3.1));
|
||||
insert into t1 values (1, POINT(5,5));
|
||||
|
||||
CALL mtr.add_suppression("InnoDB: Flagged corruption of `g` in table `test`.`t1` in CHECK TABLE; Wrong count");
|
||||
|
||||
# Select by R-tree index.
|
||||
check table t1;
|
||||
|
||||
# Cleanup.
|
||||
drop table t1;
|
1175
mysql-test/suite/innodb_gis/t/create_spatial_index.test
Normal file
1175
mysql-test/suite/innodb_gis/t/create_spatial_index.test
Normal file
File diff suppressed because it is too large
Load Diff
1444
mysql-test/suite/innodb_gis/t/gis.test
Normal file
1444
mysql-test/suite/innodb_gis/t/gis.test
Normal file
File diff suppressed because it is too large
Load Diff
144
mysql-test/suite/innodb_gis/t/precise.test
Normal file
144
mysql-test/suite/innodb_gis/t/precise.test
Normal file
@ -0,0 +1,144 @@
|
||||
-- source include/have_innodb.inc
|
||||
-- source include/have_geometry.inc
|
||||
|
||||
|
||||
#
|
||||
# Spatial objects
|
||||
#
|
||||
|
||||
--disable_warnings
|
||||
DROP TABLE IF EXISTS t1;
|
||||
--enable_warnings
|
||||
|
||||
select 1, ST_Intersects(ST_GeomFromText('POLYGON((0 0,20 0,20 20,0 20,0 0))'), ST_GeomFromText('POLYGON((10 10,30 10,30 30,10 30,10 10))'));
|
||||
select 0, ST_Intersects(ST_GeomFromText('POLYGON((0 0,20 10,10 30, 0 0))'), ST_GeomFromText('POLYGON((10 40, 40 50, 20 70, 10 40))'));
|
||||
select 1, ST_Intersects(ST_GeomFromText('POLYGON((0 0,20 10,10 30, 0 0))'), ST_GeomFromText('POINT(10 10)'));
|
||||
select 1, ST_Intersects(ST_GeomFromText('POLYGON((0 0,20 10,10 30, 0 0))'), ST_GeomFromText('POLYGON((10 10,30 20,20 40, 10 10))'));
|
||||
select 0, ST_Within(ST_GeomFromText('POLYGON((0 0,20 10,10 30, 0 0))'), ST_GeomFromText('POLYGON((10 10,30 20,20 40, 10 10))'));
|
||||
select 1, ST_Within(ST_GeomFromText('POLYGON((1 1,20 10,10 30, 1 1))'), ST_GeomFromText('POLYGON((0 0,30 5,10 40, 0 0))'));
|
||||
|
||||
|
||||
create table t1 (g point)engine=innodb;
|
||||
insert into t1 values
|
||||
(ST_GeomFromText('POINT(2 2)')), (ST_GeomFromText('POINT(2 4)')), (ST_GeomFromText('POINT(2 6)')), (ST_GeomFromText('POINT(2 8)')),
|
||||
(ST_GeomFromText('POINT(4 2)')), (ST_GeomFromText('POINT(4 4)')), (ST_GeomFromText('POINT(4 6)')), (ST_GeomFromText('POINT(4 8)')),
|
||||
(ST_GeomFromText('POINT(6 2)')), (ST_GeomFromText('POINT(6 4)')), (ST_GeomFromText('POINT(6 6)')), (ST_GeomFromText('POINT(6 8)')),
|
||||
(ST_GeomFromText('POINT(8 2)')), (ST_GeomFromText('POINT(8 4)')), (ST_GeomFromText('POINT(8 6)')), (ST_GeomFromText('POINT(8 8)'));
|
||||
|
||||
select ST_astext(g) from t1 where ST_Within(g, ST_GeomFromText('POLYGON((5 1, 7 1, 7 7, 5 7, 3 3, 5 3, 5 1))'));
|
||||
select 'Contains';
|
||||
select ST_astext(g) from t1 where ST_Contains(ST_GeomFromText('POLYGON((5 1, 7 1, 7 7, 5 7, 3 3, 5 3, 5 1))'), g);
|
||||
select 'Intersects';
|
||||
select ST_astext(g) from t1 where ST_Intersects(ST_GeomFromText('POLYGON((5 1, 7 1, 7 7, 5 7, 3 3, 5 3, 5 1))'), g);
|
||||
select 'Contains';
|
||||
select ST_astext(g) from t1 where ST_Contains(ST_GeomFromText('POLYGON((5 1, 7 1, 7 7, 5 7, 3 3, 5 3, 5 1))'), g);
|
||||
select 'Contains2';
|
||||
select ST_astext(g) from t1 where ST_Contains(ST_GeomFromText('POLYGON((5 1, 7 1, 7 7, 5 7, 3 3, 5 3, 5 1), (5.01 3.01, 6 5, 9 5, 8 3, 5.01 3.01))'), g);
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
select 0, ST_Within(ST_GeomFromText('LINESTRING(15 15, 50 50, 60 60)'), ST_GeomFromText('POLYGON((10 10,30 20,20 40, 10 10))'));
|
||||
select 1, ST_Within(ST_GeomFromText('LINESTRING(15 15, 16 16)'), ST_GeomFromText('POLYGON((10 10,30 20,20 40, 10 10))'));
|
||||
|
||||
|
||||
select 1, ST_Intersects(ST_GeomFromText('LINESTRING(15 15, 50 50)'), ST_GeomFromText('LINESTRING(50 15, 15 50)'));
|
||||
select 1, ST_Intersects(ST_GeomFromText('LINESTRING(15 15, 50 50)'), ST_GeomFromText('LINESTRING(16 16, 51 51)'));
|
||||
|
||||
select 1, ST_Intersects(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('POLYGON((50 5, 55 10, 0 45, 50 5))'));
|
||||
|
||||
select ST_astext(ST_Union(ST_geometryfromtext('point(1 1)'), ST_geometryfromtext('polygon((0 0, 2 0, 1 2, 0 0))')));
|
||||
select ST_astext(ST_Intersection(ST_geometryfromtext('point(1 1)'), ST_geometryfromtext('polygon((0 0, 2 0, 1 2, 0 0))')));
|
||||
|
||||
select ST_Intersects(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('POLYGON((50 5, 55 10, 0 45, 50 5))'));
|
||||
select ST_contains(ST_GeomFromText('MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)), ((6 6, 6 11, 11 11, 11 6, 6 6)))'), ST_GeomFromText('POINT(5 10)'));
|
||||
select ST_Disjoint(ST_GeomFromText('POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))'), ST_GeomFromText('POLYGON((10 10, 10 15, 15 15, 15 10, 10 10))'));
|
||||
select ST_Disjoint(ST_GeomFromText('POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))'), ST_GeomFromText('POLYGON((10 10, 10 4, 4 4, 4 10, 10 10))'));
|
||||
select ST_Overlaps(ST_GeomFromText('POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))'), ST_GeomFromText('POLYGON((10 10, 10 4, 4 4, 4 10, 10 10))'));
|
||||
select ST_Overlaps(ST_GeomFromText('POLYGON((0 0, 0 5, 5 5, 5 0, 0 0))'), ST_GeomFromText('POLYGON((1 1, 1 4, 4 4, 4 1, 1 1))'));
|
||||
|
||||
# Distance tests
|
||||
select ST_DISTANCE(ST_geomfromtext('polygon((0 0, 1 2, 2 1, 0 0))'), ST_geomfromtext('polygon((2 2, 3 4, 4 3, 2 2))'));
|
||||
select ST_DISTANCE(ST_geomfromtext('polygon((0 0, 1 2, 2 1, 0 0))'), ST_geomfromtext('linestring(0 1, 1 0)'));
|
||||
select ST_DISTANCE(ST_geomfromtext('polygon((0 0, 3 6, 6 3, 0 0))'), ST_geomfromtext('polygon((2 2, 3 4, 4 3, 2 2))'));
|
||||
select ST_DISTANCE(ST_geomfromtext('polygon((0 0, 3 6, 6 3, 0 0),(2 2, 3 4, 4 3, 2 2))'), ST_geomfromtext('point(3 3)'));
|
||||
select ST_DISTANCE(ST_geomfromtext('linestring(0 0, 3 6, 6 3, 0 0)'), ST_geomfromtext('polygon((2 2, 3 4, 4 3, 2 2))'));
|
||||
|
||||
|
||||
# Operations tests
|
||||
--replace_result 23.85542168674699 23.855421686746986
|
||||
select ST_astext(ST_Intersection(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('POLYGON((50 5, 55 10, 0 45, 50 5))')));
|
||||
--replace_result 23.85542168674699 23.855421686746986
|
||||
select ST_astext(ST_Intersection(ST_GeomFromText('LINESTRING(0 0, 50 45, 40 50, 0 0)'), ST_GeomFromText('LINESTRING(50 5, 55 10, 0 45, 50 5)')));
|
||||
select ST_astext(ST_Intersection(ST_GeomFromText('LINESTRING(0 0, 50 45, 40 50)'), ST_GeomFromText('LINESTRING(50 5, 55 10, 0 45)')));
|
||||
select ST_astext(ST_Intersection(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('POINT(20 20)')));
|
||||
select ST_astext(ST_Intersection(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('LINESTRING(-10 -10, 200 200)')));
|
||||
select ST_astext(ST_Intersection(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('LINESTRING(-10 -10, 200 200, 199 201, -11 -9)')));
|
||||
select ST_astext(ST_UNION(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('LINESTRING(-10 -10, 200 200, 199 201, -11 -9)')));
|
||||
|
||||
select ST_astext(ST_intersection(ST_geomfromtext('polygon((0 0, 1 0, 0 1, 0 0))'), ST_geomfromtext('polygon((0 0, 1 1, 0 2, 0 0))')));
|
||||
|
||||
select ST_astext(ST_symdifference(ST_geomfromtext('polygon((0 0, 1 0, 0 1, 0 0))'), ST_geomfromtext('polygon((0 0, 1 1, 0 2, 0 0))')));
|
||||
select ST_astext(ST_UNION(ST_GeomFromText('POLYGON((0 0, 50 45, 40 50, 0 0))'), ST_GeomFromText('LINESTRING(-10 -10, 200 200, 199 201, -11 -9)')));
|
||||
|
||||
# Buffer() tests
|
||||
--replace_regex /([0-9]+\.[0-9]{4})[0-9]*/\1/
|
||||
select ST_astext(ST_buffer(ST_geometryfromtext('point(1 1)'), 1));
|
||||
create table t1(geom geometrycollection)engine=innodb;
|
||||
# --error ER_CANT_CREATE_GEOMETRY_OBJECT
|
||||
# insert into t1 values (ST_geomfromtext('POLYGON((0 0, 10 10, 0 8, 0 0))'));
|
||||
# --error ER_CANT_CREATE_GEOMETRY_OBJECT
|
||||
# insert into t1 values (ST_geomfromtext('POLYGON((1 1, 10 10, 0 8, 1 1))'));
|
||||
--replace_regex /([0-9]+\.[0-9]{4})[0-9]*/\1/
|
||||
select ST_astext(geom), ST_area(geom),ST_area(ST_buffer(geom,2)) from t1;
|
||||
select ST_NUMPOINTS(ST_EXTERIORRING(ST_buffer(geom,2))) from t1;
|
||||
|
||||
set @geom=ST_geomfromtext('LINESTRING(2 1, 4 2, 2 3, 2 5)');
|
||||
set @buff=ST_buffer(@geom,1);
|
||||
select ST_NUMPOINTS(ST_EXTERIORRING(@buff)) from t1;
|
||||
|
||||
# cleanup
|
||||
DROP TABLE t1;
|
||||
|
||||
#ST_Touches tests
|
||||
select st_touches(ST_geomfromtext('point(0 0)'), ST_geomfromtext('point(1 1)'));
|
||||
select st_touches(ST_geomfromtext('point(1 1)'), ST_geomfromtext('point(1 1)'));
|
||||
select st_touches(ST_geomfromtext('polygon((0 0, 2 2, 0 4, 0 0))'), ST_geomfromtext('point(1 1)'));
|
||||
select st_touches(ST_geomfromtext('polygon((0 0, 2 2, 0 4, 0 0))'), ST_geomfromtext('point(1 0)'));
|
||||
select st_touches(ST_geomfromtext('polygon((0 0, 2 2, 0 4, 0 0))'), ST_geomfromtext('point(1 2)'));
|
||||
select st_touches(ST_geomfromtext('polygon((0 0, 2 2, 0 4, 0 0))'), ST_geomfromtext('polygon((1 1.2, 1 0, 2 0, 1 1.2))'));
|
||||
select st_touches(ST_geomfromtext('polygon((0 0, 2 2, 0 4, 0 0))'), ST_geomfromtext('polygon((1 1, 1 0, 2 0, 1 1))'));
|
||||
|
||||
#Equals test
|
||||
SELECT ST_Equals(ST_PolyFromText('POLYGON((67 13, 67 18, 67 18, 59 18, 59 13, 67 13) )'),ST_PolyFromText('POLYGON((67 13, 67 18, 59 19, 59 13, 59 13, 67 13) )')) as result;
|
||||
SELECT ST_Equals(ST_PolyFromText('POLYGON((67 13, 67 18, 67 18, 59 18, 59 13, 67 13) )'),ST_PolyFromText('POLYGON((67 13, 67 18, 59 18, 59 13, 59 13, 67 13) )')) as result;
|
||||
SELECT ST_Equals(ST_PointFromText('POINT (12 13)'),ST_PointFromText('POINT (12 13)')) as result;
|
||||
|
||||
|
||||
--echo #
|
||||
--echo # BUG#11755628/47429: INTERSECTION FUNCTION CRASHED MYSQLD
|
||||
--echo # BUG#11759650/51979: UNION/INTERSECTION OF POLYGONS CRASHES MYSQL
|
||||
--echo #
|
||||
|
||||
# --error ER_GIS_INVALID_DATA
|
||||
SELECT ST_ASTEXT(ST_UNION(ST_GEOMFROMTEXT('POLYGON((525000 183300,525400
|
||||
183300,525400 18370, 525000 183700,525000 183300))'),
|
||||
ST_geomfromtext('POLYGON((525298.67 183511.53,525296.57
|
||||
183510.39,525296.42 183510.31,525289.11 183506.62,525283.17
|
||||
183503.47,525280.98 183502.26,525278.63 183500.97,525278.39
|
||||
183500.84,525276.79 183500,525260.7 183491.55,525263.95
|
||||
183484.75,525265.58 183481.95,525278.97 183488.73,525276.5
|
||||
183493.45,525275.5 183495.7,525280.35 183498.2,525282.3
|
||||
183499.1,525282.2 183499.3,525283.55 183500,525301.75
|
||||
183509.35,525304.45 183504.25,525307.85 183504.95,525304.5
|
||||
183510.83,525302.81 183513.8,525298.67 183511.53),(525275.06
|
||||
183489.89,525272.06 183488.37,525268.94 183494.51,525271.94
|
||||
183496.03,525275.06 183489.89),(525263.26 183491.55,525266.15
|
||||
183493.04,525269.88 183485.82,525266.99 183484.33,525263.26
|
||||
183491.55))'))) st_u;
|
||||
|
||||
SET @a=0x0000000001030000000200000005000000000000000000000000000000000000000000000000002440000000000000000000000000000024400000000000002440000000000000000000000000000024400000000000000000000000000000000000000000000000000000F03F000000000000F03F0000000000000040000000000000F03F00000000000000400000000000000040000000000000F03F0000000000000040000000000000F03F000000000000F03F;
|
||||
# --error ER_GIS_INVALID_DATA
|
||||
SELECT ST_ASTEXT(ST_TOUCHES(@a, ST_GEOMFROMTEXT('point(0 0)'))) t;
|
||||
|
||||
|
||||
--source include/gis_debug.inc
|
74
mysql-test/suite/innodb_gis/t/rt_precise.test
Normal file
74
mysql-test/suite/innodb_gis/t/rt_precise.test
Normal file
@ -0,0 +1,74 @@
|
||||
#*****************************************************************
|
||||
# This was a Myisam testcase, converted to InnoDB
|
||||
# Since Innodb does not support the spatial key, hence converted
|
||||
# Orginal name of the testcase : gis_rt_precise.test
|
||||
#*****************************************************************
|
||||
--source include/have_innodb.inc
|
||||
-- source include/have_geometry.inc
|
||||
SET default_storage_engine=InnoDB;
|
||||
|
||||
#
|
||||
# test of rtree (using with spatial data)
|
||||
#
|
||||
--disable_warnings
|
||||
DROP TABLE IF EXISTS t1;
|
||||
--enable_warnings
|
||||
|
||||
CREATE TABLE t1 (
|
||||
fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
g GEOMETRY NOT NULL,
|
||||
KEY gis_key(g(5))
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
SHOW CREATE TABLE t1;
|
||||
|
||||
--disable_query_log
|
||||
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;
|
||||
}
|
||||
--enable_query_log
|
||||
|
||||
SELECT count(*) FROM t1;
|
||||
|
||||
ANALYZE TABLE t1;
|
||||
|
||||
--replace_column 10 #
|
||||
EXPLAIN SELECT fid, ST_AsText(g) FROM t1 WHERE ST_Within(g, ST_GeomFromText('Polygon((140 140,160 140,160 160,140 140))'));
|
||||
SELECT fid, ST_AsText(g) FROM t1 WHERE ST_Within(g, ST_GeomFromText('Polygon((140 140,160 140,160 160,140 160,140 140))')) ORDER BY fid;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
CREATE TABLE t1 (
|
||||
fid INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
||||
g GEOMETRY NOT NULL
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
--disable_query_log
|
||||
let $1=10;
|
||||
while ($1)
|
||||
{
|
||||
let $2=10;
|
||||
while ($2)
|
||||
{
|
||||
eval INSERT INTO t1 (g) VALUES (LineString(Point($1 * 10 - 9, $2 * 10 - 9), Point($1 * 10, $2 * 10)));
|
||||
dec $2;
|
||||
}
|
||||
dec $1;
|
||||
}
|
||||
--enable_query_log
|
||||
|
||||
#--error 1464
|
||||
ALTER TABLE t1 ADD SPATIAL KEY(g);
|
||||
SHOW CREATE TABLE t1;
|
||||
SELECT count(*) FROM t1;
|
||||
SELECT fid, ST_AsText(g) FROM t1 WHERE ST_Within(g,
|
||||
ST_GeomFromText('Polygon((40 40,60 40,60 60,40 40))')) ORDER BY fid;
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
--echo End of 5.5 tests.
|
236
mysql-test/suite/innodb_gis/t/rtree.test
Normal file
236
mysql-test/suite/innodb_gis/t/rtree.test
Normal file
@ -0,0 +1,236 @@
|
||||
# WL#6745 InnoDB R-tree support
|
||||
# This test case will test basic R-tree support features.
|
||||
|
||||
# Not supported in embedded
|
||||
--source include/not_embedded.inc
|
||||
|
||||
--source include/have_innodb.inc
|
||||
|
||||
# Create table with R-tree index.
|
||||
create table t1 (i int, g geometry not null, spatial index (g))engine=innodb;
|
||||
|
||||
# Insert values.
|
||||
insert into t1 values (1, POINT(1,1));
|
||||
insert into t1 values (1, POINT(1.5,1.5));
|
||||
insert into t1 values (1, POINT(3,3));
|
||||
insert into t1 values (1, POINT(3.1,3.1));
|
||||
insert into t1 values (1, 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 add primary key(i);
|
||||
alter table t1 drop primary key;
|
||||
|
||||
# create spatial index idx on t1(g) algorithm=inplace;
|
||||
create spatial index idx on t1(g);
|
||||
|
||||
create spatial index idx2 on t1(g);
|
||||
|
||||
# alter table t1 add primary key(i), algorithm=inplace;
|
||||
alter table t1 add primary key(i);
|
||||
|
||||
show create table t1;
|
||||
|
||||
drop index idx on t1;
|
||||
|
||||
drop table t1;
|
||||
|
||||
#Test multi pk table.
|
||||
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;
|
||||
|
||||
CREATE TABLE `t1` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`way` geometry NOT NULL,
|
||||
PRIMARY KEY (`id`),
|
||||
SPATIAL KEY `way` (`way`)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(1 1)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(1 2)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(1 3)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(1 4)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(1 5)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(2 1)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(2 2)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(2 3)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(2 4)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(2 5)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(3 1)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(3 2)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(3 3)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(3 4)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(3 5)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(4 1)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(4 2)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(4 3)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(4 4)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(4 5)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(5 1)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(5 2)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(5 3)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(5 4)');
|
||||
INSERT INTO t1 SET way = ST_GeomFromText('POINT(5 5)');
|
||||
|
||||
SELECT COUNT(*)
|
||||
FROM t1
|
||||
WHERE ST_CONTAINS(ST_GeomFromText('POLYGON((2 2,4 2, 4 4, 2 4, 2 2))'),way);
|
||||
|
||||
OPTIMIZE TABLE t1;
|
||||
|
||||
SELECT COUNT(*)
|
||||
FROM t1
|
||||
WHERE ST_CONTAINS(ST_GeomFromText('POLYGON((2 2,4 2, 4 4, 2 4, 2 2))'),way);
|
||||
|
||||
|
||||
DROP TABLE t1;
|
||||
|
||||
# Check the update with unchanged MBR optimization.
|
||||
# Create table with R-tree index.
|
||||
CREATE TABLE t1( i INT, g GEOMETRY NOT NULL, SPATIAL INDEX (g)) ENGINE=InnoDB;
|
||||
|
||||
# Insert values.
|
||||
INSERT INTO t1 VALUES(1, LINESTRING(POINT(1,1), POINT(4, 4)));
|
||||
INSERT INTO t1 VALUES(2, LINESTRING(POINT(2,2), POINT(5, 5)));
|
||||
|
||||
# Update value.
|
||||
UPDATE t1 SET g = LINESTRING(POINT(1,1), POINT(2,2), POINT(3,3), POINT(4,4))
|
||||
WHERE i = 1;
|
||||
UPDATE t1 SET g = LINESTRING(POINT(1,1), POINT(2,2), POINT(3,3), POINT(8,8))
|
||||
WHERE i = 2;
|
||||
|
||||
|
||||
CHECK TABLE t1;
|
||||
|
||||
DELETE FROM t1
|
||||
WHERE ST_CONTAINS(ST_GeomFromText('POLYGON((0 0,4 0, 4 4, 0 4, 0 0))'),g);
|
||||
|
||||
DROP TABLE t1;
|
@ -6655,6 +6655,7 @@ static Native_func_registry func_array[] =
|
||||
{ { C_STRING_WITH_LEN("MBRCONTAINS") }, GEOM_BUILDER(Create_func_mbr_contains)},
|
||||
{ { C_STRING_WITH_LEN("MBRDISJOINT") }, GEOM_BUILDER(Create_func_mbr_disjoint)},
|
||||
{ { C_STRING_WITH_LEN("MBREQUAL") }, GEOM_BUILDER(Create_func_mbr_equals)},
|
||||
{ { C_STRING_WITH_LEN("MBREQUALS") }, GEOM_BUILDER(Create_func_mbr_equals)},
|
||||
{ { C_STRING_WITH_LEN("MBRINTERSECTS") }, GEOM_BUILDER(Create_func_mbr_intersects)},
|
||||
{ { C_STRING_WITH_LEN("MBROVERLAPS") }, GEOM_BUILDER(Create_func_mbr_overlaps)},
|
||||
{ { C_STRING_WITH_LEN("MBRTOUCHES") }, GEOM_BUILDER(Create_func_touches)},
|
||||
|
@ -63,6 +63,8 @@ fil_get_page_type_name(
|
||||
return (const char*)"PAGE_COMPRESSED";
|
||||
case FIL_PAGE_INDEX:
|
||||
return (const char*)"INDEX";
|
||||
case FIL_PAGE_RTREE:
|
||||
return (const char*)"RTREE";
|
||||
case FIL_PAGE_UNDO_LOG:
|
||||
return (const char*)"UNDO LOG";
|
||||
case FIL_PAGE_INODE:
|
||||
@ -130,6 +132,7 @@ fil_page_type_validate(
|
||||
if (!((page_type == FIL_PAGE_PAGE_COMPRESSED ||
|
||||
page_type == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED ||
|
||||
page_type == FIL_PAGE_INDEX ||
|
||||
page_type == FIL_PAGE_RTREE ||
|
||||
page_type == FIL_PAGE_UNDO_LOG ||
|
||||
page_type == FIL_PAGE_INODE ||
|
||||
page_type == FIL_PAGE_IBUF_FREE_LIST ||
|
||||
@ -169,6 +172,7 @@ fil_page_type_validate(
|
||||
ut_ad(page_type == FIL_PAGE_PAGE_COMPRESSED ||
|
||||
page_type == FIL_PAGE_PAGE_COMPRESSED_ENCRYPTED ||
|
||||
page_type == FIL_PAGE_INDEX ||
|
||||
page_type == FIL_PAGE_RTREE ||
|
||||
page_type == FIL_PAGE_UNDO_LOG ||
|
||||
page_type == FIL_PAGE_INODE ||
|
||||
page_type == FIL_PAGE_IBUF_FREE_LIST ||
|
||||
|
Reference in New Issue
Block a user