Bug #70200 Error creating FK constraint treated as a warning
Submitted: 30 Aug 2013 14:23
Reporter: Matthew Montgomery Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S3 (Non-critical)
Version:7.3.2,7.3.7 OS:Any
Assigned to: CPU Architecture:Any

[30 Aug 2013 14:23] Matthew Montgomery
Description:
Got error 21026 'Create foreign key failed in NDB - parent index is not unique index' from NDB

Is not treated as an "error" class so does not appear when issuing SHOW ERRORS;

How to repeat:
mysql>  ALTER TABLE `library_settings` ADD CONSTRAINT `library_settings_ibfk_1` FOREIGN KEY (`id_library`) REFERENCES `library` (`id`) ON DELETE CASCADE ON UPDATE RESTRICT;
ERROR 1215 (HY000): Cannot add foreign key constraint
mysql> show errors; 
+-------+------+-----------------------------------+
| Level | Code | Message                           |
+-------+------+-----------------------------------+
| Error | 1215 | Cannot add foreign key constraint |
+-------+------+-----------------------------------+
1 row in set (0.00 sec)

mysql> 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   | 1215 | Cannot add foreign key constraint                                                              |
+---------+------+------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
[30 Aug 2013 14:28] MySQL Verification Team
create table statement for bug reproduction

Attachment: bug70200.txt (text/plain), 927 bytes.

[7 Jan 2015 13:25] MySQL Verification Team
// Still exists in GA

mysql> show variables like '%version%';
+-------------------------+------------------------------------------------------+
| Variable_name           | Value                                                |
+-------------------------+------------------------------------------------------+
| innodb_version          | 5.6.21                                               |
| ndb_version             | 459527                                               |
| ndb_version_string      | ndb-7.3.7                                            |
| ndbinfo_version         | 459527                                               |
| protocol_version        | 10                                                   |
| slave_type_conversions  |                                                      |
| version                 | 5.6.21-ndb-7.3.7-cluster-commercial-advanced-log     |
| version_comment         | MySQL Cluster Server - Advanced Edition (Commercial) |
| version_compile_machine | x86_64                                               |
| version_compile_os      | linux-glibc2.5                                       |
+-------------------------+------------------------------------------------------+
10 rows in set (0.00 sec)

mysql> use test
Database changed
mysql> CREATE TABLE `id_list` (
    ->   `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
    ->   `type` enum('post','event','profile','library','share') COLLATE utf8_bin NOT NULL,
    ->   PRIMARY KEY (`id`)
    -> ) ENGINE=ndbcluster AUTO_INCREMENT=5081 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

CREATE TABLE `library` (
  `id` bigint(20) unsigned NOT NULL DEFAULT '1',
  `id_author` bigint(20) unsigned NOT NULL,
Query OK, 0 rows affected (0.04 sec)

mysql>
mysql> CREATE TABLE `library` (
    ->   `id` bigint(20) unsigned NOT NULL DEFAULT '1',
    ->   `id_author` bigint(20) unsigned NOT NULL,
    ->   KEY `id` (`id`),
    ->   KEY `id_author` (`id_author`),
    ->   CONSTRAINT `library_ibfk_1` FOREIGN KEY(`id`) REFERENCES `id_list` (`id`) ON DELETE CASCADE ON UPDATE RESTRICT,
    ->   CONSTRAINT `library_ibfk_2` FOREIGN KEY(`id_author`) REFERENCES `id_list` (`id`) ON DELETE CASCADE ON UPDATE RESTRICT
    -> ) ENGINE=ndbcluster DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

CREATE TABLE `library_settings` (
  `id_library` bigint(20) unsigned NOT NULL,
  UNIQUE KEY `id_library` (`id_library`)
) ENGINE=ndbcluster DEFAULT CHARSET=utf8 COLLATE=utf8_bin;Query OK, 0 rows affected (0.04 sec)

mysql>
mysql> CREATE TABLE `library_settings` (
    ->   `id_library` bigint(20) unsigned NOT NULL,
    ->   UNIQUE KEY `id_library` (`id_library`)
    -> ) ENGINE=ndbcluster DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
Query OK, 0 rows affected (0.03 sec)

mysql> ALTER TABLE `library_settings` ADD CONSTRAINT `library_settings_ibfk_1` FOREIGN KEY (`id_library`) REFERENCES `library` (`id`) ON DELETE CASCADE ON UPDATE RESTRICT;
ERROR 1215 (HY000): Cannot add foreign key constraint
mysql>
mysql> show errors;
+-------+------+-----------------------------------+
| Level | Code | Message                           |
+-------+------+-----------------------------------+
| Error | 1215 | Cannot add foreign key constraint |
+-------+------+-----------------------------------+
1 row in set (0.00 sec)

mysql> 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   | 1215 | Cannot add foreign key constraint                                                              |
+---------+------+------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
[9 Jun 2015 8:37] Bugs System
Has the “Error Code: 1215. Cannot add foreign key constraint” been solved in MySQLCluster 7.4.6?

is there a limit of "MaxNoOfTriggers" in 7.4.6 to permit more foreign keys?
no matter how many I improve the number of "MaxNoOfTriggers", there is always a 
error 1215 displays.