MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Sergey Vojtovich Date:April 1 2010 12:15pm
Subject:bzr commit into mysql-5.1-bugteam branch (svoj:3527) Bug#51356
View as plain text  
#At file:///home/svoj/devel/innodb-snapshots/mysql-5.1-bugteam/ based on revid:svoj@stripped

 3527 Sergey Vojtovich	2010-04-01
      Applying InnoDB snapshot, fixes BUG#51356.
      
      Detailed revision comments:
      
      r6790 | jyang | 2010-03-10 13:09:41 +0200 (Wed, 10 Mar 2010) | 7 lines
      branches/zip: Fix bug #51356: "many valgrind errors in error messages
      with concurrent ddl". Null terminate the name string returned
      from innobase_convert_identifier() call when reporting DB_DUPLICATE_KEY
      error in create_table_def().
      rb://266 approved by Marko

    added:
      mysql-test/suite/innodb/r/innodb_bug51378.result
      mysql-test/suite/innodb/t/innodb_bug51378.test
    modified:
      storage/innodb_plugin/handler/ha_innodb.cc
=== added file 'mysql-test/suite/innodb/r/innodb_bug51378.result'
--- a/mysql-test/suite/innodb/r/innodb_bug51378.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb/r/innodb_bug51378.result	2010-04-01 12:14:51 +0000
@@ -0,0 +1,66 @@
+create table bug51378 (
+col1 int not null,
+col2 blob not null,
+col3 time not null) engine = innodb;
+create unique index idx on bug51378(col1, col2(31));
+alter table bug51378 add unique index idx2(col1, col2(31));
+create unique index idx3 on bug51378(col1, col3);
+SHOW CREATE TABLE bug51378;
+Table	Create Table
+bug51378	CREATE TABLE `bug51378` (
+  `col1` int(11) NOT NULL,
+  `col2` blob NOT NULL,
+  `col3` time NOT NULL,
+  UNIQUE KEY `idx3` (`col1`,`col3`),
+  UNIQUE KEY `idx` (`col1`,`col2`(31)),
+  UNIQUE KEY `idx2` (`col1`,`col2`(31))
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+drop index idx3 on bug51378;
+SHOW CREATE TABLE bug51378;
+Table	Create Table
+bug51378	CREATE TABLE `bug51378` (
+  `col1` int(11) NOT NULL,
+  `col2` blob NOT NULL,
+  `col3` time NOT NULL,
+  UNIQUE KEY `idx` (`col1`,`col2`(31)),
+  UNIQUE KEY `idx2` (`col1`,`col2`(31))
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+alter table bug51378 add primary key idx3(col1, col2(31));
+SHOW CREATE TABLE bug51378;
+Table	Create Table
+bug51378	CREATE TABLE `bug51378` (
+  `col1` int(11) NOT NULL,
+  `col2` blob NOT NULL,
+  `col3` time NOT NULL,
+  PRIMARY KEY (`col1`,`col2`(31)),
+  UNIQUE KEY `idx` (`col1`,`col2`(31)),
+  UNIQUE KEY `idx2` (`col1`,`col2`(31))
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+drop table bug51378;
+create table bug51378 (
+col1 int not null,
+col2 blob not null,
+col3 time not null, primary key(col1, col2(31))) engine = innodb;
+create unique index idx on bug51378(col1, col2(31));
+SHOW CREATE TABLE bug51378;
+Table	Create Table
+bug51378	CREATE TABLE `bug51378` (
+  `col1` int(11) NOT NULL,
+  `col2` blob NOT NULL,
+  `col3` time NOT NULL,
+  PRIMARY KEY (`col1`,`col2`(31)),
+  UNIQUE KEY `idx` (`col1`,`col2`(31))
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+drop table bug51378;
+create table bug51378 (
+col1 int not null,
+col2 int ) engine = innodb;
+create unique index idx on bug51378(col1, col2);
+SHOW CREATE TABLE bug51378;
+Table	Create Table
+bug51378	CREATE TABLE `bug51378` (
+  `col1` int(11) NOT NULL,
+  `col2` int(11) DEFAULT NULL,
+  UNIQUE KEY `idx` (`col1`,`col2`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+drop table bug51378;

=== added file 'mysql-test/suite/innodb/t/innodb_bug51378.test'
--- a/mysql-test/suite/innodb/t/innodb_bug51378.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/innodb/t/innodb_bug51378.test	2010-04-01 12:14:51 +0000
@@ -0,0 +1,77 @@
+# This is the test for bug 51378. Unique index created
+# through "create index" and "alter table add unique index"
+# interfaces should not be treated as primary index if indexed
+# columns contain one or more column prefix(es) (only prefix/part of
+# the column is indexed)
+# On the other hand, if there is a unique index covers all
+# columns of a table, and they are non-null columns, and
+# full length of the column are indexed, then this index
+# will be created as primary index
+# Following queries test various scenario, no mismatch
+# error message should be printed.
+--source include/have_innodb.inc
+
+# Create a table contains a BLOB column
+create table bug51378 (
+	col1 int not null,
+	col2 blob not null,
+	col3 time not null) engine = innodb;
+
+# Create following unique indexes on 'col1' and 'col2(31)'
+# of the table, the index should not be treated as primary
+# key because it indexes only first 31 bytes of col2.
+# Thus it contains "column prefix", and will not be
+# upgraded to primary index.
+# There should not be mismatch message printed in the
+# errorlog
+create unique index idx on bug51378(col1, col2(31));
+
+alter table bug51378 add unique index idx2(col1, col2(31));
+
+# Unique index on 'col1' and 'col3' will be created as primary index,
+# since the index does not contain column prefix
+create unique index idx3 on bug51378(col1, col3);
+
+# Show create table would show idx3 created as unique index, internally,
+# idx3 is treated as primary index both by MySQL and Innodb
+SHOW CREATE TABLE bug51378;
+
+# "GEN_CLUST_INDEX" will be re-created as default primary index
+# after idx3 is dropped
+drop index idx3 on bug51378;
+
+SHOW CREATE TABLE bug51378;
+
+# Or we can add the primary key through alter table interfaces
+alter table bug51378 add primary key idx3(col1, col2(31));
+
+SHOW CREATE TABLE bug51378;
+
+drop table bug51378;
+
+# Or we can create such primary key through create table interfaces
+create table bug51378 (
+        col1 int not null,
+        col2 blob not null,
+        col3 time not null, primary key(col1, col2(31))) engine = innodb;
+
+# Unique index on one or more column prefix(es) will be created
+# as non-cluster index
+create unique index idx on bug51378(col1, col2(31));
+
+SHOW CREATE TABLE bug51378;
+
+drop table bug51378;
+
+# If a table has a NULLABLE column, unique index on it will not
+# be treated as primary index.
+create table bug51378 (
+	col1 int not null,
+        col2 int ) engine = innodb;
+
+# This will be created as non-cluster index since col2 is nullable
+create unique index idx on bug51378(col1, col2);
+
+SHOW CREATE TABLE bug51378;
+
+drop table bug51378;

=== modified file 'storage/innodb_plugin/handler/ha_innodb.cc'
--- a/storage/innodb_plugin/handler/ha_innodb.cc	2010-04-01 12:12:44 +0000
+++ b/storage/innodb_plugin/handler/ha_innodb.cc	2010-04-01 12:14:51 +0000
@@ -6045,9 +6045,11 @@ create_table_def(
 
 	if (error == DB_DUPLICATE_KEY) {
 		char buf[100];
-		innobase_convert_identifier(buf, sizeof buf,
-					    table_name, strlen(table_name),
-					    trx->mysql_thd, TRUE);
+		char* buf_end = innobase_convert_identifier(
+			buf, sizeof buf - 1, table_name, strlen(table_name),
+			trx->mysql_thd, TRUE);
+
+		*buf_end = '\0';
 		my_error(ER_TABLE_EXISTS_ERROR, MYF(0), buf);
 	}
 


Attachment: [text/bzr-bundle] bzr/svoj@sun.com-20100401121451-p5ko6dnuy5fx97w7.bundle
Thread
bzr commit into mysql-5.1-bugteam branch (svoj:3527) Bug#51356Sergey Vojtovich1 Apr