Bug #75515 Modify SHOW CREATE TABLE output for better OpenStack integration
Submitted: 15 Jan 2015 13:18 Modified: 19 Jan 2015 16:00
Reporter: Andrew Morgan Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S3 (Non-critical)
Version:7.4 OS:Any
Assigned to: Thomas Nielsen CPU Architecture:Any

[15 Jan 2015 13:18] Andrew Morgan
Description:
OpenStack uses quite popular Python library SQLAlchemy to access databases - the latter expects proper format of output from them. E.g. for one of our tables with a constraint we get the following on MySQL server:

mysql> show create table endpoint\G
*************************** 1. row ***************************
      Table: endpoint
Create Table: CREATE TABLE `endpoint` (
 `id` varchar(64) NOT NULL,
 `region` varchar(255) DEFAULT NULL,
 `service_id` varchar(64) NOT NULL,
 `extra` text,
 PRIMARY KEY (`id`),
 KEY `service_id` (`service_id`),
 CONSTRAINT `endpoint_service_id_fkey` FOREIGN KEY (`service_id`) REFERENCES `service` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
1 row in set (0.00 sec)

With NDB the server changes output formatting a bit what makes impossible to use SQLAlchemy with MySQL Cluster:

mysql> show create table endpoint\G
*************************** 1. row ***************************
      Table: endpoint
Create Table: CREATE TABLE `endpoint` (
 `id` varchar(64) NOT NULL,
 `region` varchar(255) DEFAULT NULL,
 `service_id` varchar(64) NOT NULL,
 `extra` text,
 PRIMARY KEY (`id`),
 KEY `service_id` (`service_id`),
CONSTRAINT `FK_54_60` FOREIGN KEY(`service_id`) REFERENCES `service` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=ndbcluster DEFAULT CHARSET=utf8
1 row in set (0.01 sec)

The keyword CONSTRAINT missed one space ahead of it and there is no space after FOREIGN KEY

How to repeat:
Test as described above

Suggested fix:
Make output syntax for SHOW CREATE TABLE match that of InnoDB for maximum compatibility with existing middleware.
[19 Jan 2015 16:00] Jon Stephens
Documented fix in the NDB 7.4.4 changelog, as follows:

    The output format of SHOW CREATE TABLE for an NDB table
    containing foreign key constraints did not match that for an
    equivalent InnoDB table, which could cause issues with some
    third-party applications.
      
Closed.