Bug #44753 nan error in union function
Submitted: 8 May 2009 14:48 Modified: 17 Aug 2011 13:58
Reporter: John Powell Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: GIS Severity:S2 (Serious)
Version:5.1 WL#1326 OS:Linux (Centos and ubuntu)
Assigned to: Alexey Botchkov CPU Architecture:Any
Tags: gis, union function

[8 May 2009 14:48] John Powell
Description:
Writing a procedure to add together lots of different areas using union function. Notice that often the union function produces a multipolygon with nan values. If attempting to do anything with the multipolygon in question, such as insert into a table, get a ERROR 2013 (HY000): Lost connection to MySQL server during query.

How to repeat:
mysql>set @geom=geomfromtext('POLYGON((382500 364250,382500 362750,384750 362750,384750 364250,382500 364250))');

mysql>set @geom1=geomfromtext('MULTIPOLYGON(((164000 39750,164000 41250,164000 41250,166250 41250,166250 41250,166250 39750,164000 39750)),((383200 363200,383200 363800,384100 363800,384100 363200,383200 363200)))');

#sanity check that these are proper geometry objects

mysql> select area(@geom);
+-------------+
| area(@geom) |
+-------------+
|     3375000 |
+-------------+
1 row in set (0.00 sec)

mysql> select area(@geom1);
+--------------+
| area(@geom1) |
+--------------+
|      3915000 |
+--------------+
1 row in set (0.00 sec)

#join two geometries into one, with union -- get multipolygon with nan.

mysql> set @union=union(@geom,@geom1);

mysql> select astext(@union);
MULTIPOLYGON(((164000 39750,164000 41250,nan 41250,166250 41250,166250 39750,1
64000 39750)),((166250 41250,164000 41250,nan 41250,166250 41250)),((382500 3627
50,382500 364250,384750 364250,384750 362750,382500 362750)))
[8 May 2009 14:51] John Powell
To reviewer, this should be assigned to Alexey Botchkov. Thanks.
[12 May 2009 10:49] Sveta Smirnova
Thank you for the report.

Verified as described.
[12 May 2009 16:55] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/73847

2660 Alexey Botchkov	2009-05-12
      Bug#44753      nan error in union function
           The 'slicescan' algorithm fails if it meets a sequence of
           points in a polygon with exactly same coordinates.
           Fixed by separately checking if (y1 - y0 == 0.0)
      
           Makefiles also fixed to make the windows build possible.
      
      per-file comments:
        libmysqld/CMakeLists.txt
           sql/stacktrace.cc removed
      
        sql/CMakeLists.txt
           sql/gcalc_slicescan.cc and sql/gcalc_tools.cc added to the package
      
        sql/gcalc_slicescan.cc
      Bug#44753      nan error in union function
           GET_DX_DY function fixed to handle (0,0) case properly
[17 Aug 2011 13:58] Jon Stephens
Fixed in tree. Doesn't seem to have appeared in a release; closed.