[Commits] Rev 3573: Bug #1043845 st_distance() results are incorrect depending on variable order. in file:///home/hf/wmar/5.3-gis/

holyfoot at askmonty.org holyfoot at askmonty.org
Fri Aug 31 19:03:45 EEST 2012


At file:///home/hf/wmar/5.3-gis/

------------------------------------------------------------
revno: 3573
revision-id: holyfoot at askmonty.org-20120831145045-di4y4vy28o4kl48t
parent: sergii at pisem.net-20120831100152-a261yml0vddxaknj
committer: Alexey Botchkov <holyfoot at askmonty.org>
branch nick: 5.3-gis
timestamp: Fri 2012-08-31 19:50:45 +0500
message:
  Bug #1043845 st_distance() results are incorrect depending on variable order.
          Autointersections of an object were treated as nodes, so the wrong result.
  
  per-file comments:
    mysql-test/r/gis.result
  Bug #1043845 st_distance() results are incorrect depending on variable order.
          test result updated.
    mysql-test/t/gis.test
  Bug #1043845 st_distance() results are incorrect depending on variable order.
          test case added.
    sql/item.cc
          small fix to make compilers happy.
    sql/item_geofunc.cc
  Bug #1043845 st_distance() results are incorrect depending on variable order.
          Skip intersection points when calculate distance.
-------------- next part --------------
=== modified file 'mysql-test/r/gis.result'
--- a/mysql-test/r/gis.result	2012-05-20 12:57:29 +0000
+++ b/mysql-test/r/gis.result	2012-08-31 14:50:45 +0000
@@ -1473,3 +1473,26 @@ WHERE ST_Contains(ST_Buffer(bridges.posi
 count(*)
 1
 DROP DATABASE gis_ogs;
+#
+# BUG #1043845 st_distance() results are incorrect depending on variable order
+#
+select st_distance(geomfromtext('LINESTRING(-95.9673005697771 36.13509598461,
+                                            -95.9673057475387 36.1344478941074,
+                                            -95.9673063519371 36.134484524621,
+                                            -95.9673049102515 36.1343976584193)'),
+geomfromtext('point(-95.96269500000000000000 36.14181833333330000000)')) ;
+st_distance(geomfromtext('LINESTRING(-95.9673005697771 36.13509598461,
+                                            -95.9673057475387 36.1344478941074,
+                                            -95.9673063519371 36.134484524621,
+                         
+0.008148695928138
+select st_distance(geomfromtext('point(-95.96269500000000000000 36.14181833333330000000)'),
+geomfromtext('LINESTRING(-95.9673005697771 36.13509598461,
+                           -95.9673057475387 36.1344478941074,
+                           -95.9673063519371 36.134484524621,
+                           -95.9673049102515 36.1343976584193) ')) ;
+st_distance(geomfromtext('point(-95.96269500000000000000 36.14181833333330000000)'),
+geomfromtext('LINESTRING(-95.9673005697771 36.13509598461,
+                           -95.9673057475387 36.1344478941074,
+                           -95.9673063519371 36.
+0.008148695928138

=== modified file 'mysql-test/t/gis.test'
--- a/mysql-test/t/gis.test	2012-05-20 12:57:29 +0000
+++ b/mysql-test/t/gis.test	2012-08-31 14:50:45 +0000
@@ -1355,3 +1355,19 @@ WHERE ST_Contains(ST_Buffer(bridges.posi
 #WHERE lakes.name = 'Blue Lake'; 
 
 DROP DATABASE gis_ogs;
+
+--echo #
+--echo # BUG #1043845 st_distance() results are incorrect depending on variable order
+--echo #
+
+select st_distance(geomfromtext('LINESTRING(-95.9673005697771 36.13509598461,
+                                            -95.9673057475387 36.1344478941074,
+                                            -95.9673063519371 36.134484524621,
+                                            -95.9673049102515 36.1343976584193)'),
+  geomfromtext('point(-95.96269500000000000000 36.14181833333330000000)')) ;
+select st_distance(geomfromtext('point(-95.96269500000000000000 36.14181833333330000000)'),
+  geomfromtext('LINESTRING(-95.9673005697771 36.13509598461,
+                           -95.9673057475387 36.1344478941074,
+                           -95.9673063519371 36.134484524621,
+                           -95.9673049102515 36.1343976584193) ')) ;
+

=== modified file 'sql/item.cc'
--- a/sql/item.cc	2012-08-31 10:01:52 +0000
+++ b/sql/item.cc	2012-08-31 14:50:45 +0000
@@ -8858,7 +8858,7 @@ bool Item_type_holder::join_types(THD *t
                        item->max_length, item->decimals));
   fld_type= Field::field_type_merge(fld_type, get_real_type(item));
   {
-    int item_decimals= item->decimals;
+    uint item_decimals= item->decimals;
     /* fix variable decimals which always is NOT_FIXED_DEC */
     if (Field::result_merge_type(fld_type) == INT_RESULT)
       item_decimals= 0;

=== modified file 'sql/item_geofunc.cc'
--- a/sql/item_geofunc.cc	2012-04-29 13:08:11 +0000
+++ b/sql/item_geofunc.cc	2012-08-31 14:50:45 +0000
@@ -1693,7 +1693,8 @@ double Item_func_distance::val_real()
     for (dist_point= collector.get_first(); dist_point; dist_point= dist_point->get_next())
     {
       /* We only check vertices of object 2 */
-      if (dist_point->shape < obj2_si)
+      if (dist_point->type != Gcalc_heap::nt_shape_node ||
+          dist_point->shape < obj2_si)
         continue;
 
       /* if we have an edge to check */



More information about the commits mailing list