WL#10166: Require WKB input in WKB parsing functions

Affects: Server-8.0   —   Status: Complete   —   Priority: Medium

The WKB parsing functions accept a non-standard geometry argument instead of a WKB string. This behavior is nonsensical unless an SRID parameter is provided, in which case it duplicates the behavior of ST_SRID(,). This non-standard behavior is confusing, bug prone and causes extra implementation and testing costs.

This WL modifies ST_GeomFromWKB, ST_GeometryFromWKB, ST_PointFromWKB, ST_LineFromWKB, ST_LineStringFromWKB, ST_PolyFromWKB, ST_PolygonFromWKB, ST_GeomCollFromWKB, ST_GeometryCollectionFromWKB, ST_MPointFromWKB, ST_MultiPointFromWKB, ST_MLineFromWKB, ST_MultiLineStringFromWKB, ST_MPolyFromWKB and ST_MultiPolygonFromWKB behavior by requiring the WKB parameter to be WKB. It removes the support for using geometries as parameters to these functions.

Examples:

  • ST_GEOMFROMWKB(POINT(0, 0)) will not be allowed. The user should instead write POINT(0, 0).
  • ST_GEOMFROMWKB(POINT(0, 0), 1234) will not be allowed. The user should instead write ST_SRID(POINT(0, 0), 1234) or ST_GEOMFROMWKB(ST_ASWKB(POINT(0, 0)), 1234).
  • ST_GEOMFROMWKB(x'0101000000...') and ST_GEOMFROMWKB(x'0101000000...', 1234) will still work.

A warning is added to MySQL 5.7 notifying the user that supplying geometries instead of WKB is no longer supported.

The non-standard behavior was introduced in MySQL 5.0.82, 5.1.35 and 6.0.12 by the fix for BUG#38990. The support for changing the SRID by using a second parameter was introduced in 5.6.7 and 5.7.0 by the fix for BUG#65094.

User Documentation

5.7

F-1
In 5.7, if given a first argument of type MYSQL_TYPE_GEOMETRY and no second argument, the functions MUST raise ER_WARN_USING_GEOMFROMWKB_TO_SET_SRID_ZERO.
F-2
In 5.7, if given a first argument of type MYSQL_TYPE_GEOMETRY and a second argument, the function MUST raise ER_WARN_USING_GEOMFROMWKB_TO_SET_SRID.

8.0

F-3
In 8.0, if the first argument is not a valid WKB string, the functions MUST raise ER_GIS_INVALID_DATA.
F-4
In 8.0, if the first argument is a valid WKB string, the function MUST NOT change behavior.

5.7

I-1
No new files.
I-2
No new syntax.
I-3
No new commands.
I-4
No new tools.
I-5
Changes to existing functionality in 5.7: A warning is raised if the first parameter to WKB parsing functions is of type MYSQL_TYPE_GEOMETRY.
I-6
No new errors.
I-7
Interface ERR01 is extended with one new warnings:
ER_WARN_USING_GEOMFROMWKB_TO_SET_SRID_ZERO, SQLSTATE 01000, "%.192s(geometry) is deprecated and will be replaced by st_srid(geometry, 0) in a future version. Use %.192s(st_aswkb(geometry), 0) instead."
ER_WARN_USING_GEOMFROMWKB_TO_SET_SRID, SQLSTATE 01000, "%.192s(geometry, srid) is deprecated and will be replaced by st_srid(geometry, srid) in a future version. Use %.192s(st_aswkb(geometry), srid) instead."

8.0

I-8
No new files.
I-9
No new syntax.
I-10
No new commands.
I-11
No new tools.
I-12
Changes to existing functionality in 8.0: An error is returned if the first parameter to WKB parsing functions is not WKB.
I-13
Two warnings are removed from interface ERR01 in 8.0: ER_WARN_USING_GEOMFROMWKB_TO_SET_SRID_ZERO and ER_WARN_USING_GEOMFROMWKB_TO_SET_SRID
I-14
No new warnings in 8.0.