Bug #77505 Polygons with open rings are auto-closed
Submitted: 26 Jun 2015 13:08 Modified: 26 Aug 2015 14:20
Reporter: Norvald Ryeng Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: GIS Severity:S3 (Non-critical)
Version:5.7.8 OS:Any
Assigned to: CPU Architecture:Any

[26 Jun 2015 13:08] Norvald Ryeng
Description:
Invalid polygons with open rings (i.e., start point != end point) are accepted in MySQL 5.7. According to SFA-CA, the rings of a polygon must be closed. Other invalid input will raise an exception condition in 5.7. In 5.6 the functions return NULL for invalid input, including open rings.

Since MySQL accepts these non-closed rings and adds the missing endpoint, these polygons end up in our test suites. Since all other systems we test against refuse to accept them, it's very hard to verify results, and it creates _a_lot_ of unnecessary work when comparing results with other systems.

How to repeat:
Some examples:

SELECT ST_GeomFromText('POLYGON((1 1, 2 1, 2 2))');
SELECT Polygon(LineString(Point(1,1),Point(2,1),Point(2,2)));
SELECT ST_GeomFromWKB(0x01030000000100000003000000000000000000F03F000000000000F03F0000000000000040000000000000F03F00000000000000400000000000000040);

Suggested fix:
Raise an exception condition telling the user to use closed rings.
[26 Aug 2015 14:20] Paul DuBois
Noted in 5.7.9, 5.8.0 changelogs.

For spatial functions, input polygons were automatically closed if
open. However, the Open Geospatial Consortium guidelines require that
input polygons already be closed. Such polygons are now rejected as
invalid rather than being closed.