1# 2# This is a shared file included from t/gis-precise.test and t/gis-debug.test 3# 4# - gis-precise.test is executed both in debug and production builds 5# and makes sure that the checked GIS functions return the expected results. 6# 7# - gis-debug.test is executed only in debug builds 8# (and is skipped in production builds). 9# gis-debug.test activates tracing of the internal GIS routines. 10# The trace log is printed to the client side warnings. 11# So gis-debug.test makes sure not only that the correct results are returned, 12# but also check *how* these results were generated - makes sure that 13# the internal GIS routines went through the expected data and code flow paths. 14# 15 16--disable_warnings 17DROP TABLE IF EXISTS p1; 18--enable_warnings 19 20DELIMITER |; 21CREATE PROCEDURE p1(dist DOUBLE, geom TEXT) 22BEGIN 23 DECLARE g GEOMETRY; 24 SET g=ST_GeomFromText(geom); 25 SELECT geom AS `-----`; 26 SELECT dist, ST_GeometryType(@buf:=ST_Buffer(g, dist)) AS `buffer`, ROUND(ST_AREA(@buf),2) AS buf_area; 27END| 28DELIMITER ;| 29 30--disable_query_log 31 32--echo # 33--echo # Testing ST_BUFFER with positive distance 34--echo # 35--error ER_GIS_INVALID_DATA 36CALL p1(1, 'POINT(0 0))'); 37CALL p1(1, 'POINT(0 0)'); 38--error ER_GIS_INVALID_DATA 39CALL p1(1, 'LineString(0 1, 1 1))'); 40CALL p1(1, 'LineString(0 1, 1 1)'); 41CALL p1(1, 'LineString(9 9,8 1,1 5,0 0)'); 42CALL p1(1, 'Polygon((2 2,2 8,8 8,8 2,2 2))'); 43CALL p1(1, 'Polygon((0 0,0 8,8 8,8 0,0 0),(2 2,6 2,6 6,2 6,2 2))'); 44CALL p1(1, 'Polygon((0 0, 0 8, 8 8, 8 10, -10 10, -10 0, 0 0))'); 45CALL p1(1, 'MultiPoint(9 9,8 1,1 5)'); 46CALL p1(1, 'MultiLineString((0 0,2 2))'); 47CALL p1(1, 'MultiLineString((0 0,2 2,0 4))'); 48CALL p1(1, 'MultiLineString((0 0,2 2),(0 2,2 0))'); 49CALL p1(1, 'MultiLineString((2 2,2 8,-2 8),(-6 -6, 6 6),(10 10, 14 14))'); 50CALL p1(1, 'MultiLineString((0 0,0 1),(3 0,3 1))'); 51CALL p1(1, 'MultiPolygon(((2 2,2 8,8 8,8 2,2 2)), ((9 9,8 1,1 5,9 9)))'); 52CALL p1(1, '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)))'); 53CALL p1(1, 'GeometryCollection(Point(0 0))'); 54--error ER_GIS_INVALID_DATA 55CALL p1(1, 'GeometryCollection(LineString(0 0, 2 2)))'); 56CALL p1(1, 'GeometryCollection(LineString(0 0, 2 2))'); 57--error ER_GIS_INVALID_DATA 58CALL p1(1, 'GeometryCollection(Polygon((2 2,2 8,8 8,8 2,2 2))))'); 59CALL p1(1, 'GeometryCollection(Polygon((2 2,2 8,8 8,8 2,2 2)))'); 60CALL p1(1, 'GeometryCollection(MultiPoint(9 9,8 1,1 5))'); 61CALL p1(1, 'GeometryCollection(MultiLineString((0 0,0 1),(3 0,3 1)))'); 62CALL p1(1, 'GeometryCollection(MultiPolygon(((0 0, 3 0, 3 3, 0 3, 0 0)),((6 6,6 9,9 9,9 6,6 6))))'); 63CALL p1(1, 'GeometryCollection(Point(9 9),LineString(1 5,0 0),Polygon((2 2,2 8,8 8,8 2,2 2)))'); 64 65 66--echo # 67--echo # Testing ST_BUFFER with zero distance 68--echo # 69 70--error ER_GIS_INVALID_DATA 71CALL p1(0, 'POINT(0 0))'); 72CALL p1(0, 'POINT(0 0)'); 73--error ER_GIS_INVALID_DATA 74CALL p1(0, 'LineString(0 1, 1 1))'); 75CALL p1(0, 'LineString(0 1, 1 1)'); 76CALL p1(0, 'LineString(9 9,8 1,1 5,0 0)'); 77CALL p1(0, 'Polygon((2 2,2 8,8 8,8 2,2 2))'); 78CALL p1(0, 'Polygon((0 0,0 8,8 8,8 0,0 0),(2 2,6 2,6 6,2 6,2 2))'); 79CALL p1(0, 'Polygon((0 0, 0 8, 8 8, 8 10, -10 10, -10 0, 0 0))'); 80CALL p1(0, 'MultiPoint(9 9,8 1,1 5)'); 81CALL p1(0, 'MultiLineString((0 0,2 2))'); 82CALL p1(0, 'MultiLineString((0 0,2 2,0 4))'); 83CALL p1(0, 'MultiLineString((0 0,2 2),(0 2,2 0))'); 84CALL p1(0, 'MultiLineString((2 2,2 8,-2 8),(-6 -6, 6 6),(10 10, 14 14))'); 85CALL p1(0, 'MultiPolygon(((2 2,2 8,8 8,8 2,2 2)), ((9 9,8 1,1 5,9 9)))'); 86CALL p1(0, '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)))'); 87CALL p1(0, 'GeometryCollection(Point(0 0))'); 88--error ER_GIS_INVALID_DATA 89CALL p1(0, 'GeometryCollection(LineString(0 0, 2 2)))'); 90CALL p1(0, 'GeometryCollection(LineString(0 0, 2 2))'); 91--error ER_GIS_INVALID_DATA 92CALL p1(0, 'GeometryCollection(Polygon((2 2,2 8,8 8,8 2,2 2))))'); 93CALL p1(0, 'GeometryCollection(Polygon((2 2,2 8,8 8,8 2,2 2)))'); 94CALL p1(0, 'GeometryCollection(MultiPoint(9 9,8 1,1 5))'); 95CALL p1(0, 'GeometryCollection(MultiLineString((0 0,0 1),(3 0,3 1)))'); 96CALL p1(0, 'GeometryCollection(MultiPolygon(((0 0, 3 0, 3 3, 0 3, 0 0)),((6 6,6 9,9 9,9 6,6 6))))'); 97CALL p1(0, 'GeometryCollection(Point(9 9),LineString(1 5,0 0),Polygon((2 2,2 8,8 8,8 2,2 2)))'); 98 99 100--echo # 101--echo # Testing ST_BUFFER with negative distance 102--echo # 103 104--error ER_WRONG_ARGUMENTS 105CALL p1(-1, 'POINT(0 0)'); 106--error ER_WRONG_ARGUMENTS 107CALL p1(-1, 'LineString(0 1, 1 1)'); 108--error ER_WRONG_ARGUMENTS 109CALL p1(-1, 'LineString(9 9,8 1,1 5,0 0)'); 110CALL p1(-1, 'Polygon((2 2,2 8,8 8,8 2,2 2))'); 111# 112# Wrong shape 113CALL p1(-1, 'Polygon((0 0,0 8,8 8,8 0,0 0),(2 2,6 2,6 6,2 6,2 2))'); 114# Wrong shape 115CALL p1(-1, 'Polygon((0 0, 0 8, 8 8, 8 10, -10 10, -10 0, 0 0))'); 116# 117--error ER_WRONG_ARGUMENTS 118CALL p1(-1, 'MultiPoint(9 9,8 1,1 5)'); 119--error ER_WRONG_ARGUMENTS 120CALL p1(-1, 'MultiLineString((0 0,2 2))'); 121--error ER_WRONG_ARGUMENTS 122CALL p1(-1, 'MultiLineString((0 0,2 2,0 4))'); 123--error ER_WRONG_ARGUMENTS 124CALL p1(-1, 'MultiLineString((0 0,2 2),(0 2,2 0))'); 125--error ER_WRONG_ARGUMENTS 126CALL p1(-1, 'MultiLineString((2 2,2 8,-2 8),(-6 -6, 6 6),(10 10, 14 14))'); 127# 128# Wrong shape 129CALL p1(-1, 'MultiPolygon(((2 2,2 8,8 8,8 2,2 2)), ((9 9,8 1,1 5,9 9)))'); 130CALL p1(-1, '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)))'); 131# 132--error ER_WRONG_ARGUMENTS 133CALL p1(-1, 'GeometryCollection(Point(0 0))'); 134--error ER_WRONG_ARGUMENTS 135CALL p1(-1, 'GeometryCollection(LineString(0 0, 2 2))'); 136--error ER_GIS_INVALID_DATA 137CALL p1(-1, 'GeometryCollection(LineString(0 0, 2 2)))'); 138--error ER_GIS_INVALID_DATA 139CALL p1(-1, 'GeometryCollection(Polygon((2 2,2 8,8 8,8 2,2 2))))'); 140CALL p1(-1, 'GeometryCollection(Polygon((2 2,2 8,8 8,8 2,2 2)))'); 141--error ER_WRONG_ARGUMENTS 142CALL p1(-1, 'GeometryCollection(MultiPoint(9 9,8 1,1 5))'); 143--error ER_WRONG_ARGUMENTS 144CALL p1(-1, 'GeometryCollection(MultiLineString((0 0,0 1),(3 0,3 1)))'); 145# 146# Wrong shape 147# CALL p1(-1, 'GeometryCollection(MultiPolygon(((0 0, 3 0, 3 3, 0 3, 0 0)),((6 6,6 9,9 9,9 6,6 6))))'); 148# 149--error ER_WRONG_ARGUMENTS 150CALL p1(-1, 'GeometryCollection(Point(9 9),LineString(1 5,0 0),Polygon((2 2,2 8,8 8,8 2,2 2)))'); 151 152 153--enable_query_log 154 155SELECT ST_CONTAINS( 156 ST_GeomFromText('MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)),((6 6, 6 11, 11 11, 11 6, 6 6)))'), 157 ST_GeomFromText('POINT(5 10)')); 158SELECT ST_AsText(ST_UNION( 159 ST_GeomFromText('MULTIPOLYGON(((0 0, 0 5, 5 5, 5 0, 0 0)),((6 6, 6 11, 11 11, 11 6, 6 6)))'), 160 ST_GeomFromText('POINT(5 10)'))); 161 162DROP PROCEDURE p1; 163 164--echo # 165--echo # Bug #13833019 ASSERTION `T1->RESULT_RANGE' FAILED IN GCALC_OPERATION_REDUCER::END_COUPLE 166--echo # 167SELECT 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)); 168 169--echo # 170--echo # Bug #13832749 HANDLE_FATAL_SIGNAL IN GCALC_FUNCTION::COUNT_INTERNAL 171--echo # 172SELECT 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)); 173 174 175--echo # 176--echo # Bug#13358363 - ASSERTION: N > 0 && N < SINUSES_CALCULATED*2+1 | GET_N_SINCOS/ADD_EDGE_BUFFER 177--echo # 178 179DO ST_BUFFER(ST_GEOMCOLLFROMTEXT('linestring(1 1,2 2)'),''); 180 181SELECT ST_WITHIN( 182 ST_LINESTRINGFROMTEXT(' LINESTRING(3 8,9 2,3 8,3 3,7 6,4 7,4 7,8 1) '), 183 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))) '), 184 ST_NUMINTERIORRINGS(ST_POLYGONFROMTEXT('POLYGON((3 5,2 4,2 5,3 5)) ')))); 185 186SELECT ST_DIMENSION(ST_BUFFER(ST_POLYGONFROMTEXT(' POLYGON((3 5,2 5,2 4,3 4,3 5)) '), 187 ST_NUMINTERIORRINGS(ST_POLYGONFROMTEXT(' POLYGON((0 0,9 3,4 2,0 0))')))); 188 189SELECT ST_NUMINTERIORRINGS( 190 ST_ENVELOPE(ST_BUFFER(ST_MULTIPOLYGONFROMTEXT('MULTIPOLYGON(((3 5,2 5,2 4,3 4,3 5))) '), 191 ST_SRID(ST_MULTILINESTRINGFROMTEXT('MULTILINESTRING((2 2,4 2,1 2,2 4,2 2)) '))))); 192 193SELECT ST_ASTEXT(ST_BUFFER(ST_POLYGONFROMTEXT(' POLYGON((9 9,5 2,4 5,9 9))'), 194 ST_SRID(ST_GEOMETRYFROMTEXT(' MULTIPOINT(8 4,5 0,7 8,6 9,3 4,7 3,5 5) ')))); 195 196--echo # 197--echo # 18701868 CRASH IN MY_DECIMAL::SANITY_CHECK, 198--echo # ORDER BY CAST (INVALID GIS FUNCTION RESULT) 199--echo # 200 201CREATE TABLE t1 (a INT) engine=innodb; 202INSERT INTO t1 VALUES (1); 203SELECT * FROM t1 ORDER BY cast(st_distance(1,1) as DECIMAL); 204--error ER_GIS_INVALID_DATA 205DELETE FROM t1 ORDER BY cast(st_distance(1,1) as DECIMAL); 206--error ER_GIS_INVALID_DATA 207UPDATE t1 SET a=1 ORDER BY cast(st_distance(1,1) as DECIMAL); 208DROP TABLE t1; 209