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.