Skip to main content

MySQL spatial support

View Markdown versionEdit this page on GitHub

Platform and version scope​

DBMS behavior: sources are the MySQL 8.4 Reference Manual, checked on 2026-10-11. They do not establish equivalent behavior in MySQL 5.7, 8.0 or MariaDB. Integration records describe Doctrine Spatial 6.0.0 source code; no tested server-version compatibility range is asserted.

Spatial behavior​

SubjectMySQL 8.4 behavior and vendor source
Types/geometriesGEOMETRY, Point, LineString, Polygon, their three multi-types and GeometryCollection. A subtype column constrains its values; GEOMETRY accepts the supported families. 13.4.1
DimensionsThe documented model uses X/Y coordinate pairs. XYZ, XYM and XYZM persistence is outside this model; geometric dimension returned by ST_Dimension is a separate concept. 13.4.2.2
CRS/SRIDSRID 0 is an unbounded Cartesian plane. Nonzero SRIDs refer to defined SRSs; multi-geometry operations require matching systems. 13.4.2.2, 14.16.2
Axis orderWKT constructors accept an axis-order option; default srid-defined follows the SRS. Geographic range checks apply. Do not infer longitude-first input merely from SRID 4326. 14.16.3
FormatsWKT/WKB are interchange formats. Internal binary values add four SRID bytes before the WKB portion; raw column bytes are not bare WKB. 13.4.3
RestrictionsOnly GeometryCollection can be empty; POINT EMPTY is unsupported. Curve and surface families beyond the listed types are unsupported. 13.4.3, 14.16.7.1

Informative example: this deliberately uses SRID 0 to avoid an implicit geographic axis convention. It is SQL, not a LongitudeOne API example.

SELECT ST_AsText(ST_GeomFromText('POINT(1 2)', 0));

Differences from standards​

Vendor restriction: MySQL's XY/type/EMPTY subset is narrower than the OGC 06-103r4 WKT grammar in clauses 7.2.2–7.2.5, including its dimensional and empty productions. The OGC representation reference owns those requirements; MySQL acceptance is not their definition.

Vendor representation: the SRID-prefixed internal binary format is distinct from OGC WKB structures (8.2.8). MySQL constructor axis-order options remain platform behavior, not a portable serialization rule.

LongitudeOne integration and support​

Every row concerns Doctrine Spatial 6.0.0, MySQL adapter; the MySQL 8.4 capability description above is not an assertion that this release was tested against that server. Per-function DQL acceptance must also be checked in the library; adapter recognition is not a promise that all spatial functions work.

FeatureImplementation scopeStatusLimitationsImplementation decisionExtensionsEvidence
XY linear geometry persistenceDoctrine Spatial 6.0.0, MySQLSupportedPHP Point, LineString, Polygon and three multi-types; no universal native type coverage.Write WKT with ST_GeomFromText; read WKB with ST_AsBinary.None documented.MySql adapter, PHP types
Geography modelDoctrine Spatial 6.0.0, MySQLPartially supportedMapping to GEOMETRY does not provide a separate geography column or automatic geodetic semantics.Declare the generic geography mapping as GEOMETRY.None documented.Adapter
Preserving supplied SRID in ordinary persistenceDoctrine Spatial 6.0.0, MySQLUnsupportedWKT omits the object's SRID; generated constructor has one argument, and declaration omits SRID constraints.Ordinary persistence does not forward SRID; this differs from an explicit SQL constructor.None documented.Adapter
SRID setter SQL adaptationDoctrine Spatial 6.0.0, MySQLSupportedChanging an SRID does not transform coordinates; native version support still matters.Translate ST_SetSRID to MySQL ST_SRID.None documented.Adapter
XYZ, XYM, XYZM and GeometryCollection PHP valuesDoctrine Spatial 6.0.0, MySQLUnsupportedPoint has only X/Y; no GeometryCollection PHP class.Retain released PHP type scope.None documented.PHP types, Point
Complete EMPTY round trips and geographic axis adaptationDoctrine Spatial 6.0.0, MySQLNot assessedNo blanket guarantee for these paths; the adapter supplies no axis-order option.No new compatibility behavior defined.None documented.Adapter, PHP types

DBMS overview, MariaDB differences, geometry families, dimensions, CRS/SRID, formats, SQL/MM Spatial and Doctrine Spatial 6.x usage.