Bug #90769 ST_PolyFromText validate error.
Submitted: 6 May 2018 10:33 Modified: 7 May 2018 6:27
Reporter: Lee Eric Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: GIS Severity:S2 (Serious)
Version:8 OS:CentOS (7.3)
Assigned to: CPU Architecture:x86
Tags: spatial, ST_PolyFromText, validate

[6 May 2018 10:33] Lee Eric
Description:
sql:
UPDATE se_layer SET data_update_user='1', rect=ST_PolyFromText('POLYGON((-180 -90,180 -90,180 90,-180 90,-180 -90))',4326), data_update_time=NOW(), data_version=data_version + 1 WHERE data_id='1001'

report error:
错误代码: 3617
Latitude -180.000000 is out of range in function st_polyfromtext. It must be within [-90.000000, 90.000000].

Fisrt of wkt of point is within [-180.000000, 180.000000]. mysql server make a wrong check.

How to repeat:
sql:
UPDATE se_layer SET data_update_user='1', rect=ST_PolyFromText('POLYGON((-180 -90,180 -90,180 90,-180 90,-180 -90))',4326), data_update_time=NOW(), data_version=data_version + 1 WHERE data_id='1001'

report error:
错误代码: 3617
Latitude -180.000000 is out of range in function st_polyfromtext. It must be within [-90.000000, 90.000000].
[6 May 2018 13:44] MySQL Verification Team
Thank you for the bug report. Please provide the complete test case (create table, insert data and then update). Thanks.
[6 May 2018 14:12] Lee Eric
create database and insert data

Attachment: test.sql (application/octet-stream, text), 2.87 KiB.

[6 May 2018 14:16] Lee Eric
if you want to test. Just create a table with a polygon column and srid is 4326. Insert the data like ST_PolyFromText('POLYGON((-180 -90,180 -90,180 90,-180 90,-180 -90)). The error will show.
[6 May 2018 14:18] Lee Eric
I check the define of wkt. the point format is "x y". But I test mysql8, it looks like "y x".
[7 May 2018 6:27] Norvald Ryeng
Hi,

The test case tries to create the polygon with:

ST_PolyFromText('POLYGON((-180 -90,180 -90,180 90,-180 90,-180 -90))',4326)

SRID 4326 is a geographic spatial reference system with axis order latitude-longitude, not longitude-latitude. Therefore, coordinates are also expected in that order, i.e., "POLYGON((lat1 lon1, lat2 lon2, ...)). 

For more details, see https://mysqlserverteam.com/axis-order-in-spatial-reference-systems/.