Bug #117047 ST_Touches always return null with Point and GeometryCollection with Points
Submitted: 26 Dec 2024 8:27 Modified: 30 Dec 2024 13:44
Reporter: shijie li Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: GIS Severity:S1 (Critical)
Version:8.0.40 OS:Any
Assigned to: CPU Architecture:Any

[26 Dec 2024 8:27] shijie li
Description:
https://dev.mysql.com/doc/refman/8.4/en/spatial-relation-functions-object-shapes.html#func....
It is specifically pointed out that,ST_Touches() handles its arguments as described in the introduction to this section except that the return value is NULL for the additional condition that both geometries are of dimension 0 (Point or MultiPoint).

But when it encounters a Point and a GeometryCollection with dimensions greater than 0 and Points, it still returns NULL, which is not as expected.

How to repeat:
SELECT ST_Touches(ST_GeomFromText('GEOMETRYCOLLECTION(LINESTRING(0 0, 1 1),POINT(2 2))'),ST_GeomFromText('POINT(0 0)')),
         ST_Dimension(ST_GeomFromText('GEOMETRYCOLLECTION(POINT(2 2),LINESTRING(0 0, 1 1))')),
         ST_Dimension(ST_GeomFromText('POINT(2 2)'));

--expected:{t, 1, 0}or{f,1,0}
--actual  :{NULL, 1, 0}

Suggested fix:
A simple fix is:
For a GEOMETRYCOLLECTION, it is necessary to check its dimension. When its dimension is not 0 (not empty or acutally multipoint), needs to consider whether the geometry other than points touches it,  and then return 1 or 0.
[26 Dec 2024 11:43] MySQL Verification Team
Hello shijie li,

Thank you for the report and feedback.

regards,
Umesh
[30 Dec 2024 13:44] shijie li
If possible, please let me know the reason for the bug and whether you will fix this bug. Thank you.