Bug #74183 syntax errors where none exist
Submitted: 1 Oct 2014 20:21 Modified: 19 Jan 2017 17:48
Reporter: Chris Cheshire Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Workbench: SQL Editor Severity:S3 (Non-critical)
Version:6.2.3, 6.2.4 OS:MacOS
Assigned to: CPU Architecture:Any

[1 Oct 2014 20:21] Chris Cheshire
Description:
Upgraded to 6.2.3 from 6.1.4 and seeing syntax error highlighting in my scripts where none actually exist.

Example 1:

alter table foo modify column bar varchar(50) not null;

Has an error highlight under varchar, with a tooltip of 

Syntax error: Unexpected 'varchar' (varchar)

Example 2:
create table foo (
id bigint unsigned not null auto_increment primary key,
bar bigint unsigned,
constraint fk_foo foreign key (bar) references some_table (id) on update cascade on delete cascade
);

The first 'cascade' is highlighted with the tooltip of

Syntax error: missing 'closing parenthesis'

Example 3:

alter table foo add constraint fk_foo foreign key (bar) references some_table (id) on update cascade on delete cascade;

The second 'on' is highlighted with the tooltip of 

Syntax error: Unexpected 'on' (on)

All of the above execute correctly.

How to repeat:
Open a new SQL editor and type the above commands. They have been sanitized to use fake names, but they still give the same syntax errors as with my correct table definitions.
[1 Oct 2014 23:35] MySQL Verification Team
Thank you for the bug report. Could you please paste here the same SQL command which success and failed with WorkBench using the mysql client command tool. Thanks.
[2 Nov 2014 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[21 Nov 2014 16:20] Sinan Can Keskin
i'm also geting the same error in for my query;

CREATE TABLE commend (
commendId INTEGER NOT NULL AUTO_INCREMENT,
inputId INTEGER NOT NULL,
userId INTEGER NOT NULL,
commendTitle VARCHAR(100) NOT NULL,
commendInclude text NOT NULL,
commendDate datetime NOT NULL,
PRIMARY KEY(commendId),
FOREIGN KEY (userId) REFERENCES users(userId) ON UPDATE cascade ON DELETE CASCADE,
FOREIGN KEY (inputId) REFERENCES input(inputId) ON UPDATE on cascade delete cascade
);

first cascade is highlighted and error sentence is as belov;

"18:16:29	CREATE TABLE commend ( commendId INTEGER NOT NULL AUTO_INCREMENT, inputId INTEGER NOT NULL, userId INTEGER NOT NULL, commendTitle VARCHAR(100) NOT NULL, commendInclude text NOT NULL, commendDate datetime NOT NULL, PRIMARY KEY(commendId), FOREIGN KEY (userId) REFERENCES users(userId) ON UPDATE cascade ON DELETE CASCADE, FOREIGN KEY (inputId) REFERENCES input(inputId) ON UPDATE on cascade delete cascade )	Error Code: 1064. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'on cascade delete cascade )' at line 10	0.000 sec
[21 Nov 2014 17:47] Sinan Can Keskin
*PS: i also wrote same query at "Navicat" and it worked correctly.
[30 Nov 2014 9:42] MySQL Verification Team
Thank you for the feedback.
Confirmed that valid statement shows syntax error in SQL editor(no issues if executed in WB or even in CLI).
// SQL editor shows syntax error for cascade(update cascade)

CREATE TABLE parent (
    id INT NOT NULL,
    PRIMARY KEY (id)
) ENGINE=INNODB;

CREATE TABLE child (
    id INT, 
    parent_id INT,
    INDEX par_ind (parent_id),
    FOREIGN KEY (parent_id) 
        REFERENCES parent(id)
         on update cascade on delete cascade
) ENGINE=INNODB;
[30 Nov 2014 9:42] MySQL Verification Team
Screenshot..6.2.4

Attachment: 74183_6_2_4.png (image/png, text), 37.18 KiB.

[30 Nov 2014 9:48] MySQL Verification Team
Screenshot..6.1.7

Attachment: 74183_6_1_7.png (image/png, text), 24.22 KiB.

[10 Feb 2015 23:25] chiranjit das
I am learning sql and using mysql figured out it throws no error when used as 
create table department (department_name varchar(40), department_code varchar(40), employee_id int(4) not null,
foreign key fk_cat(employee_id)
references company(employee_id) 
on delete set null
on update cascade
)engine=InnoDB;

first we delete the data and then update the table which seems to be the logic which is quite normal.
[26 Jul 2015 9:52] Paul Weiss
Chris's original examples are still displaying as errors in 6.3.4.0 on Microsoft Windows 7 Home Premium SP 1, 64-bit.
[19 Jan 2017 17:48] Christine Cole
Posted by developer:
 
Fixed as of the upcoming Workbench 6.3.9 release, and here's the changelog entry:

SQL Editor identified syntax errors in valid statements that executed
properly.

Thank you for the bug report.