Subject: | Valid MySQL table definition not understood |
I'm on a linux machine using perl5.6.1. I run the command:
/usr/local/scripts/sqlt-diagram --db=MySQL -o p13n.3 --color p13n.3.sql
The sql file contains the following:
CREATE TABLE Data (
InstanceID INTEGER NOT NULL,
Userid VARCHAR(128) NOT NULL,
Keyname VARCHAR(128) NOT NULL,
Value BLOB,
Modified INTEGER NOT NULL,
Serialized TINYINT(1) NOT NULL DEFAULT 0,
PRIMARY KEY (InstanceID, Userid, Keyname),
CONSTRAINT FOREIGN KEY (InstanceID) REFERENCES Instance (ID) ON DELETE CASCADE ON UPDATE CASCADE
) TYPE = InnoDB;
Which is a perfectly valid table definition. It returns the error:
ERROR (line 1): Invalid statement: Was expecting comment, or use, or
set, or drop, or create
Error: translate: Error with parser 'SQL::Translator::Parser::MySQL': no results at /usr/local/scripts/sqlt-diagram line 116.
Removing the 'CONSTRAINT FOREIGN KEY...' line fixes the problem and I get an image produced.
Also I get the error:
ERROR (line 1): Invalid statement: Was expecting comment, or use, or
set, or drop, or create
Error: translate: Error with parser 'SQL::Translator::Parser::MySQL': no results at /usr/local/scripts/sqlt-diagram line 116.
With the following sql extracted from MySQL itself using the SHOW CREATE TABLE command:
CREATE TABLE `Instance` (
`ID` int(11) NOT NULL auto_increment,
`Site` varchar(255) NOT NULL default '',
`App` varchar(255) NOT NULL default '',
`Passwd` varchar(32) default NULL,
`Expires` int(11) default NULL,
`Archive` tinyint(1) default NULL,
PRIMARY KEY (`ID`),
UNIQUE KEY `instance_site_app_uniq` (`Site`,`App`)
) TYPE=InnoDB;
Can you offer any help? We want to use SQL::T to generate documentation for all our databases but at the moment it fails on some of our sql files.
thanks
P