Bug #65348 | Within() yields no results when spatial index is used | ||
---|---|---|---|
Submitted: | 17 May 2012 9:23 | Modified: | 20 Jul 2012 3:09 |
Reporter: | Arno Hollosi | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: GIS | Severity: | S2 (Serious) |
Version: | 5.6.5-m8-log, 5.6.6-m9 | OS: | Linux (debian5.0/i686) |
Assigned to: | CPU Architecture: | Any | |
Tags: | INDEX, no result, regression, within |
[17 May 2012 9:23]
Arno Hollosi
[17 May 2012 10:36]
Arno Hollosi
Continuing, even more bizarre: Add a second polygon: INSERT INTO b VALUES (3, MultiPolygonFromText('MULTIPOLYGON(((13.326 52.513, 13.328 52.513, 13.328 52.511,13.326 52.511,13.326 52.513)))')); SELECT p2.id, b.id from b, p2 where ST_Within(location,boundary); +----------+-----+ | id | id | +----------+-----+ | 26708183 | 171 | | 26708184 | 171 | | 26708183 | 3 | +----------+-----+ Note that id=171 matches now! DELETE from b where id=3; SELECT p2.id, b.id from b, p2 where ST_Within(location,boundary); Empty set (0.00 sec) Note that id=171 no longer matches!? BUT: using primary key of p2: SELECT p2.id, b.id from b, p2 where ST_Within(location,boundary) and p2.id=26708183; +----------+-----+ | id | id | +----------+-----+ | 26708183 | 171 | +----------+-----+ But not the following: SELECT p2.id, b.id from b, p2 where ST_Within(location,boundary) and p2.id>26708182; Empty set (0.00 sec)
[17 May 2012 11:10]
Valeriy Kravchuk
Thank you for the bug report. Verified with current mysql-trunk also: ... mysql> select version(); +----------------+ | version() | +----------------+ | 5.6.6-m9-debug | +----------------+ 1 row in set (0.00 sec) mysql> SELECT p2.id from b, p2 where ST_Contains(boundary,location); +----------+ | id | +----------+ | 26708183 | | 26708184 | +----------+ 2 rows in set (0.00 sec) mysql> SELECT p2.id from b, p2 ignore index (idx_loc) where ST_Within(location,boundary); +----------+ | id | +----------+ | 26708183 | | 26708184 | +----------+ 2 rows in set (0.00 sec) mysql> SELECT p2.id from b, p2 where ST_Within(location,boundary); Empty set (0.00 sec) mysql> SELECT p2.id from b, p2 where Within(location,boundary); Empty set (0.00 sec) mysql> SELECT p2.id from b, p2 where MBRWithin(location,boundary); Empty set (0.00 sec) Moreover, last 2 functions produce correct results in 5.5.23 (ST_Within() etc do not exist in 5.5), so this is a regression of a kind in 5.6.x.
[20 Jul 2012 3:09]
Paul DuBois
Noted in 5.6.7, 5.7.0 changelogs. The ST_Contains() and Within() functions yielded an incorrect result when used on a column with a SPATIAL index.