List:Internals« Previous MessageNext Message »
From:Jim Winstead Date:June 2 2005 7:00pm
Subject:bk commit into 5.0 tree (jimw:1.1913) BUG#10543
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of jimw. When jimw 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
  1.1913 05/06/02 10:00:36 jimw@stripped +3 -0
  Additional tweak to fix for bug #10543, to prevent a change in
  behavior when extending fields that were fully part of a
  multi-part key.

  sql/sql_table.cc
    1.247 05/06/02 10:00:32 jimw@stripped +4 -0
    Reset key_part_length when old field length was the same as the
    old key_part_length.

  mysql-test/t/key.test
    1.20 05/06/02 10:00:32 jimw@stripped +13 -0
    Add test for behavior of extending fields in a multi-part key
    that were defined with a partial length the same as their
    field length.

  mysql-test/r/key.result
    1.25 05/06/02 10:00:32 jimw@stripped +25 -0
    Update results

# 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:	jimw
# Host:	rama.(none)
# Root:	/home/jimw/my/mysql-5.0-10543

--- 1.246/sql/sql_table.cc	2005-05-25 18:11:44 -07:00
+++ 1.247/sql/sql_table.cc	2005-06-02 10:00:32 -07:00
@@ -3341,11 +3341,15 @@
           previous type, or the field length is less than the key part
           length, unset the key part length.
 
+          We also unset the key part length if it is the same as the
+          old field's length, so the whole new field will be used.
+
           BLOBs may have cfield->length == 0, which is why we test it before
           checking whether cfield->length < key_part_length (in chars).
          */
         if (!Field::type_can_have_key_part(cfield->field->type()) ||
             !Field::type_can_have_key_part(cfield->sql_type) ||
+            cfield->field->field_length == key_part_length ||
 	    (cfield->length && (cfield->length < key_part_length /
                                 key_part->field->charset()->mbmaxlen)))
 	  key_part_length= 0;			// Use whole field

--- 1.24/mysql-test/r/key.result	2004-11-22 11:54:41 -08:00
+++ 1.25/mysql-test/r/key.result	2005-06-02 10:00:32 -07:00
@@ -329,3 +329,28 @@
 alter table t1 add key (c1,c1,c2);
 ERROR 42S21: Duplicate column name 'c1'
 drop table t1;
+create table t1 (a varchar(10), b varchar(10), key(a(10),b(10)));
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` varchar(10) default NULL,
+  `b` varchar(10) default NULL,
+  KEY `a` (`a`,`b`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+alter table t1 modify b varchar(20);
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` varchar(10) default NULL,
+  `b` varchar(20) default NULL,
+  KEY `a` (`a`,`b`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+alter table t1 modify a varchar(20);
+show create table t1;
+Table	Create Table
+t1	CREATE TABLE `t1` (
+  `a` varchar(20) default NULL,
+  `b` varchar(20) default NULL,
+  KEY `a` (`a`,`b`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;

--- 1.19/mysql-test/t/key.test	2004-11-22 11:54:42 -08:00
+++ 1.20/mysql-test/t/key.test	2005-06-02 10:00:32 -07:00
@@ -324,3 +324,16 @@
 --error 1060
 alter table t1 add key (c1,c1,c2);
 drop table t1;
+
+#
+# If we use a partial field for a key that is actually the length of the
+# field, and we extend the field, we end up with a key that includes the
+# whole new length of the field.
+#
+create table t1 (a varchar(10), b varchar(10), key(a(10),b(10)));
+show create table t1;
+alter table t1 modify b varchar(20);
+show create table t1;
+alter table t1 modify a varchar(20);
+show create table t1;
+drop table t1;
Thread
bk commit into 5.0 tree (jimw:1.1913) BUG#10543Jim Winstead2 Jun