In MySQL < 5.7 the spatial functions returned NULL when given invalid WKT, eg:
mysql> select astext(geomfromtext('polygon()'));
+-----------------------------------+
| astext(geomfromtext('polygon()')) |
+-----------------------------------+
| NULL |
+-----------------------------------+
1 row in set (0.00 sec)
But with newer MySQL the same input gives:
ERROR 3037 (22023): Invalid GIS data provided to function st_geometryfromtext.
Is there a way of checking whether the WKT is valid before sending it to the geometry functions? Alternatively is there a setting to force the geometry functions to produce NULL rather than error for invalid input?