Bug #65094 srid information not included when inserting GIS data with GeomFromWKB functions
Submitted: 24 Apr 2012 16:53 Modified: 30 Jul 2012 15:17
Reporter: Brian Bernstein Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: GIS Severity:S3 (Non-critical)
Version:5.1.57, 5.1.58, 5.5.25 OS:Any
Assigned to: CPU Architecture:Any

[24 Apr 2012 16:53] Brian Bernstein
Description:
When inserting geometry data using the well known text methods, the data is inserted properly.  However, if providing the same data via the well known binary methods, the srid information is not included in the blob even though it was included in the function's second optional parameter.

This can be demonstrated with the following query:
SELECT hex(PointFromWKB(Point(0, 0), 4326)), hex(PointFromText('Point(0 0)', 4326));

This query, on the mysql versions tested, yielded the following results:
hex(PointFromWKB(Point(0, 0), 4326)): 00000000010100000000000000000000000000000000000000

hex(PointFromText('Point(0 0)', 4326)):
E6100000010100000000000000000000000000000000000000

Although the srid is being provided in both functions, it is only included in the blob with the 'FromText' functions (the same issue occurs when using the more generic GeomFromText/WKB functions).  This is a signifigant annoyance, especially if trying to utilize a unique constraint, as the two points should be equivalent, but is not because the underlieing method of insert was different.

How to repeat:
Execute the following query:
SELECT hex(PointFromWKB(Point(0, 0), 4326)), hex(PointFromText('Point(0 0)', 4326));

Notice that the first value is lacking the E610 prefix that is found in the second value.

Suggested fix:
PointFromWKB should include the srid in the blob if provided.  The two values from the previous query should be identical.
[24 Apr 2012 21:13] Sveta Smirnova
Thank you for the report.

Verified as described.
[30 Jul 2012 15:17] Paul DuBois
Noted in 5.6.7, 5.7.0 changelogs.

The GeomFromWKB() function did not return NULL if the SRID argument
was NULL, and non-NULL SRID values were not included in the converted
result.