From: Martin Skold Date: September 19 2012 1:38pm Subject: bzr push into mysql-5.5-cluster-7.3-fk branch (Martin.Skold:3916 to 3917) Bug#14195170 List-Archive: http://lists.mysql.com/commits/144818 X-Bug: 14195170 Message-Id: <20120919133835.650AF9F8D7F@quadfish> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit 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 3916 Pekka Nousiainen 2012-09-18 wl#6244 errcode3.diff push_warning_printf WARN_LEVEL_ERROR not allowed modified: 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-18 09:47:07 +0000 +++ b/mysql-test/suite/ndb/r/ndb_fk_bugs.result 2012-09-19 13:37:43 +0000 @@ -41,3 +41,19 @@ alter table t2 add constraint fk1 foreign key (b) references t1 (a) on delete cascade on update restrict; drop table t2, t1; +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; +CREATE TABLE product_order (no INT NOT NULL AUTO_INCREMENT, product_category INT NOT NULL, product_id INT NOT NULL, customer_id INT NOT NULL, PRIMARY KEY(no), INDEX (product_category, product_id), FOREIGN KEY (product_category, product_id) REFERENCES product(category, id) ON UPDATE CASCADE ON DELETE RESTRICT, INDEX (customer_id), FOREIGN KEY (customer_id) REFERENCES customer(id)) ENGINE=ndb; +ERROR HY000: Can't create table 'test.product_order' (errno: 150) +show warnings; +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) +CREATE TABLE product_order (no INT NOT NULL AUTO_INCREMENT, product_category INT NOT NULL, product_id INT NOT NULL, customer_id INT NOT NULL, PRIMARY KEY(no), INDEX (product_category, product_id), FOREIGN KEY (product_category, product_id) REFERENCES product(category, id) ON UPDATE CASCADE ON DELETE RESTRICT, INDEX (customer_id), FOREIGN KEY (customer_id) REFERENCES customer(id)) ENGINE=ndb; +ERROR HY000: Can't create table 'test.product_order' (errno: 150) +show warnings; +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; === modified file 'mysql-test/suite/ndb/t/ndb_fk_bugs.test' --- a/mysql-test/suite/ndb/t/ndb_fk_bugs.test 2012-09-18 09:47:07 +0000 +++ b/mysql-test/suite/ndb/t/ndb_fk_bugs.test 2012-09-19 13:37:43 +0000 @@ -56,3 +56,20 @@ alter table t2 on delete cascade on update restrict; drop table t2, t1; + +# Bug #14195170 FAILING CREATE TABLE WITH FK CONSTRAINTS LEAVES ORPHANED .FRM + +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; + +--error ER_CANT_CREATE_TABLE +CREATE TABLE product_order (no INT NOT NULL AUTO_INCREMENT, product_category INT NOT NULL, product_id INT NOT NULL, customer_id INT NOT NULL, PRIMARY KEY(no), INDEX (product_category, product_id), FOREIGN KEY (product_category, product_id) REFERENCES product(category, id) ON UPDATE CASCADE ON DELETE RESTRICT, INDEX (customer_id), FOREIGN KEY (customer_id) REFERENCES customer(id)) ENGINE=ndb; +show warnings; + +--error ER_CANT_CREATE_TABLE +CREATE TABLE product_order (no INT NOT NULL AUTO_INCREMENT, product_category INT NOT NULL, product_id INT NOT NULL, customer_id INT NOT NULL, PRIMARY KEY(no), INDEX (product_category, product_id), FOREIGN KEY (product_category, product_id) REFERENCES product(category, id) ON UPDATE CASCADE ON DELETE RESTRICT, INDEX (customer_id), FOREIGN KEY (customer_id) REFERENCES customer(id)) ENGINE=ndb; +show warnings; + +DROP TABLE customer, product; === modified file 'sql/ha_ndbcluster.cc' --- a/sql/ha_ndbcluster.cc 2012-07-09 12:22:46 +0000 +++ b/sql/ha_ndbcluster.cc 2012-09-19 13:37:43 +0000 @@ -9741,6 +9741,14 @@ abort: DBUG_PRINT("info", ("Failed to abort schema transaction, %i", dict->getNdbError().code)); m_table= 0; + + { + // Flush the table out of ndbapi's dictionary cache + Ndb_table_guard ndbtab_g(dict); + ndbtab_g.init(m_tabname); + ndbtab_g.invalidate(); + } + DBUG_RETURN(my_errno); abort_return: DBUG_PRINT("info", ("Aborting schema transaction")); No bundle (reason: useless for push emails).