MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Magne Mahre Date:September 1 2010 5:38pm
Subject:bzr commit into mysql-5.1-bugteam branch (magne.mahre:3498) Bug#39932
View as plain text  
#At file:///data/x/mysql-5.1-bugteam-39932/ based on revid:davi.arnaut@stripped

 3498 Magne Mahre	2010-09-01
      Bug#39932 "create table fails if column for FK is in different
                case than in corr index".
            
      Server was unable to find existing or explicitly created supporting
      index for foreign key if corresponding statement clause used field
      names in case different than one used in key specification and created
      yet another supporting index.
      In cases when name of constraint (and thus name of generated index)
      was the same as name of existing/explicitly created index this led
      to duplicate key name error.
            
      The problem was that unlike all other code Key_part_spec::operator==()
      compared field names in case sensitive fashion. As result routines
      responsible for getting rid of redundant generated supporting indexes
      for foreign key were not working properly for versions of field names
      using different cases.
      
      (backported from mysql-trunk)
     @ sql/sql_class.cc
        Make field name comparison case-insensitive like it is
        in the rest of server.

    modified:
      mysql-test/suite/innodb/r/innodb_mysql.result
      mysql-test/suite/innodb/t/innodb_mysql.test
      sql/sql_class.cc
=== modified file 'mysql-test/suite/innodb/r/innodb_mysql.result'
--- a/mysql-test/suite/innodb/r/innodb_mysql.result	2010-08-26 09:31:04 +0000
+++ b/mysql-test/suite/innodb/r/innodb_mysql.result	2010-09-01 17:38:34 +0000
@@ -2588,3 +2588,23 @@ Extra	Using index
 DROP TABLE t1;
 #
 End of 5.1 tests
+#
+# Test for bug #39932 "create table fails if column for FK is in different
+#                      case than in corr index".
+#
+drop tables if exists t1, t2;
+create table t1 (pk int primary key) engine=InnoDB;
+# Even although the below statement uses uppercased field names in
+# foreign key definition it still should be able to find explicitly
+# created supporting index. So it should succeed and should not
+# create any additional supporting indexes.
+create table t2 (fk int, key x (fk),
+constraint x foreign key (FK) references t1 (PK)) engine=InnoDB;
+show create table t2;
+Table	Create Table
+t2	CREATE TABLE `t2` (
+  `fk` int(11) DEFAULT NULL,
+  KEY `x` (`fk`),
+  CONSTRAINT `x` FOREIGN KEY (`fk`) REFERENCES `t1` (`pk`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+drop table t2, t1;

=== modified file 'mysql-test/suite/innodb/t/innodb_mysql.test'
--- a/mysql-test/suite/innodb/t/innodb_mysql.test	2010-08-26 11:23:44 +0000
+++ b/mysql-test/suite/innodb/t/innodb_mysql.test	2010-09-01 17:38:34 +0000
@@ -813,3 +813,21 @@ DROP TABLE t1;
 
 
 --echo End of 5.1 tests
+
+
+--echo #
+--echo # Test for bug #39932 "create table fails if column for FK is in different
+--echo #                      case than in corr index".
+--echo #
+--disable_warnings
+drop tables if exists t1, t2;
+--enable_warnings
+create table t1 (pk int primary key) engine=InnoDB;
+--echo # Even although the below statement uses uppercased field names in
+--echo # foreign key definition it still should be able to find explicitly
+--echo # created supporting index. So it should succeed and should not
+--echo # create any additional supporting indexes.
+create table t2 (fk int, key x (fk),
+                 constraint x foreign key (FK) references t1 (PK)) engine=InnoDB;
+show create table t2;
+drop table t2, t1;

=== modified file 'sql/sql_class.cc'
--- a/sql/sql_class.cc	2010-07-23 11:15:56 +0000
+++ b/sql/sql_class.cc	2010-09-01 17:38:34 +0000
@@ -91,7 +91,9 @@ extern "C" void free_user_var(user_var_e
 
 bool Key_part_spec::operator==(const Key_part_spec& other) const
 {
-  return length == other.length && !strcmp(field_name, other.field_name);
+  return length == other.length &&
+         !my_strcasecmp(system_charset_info, field_name,
+                        other.field_name);
 }
 
 /**


Attachment: [text/bzr-bundle] bzr/magne.mahre@sun.com-20100901173834-7lrqgycyuxsg4ab7.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (magne.mahre:3498) Bug#39932Magne Mahre1 Sep