Bug #65749 "Creation of ERR diagram from SQL script" silently ignores some scripts
Submitted: 27 Jun 2012 11:09 Modified: 11 Feb 2014 8:12
Reporter: Leo Gordon Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Workbench: Modeling Severity:S2 (Serious)
Version:5.2.37-5.2.40 OS:Any (MacOSX 10.6 and Ubuntu 12.04)
Assigned to: CPU Architecture:Any
Tags: empty first line, ERR Diagram, ignored, import, sql script

[27 Jun 2012 11:09] Leo Gordon
Description:
If your MySQL script starts with an empty line (not a comment, but a true newline),
importing of the ERR diagram from it is broken: you get zero tables, zero foreign keys, zero procedures.

The bug appears at least in the following versions:
* 5.2.37 on MacOSX 10.6
* 5.2.38 on Ubuntu 12.04
* 5.2.40 on MacOSX 10.6
(so it doesn't seem to be OS-dependent)

Why I believe it is a bug and not a feature:
(1) The same script works in mysql client and produces results (creates tables, foreign keys, procedures...), so the inability to parse is a specific property of the Workbench.
(2) It is not documented ("don't start your script with an empty line if you don't want it to be ignored by Workbench")
(3) The ignoring of the rest of the script is completely silent. You don't get any warnings like "Your script starts with a newline - ignoring the rest".

It just ignores the whole script, which I believe it shouldn't. I believe it is serious, because there is nothing to let the user know what is going on. 

How to repeat:
1) Try to create an ERR diagram from the following file:

----------------------->cut here<-----------------
# this will work

CREATE TABLE IF NOT EXISTS meta (
  meta_id                     INT NOT NULL AUTO_INCREMENT
) COLLATE=latin1_swedish_ci ENGINE=MyISAM;
----------------------->cut here<-----------------

(2) Now try to create an ERR diagram from the following one:

----------------------->cut here<-----------------

# this will NOT work

CREATE TABLE IF NOT EXISTS meta (
  meta_id                     INT NOT NULL AUTO_INCREMENT
) COLLATE=latin1_swedish_ci ENGINE=MyISAM;
----------------------->cut here<-----------------

I see no objects imported or placed on the diagram.

Suggested fix:

I'm not a developer of the Workbench, but would first look at the parser, check whether the parser expects a non-empty first line, or has some weird file-loading loop whose condition makes it exit if your first line has zero length or similar. Improvise :)
[27 Jun 2012 13:17] Valeriy Kravchuk
Thank you for the bug report. Verified with Workbench 5.2.40 on Mac OS X 10.5.
[11 Feb 2014 8:12] Philip Olson
Fixed as of the upcoming MySQL Workbench 6.1.2 release, and here's the changelog entry:

Using a MySQL script that started with an empty line to create an EER
diagram would generate an empty EER diagram.

Thank you for the bug report.