From: Pekka Nousiainen Date: September 22 2012 6:43pm Subject: bzr push into mysql-5.5-cluster-7.3-fk branch (pekka.nousiainen:3919 to 3920) WL#6244 List-Archive: http://lists.mysql.com/commits/144861 Message-Id: <20120922184315.10060.70624.3920@cuda> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 3920 Pekka Nousiainen 2012-09-22 wl#6244 errcode6.diff more DDL error tests modified: mysql-test/suite/ndb/r/ndb_fk_bugs.result mysql-test/suite/ndb/t/ndb_fk_bugs.test 3919 Pekka Nousiainen 2012-09-22 wl#6244 errcode5.diff column compatibility (from Jul 2 patch) modified: mysql-test/suite/ndb/r/ndb_fk_bugs.result mysql-test/suite/ndb/t/ndb_fk_bugs.test sql/ha_ndb_ddl_fk.cc === modified file 'mysql-test/suite/ndb/r/ndb_fk_bugs.result' --- a/mysql-test/suite/ndb/r/ndb_fk_bugs.result 2012-09-22 10:10:42 +0000 +++ b/mysql-test/suite/ndb/r/ndb_fk_bugs.result 2012-09-22 18:42:26 +0000 @@ -90,7 +90,7 @@ Warning 1296 Got error 21026 'Create for Error 1005 Can't create table 'test.languages' (errno: 150) CREATE TABLE languages (id INT NOT NULL PRIMARY KEY) engine=ndb; drop table languages, towns, counties; -"# test: child vs parent column types" +# test: child vs parent column types create table t1 ( a int not null, b int not null, @@ -123,3 +123,212 @@ Level Code Message Warning 1215 Parent column t1.b is incompatible with child column t2.b in NDB Error 150 Cannot add foreign key constraint drop table t2, t1; +# test: parent table not exist +create table t2 ( +a int not null, +b int not null, +primary key using hash (a), +key (b), +constraint fk1 foreign key (b) references t1 (b) +) engine ndb; +ERROR HY000: Can't create table 'test.t2' (errno: 155) +show warnings; +Level Code Message +Error 1005 Can't create table 'test.t2' (errno: 155) +create table t2 ( +a int not null, +b int not null, +primary key using hash (a), +key (b) +) engine ndb; +alter online table t2 +add constraint fk1 foreign key (b) references t1 (b); +ERROR HY000: No such table: '(null)' +show warnings; +Level Code Message +Error 155 No such table: '(null)' +drop table t2; +# test: parent column not exist +create table t1 ( +a int not null, +primary key using hash (a) +) engine ndb; +create table t2 ( +a int not null, +b int not null, +primary key using hash (a), +key (b), +constraint fk1 foreign key (b) references t1 (b) +) engine ndb; +ERROR HY000: Can't create table 'test.t2' (errno: 150) +show warnings; +Level Code Message +Warning 1215 Parent table t1 has no column b in NDB +Error 1005 Can't create table 'test.t2' (errno: 150) +create table t2 ( +a int not null, +b int not null, +primary key using hash (a), +key (b) +) engine ndb; +alter online table t2 +add constraint fk1 foreign key (b) references t1 (b); +ERROR HY000: Cannot add foreign key constraint +show warnings; +Level Code Message +Warning 1215 Parent table t1 has no column b in NDB +Error 150 Cannot add foreign key constraint +drop table t2, t1; +# test: parent key no index +create table t1 ( +a int not null, +b int not null, +primary key using hash (a) +) engine ndb; +create table t2 ( +a int not null, +b int not null, +primary key using hash (a), +key (b), +constraint fk1 foreign key (b) references t1 (b) +) engine ndb; +ERROR HY000: Can't create table 'test.t2' (errno: 150) +show warnings; +Level Code Message +Warning 1215 Parent table t1 foreign key columns match no index in NDB +Error 1005 Can't create table 'test.t2' (errno: 150) +create table t2 ( +a int not null, +b int not null, +primary key using hash (a), +key (b) +) engine ndb; +alter online table t2 +add constraint fk1 foreign key (b) references t1 (b); +ERROR HY000: Cannot add foreign key constraint +show warnings; +Level Code Message +Warning 1215 Parent table t1 foreign key columns match no index in NDB +Error 150 Cannot add foreign key constraint +drop table t2, t1; +# test: parent key no unique index +create table t1 ( +a int not null, +b int not null, +primary key using hash (a), +key (b) +) engine ndb; +create table t2 ( +a int not null, +b int not null, +primary key using hash (a), +key (b), +constraint fk1 foreign key (b) references t1 (b) +) engine ndb; +ERROR HY000: Can't create table 'test.t2' (errno: 150) +show warnings; +Level Code Message +Warning 1296 Got error 21026 'Create foreign key failed in NDB - parent index is not unique index' from NDB +Error 1005 Can't create table 'test.t2' (errno: 150) +create table t2 ( +a int not null, +b int not null, +primary key using hash (a), +key (b) +) engine ndb; +alter online table t2 +add constraint fk1 foreign key (b) references t1 (b); +ERROR HY000: Cannot add foreign key constraint +show warnings; +Level Code Message +Warning 1296 Got error 21026 'Create foreign key failed in NDB - parent index is not unique index' from NDB +Error 150 Cannot add foreign key constraint +drop table t2, t1; +# test: child column not exist +create table t1 ( +a int not null, +b int not null, +primary key using hash (a), +unique key using hash (b) +) engine ndb; +create table t2 ( +a int not null, +b int not null, +primary key using hash (a), +key (b), +constraint fk1 foreign key (c) references t1 (b) +) engine ndb; +ERROR 42000: Key column 'c' doesn't exist in table +show warnings; +Level Code Message +Error 1072 Key column 'c' doesn't exist in table +create table t2 ( +a int not null, +b int not null, +primary key using hash (a), +key (b) +) engine ndb; +alter online table t2 +add constraint fk1 foreign key (c) references t1 (b); +ERROR 42000: Key column 'c' doesn't exist in table +show warnings; +Level Code Message +Error 1072 Key column 'c' doesn't exist in table +drop table t2, t1; +# test: child column no index +# no error - server creates KEY +create table t1 ( +a int not null, +b int not null, +primary key using hash (a), +unique key using hash (b) +) engine ndb; +create table t2 ( +a int not null, +b int not null, +primary key using hash (a), +constraint fk1 foreign key (b) references t1 (b) +) engine ndb; +drop table t2; +create table t2 ( +a int not null, +b int not null, +primary key using hash (a) +) engine ndb; +alter online table t2 +add constraint fk1 foreign key (b) references t1 (b); +drop table t2, t1; +# test: child vs parent column count +create table t1 ( +a int not null, +b int not null, +c int not null, +primary key using hash (a), +unique key using hash (b, c) +) engine ndb; +create table t2 ( +a int not null, +b int not null, +primary key using hash (a), +key (b), +constraint fk1 foreign key (b) references t1 (b) +) engine ndb; +ERROR HY000: Can't create table 'test.t2' (errno: 150) +show warnings; +Level Code Message +Warning 1215 Parent table t1 foreign key columns match no index in NDB +Error 1005 Can't create table 'test.t2' (errno: 150) +create table t2 ( +a int not null, +b int not null, +primary key using hash (a), +key (b) +) engine ndb; +alter online table t2 +add constraint fk1 foreign key (b) references t1 (b); +ERROR HY000: Cannot add foreign key constraint +show warnings; +Level Code Message +Warning 1215 Parent table t1 foreign key columns match no index in NDB +Error 150 Cannot add foreign key constraint +drop table t2, t1; === modified file 'mysql-test/suite/ndb/t/ndb_fk_bugs.test' --- a/mysql-test/suite/ndb/t/ndb_fk_bugs.test 2012-09-22 10:10:42 +0000 +++ b/mysql-test/suite/ndb/t/ndb_fk_bugs.test 2012-09-22 18:42:26 +0000 @@ -111,7 +111,7 @@ CREATE TABLE languages (id INT NOT NULL drop table languages, towns, counties; ---echo "# test: child vs parent column types" +--echo # test: child vs parent column types create table t1 ( a int not null, @@ -136,6 +136,225 @@ create table t2 ( primary key using hash (a), key (b) ) engine ndb; + +--error 150 +alter online table t2 + add constraint fk1 foreign key (b) references t1 (b); +show warnings; + +drop table t2, t1; + +--echo # test: parent table not exist + +--error ER_CANT_CREATE_TABLE +create table t2 ( + a int not null, + b int not null, + primary key using hash (a), + key (b), + constraint fk1 foreign key (b) references t1 (b) +) engine ndb; +show warnings; + +create table t2 ( + a int not null, + b int not null, + primary key using hash (a), + key (b) +) engine ndb; + +--error 155 +alter online table t2 + add constraint fk1 foreign key (b) references t1 (b); +show warnings; + +drop table t2; + +--echo # test: parent column not exist + +create table t1 ( + a int not null, + primary key using hash (a) +) engine ndb; + +--error ER_CANT_CREATE_TABLE +create table t2 ( + a int not null, + b int not null, + primary key using hash (a), + key (b), + constraint fk1 foreign key (b) references t1 (b) +) engine ndb; +show warnings; + +create table t2 ( + a int not null, + b int not null, + primary key using hash (a), + key (b) +) engine ndb; + +--error 150 +alter online table t2 + add constraint fk1 foreign key (b) references t1 (b); +show warnings; + +drop table t2, t1; + +--echo # test: parent key no index + +create table t1 ( + a int not null, + b int not null, + primary key using hash (a) +) engine ndb; + +--error ER_CANT_CREATE_TABLE +create table t2 ( + a int not null, + b int not null, + primary key using hash (a), + key (b), + constraint fk1 foreign key (b) references t1 (b) +) engine ndb; +show warnings; + +create table t2 ( + a int not null, + b int not null, + primary key using hash (a), + key (b) +) engine ndb; + +--error 150 +alter online table t2 + add constraint fk1 foreign key (b) references t1 (b); +show warnings; + +drop table t2, t1; + +--echo # test: parent key no unique index + +create table t1 ( + a int not null, + b int not null, + primary key using hash (a), + key (b) +) engine ndb; + +--error ER_CANT_CREATE_TABLE +create table t2 ( + a int not null, + b int not null, + primary key using hash (a), + key (b), + constraint fk1 foreign key (b) references t1 (b) +) engine ndb; +show warnings; + +create table t2 ( + a int not null, + b int not null, + primary key using hash (a), + key (b) +) engine ndb; + +--error 150 +alter online table t2 + add constraint fk1 foreign key (b) references t1 (b); +show warnings; + +drop table t2, t1; + +--echo # test: child column not exist + +create table t1 ( + a int not null, + b int not null, + primary key using hash (a), + unique key using hash (b) +) engine ndb; + +--error ER_KEY_COLUMN_DOES_NOT_EXITS +create table t2 ( + a int not null, + b int not null, + primary key using hash (a), + key (b), + constraint fk1 foreign key (c) references t1 (b) +) engine ndb; +show warnings; + +create table t2 ( + a int not null, + b int not null, + primary key using hash (a), + key (b) +) engine ndb; + +--error ER_KEY_COLUMN_DOES_NOT_EXITS +alter online table t2 + add constraint fk1 foreign key (c) references t1 (b); +show warnings; + +drop table t2, t1; + +--echo # test: child column no index +--echo # no error - server creates KEY + +create table t1 ( + a int not null, + b int not null, + primary key using hash (a), + unique key using hash (b) +) engine ndb; + +create table t2 ( + a int not null, + b int not null, + primary key using hash (a), + constraint fk1 foreign key (b) references t1 (b) +) engine ndb; + +drop table t2; + +create table t2 ( + a int not null, + b int not null, + primary key using hash (a) +) engine ndb; + +alter online table t2 + add constraint fk1 foreign key (b) references t1 (b); + +drop table t2, t1; + +--echo # test: child vs parent column count + +create table t1 ( + a int not null, + b int not null, + c int not null, + primary key using hash (a), + unique key using hash (b, c) +) engine ndb; + +--error ER_CANT_CREATE_TABLE +create table t2 ( + a int not null, + b int not null, + primary key using hash (a), + key (b), + constraint fk1 foreign key (b) references t1 (b) +) engine ndb; +show warnings; + +create table t2 ( + a int not null, + b int not null, + primary key using hash (a), + key (b) +) engine ndb; --error 150 alter online table t2 No bundle (reason: useless for push emails).