3277
MySQLERRORNotableGIS / GeometryHIGH confidence

SRS is not a geographic coordinate system

Production Risk

Medium — spatial queries fail; convert to the correct SRS.

How to reproduce
trigger — this will error
trigger — this will error
SELECT ST_Distance_Sphere(ST_GeomFromText('POINT(0 0)', 0), ST_GeomFromText('POINT(1 1)', 0));

expected output

ERROR 3277 (HY000): Function requires a geographic spatial reference system, but got Cartesian SRS.

Fix

Use geographic SRS

Use geographic SRS
SELECT ST_Distance_Sphere(ST_GeomFromText('POINT(139.7 35.7)', 4326), ST_GeomFromText('POINT(135.5 34.7)', 4326));

Why this works

Geographic functions require lat/long coordinates in a geographic SRS.

What not to do

Sources
Official documentation ↗

MySQL 8.0 — 3277 ER_SRS_NOT_GEOGRAPHIC

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

← All MySQL errors