MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Georgi Kodinov Date:October 20 2009 1:58pm
Subject:bzr commit into mysql-5.1-bugteam branch (joro:3188) Bug#47780
View as plain text  
#At file:///home/kgeorge/mysql/work/B47780-5.1-bugteam/ based on revid:bar@stripped

 3188 Georgi Kodinov	2009-10-20
      Bug #47780: crash when comparing GIS items from subquery
      
      If the first argument to GeomFromWKB function is a geometry
      field then the function just returns its value.
      However in doing so it's not preserving first argument's 
      null_value flag and this causes unexpected null value to
      be returned to the calling function.
      
      Fixed by updating the null_value of the GeomFromWKB function
      in such cases.

    modified:
      mysql-test/r/gis.result
      mysql-test/t/gis.test
      sql/item_geofunc.cc
=== modified file 'mysql-test/r/gis.result'
--- a/mysql-test/r/gis.result	2009-07-10 23:12:13 +0000
+++ b/mysql-test/r/gis.result	2009-10-20 13:58:42 +0000
@@ -1032,4 +1032,16 @@ NULL
 SELECT Polygon(12345123,'');
 Polygon(12345123,'')
 NULL
+#
+# Bug #47780: crash when comparing GIS items from subquery
+#
+CREATE TABLE t1(a INT, b MULTIPOLYGON);
+INSERT INTO t1 VALUES 
+(0,
+GEOMFROMTEXT(
+'multipolygon(((1 2,3 4,5 6,7 8,9 8),(7 6,5 4,3 2,1 2,3 4)))'));
+# must not crash
+SELECT 1 FROM t1 WHERE a <> (SELECT GEOMETRYCOLLECTIONFROMWKB(b) FROM t1);
+1
+DROP TABLE t1;
 End of 5.1 tests

=== modified file 'mysql-test/t/gis.test'
--- a/mysql-test/t/gis.test	2009-07-10 23:12:13 +0000
+++ b/mysql-test/t/gis.test	2009-10-20 13:58:42 +0000
@@ -691,4 +691,21 @@ SELECT Polygon(123451,'');
 SELECT Polygon(1234512,'');
 SELECT Polygon(12345123,'');
 
+
+--echo #
+--echo # Bug #47780: crash when comparing GIS items from subquery
+--echo #
+
+CREATE TABLE t1(a INT, b MULTIPOLYGON);
+INSERT INTO t1 VALUES 
+  (0,
+   GEOMFROMTEXT(
+    'multipolygon(((1 2,3 4,5 6,7 8,9 8),(7 6,5 4,3 2,1 2,3 4)))'));
+
+--echo # must not crash
+SELECT 1 FROM t1 WHERE a <> (SELECT GEOMETRYCOLLECTIONFROMWKB(b) FROM t1);
+
+DROP TABLE t1;
+
+
 --echo End of 5.1 tests

=== modified file 'sql/item_geofunc.cc'
--- a/sql/item_geofunc.cc	2009-07-10 23:12:13 +0000
+++ b/sql/item_geofunc.cc	2009-10-20 13:58:42 +0000
@@ -84,7 +84,9 @@ String *Item_func_geometry_from_wkb::val
 
   if (args[0]->field_type() == MYSQL_TYPE_GEOMETRY)
   {
-    return args[0]->val_str(str);
+    String *str_ret= args[0]->val_str(str);
+    null_value= args[0]->is_null();
+    return str_ret;
   }
 
   wkb= args[0]->val_str(&arg_val);


Attachment: [text/bzr-bundle] bzr/joro@sun.com-20091020135842-yvo4o10mlt4j5ycv.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (joro:3188) Bug#47780Georgi Kodinov20 Oct