List:Commits« Previous MessageNext Message »
From:Pekka Nousiainen Date:May 29 2012 4:40pm
Subject:bzr push into mysql-5.5-cluster-7.3-fk branch (pekka.nousiainen:3905 to
3906) WL#6244
View as plain text  
 3906 Pekka Nousiainen	2012-05-29
      wl#6244 bug14095838.diff
      disallow on-update-cascade if pk is primary key

    modified:
      mysql-test/suite/ndb/r/ndb_fk_bugs.result
      mysql-test/suite/ndb/t/ndb_fk_bugs.test
      storage/ndb/src/ndbapi/NdbDictionary.cpp
      storage/ndb/src/ndbapi/ndberror.c
 3905 Pekka Nousiainen	2012-05-28
      wl#6244 bug14119592a.diff
      bug#14119592: set error to avoid mysqld crash

    modified:
      sql/ha_ndb_ddl_fk.cc
      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-05-23 18:35:12 +0000
+++ b/mysql-test/suite/ndb/r/ndb_fk_bugs.result	2012-05-29 16:39:13 +0000
@@ -1,4 +1,5 @@
 drop table if exists t2, t1;
+# bug#14095785
 create table t1 (
 a int not null,
 b int not null,
@@ -17,3 +18,22 @@ alter table t2
 drop foreign key;
 ERROR 42000: Drop foreign key must specify key name
 drop table t2, t1;
+# bug#14095838
+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)
+) engine ndb;
+alter table t2
+add constraint fk1 foreign key (b) references t1 (a)
+on delete cascade on update cascade;
+ERROR HY000: Cannot add foreign key constraint
+alter table t2
+add constraint fk1 foreign key (b) references t1 (a)
+on delete cascade on update restrict;
+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-05-23 18:35:12 +0000
+++ b/mysql-test/suite/ndb/t/ndb_fk_bugs.test	2012-05-29 16:39:13 +0000
@@ -1,12 +1,13 @@
 -- source include/have_ndb.inc
 -- source have_ndb_fk.inc
 
-# BUG 14095785 - DROPPING FK WITHOUT LABEL CAUSED MYSQLD TO CRASH
-
 -- disable_warnings
 drop table if exists t2, t1;
 -- enable_warnings
 
+# BUG 14095785 - DROPPING FK WITHOUT LABEL CAUSED MYSQLD TO CRASH
+-- echo # bug#14095785
+
 create table t1 (
   a int not null,
   b int not null,
@@ -29,3 +30,29 @@ alter table t2
   drop foreign key;
 
 drop table t2, t1;
+
+# BUG 14095838 - CHANGING PK CAUSES CASCADE FK TO DELETE ROWS
+-- echo # bug#14095838
+
+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)
+) engine ndb;
+
+-- error 150
+alter table t2
+  add constraint fk1 foreign key (b) references t1 (a)
+  on delete cascade on update cascade;
+
+alter table t2
+  add constraint fk1 foreign key (b) references t1 (a)
+  on delete cascade on update restrict;
+
+drop table t2, t1;

=== modified file 'storage/ndb/src/ndbapi/NdbDictionary.cpp'
--- a/storage/ndb/src/ndbapi/NdbDictionary.cpp	2012-05-16 09:11:14 +0000
+++ b/storage/ndb/src/ndbapi/NdbDictionary.cpp	2012-05-29 16:39:13 +0000
@@ -3920,6 +3920,13 @@ NdbDictionary::Dictionary::createForeign
   if (dst == 0)
     dst = &tmp;
 
+  if (fk.getParentIndex() == 0 // primary key
+      && fk.getOnUpdateAction() == NdbDictionary::ForeignKey::Cascade)
+  {
+    m_impl.m_error.code = 21001;
+    return -1;
+  }
+
   int ret;
   DO_TRANS(ret,
            m_impl.m_receiver.create_fk(NdbForeignKeyImpl::getImpl(fk),

=== modified file 'storage/ndb/src/ndbapi/ndberror.c'
--- a/storage/ndb/src/ndbapi/ndberror.c	2012-05-16 09:49:18 +0000
+++ b/storage/ndb/src/ndbapi/ndberror.c	2012-05-29 16:39:13 +0000
@@ -99,6 +99,7 @@ static const char* empty_string = "";
  * 4800 - API, QueryBuilder
  * 5000 - Management server
  * 20000 - SPJ
+ * 21000 - DICT FK
  */
 
 static
@@ -167,6 +168,12 @@ ErrorBundle ErrorCodes[] = {
   { 20016, DMEC, NR, "Query aborted due to node failure" },
   { 20017, DMEC, IE, "Query aborted due to invalid node count" },
   { 20018, DMEC, IE, "Query aborted due to index fragment not found" },
+
+  /**
+   * DICT FK kernel and ndbapi error codes
+   */
+  { 21001, HA_ERR_CANNOT_ADD_FOREIGN, AE, "Foreign key create failed: parent key is primary key: on-update-cascade is currently not allowed" },
+
   
   /**
    * Node shutdown

No bundle (reason: useless for push emails).
Thread
bzr push into mysql-5.5-cluster-7.3-fk branch (pekka.nousiainen:3905 to3906) WL#6244Pekka Nousiainen29 May