3234
MariaDBERRORNotableGIS / SpatialHIGH confidence

Spatial operation on geometries with different SRIDs

Production Risk

Medium — spatial queries fail; data may need migration.

Why it happens
  1. 1Two geometry arguments to a spatial function have different SRID (spatial reference system) values.
  2. 2Mixing SRID=0 geometries with projected or geographic SRS geometries.
How to reproduce
trigger — this will error
trigger — this will error
SELECT ST_Distance(ST_GeomFromText('POINT(0 0)', 4326), ST_GeomFromText('POINT(1 1)', 3857));

expected output

ERROR 3234 (HY000): Geometries have different SRIDs. Operation aborted.

Fix 1

Transform all geometries to a common SRID

Transform all geometries to a common SRID
SELECT ST_Distance(ST_Transform(g1, 4326), ST_Transform(g2, 4326)) FROM t1;

Why this works

ST_Transform() reprojects geometries to a target SRID.

Fix 2

Store all spatial data with the same SRID

Store all spatial data with the same SRID
-- Standardize on SRID=4326 (WGS84) for geographic data.

Why this works

Consistent SRIDs prevent SRID mismatch errors at query time.

What not to do

Sources
Official documentation ↗

MySQL 8.0 — 3234 ER_GIS_DIFFERENT_SRIDS

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All MariaDB errors