Conversation
ST_Disjoint can omit rows from a spatially indexed InnoDB table when two geometries are disjoint but their minimum bounding rectangles overlap. The SP_DISJOINT_FUNC range construction uses HA_READ_MBR_DISJOINT for both exact geometric disjointness and bounding-rectangle disjointness. Bounding-rectangle disjointness is too restrictive as a candidate range for the exact predicate. Add an mbr_range_is_exact() capability that defaults to false for exact spatial relations and is true for Item_func_spatial_mbr_rel. Create the MBR-disjoint index range only when that capability is true. Preserve the MBRDisjoint range optimization while allowing exact ST_Disjoint to consider geometries with overlapping bounding rectangles. The regression places a small polygon outside a triangular polygon but inside its bounding rectangle. Both that triangle and a distant polygon must be returned by the exact disjoint query. Bug report: https://jira.mariadb.org/browse/MDEV-41091
DerZc
force-pushed
the
fix-mdev-41091
branch
from
September 21, 2026 05:59
f49923c to
2ab30ea
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ST_Disjoint can omit rows from a spatially indexed InnoDB table when two geometries are disjoint but their minimum bounding rectangles overlap.
Bug report: https://jira.mariadb.org/browse/MDEV-41091
Root cause
The SP_DISJOINT_FUNC range construction uses HA_READ_MBR_DISJOINT for both exact geometric disjointness and bounding-rectangle disjointness. Bounding-rectangle disjointness is too restrictive as a candidate range for the exact predicate.
Changes
Regression coverage
The regression places a small polygon outside a triangular polygon but inside its bounding rectangle. Both that triangle and a distant polygon must be returned by the exact disjoint query.
mysql-test/main/spatial_disjoint_overlap.testmysql-test/main/spatial_disjoint_overlap.resultValidation
On
11.4atd10e5d726799b1cd57cc866f40aad68c720803da:main.spatial_disjoint_overlapfailed on the unchanged target branch and passed with this fix.main.select.