mirror of
https://github.com/MariaDB/server.git
synced 2025-01-20 05:52:27 +01:00
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
This commit is contained in:
parent
178dccaae5
commit
aacb485899
3 changed files with 148 additions and 3 deletions
66
mysql-test/suite/innodb/r/innodb_bug51378.result
Normal file
66
mysql-test/suite/innodb/r/innodb_bug51378.result
Normal file
|
@ -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;
|
77
mysql-test/suite/innodb/t/innodb_bug51378.test
Normal file
77
mysql-test/suite/innodb/t/innodb_bug51378.test
Normal file
|
@ -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;
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue