We are upgrading MySQL from 5.7 to 8.0. Table cuatom_shapes
has column shape
with SRID=0
, in which few rows have data with GEOMETRYCOLLECTION
and few other rows have data with POLYGON
.
Though column SRID is set to 0, for POLYGON data correct SRID is 4326. So we decided to set SRID=4326 at column level but due to GEOMETRYCOLLECTION rows we are unable to set the SRID.
How to handle this use case?
2
Answers
Were the values stored in the
GEOMETRYCOLLECTION
column rebuilt to have the different SRID?I think the answer is that you must dump the value, change the SRID, then re-insert.
File a bug with bugs.mysql.com . It sounds like
ALTER COLUMN
fails to dig in to do the SRID change.I think the best way to handle this case is by creating a new column with the correct SRID and then updating values.
In your case here is an example:
Once you update those values, you can actually drop the old data and rename the new column.
By following these rules you can set the correct SRID for the POLYGON data while keeping the GEOMETRYCOLLECTION data.