Skip to content

Commit f978067

Browse files
committed
Make GeomFromText tests compatible with MySQL 8
The function has been renamed to ST_GeomFromText.
1 parent 58cc66e commit f978067

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

ext/mysqli/tests/mysqli_stmt_fetch_geom.phpt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,15 @@ mysqli_stmt_fetch - geometry / spatial types
121121
return true;
122122
}
123123

124-
func_mysqli_stmt_fetch_geom($link, $engine, "GEOMETRY", "GeomFromText('POINT(2 2)')", 20);
125-
func_mysqli_stmt_fetch_geom($link, $engine, "POINT", "GeomFromText('POINT(1 1)')", 40);
126-
func_mysqli_stmt_fetch_geom($link, $engine, "LINESTRING", "GeomFromText('LINESTRING(0 0,1 1,2 2)')", 60);
127-
func_mysqli_stmt_fetch_geom($link, $engine, "POLYGON", "GeomFromText('POLYGON((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5))')", 80);
128-
func_mysqli_stmt_fetch_geom($link, $engine, "MULTIPOINT", "GeomFromText('MULTIPOINT(1 1, 2 2)')", 100);
129-
func_mysqli_stmt_fetch_geom($link, $engine, "MULTILINESTRING", "GeomFromText('MULTILINESTRING((0 0,1 1,2 2),(0 0,1 1,3 3))')", 120);
130-
func_mysqli_stmt_fetch_geom($link, $engine, "MULTIPOLYGON", "GeomFromText('MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5)),((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5)))')", 140);
131-
func_mysqli_stmt_fetch_geom($link, $engine, "GEOMETRYCOLLECTION", "GeomFromText('GEOMETRYCOLLECTION(POINT(1 1),LINESTRING(0 0,1 1,2 2,3 3,4 4))')", 160);
124+
$geomFromText = $link->server_version >= 80000 ? "ST_GeomFromText" : "GeomFromText";
125+
func_mysqli_stmt_fetch_geom($link, $engine, "GEOMETRY", "$geomFromText('POINT(2 2)')", 20);
126+
func_mysqli_stmt_fetch_geom($link, $engine, "POINT", "$geomFromText('POINT(1 1)')", 40);
127+
func_mysqli_stmt_fetch_geom($link, $engine, "LINESTRING", "$geomFromText('LINESTRING(0 0,1 1,2 2)')", 60);
128+
func_mysqli_stmt_fetch_geom($link, $engine, "POLYGON", "$geomFromText('POLYGON((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5))')", 80);
129+
func_mysqli_stmt_fetch_geom($link, $engine, "MULTIPOINT", "$geomFromText('MULTIPOINT(1 1, 2 2)')", 100);
130+
func_mysqli_stmt_fetch_geom($link, $engine, "MULTILINESTRING", "$geomFromText('MULTILINESTRING((0 0,1 1,2 2),(0 0,1 1,3 3))')", 120);
131+
func_mysqli_stmt_fetch_geom($link, $engine, "MULTIPOLYGON", "$geomFromText('MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5)),((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5)))')", 140);
132+
func_mysqli_stmt_fetch_geom($link, $engine, "GEOMETRYCOLLECTION", "$geomFromText('GEOMETRYCOLLECTION(POINT(1 1),LINESTRING(0 0,1 1,2 2,3 3,4 4))')", 160);
132133

133134
mysqli_close($link);
134135
print "done!";

ext/mysqli/tests/mysqli_stmt_get_result_geom.phpt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,15 @@ mysqli_stmt_get_result - geometry / spatial types
123123
return true;
124124
}
125125

126-
func_mysqli_stmt_get_result_geom($link, $engine, "GEOMETRY", "GeomFromText('POINT(2 2)')", 20);
127-
func_mysqli_stmt_get_result_geom($link, $engine, "POINT", "GeomFromText('POINT(1 1)')", 40);
128-
func_mysqli_stmt_get_result_geom($link, $engine, "LINESTRING", "GeomFromText('LINESTRING(0 0,1 1,2 2)')", 60);
129-
func_mysqli_stmt_get_result_geom($link, $engine, "POLYGON", "GeomFromText('POLYGON((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5))')", 80);
130-
func_mysqli_stmt_get_result_geom($link, $engine, "MULTIPOINT", "GeomFromText('MULTIPOINT(1 1, 2 2)')", 100);
131-
func_mysqli_stmt_get_result_geom($link, $engine, "MULTILINESTRING", "GeomFromText('MULTILINESTRING((0 0,1 1,2 2),(0 0,1 1,3 3))')", 120);
132-
func_mysqli_stmt_get_result_geom($link, $engine, "MULTIPOLYGON", "GeomFromText('MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5)),((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5)))')", 140);
133-
func_mysqli_stmt_get_result_geom($link, $engine, "GEOMETRYCOLLECTION", "GeomFromText('GEOMETRYCOLLECTION(POINT(1 1),LINESTRING(0 0,1 1,2 2,3 3,4 4))')", 160);
126+
$geomFromText = $link->server_version >= 80000 ? "ST_GeomFromText" : "GeomFromText";
127+
func_mysqli_stmt_get_result_geom($link, $engine, "GEOMETRY", "$geomFromText('POINT(2 2)')", 20);
128+
func_mysqli_stmt_get_result_geom($link, $engine, "POINT", "$geomFromText('POINT(1 1)')", 40);
129+
func_mysqli_stmt_get_result_geom($link, $engine, "LINESTRING", "$geomFromText('LINESTRING(0 0,1 1,2 2)')", 60);
130+
func_mysqli_stmt_get_result_geom($link, $engine, "POLYGON", "$geomFromText('POLYGON((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5))')", 80);
131+
func_mysqli_stmt_get_result_geom($link, $engine, "MULTIPOINT", "$geomFromText('MULTIPOINT(1 1, 2 2)')", 100);
132+
func_mysqli_stmt_get_result_geom($link, $engine, "MULTILINESTRING", "$geomFromText('MULTILINESTRING((0 0,1 1,2 2),(0 0,1 1,3 3))')", 120);
133+
func_mysqli_stmt_get_result_geom($link, $engine, "MULTIPOLYGON", "$geomFromText('MULTIPOLYGON(((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5)),((0 0,10 0,10 10,0 10,0 0),(5 5,7 5,7 7,5 7, 5 5)))')", 140);
134+
func_mysqli_stmt_get_result_geom($link, $engine, "GEOMETRYCOLLECTION", "$geomFromText('GEOMETRYCOLLECTION(POINT(1 1),LINESTRING(0 0,1 1,2 2,3 3,4 4))')", 160);
134135

135136
mysqli_close($link);
136137
print "done!";

0 commit comments

Comments
 (0)