Common SQL Errors

MySQL Error 3122: ER_BOOST_GEOMETRY_INCONSISTENT_TURNS_EXCEPTION - How to Fix Inconsistent Intersection Points

Galaxy Team
August 8, 2025

MySQL raises error 3122 (ER_BOOST_GEOMETRY_INCONSISTENT_TURNS_EXCEPTION) when Boost.Geometry detects contradictory intersection points in a spatial operation.

Sign up for the latest in common SQL errors from the Galaxy Team!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

What is MySQL error 3122 ER_BOOST_GEOMETRY_INCONSISTENT_TURNS_EXCEPTION?

MySQL error 3122 ER_BOOST_GEOMETRY_INCONSISTENT_TURNS_EXCEPTION appears when a spatial query returns conflicting intersection points. Validate and clean your geometry, simplify overly complex shapes, or repair invalid polygons to resolve the issue quickly.

Error Highlights

Typical Error Message

ER_BOOST_GEOMETRY_INCONSISTENT_TURNS_EXCEPTION

Error Type

Data Error

Language

MySQL

Symbol

ER_BOOST_GEOMETRY_INCONSISTENT_TURNS_EXCEPTION was added in 5.7.7.

Error Code

3122

SQL State

HY000

Explanation

Table of Contents

What is MySQL error 3122 ER_BOOST_GEOMETRY_INCONSISTENT_TURNS_EXCEPTION?

Error 3122 fires when MySQL's Boost.Geometry engine processes a spatial function and finds two intersection points that should coincide but do not. The engine treats this as corrupt or ambiguous geometry data and aborts the query.

The condition was introduced in MySQL 5.7.7, so older versions never emit it. Most often it appears during ST_Intersection, ST_Union, ST_Difference, or ST_IsValid checks.

What Causes This Error?

Inconsistent vertex ordering, overlapping rings, or self-intersecting polygons produce contradictory turn data inside Boost.Geometry. Large coordinate precision gaps can also cause floating-point rounding that mislabels turns as distinct.

User-supplied WKT/WKB imported from GIS tools frequently carries invalid shapes. Programmatic generation of complex multipolygons without validation is another trigger.

How to Fix ER_BOOST_GEOMETRY_INCONSISTENT_TURNS_EXCEPTION

First validate the geometry with ST_IsValid. If it returns 0, repair it using ST_MakeValid or ST_SimplifyPreserveTopology. Simplifying tolerates tiny slivers causing the inconsistency.

If ST_IsValid passes yet the error persists, cast all coordinate values to a consistent precision and re-run the query. This eliminates rounding distortions.

Common Scenarios and Solutions

Bulk import of shapefiles - Run an ETL step that discards self-intersections before loading into MySQL.

Dynamically generated polygons - Add unit tests that call ST_IsValid after generation. Fail the build when invalid shapes appear.

Legacy tables - Schedule a nightly job in Galaxy that scans for invalid geometry and rewrites bad rows with ST_MakeValid.

Best Practices to Avoid This Error

Always validate and simplify geometry on ingest. Limit coordinate precision to a sane number of decimal places to prevent floating-point drift.

Leverage Galaxy's AI copilot to review spatial queries and suggest ST_IsValid guards automatically, reducing the risk of production failures.

Related Errors and Solutions

Error 1366 - invalid string for Geometry - occurs on malformed WKT.

Error 3037 - geometry overlay failed - similar root cause but raised for general overlay issues.

Common Causes

Invalid or self-intersecting polygons

Rings that cross themselves force Boost.Geometry to detect conflicting turns.

Duplicate vertices with different precision

Points that should match but differ at micro-precision lead to inconsistent intersections.

Incorrect ring orientation

Mixing clockwise and anticlockwise ordering inside one multipolygon confuses the overlay algorithm.

Unvalidated GIS imports

Third-party shapefiles often contain corrupt geometries that MySQL rejects during spatial operations.

Related Errors

Error 3037 GEOMETRY_OVERLAY_ERROR

Raised when any overlay operation fails, not just inconsistent turns.

Error 1366 Incorrect Geometry Value

Appears during insert/update of malformed WKT or WKB.

Error 1416 Cannot Get Geometry Object

Returned when spatial index lookup encounters corrupt data blocks.

FAQs

Does this error indicate data loss?

No rows are deleted. MySQL simply aborts the spatial function and returns an error.

Will upgrading MySQL remove the error?

Newer versions still enforce geometry consistency. You must fix the data.

Can I ignore invalid shapes?

You can filter them with ST_IsValid but long term you should repair or drop them to avoid future failures.

How does Galaxy help?

Galaxy prompts you to validate geometry during query composition and can schedule nightly auto-repair jobs.

Start Querying with the Modern SQL Editor Today!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Check out some other errors

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo