3146
MySQLERRORNotableSpatialHIGH confidence
ST_Difference function not implemented for this geometry type
Production Risk
Low — query fails at runtime.
What this means
The ST_Difference() function does not support the supplied geometry type combination.
Why it happens
- 1Calling ST_Difference() with an unsupported geometry type such as GeometryCollection.
How to reproduce
trigger — this will error
trigger — this will error
SELECT ST_Difference(ST_GeomFromText('GEOMETRYCOLLECTION EMPTY'), ST_GeomFromText('POINT(0 0)'));expected output
ERROR 3146 (HY000): st_difference not implemented for 'GeometryCollection'.
Fix
Use POLYGON or MULTIPOLYGON geometries
Use POLYGON or MULTIPOLYGON geometries
SELECT ST_Difference(ST_GeomFromText('POLYGON((0 0,0 10,10 10,10 0,0 0))'), ST_GeomFromText('POLYGON((2 2,2 5,5 5,5 2,2 2))'));Why this works
ST_Difference is implemented for standard polygon types.
What not to do
✕
Sources
Official documentation ↗
MySQL 8.0 — 3146 ER_SPATIAL_DIFFERENCE_NOT_IMPLEMENTED
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev