List:Commits« Previous MessageNext Message »
From:kgeorge Date:March 12 2007 5:48pm
Subject:bk commit into 5.1 tree (gkodinov:1.2483) BUG#26794
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of kgeorge. When kgeorge does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet@stripped, 2007-03-12 18:48:51+02:00, gkodinov@stripped +5 -0
  Bug #26794: 5.1 part
   It was syntactically correct to define 
   spatial keys over parts of columns (e.g.
   ALTER TABLE t1 ADD x GEOMETRY NOT NULL, 
     ADD SPATIAL KEY (x(32))).
   This may lead to undefined results and/or
   interpretation.
   Fixed by not allowing partial column 
   specification in a SPATIAL index definition.

  mysql-test/r/alter_table.result@stripped, 2007-03-12 18:48:50+02:00, gkodinov@stripped +6 -4
    Bug #26794: 5.1 part
     test case

  mysql-test/r/gis-rtree.result@stripped, 2007-03-12 18:48:50+02:00, gkodinov@stripped +3 -3
    Bug #26794: 5.1 part
     updated the tests to the new syntax

  mysql-test/t/alter_table.test@stripped, 2007-03-12 18:48:50+02:00, gkodinov@stripped +4 -0
    Bug #26794: 5.1 part
     test case

  mysql-test/t/gis-rtree.test@stripped, 2007-03-12 18:48:50+02:00, gkodinov@stripped +3 -3
    Bug #26794: 5.1 part
     updated the tests to the new syntax

  sql/sql_table.cc@stripped, 2007-03-12 18:48:50+02:00, gkodinov@stripped +8 -0
    Bug #26794: 5.1 part
     Disable defining SPATIAL KEYS with sub-key parts

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	gkodinov
# Host:	magare.gmz
# Root:	/home/kgeorge/mysql/work/B26794-5.1-opt

--- 1.394/sql/sql_table.cc	2007-03-12 17:01:25 +02:00
+++ 1.395/sql/sql_table.cc	2007-03-12 18:48:50 +02:00
@@ -2791,6 +2791,12 @@ static int mysql_prepare_table(THD *thd,
       {
 	column->length*= sql_field->charset->mbmaxlen;
 
+        if (key->type == Key::SPATIAL && column->length)
+        {
+	  my_message(ER_WRONG_SUB_KEY, ER(ER_WRONG_SUB_KEY), MYF(0));
+	  DBUG_RETURN(-1);
+	}
+
 	if (f_is_blob(sql_field->pack_flag) ||
             (f_is_geom(sql_field->pack_flag) && key->type != Key::SPATIAL))
 	{
@@ -5861,6 +5867,8 @@ view_err:
         if (!Field::type_can_have_key_part(cfield->field->type()) ||
             (!Field::type_can_have_key_part(cfield->sql_type) &&
              !f_is_geom (cfield->pack_flag)) ||
+            /* spatial keys can't have sub-key length */
+            (key_info->flags & HA_SPATIAL) ||
             (cfield->field->field_length == key_part_length &&
              !f_is_blob(key_part->key_type)) ||
 	    (cfield->length && (cfield->length < key_part_length /

--- 1.74/mysql-test/r/alter_table.result	2007-03-12 17:08:40 +02:00
+++ 1.75/mysql-test/r/alter_table.result	2007-03-12 18:48:50 +02:00
@@ -886,7 +886,7 @@ ALTER TABLE t1 ADD b GEOMETRY NOT NULL, 
 SHOW CREATE TABLE t1;
 Table	Create Table
 t1	CREATE TABLE `t1` (
-  `a` varchar(500) default NULL,
+  `a` varchar(500) DEFAULT NULL,
   `b` geometry NOT NULL,
   SPATIAL KEY `b` (`b`)
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
@@ -894,7 +894,7 @@ ALTER TABLE t1 ADD KEY(b(50));
 SHOW CREATE TABLE t1;
 Table	Create Table
 t1	CREATE TABLE `t1` (
-  `a` varchar(500) default NULL,
+  `a` varchar(500) DEFAULT NULL,
   `b` geometry NOT NULL,
   SPATIAL KEY `b` (`b`),
   KEY `b_2` (`b`(50))
@@ -903,9 +903,9 @@ ALTER TABLE t1 ADD c POINT;
 SHOW CREATE TABLE t1;
 Table	Create Table
 t1	CREATE TABLE `t1` (
-  `a` varchar(500) default NULL,
+  `a` varchar(500) DEFAULT NULL,
   `b` geometry NOT NULL,
-  `c` point default NULL,
+  `c` point DEFAULT NULL,
   SPATIAL KEY `b` (`b`),
   KEY `b_2` (`b`(50))
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
@@ -913,6 +913,8 @@ CREATE TABLE t2 (a INT, KEY (a(20)));
 ERROR HY000: Incorrect sub part key; the used key part isn't a string, the used length is longer than the key part, or the storage engine doesn't support unique sub keys
 ALTER TABLE t1 ADD d INT;
 ALTER TABLE t1 ADD KEY (d(20));
+ERROR HY000: Incorrect sub part key; the used key part isn't a string, the used length is longer than the key part, or the storage engine doesn't support unique sub keys
+ALTER TABLE t1 ADD e GEOMETRY NOT NULL, ADD SPATIAL KEY (e(30));
 ERROR HY000: Incorrect sub part key; the used key part isn't a string, the used length is longer than the key part, or the storage engine doesn't support unique sub keys
 DROP TABLE t1;
 CREATE TABLE t1 (s CHAR(8) BINARY);

--- 1.58/mysql-test/t/alter_table.test	2007-03-12 17:08:40 +02:00
+++ 1.59/mysql-test/t/alter_table.test	2007-03-12 18:48:50 +02:00
@@ -662,6 +662,10 @@ ALTER TABLE t1 ADD d INT;
 --error ER_WRONG_SUB_KEY
 ALTER TABLE t1 ADD KEY (d(20));
 
+# the 5.1 part of the test
+--error ER_WRONG_SUB_KEY
+ALTER TABLE t1 ADD e GEOMETRY NOT NULL, ADD SPATIAL KEY (e(30));
+
 DROP TABLE t1;
 
 #

--- 1.28/mysql-test/r/gis-rtree.result	2007-03-12 17:01:25 +02:00
+++ 1.29/mysql-test/r/gis-rtree.result	2007-03-12 18:48:50 +02:00
@@ -803,7 +803,7 @@ CREATE TABLE t2 (geom GEOMETRY NOT NULL,
 INSERT INTO t2 SELECT GeomFromText(st) FROM t1;
 ERROR 22003: Cannot get geometry object from data you send to the GEOMETRY field
 drop table t1, t2;
-CREATE TABLE t1 (`geometry` geometry NOT NULL default '',SPATIAL KEY `gndx` (`geometry`(32))) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+CREATE TABLE t1 (`geometry` geometry NOT NULL default '',SPATIAL KEY `gndx` (`geometry`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;
 Warnings:
 Warning	1101	BLOB/TEXT column 'geometry' can't have a default value
 INSERT INTO t1 (geometry) VALUES
@@ -820,7 +820,7 @@ test.t1	check	status	OK
 drop table t1;
 CREATE TABLE t1 (
 c1 geometry NOT NULL default '',
-SPATIAL KEY i1 (c1(32))
+SPATIAL KEY i1 (c1)
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
 Warnings:
 Warning	1101	BLOB/TEXT column 'c1' can't have a default value
@@ -836,7 +836,7 @@ test.t1	check	status	OK
 DROP TABLE t1;
 CREATE TABLE t1 (
 c1 geometry NOT NULL default '',
-SPATIAL KEY i1 (c1(32))
+SPATIAL KEY i1 (c1)
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
 Warnings:
 Warning	1101	BLOB/TEXT column 'c1' can't have a default value

--- 1.21/mysql-test/t/gis-rtree.test	2007-01-08 12:30:58 +02:00
+++ 1.22/mysql-test/t/gis-rtree.test	2007-03-12 18:48:50 +02:00
@@ -172,7 +172,7 @@ CREATE TABLE t2 (geom GEOMETRY NOT NULL,
 INSERT INTO t2 SELECT GeomFromText(st) FROM t1;
 drop table t1, t2;
 
-CREATE TABLE t1 (`geometry` geometry NOT NULL default '',SPATIAL KEY `gndx` (`geometry`(32))) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+CREATE TABLE t1 (`geometry` geometry NOT NULL default '',SPATIAL KEY `gndx` (`geometry`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;
 
 INSERT INTO t1 (geometry) VALUES
 (PolygonFromText('POLYGON((-18.6086111000 -66.9327777000, -18.6055555000
@@ -192,7 +192,7 @@ drop table t1;
 #
 CREATE TABLE t1 (
   c1 geometry NOT NULL default '',
-  SPATIAL KEY i1 (c1(32))
+  SPATIAL KEY i1 (c1)
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
 INSERT INTO t1 (c1) VALUES (
   PolygonFromText('POLYGON((-18.6086111000 -66.9327777000,
@@ -206,7 +206,7 @@ DROP TABLE t1;
 #
 CREATE TABLE t1 (
   c1 geometry NOT NULL default '',
-  SPATIAL KEY i1 (c1(32))
+  SPATIAL KEY i1 (c1)
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
 INSERT INTO t1 (c1) VALUES (
   PolygonFromText('POLYGON((-18.6086111000 -66.9327777000,
Thread
bk commit into 5.1 tree (gkodinov:1.2483) BUG#26794kgeorge12 Mar