3918 Pekka Nousiainen 2012-09-20
wl#6244 errcode4.diff
bug#14124623 test case from bug report
modified:
mysql-test/suite/ndb/r/ndb_fk_bugs.result
mysql-test/suite/ndb/t/ndb_fk_bugs.test
3917 Martin Skold 2012-09-19
Bug#14195170 FAILING CREATE TABLE WITH FK CONSTRAINTS LEAVES ORPHANED .FRM: create_fks will create a reference to the uncommitted table in the local dictionary, this reference needs to be invalidated if create_fks fail
modified:
mysql-test/suite/ndb/r/ndb_fk_bugs.result
mysql-test/suite/ndb/t/ndb_fk_bugs.test
sql/ha_ndbcluster.cc
=== modified file 'mysql-test/suite/ndb/r/ndb_fk_bugs.result'
--- a/mysql-test/suite/ndb/r/ndb_fk_bugs.result 2012-09-19 13:37:43 +0000
+++ b/mysql-test/suite/ndb/r/ndb_fk_bugs.result 2012-09-20 08:36:30 +0000
@@ -41,6 +41,7 @@ alter table t2
add constraint fk1 foreign key (b) references t1 (a)
on delete cascade on update restrict;
drop table t2, t1;
+# bug#14195170
CREATE TABLE customer (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=NDB;
CREATE TABLE product (category INT NOT NULL, id INT NOT NULL,
price DECIMAL, PRIMARY KEY(category, id)) ENGINE=NDB;
@@ -57,3 +58,35 @@ Level Code Message
Warning 1296 Got error 21000 'Create foreign key failed - parent key is primary key and on-update-cascade is not allowed' from NDB
Error 1005 Can't create table 'test.product_order' (errno: 150)
DROP TABLE customer, product;
+# bug#14124623
+CREATE TABLE counties (county VARCHAR(30) NOT NULL PRIMARY KEY,
+country VARCHAR(30), INDEX county_country_index(country)) ENGINE=ndb;
+INSERT INTO counties VALUES
+('Berkshire','England'),('Shropshire','England'),('Oxfordshire','England'),('Buckinghamshire','England');
+CREATE TABLE towns (town VARCHAR(30) NOT NULL PRIMARY KEY, county
+VARCHAR(30), INDEX county_county_index (county), CONSTRAINT county_town
+FOREIGN KEY (county) REFERENCES counties(county) ON DELETE RESTRICT ON UPDATE
+RESTRICT) ENGINE=ndb;
+INSERT INTO towns VALUES
+('Maidenhead','Berkshire'),('Reading','Berkshire'),('Shrewsbury','Shropshire')
+,('Oxford','Oxfordshire');
+CREATE TABLE languages (language VARCHAR(30) NOT NULL PRIMARY KEY,
+country VARCHAR(30), INDEX lang_country_index(country), CONSTRAINT
+country_language FOREIGN KEY (country) REFERENCES counties(country) ON DELETE
+RESTRICT ON UPDATE RESTRICT) engine=ndb;
+ERROR HY000: Can't create table 'test.languages' (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.languages' (errno: 150)
+CREATE TABLE languages (language VARCHAR(30) NOT NULL PRIMARY KEY,
+country VARCHAR(30), INDEX lang_country_index(country), CONSTRAINT
+country_language FOREIGN KEY (country) REFERENCES counties(country) ON DELETE
+RESTRICT ON UPDATE RESTRICT) engine=ndb;
+ERROR HY000: Can't create table 'test.languages' (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.languages' (errno: 150)
+CREATE TABLE languages (id INT NOT NULL PRIMARY KEY) engine=ndb;
+drop table languages, towns, counties;
=== modified file 'mysql-test/suite/ndb/t/ndb_fk_bugs.test'
--- a/mysql-test/suite/ndb/t/ndb_fk_bugs.test 2012-09-19 13:37:43 +0000
+++ b/mysql-test/suite/ndb/t/ndb_fk_bugs.test 2012-09-20 08:36:30 +0000
@@ -58,6 +58,7 @@ alter table t2
drop table t2, t1;
# Bug #14195170 FAILING CREATE TABLE WITH FK CONSTRAINTS LEAVES ORPHANED .FRM
+--echo # bug#14195170
CREATE TABLE customer (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=NDB;
@@ -73,3 +74,39 @@ CREATE TABLE product_order (no INT NOT N
show warnings;
DROP TABLE customer, product;
+
+# Bug #14124623 - CREATING TABLE WITH FK CONSTRAINT FAILS AND LEAVES DB CORRUPT
+--echo # bug#14124623
+
+CREATE TABLE counties (county VARCHAR(30) NOT NULL PRIMARY KEY,
+country VARCHAR(30), INDEX county_country_index(country)) ENGINE=ndb;
+
+INSERT INTO counties VALUES
+('Berkshire','England'),('Shropshire','England'),('Oxfordshire','England'),('Buckinghamshire','England');
+
+CREATE TABLE towns (town VARCHAR(30) NOT NULL PRIMARY KEY, county
+VARCHAR(30), INDEX county_county_index (county), CONSTRAINT county_town
+FOREIGN KEY (county) REFERENCES counties(county) ON DELETE RESTRICT ON UPDATE
+RESTRICT) ENGINE=ndb;
+
+INSERT INTO towns VALUES
+('Maidenhead','Berkshire'),('Reading','Berkshire'),('Shrewsbury','Shropshire')
+,('Oxford','Oxfordshire');
+
+--error ER_CANT_CREATE_TABLE
+CREATE TABLE languages (language VARCHAR(30) NOT NULL PRIMARY KEY,
+country VARCHAR(30), INDEX lang_country_index(country), CONSTRAINT
+country_language FOREIGN KEY (country) REFERENCES counties(country) ON DELETE
+RESTRICT ON UPDATE RESTRICT) engine=ndb;
+show warnings;
+
+--error ER_CANT_CREATE_TABLE
+CREATE TABLE languages (language VARCHAR(30) NOT NULL PRIMARY KEY,
+country VARCHAR(30), INDEX lang_country_index(country), CONSTRAINT
+country_language FOREIGN KEY (country) REFERENCES counties(country) ON DELETE
+RESTRICT ON UPDATE RESTRICT) engine=ndb;
+show warnings;
+
+CREATE TABLE languages (id INT NOT NULL PRIMARY KEY) engine=ndb;
+
+drop table languages, towns, counties;
No bundle (reason: useless for push emails).
| Thread |
|---|
| • bzr push into mysql-5.5-cluster-7.3-fk branch (pekka.nousiainen:3917 to3918) Bug#14124623 WL#6244 | Pekka Nousiainen | 20 Sep |