MySQL MariaDB – LineString Constructor with Points Support

mariadbMySQLmysql-8.0spatial

It seems with MySQL and MariaDB I'm getting the following when I try to use the LineString constructor. In PostGIS I can do this with ST_MakeLine(pt1,pt2)

> SELECT ST_MakeLine(Point(0,0), Point(0,1));
ERROR 1305 (42000): FUNCTION ST_MakeLine does not exist

> SELECT ST_LineString(Point(0,0), Point(0,1));
ERROR 1305 (42000): FUNCTION ST_LineString does not exist

Is the only way to construct a LINESTRING to use ST_GeomFromText or ST_LineFromText, or ST_LineStringFromText?

Best Answer

No, as a general rule the constructors for MySQL are only available with non-ST_ prefixes.

So you'll want LineString(pt1,pt2)

SELECT LineString(Point(0,0), Point(0,1));