Bug #97347 In some cases queries with ST_CONTAINS do not return any results

Submitted: 23 Oct 2019 17:11 Modified: 30 Jun 2020 15:58
Reporter: Christian Koinig Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: GIS Severity:S3 (Non-critical)
Version:8.0.18-community/5.7 OS:Any
Assigned to: CPU Architecture:Any

[23 Oct 2019 17:11] Christian Koinig
Description:
In some cases queries with ST_CONTAINS do not return any results unless >0 is added.
The same query using the same data did return results in 8.0.11.

How to repeat:
CREATE TABLE test (
`id` int(11) NOT NULL AUTO_INCREMENT, 
`geo_footprint` geometry NOT NULL /*!80003 SRID 4326 */, 
SPATIAL KEY `geo_footprint` (`geo_footprint`),
PRIMARY KEY (`id`)
);

INSERT INTO test (geo_footprint) VALUES(ST_GeomFromGeoJSON('{"type": "Polygon", "coordinates": [[[14.9997279, 48.753013], [14.9997331, 47.76525654], [16.46465601, 47.75591029], [16.4931335, 48.74333898], [14.9997279, 48.753013]]]}'));

-- this query does not return any results
select * FROM test 
WHERE ST_CONTAINS(
 geo_footprint,
 ST_GeomFromGeoJSON('{"type":"Polygon","coordinates":[[[15.113334808199966,48.1337532388],[15.113329984100005,48.1337371609],[15.113411697200036,48.1337166354],[15.113673777399981,48.1336819199],[15.114544787600039,48.1335464618],[15.115336574000025,48.1334415189],[15.116374992200008,48.1332937084],[15.117266346799966,48.1330924824],[15.11769786879995,48.1329803459],[15.118129375299986,48.132868199],[15.118515258099933,48.1327388086],[15.118597296700045,48.1327141533],[15.118635348899943,48.132702717],[15.11867907729993,48.1327796282],[15.11876276890007,48.13290987],[15.118805112699988,48.1330357889],[15.118850101500016,48.1333486685],[15.118823191700017,48.1334777297],[15.118820984299987,48.1334784295],[15.118821076099948,48.1334779691],[15.113334808199966,48.1337532388],[15.113334808199966,48.1337532388]]]}')
);

-- note that adding >0 will cause the query to return results
select * FROM test 
WHERE ST_CONTAINS(
 geo_footprint,
 ST_GeomFromGeoJSON('{"type":"Polygon","coordinates":[[[15.113334808199966,48.1337532388],[15.113329984100005,48.1337371609],[15.113411697200036,48.1337166354],[15.113673777399981,48.1336819199],[15.114544787600039,48.1335464618],[15.115336574000025,48.1334415189],[15.116374992200008,48.1332937084],[15.117266346799966,48.1330924824],[15.11769786879995,48.1329803459],[15.118129375299986,48.132868199],[15.118515258099933,48.1327388086],[15.118597296700045,48.1327141533],[15.118635348899943,48.132702717],[15.11867907729993,48.1327796282],[15.11876276890007,48.13290987],[15.118805112699988,48.1330357889],[15.118850101500016,48.1333486685],[15.118823191700017,48.1334777297],[15.118820984299987,48.1334784295],[15.118821076099948,48.1334779691],[15.113334808199966,48.1337532388],[15.113334808199966,48.1337532388]]]}')
)>0;
[24 Oct 2019 10:24] MySQL Verification Team
Thank you for the bug report.
[30 Jun 2020 15:58] Paul DuBois
Posted by developer:
 
Fixed in 8.0.20.

Some queries that used ST_Contains() did not return any results
unless > 0 was added.

NOTE:
For upgrades from earlier versions of MySQL, you should recreate
spatial indexes in tables that have them.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.056 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.