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)
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,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))')));
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.7071067811865476
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((21.951219512195124 27.4390243902439,26.470588235294116 23.823529411764707,29.28994082840237 26.36094674556213,23.85542168674699 29.819277108433734,21.951219512195124 27.4390243902439))
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((21.951219512195124 27.4390243902439),(23.85542168674699 29.819277108433734),(26.470588235294116 23.823529411764707),(29.28994082840237 26.36094674556213))
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.28994082840237 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),(45.333333333333336 47.333333333333336,8 10))
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(POLYGON((0 0,50 45,40 50,0 0)),MULTILINESTRING((-10 -10,0 0),(46.666666666666664 46.666666666666664,200 200,199 201,45.333333333333336 47.333333333333336),(8 10,-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))')));
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 1,0 0,0.5 0.5,0 1))
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.5 0.5,0 0,1 0,0.5 0.5)),((0 1,0.5 0.5,1 1,0 2,0 1)))
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(POLYGON((0 0,50 45,40 50,0 0)),MULTILINESTRING((-10 -10,0 0),(46.666666666666664 46.666666666666664,200 200,199 201,45.333333333333336 47.333333333333336),(8 10,-11 -9)))
select ST_astext(ST_buffer(ST_geometryfromtext('point(1 1)'), 1));
ST_astext(ST_buffer(ST_geometryfromtext('point(1 1)'), 1))
POLYGON((2 1,1.98078528040323 1.19509032201612,1.92387953251129 1.38268343236509,1.83146961230255 1.5555702330196,1.70710678118655 1.70710678118655,1.5555702330196 1.83146961230254,1.38268343236509 1.92387953251129,1.19509032201613 1.98078528040323,1 2,0.80490967798387 1.98078528040323,0.61731656763491 1.92387953251129,0.4444297669804 1.83146961230255,0.29289321881345 1.70710678118655,0.16853038769746 1.5555702330196,0.07612046748871 1.38268343236509,0.01921471959677 1.19509032201613,0 1,0.01921471959677 0.80490967798387,0.07612046748871 0.61731656763491,0.16853038769745 0.4444297669804,0.29289321881345 0.29289321881345,0.4444297669804 0.16853038769745,0.61731656763491 0.07612046748871,0.80490967798387 0.01921471959677,1 0,1.19509032201613 0.01921471959677,1.38268343236509 0.07612046748871,1.5555702330196 0.16853038769745,1.70710678118655 0.29289321881345,1.83146961230255 0.4444297669804,1.92387953251129 0.61731656763491,1.98078528040323 0.80490967798387,2 1))
create table t1(geom geometrycollection)engine=innodb;
insert into t1 values (ST_geomfromtext('POLYGON((0 0, 10 10, 0 8, 0 0))'));
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
insert into t1 values (ST_geomfromtext('POLYGON((1 1, 10 10, 0 8, 1 1))'));
ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
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;
ERROR 22023: Invalid GIS data provided to function st_union.
SET @a=0x0000000001030000000200000005000000000000000000000000000000000000000000000000002440000000000000000000000000000024400000000000002440000000000000000000000000000024400000000000000000000000000000000000000000000000000000F03F000000000000F03F0000000000000040000000000000F03F00000000000000400000000000000040000000000000F03F0000000000000040000000000000F03F000000000000F03F;
SELECT ST_ASTEXT(ST_TOUCHES(@a, ST_GEOMFROMTEXT('point(0 0)'))) t;
ERROR 22023: Invalid GIS data provided to function st_touches.
DROP TABLE IF EXISTS p1;
CREATE PROCEDURE p1(dist DOUBLE, geom TEXT)
BEGIN
DECLARE g GEOMETRY;
SET g=ST_GeomFromText(geom);
SELECT geom AS `-----`;
SELECT dist, ST_GeometryType(@buf:=ST_Buffer(g, dist)) AS `buffer`, ROUND(ST_AREA(@buf),2) AS buf_area;
END|
#
# Testing ST_BUFFER with positive distance
#
ERROR 22023: Invalid GIS data provided to function st_geometryfromtext.
-----
POINT(0 0)
dist	buffer	buf_area
1	POLYGON	3.12
ERROR 22023: Invalid GIS data provided to function st_geometryfromtext.
-----
LineString(0 1, 1 1)
dist	buffer	buf_area
1	POLYGON	5.12
-----
LineString(9 9,8 1,1 5,0 0)
dist	buffer	buf_area
1	POLYGON	44.60
-----
Polygon((2 2,2 8,8 8,8 2,2 2))
dist	buffer	buf_area
1	POLYGON	63.12
-----
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.12
-----
Polygon((0 0, 0 8, 8 8, 8 10, -10 10, -10 0, 0 0))
dist	buffer	buf_area
1	POLYGON	174.90
-----
MultiPoint(9 9,8 1,1 5)
dist	buffer	buf_area
1	MULTIPOLYGON	9.36
-----
MultiLineString((0 0,2 2))
dist	buffer	buf_area
1	POLYGON	8.78
-----
MultiLineString((0 0,2 2,0 4))
dist	buffer	buf_area
1	POLYGON	14.22
-----
MultiLineString((0 0,2 2),(0 2,2 0))
dist	buffer	buf_area
1	POLYGON	13.56
-----
MultiLineString((2 2,2 8,-2 8),(-6 -6, 6 6),(10 10, 14 14))
dist	buffer	buf_area
1	MULTIPOLYGON	70.01
-----
MultiLineString((0 0,0 1),(3 0,3 1))
dist	buffer	buf_area
1	MULTIPOLYGON	10.24
-----
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.16
-----
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.16
-----
GeometryCollection(Point(0 0))
dist	buffer	buf_area
1	POLYGON	3.12
ERROR 22023: Invalid GIS data provided to function st_geometryfromtext.
-----
GeometryCollection(LineString(0 0, 2 2))
dist	buffer	buf_area
1	POLYGON	8.78
ERROR 22023: Invalid GIS data provided to function st_geometryfromtext.
-----
GeometryCollection(Polygon((2 2,2 8,8 8,8 2,2 2)))
dist	buffer	buf_area
1	POLYGON	63.12
-----
GeometryCollection(MultiPoint(9 9,8 1,1 5))
dist	buffer	buf_area
1	MULTIPOLYGON	9.36
-----
GeometryCollection(MultiLineString((0 0,0 1),(3 0,3 1)))
dist	buffer	buf_area
1	MULTIPOLYGON	10.24
-----
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.24
-----
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.88
#
# Testing ST_BUFFER with zero distance
#
ERROR 22023: Invalid GIS data provided to function st_geometryfromtext.
-----
POINT(0 0)
dist	buffer	buf_area
0	POINT	0.00
ERROR 22023: Invalid GIS data provided to function st_geometryfromtext.
-----
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	0.00
-----
MultiLineString((0 0,2 2))
dist	buffer	buf_area
0	LINESTRING	0.00
-----
MultiLineString((0 0,2 2,0 4))
dist	buffer	buf_area
0	LINESTRING	0.00
-----
MultiLineString((0 0,2 2),(0 2,2 0))
dist	buffer	buf_area
0	MULTILINESTRING	0.00
-----
MultiLineString((2 2,2 8,-2 8),(-6 -6, 6 6),(10 10, 14 14))
dist	buffer	buf_area
0	MULTILINESTRING	0.00
-----
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	POINT	0.00
ERROR 22023: Invalid GIS data provided to function st_geometryfromtext.
-----
GeometryCollection(LineString(0 0, 2 2))
dist	buffer	buf_area
0	LINESTRING	0.00
ERROR 22023: Invalid GIS data provided to function st_geometryfromtext.
-----
GeometryCollection(Polygon((2 2,2 8,8 8,8 2,2 2)))
dist	buffer	buf_area
0	POLYGON	36.00
-----
GeometryCollection(MultiPoint(9 9,8 1,1 5))
dist	buffer	buf_area
0	MULTIPOINT	0.00
-----
GeometryCollection(MultiLineString((0 0,0 1),(3 0,3 1)))
dist	buffer	buf_area
0	MULTILINESTRING	0.00
-----
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	MULTIPOLYGON	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)
ERROR HY000: Incorrect arguments to st_buffer
-----
LineString(0 1, 1 1)
ERROR HY000: Incorrect arguments to st_buffer
-----
LineString(9 9,8 1,1 5,0 0)
ERROR HY000: Incorrect arguments to st_buffer
-----
Polygon((2 2,2 8,8 8,8 2,2 2))
dist	buffer	buf_area
-1	POLYGON	16.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
-1	MULTIPOLYGON	0.88
-----
Polygon((0 0, 0 8, 8 8, 8 10, -10 10, -10 0, 0 0))
dist	buffer	buf_area
-1	POLYGON	64.22
-----
MultiPoint(9 9,8 1,1 5)
ERROR HY000: Incorrect arguments to st_buffer
-----
MultiLineString((0 0,2 2))
ERROR HY000: Incorrect arguments to st_buffer
-----
MultiLineString((0 0,2 2,0 4))
ERROR HY000: Incorrect arguments to st_buffer
-----
MultiLineString((0 0,2 2),(0 2,2 0))
ERROR HY000: Incorrect arguments to st_buffer
-----
MultiLineString((2 2,2 8,-2 8),(-6 -6, 6 6),(10 10, 14 14))
ERROR HY000: Incorrect arguments to st_buffer
-----
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	8.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
-1	MULTIPOLYGON	0.30
-----
GeometryCollection(Point(0 0))
ERROR HY000: Incorrect arguments to st_buffer
-----
GeometryCollection(LineString(0 0, 2 2))
ERROR HY000: Incorrect arguments to st_buffer
ERROR 22023: Invalid GIS data provided to function st_geometryfromtext.
ERROR 22023: Invalid GIS data provided to function st_geometryfromtext.
-----
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))
ERROR HY000: Incorrect arguments to st_buffer
-----
GeometryCollection(MultiLineString((0 0,0 1),(3 0,3 1)))
ERROR HY000: Incorrect arguments to st_buffer
-----
GeometryCollection(Point(9 9),LineString(1 5,0 0),Polygon((2 2,2 8,8 8,8 2,2 2)))
ERROR HY000: Incorrect arguments to st_buffer
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_AsText(ST_UNION(
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_AsText(ST_UNION(
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)')))
GEOMETRYCOLLECTION(MULTIPOLYGON(((0 0,5 0,5 5,0 5,0 0)),((6 6,11 6,11 11,6 11,6 6))),POINT(5 10))
DROP PROCEDURE p1;
#
# Bug #13833019 ASSERTION `T1->RESULT_RANGE' FAILED IN GCALC_OPERATION_REDUCER::END_COUPLE
#
SELECT ST_GeometryType(ST_BUFFER(ST_MULTIPOLYGONFROMTEXT('MULTIPOLYGON(((0 0,9 4,3 3,0 0)),((2 2,2 2,8 8,2 3,2 2)))'), 3));
ST_GeometryType(ST_BUFFER(ST_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 ST_GeometryType(ST_BUFFER(ST_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));
ST_GeometryType(ST_BUFFER(ST_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)'),'');
SELECT ST_WITHIN(
ST_LINESTRINGFROMTEXT(' LINESTRING(3 8,9 2,3 8,3 3,7 6,4 7,4 7,8 1) '),
ST_BUFFER(ST_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(ST_POLYGONFROMTEXT('POLYGON((3 5,2 4,2 5,3 5)) '))));
ST_WITHIN(
ST_LINESTRINGFROMTEXT(' LINESTRING(3 8,9 2,3 8,3 3,7 6,4 7,4 7,8 1) '),
ST_BUFFER(ST_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(ST_POLYGONFROMTEXT(' POLYGON((3 5,2 5,2 4,3 4,3 5)) '),
ST_NUMINTERIORRINGS(ST_POLYGONFROMTEXT(' POLYGON((0 0,9 3,4 2,0 0))'))));
ST_DIMENSION(ST_BUFFER(ST_POLYGONFROMTEXT(' POLYGON((3 5,2 5,2 4,3 4,3 5)) '),
ST_NUMINTERIORRINGS(ST_POLYGONFROMTEXT(' POLYGON((0 0,9 3,4 2,0 0))'))))
2
SELECT ST_NUMINTERIORRINGS(
ST_ENVELOPE(ST_BUFFER(ST_MULTIPOLYGONFROMTEXT('MULTIPOLYGON(((3 5,2 5,2 4,3 4,3 5))) '),
ST_SRID(ST_MULTILINESTRINGFROMTEXT('MULTILINESTRING((2 2,4 2,1 2,2 4,2 2)) ')))));
ST_NUMINTERIORRINGS(
ST_ENVELOPE(ST_BUFFER(ST_MULTIPOLYGONFROMTEXT('MULTIPOLYGON(((3 5,2 5,2 4,3 4,3 5))) '),
ST_SRID(ST_MULTILINESTRINGFROMTEXT('MULTILINESTRING((2 2,4 2,1 2,2 4,2 2)) ')))))
0
SELECT ST_ASTEXT(ST_BUFFER(ST_POLYGONFROMTEXT(' POLYGON((9 9,5 2,4 5,9 9))'),
ST_SRID(ST_GEOMETRYFROMTEXT(' MULTIPOINT(8 4,5 0,7 8,6 9,3 4,7 3,5 5) '))));
ST_ASTEXT(ST_BUFFER(ST_POLYGONFROMTEXT(' POLYGON((9 9,5 2,4 5,9 9))'),
ST_SRID(ST_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))
#
# 18701868 CRASH IN MY_DECIMAL::SANITY_CHECK,
#          ORDER BY CAST (INVALID GIS FUNCTION RESULT)
#
CREATE TABLE t1 (a INT) engine=innodb;
INSERT INTO t1 VALUES (1);
SELECT * FROM t1 ORDER BY cast(st_distance(1,1) as DECIMAL);
a
1
DELETE FROM t1 ORDER BY cast(st_distance(1,1) as DECIMAL);
ERROR 22023: Invalid GIS data provided to function st_distance.
UPDATE t1 SET a=1 ORDER BY cast(st_distance(1,1) as DECIMAL);
ERROR 22023: Invalid GIS data provided to function st_distance.
DROP TABLE t1;
