[MDEV-3930] Spatial functions: Return error instead of NULL for non supported geometry types Created: 2012-12-11  Updated: 2014-06-06

Status: Open
Project: MariaDB Server
Component/s: None
Affects Version/s: 5.5.28a
Fix Version/s: 5.5

Type: Bug Priority: Minor
Reporter: Georg Richter Assignee: Alexey Botchkov
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-3819 missing constraints for spatial colum... Closed

 Description   

This issue might be related to MDEV-3819.

Geometry functions should be more restrictive and produce an error in case parameter is a valid geometry but has the wrong type.

According to the OGC standard definition the return value for a
function is NULL if the geometry is NULL (RETURNS NULL ON NULL).

The standard also defines the valid geometry types for functions:

7.2.9 SQL routines on type POINT

The SQL/MM ST_X, ST_Y, ST_Z and ST_M routines and all routines supported by type GEOMETRY shall be supported for geometries of type Point.

Example:

PostGIS

osm=# select st_x(GeomFromText('LINESTRING(1 1, 2 2)'));
ERROR:  Argument to X() must be a point

MariaDB

mysql> select st_x(GeomFromText('LINESTRING(1 1, 2 2)'));
+--------------------------------------------+
| st_x(GeomFromText('LINESTRING(1 1, 2 2)')) |
+--------------------------------------------+
|                                       NULL |
+--------------------------------------------+
1 row in set (0.06 sec)

Affected functions (might be incomplete)

Geometry type POINT
  • ST_X()
  • ST_Y()
  • ST_Z() (not implemented yet)
Geometry type CURVE (includes LINESTRING, LINE, LINEARRING)
  • ST_StartPoint()
  • ST_EndPoint()
  • ST_IsRing()
  • ST_Length()
Geometry type LINESTRING
  • ST_NumPoints()
  • ST_PointN()
Geometry type SURFACE (includes POLYGON, POLYHEDRALSURFACE)
  • ST_Centroid()
  • ST_Area()
  • ST_PointOnSurface()
Geometry type POLYGON
  • ST_ExteriorRing()
  • ST_InteriorRingN()
  • ST_NumInteriorRing()

Generated at Thu Feb 08 06:52:21 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.