Skip to content

MDEV-41091 Wrong result with ST_Disjoint, InnoDB only - #5710

Open
DerZc wants to merge 1 commit into
MariaDB:11.4from
DerZc:fix-mdev-41091
Open

DerZc wants to merge 1 commit into
MariaDB:11.4from
DerZc:fix-mdev-41091

Conversation

@DerZc

@DerZc DerZc commented Sep 21, 2026

Copy link
Copy Markdown

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

  • 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.

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.test
  • mysql-test/main/spatial_disjoint_overlap.result

Validation

On 11.4 at d10e5d726799b1cd57cc866f40aad68c720803da:

  • The server build passed.
  • main.spatial_disjoint_overlap failed on the unchanged target branch and passed with this fix.
  • Existing MTR tests passed: main.select.
  • MTR reported no test-state cleanup failures.
  • The full regression suite was not run.

@CLAassistant

CLAassistant commented Sep 21, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants