MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Georgi Kodinov Date:October 24 2009 6:53am
Subject:bzr commit into mysql-5.0 branch (joro:2824) Bug#47780
View as plain text  
#At file:///home/kgeorge/mysql/work/B47780-5.0-bugteam/ based on revid:ramil@stripped

 2824 Georgi Kodinov	2009-10-21
      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 (and all other cases that return a NULL e.g.
      because of not enough memory for the return buffer).

    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-04-28 09:47:26 +0000
+++ b/mysql-test/r/gis.result	2009-10-21 08:43:45 +0000
@@ -971,4 +971,16 @@ select min(`col002`) from t1 union selec
 min(`col002`)
 NULL
 drop table t1;
+#
+# 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.0 tests

=== modified file 'mysql-test/t/gis.test'
--- a/mysql-test/t/gis.test	2009-04-28 09:47:26 +0000
+++ b/mysql-test/t/gis.test	2009-10-21 08:43:45 +0000
@@ -654,4 +654,20 @@ insert into t1 values (),(),();
 select min(`col002`) from t1 union select `col002` from t1;
 drop table t1;
 
+--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.0 tests

=== modified file 'sql/item_geofunc.cc'
--- a/sql/item_geofunc.cc	2009-04-28 09:47:26 +0000
+++ b/sql/item_geofunc.cc	2009-10-21 08:43:45 +0000
@@ -76,7 +76,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]->null_value;
+    return str_ret;
   }
 
   wkb= args[0]->val_str(&arg_val);
@@ -86,7 +88,10 @@ String *Item_func_geometry_from_wkb::val
 
   str->set_charset(&my_charset_bin);
   if (str->reserve(SRID_SIZE, 512))
-    return 0;
+  {
+    null_value= TRUE;                           /* purecov: inspected */
+    return 0;                                   /* purecov: inspected */
+  }
   str->length(0);
   str->q_append(srid);
   if ((null_value= 


Attachment: [text/bzr-bundle] bzr/joro@sun.com-20091021084345-iki6z0uceieoupey.bundle
Thread
bzr commit into mysql-5.0 branch (joro:2824) Bug#47780Georgi Kodinov24 Oct