3236
MariaDBERRORNotableGIS / SpatialHIGH confidence
SRID mismatch in spatial aggregation function
Production Risk
Medium — aggregation fails; data migration may be required.
Why it happens
- 1Spatial aggregation function (e.g., ST_Collect) received geometries with different SRIDs.
- 2Aggregating rows where spatial column contains mixed SRIDs.
How to reproduce
trigger — this will error
trigger — this will error
SELECT ST_Collect(geom_col) FROM t1; -- geom_col has rows with SRID 4326 and 3857
expected output
ERROR 3236 (HY000): SRID mismatch found in aggregation.
Fix 1
Ensure all rows use the same SRID
Ensure all rows use the same SRID
UPDATE t1 SET geom_col = ST_Transform(geom_col, 4326) WHERE ST_SRID(geom_col) != 4326;
Why this works
Standardizing SRID across all rows allows aggregation to succeed.
Fix 2
Filter to rows with matching SRID before aggregation
Filter to rows with matching SRID before aggregation
SELECT ST_Collect(geom_col) FROM t1 WHERE ST_SRID(geom_col) = 4326;
Why this works
Aggregate only rows with consistent SRID.
What not to do
✕
Sources
Official documentation ↗
MySQL 8.0 — 3236 ER_GIS_DIFFERENT_SRIDS_AGGREGATION
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev