MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Magne Mahre Date:February 3 2010 9:57pm
Subject:bzr commit into mysql-5.5-trunk-bugfixing branch (magne.mahre:2933)
Bug#50574
View as plain text  
#At file:///data/z/mysql-trunk-bugfixing-50574/ based on revid:li-bing.song@stripped

 2933 Magne Mahre	2010-02-03
      Bug#50574 5.5.x allows spatial indexes on non-spatial columns, 
                causing crashes!
      
      Adding a SPATIAL INDEX on non-geometrical columns caused a
      segmentation fault when the table was subsequently 
      inserted into.
      
      A test was added in mysql_prepare_create_table to explicitly
      check whether non-geometrical columns are used in a
      spatial index, and throw an error if so.

    modified:
      mysql-test/r/gis.result
      mysql-test/t/gis.test
      sql/share/errmsg-utf8.txt
      sql/sql_table.cc
=== modified file 'mysql-test/r/gis.result'
--- a/mysql-test/r/gis.result	2009-12-16 13:47:07 +0000
+++ b/mysql-test/r/gis.result	2010-02-03 21:56:56 +0000
@@ -1058,3 +1058,15 @@ SELECT Polygon(12345123,'');
 Polygon(12345123,'')
 NULL
 End of 5.1 tests
+create table t1(
+col0 binary not null ,
+col2 timestamp,spatial index idx0 (col0)
+) engine=myisam;
+ERROR 42000: A SPATIAL index may only contain geometrical columns
+create table t2(
+col0 binary not null ,
+col2 timestamp
+) engine=myisam;
+create spatial index idx0 on t2(col0);
+ERROR 42000: A SPATIAL index may only contain geometrical columns
+drop table t2;

=== modified file 'mysql-test/t/gis.test'
--- a/mysql-test/t/gis.test	2009-12-16 13:47:07 +0000
+++ b/mysql-test/t/gis.test	2010-02-03 21:56:56 +0000
@@ -723,3 +723,24 @@ SELECT Polygon(1234512,'');
 SELECT Polygon(12345123,'');
 
 --echo End of 5.1 tests
+
+#
+# Bug #50574 5.5.x allows spatial indexes on non-spatial 
+#           columns, causing crashes!
+#
+--error ER_SPATIAL_MUST_HAVE_GEOM_COLS
+create table t1(
+  col0 binary not null ,
+  col2 timestamp,spatial index idx0 (col0)
+) engine=myisam;
+
+create table t2(
+  col0 binary not null ,
+  col2 timestamp
+) engine=myisam;
+
+--error ER_SPATIAL_MUST_HAVE_GEOM_COLS
+create spatial index idx0 on t2(col0);
+
+drop table t2;
+

=== modified file 'sql/share/errmsg-utf8.txt'
--- a/sql/share/errmsg-utf8.txt	2009-12-16 13:47:07 +0000
+++ b/sql/share/errmsg-utf8.txt	2010-02-03 21:56:56 +0000
@@ -6260,3 +6260,5 @@ ER_FIELD_TYPE_NOT_ALLOWED_AS_PARTITION_F
   eng "Field '%-.192s' is of a not allowed type for this type of partitioning"
 ER_PARTITION_FIELDS_TOO_LONG
   eng "The total length of the partitioning fields is too large"
+ER_SPATIAL_MUST_HAVE_GEOM_COLS 42000
+  eng "A SPATIAL index may only contain geometrical columns"

=== modified file 'sql/sql_table.cc'
--- a/sql/sql_table.cc	2009-12-11 09:39:38 +0000
+++ b/sql/sql_table.cc	2010-02-03 21:56:56 +0000
@@ -3268,6 +3268,16 @@ mysql_prepare_create_table(THD *thd, HA_
 	    }
 	  }
 	}
+        else if (!f_is_geom(sql_field->pack_flag) && 
+                 key->type == Key::SPATIAL)
+        {
+          /* A spatial index can only be created on
+             a geometrical column */
+	  my_message(ER_SPATIAL_MUST_HAVE_GEOM_COLS, 
+                     ER(ER_SPATIAL_MUST_HAVE_GEOM_COLS), 
+                     MYF(0));
+	  DBUG_RETURN(TRUE);
+        }
 	else if (!f_is_geom(sql_field->pack_flag) &&
                  ((column->length > length &&
                    !Field::type_can_have_key_part (sql_field->sql_type)) ||


Attachment: [text/bzr-bundle] bzr/magne.mahre@sun.com-20100203215656-4t6air22clx7iql1.bundle
Thread
bzr commit into mysql-5.5-trunk-bugfixing branch (magne.mahre:2933)Bug#50574Magne Mahre3 Feb
  • Re: bzr commit into mysql-5.5-trunk-bugfixing branch(magne.mahre:2933) Bug#50574Ramil Kalimullin <ramil@sun.com>11 Feb