Commit 4cc4b2c7 authored by vasil's avatar vasil

branches/zip:

Disable part of innodb-index test because MySQL changed its behavior and
is not calling ::add_index() anymore in the following ALTER TABLE:

CREATE TABLE t (a INT) ENGINE=INNODB;
INSERT INTO t VALUES (NULL);
ALTER TABLE t ADD PRIMARY KEY (a);  -- adding primary index on non-NULL column

Previously, in ALTER TABLE, MySQL would call ::add_index() which would
fail with a "primary key cannot contain NULL" error.

The change occured in:

  mysql-5.1$ bzr log -v -r2667
  ------------------------------------------------------------
  revno: 2667
  committer: Davi Arnaut <davi@mysql.com>
  branch nick: 33873-5.1
  timestamp: Tue 2008-06-17 11:12:21 -0300
  message:
    Bug#33873: Fast ALTER TABLE doesn't work with multibyte character sets
    
    The problem was that when comparing tables for a possible
    fast alter table, the comparison was being performed using
    the parsed information and not the final definition.
          
    The solution is to use the possible final table layout to
    compare if a fast alter is possible or not.
  modified:
    mysql-test/include/mix1.inc
    mysql-test/r/alter_table.result
    mysql-test/r/innodb_mysql.result
    mysql-test/t/alter_table.test
    sql/sql_table.cc
  mysql-5.1$
parent 8093d7a5
......@@ -765,7 +765,6 @@ insert into t2 values ('jejdkrun87'),('adfd72nh9k'),
('adfdpplkeock'),('adfdijnmnb78k'),('adfdijn0loKNHJik');
create table t1(a int, b blob, c text, d text not null)
engine=innodb default charset = utf8;
insert into t1 values (null,null,null,'null');
insert into t1
select a,left(repeat(d,100*a),65535),repeat(d,20*a),d from t2,t3;
drop table t2, t3;
......@@ -775,7 +774,6 @@ count(*)
select a,
length(b),b=left(repeat(d,100*a),65535),length(c),c=repeat(d,20*a),d from t1;
a length(b) b=left(repeat(d,100*a),65535) length(c) c=repeat(d,20*a) d
NULL NULL NULL NULL NULL null
22 22000 1 4400 1 adfd72nh9k
22 35200 1 7040 1 adfdijn0loKNHJik
22 28600 1 5720 1 adfdijnmnb78k
......@@ -802,9 +800,6 @@ NULL NULL NULL NULL NULL null
66 65535 1 15840 1 adfdpplkeock
66 65535 1 13200 1 jejdkrun87
alter table t1 add primary key (a), add key (b(20));
ERROR 42000: All parts of a PRIMARY KEY must be NOT NULL; if you need NULL in a key, use UNIQUE instead
delete from t1 where d='null';
alter table t1 add primary key (a), add key (b(20));
ERROR 23000: Duplicate entry '22' for key 'PRIMARY'
delete from t1 where a%2;
check table t1;
......
......@@ -239,16 +239,47 @@ insert into t2 values ('jejdkrun87'),('adfd72nh9k'),
create table t1(a int, b blob, c text, d text not null)
engine=innodb default charset = utf8;
insert into t1 values (null,null,null,'null');
# r2667 The following test is disabled because MySQL behavior changed.
# r2667 The test was added with this comment:
# r2667
# r2667 ------------------------------------------------------------------------
# r2667 r1699 | marko | 2007-08-10 19:53:19 +0300 (Fri, 10 Aug 2007) | 5 lines
# r2667
# r2667 branches/zip: Add changes that accidentally omitted from r1698:
# r2667
# r2667 innodb-index.test, innodb-index.result: Add a test for creating
# r2667 a PRIMARY KEY on a column that contains a NULL value.
# r2667 ------------------------------------------------------------------------
# r2667
# r2667 but in BZR-r2667:
# r2667 http://bazaar.launchpad.net/~mysql/mysql-server/mysql-5.1/revision/davi%40mysql.com-20080617141221-8yre8ys9j4uw3xx5?start_revid=joerg%40mysql.com-20080630105418-7qoe5ehomgrcdb89
# r2667 MySQL changed the behavior to do full table copy when creating PRIMARY INDEX
# r2667 on a non-NULL column instead of calling ::add_index() which would fail (and
# r2667 this is what we were testing here). Before r2667 the code execution path was
# r2667 like this (when adding PRIMARY INDEX on a non-NULL column with ALTER TABLE):
# r2667
# r2667 mysql_alter_table()
# r2667 compare_tables() // would return ALTER_TABLE_INDEX_CHANGED
# r2667 ::add_index() // would fail with "primary index cannot contain NULL"
# r2667
# r2667 after r2667 the code execution path is the following:
# r2667
# r2667 mysql_alter_table()
# r2667 compare_tables() // returns ALTER_TABLE_DATA_CHANGED
# r2667 full copy is done, without calling ::add_index()
# r2667
# r2667 To enable, remove "# r2667: " below.
# r2667
# r2667: insert into t1 values (null,null,null,'null');
insert into t1
select a,left(repeat(d,100*a),65535),repeat(d,20*a),d from t2,t3;
drop table t2, t3;
select count(*) from t1 where a=44;
select a,
length(b),b=left(repeat(d,100*a),65535),length(c),c=repeat(d,20*a),d from t1;
--error ER_PRIMARY_CANT_HAVE_NULL
alter table t1 add primary key (a), add key (b(20));
delete from t1 where d='null';
# r2667: --error ER_PRIMARY_CANT_HAVE_NULL
# r2667: alter table t1 add primary key (a), add key (b(20));
# r2667: delete from t1 where d='null';
--error ER_DUP_ENTRY
alter table t1 add primary key (a), add key (b(20));
delete from t1 where a%2;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment