Bug #37863 Error when handling negative (-) columns where column name is quoted in script
Submitted: 4 Jul 2008 9:52 Modified: 4 Jun 2009 12:56
Reporter: Anders Karlsson Email Updates:
Status: Won't fix Impact on me:
None 
Category:MySQL Query Browser Severity:S3 (Non-critical)
Version:1.2.12 OS:Windows
Assigned to: CPU Architecture:Any

[4 Jul 2008 9:52] Anders Karlsson
Description:
When running a SQL script from MySQL QB where there is a minus sign prefixing a quoted identifier, the handling of the end of statement fails it seems, and if there is another statement following this statement, an error is generated. The situation is a bif difficult to explain, but is easy to reproduce, so look at the "How to repeat" section below. Please note that this ONLY hapens when running the statements as a script, not when the statements are entered as is as a QB query.

The error you get clearly indicates that something in the handling of the query termination goes wrong, as the trailing semicolon is part of the errormessage you get:
Script line: 3	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 ';
SELECT * FROM `t1`' at line 1

To check my simple analysis of the issue, repeat the "How to repeat" section below, but change the first SELECT statement to:
SELECT `c1` FROM `t1`;
or
SELECT -c1 FROM `t1`;
And no errors will be reported.

Also note that this bug does not reproduce when running from the MySQL commandline, it is only an issue with MySQL QB.

How to repeat:
1) Create a SQL file with the following statements (the two first statements are not necessary for the bug per se, of course):
DROP TABLE IF EXISTS t1;
CREATE TABLE t1(c1 INTEGER);
SELECT -`c1` FROM `t1`;
SELECT * FROM `t1`;

2) Open MySQL QB and select File->Open Script

3) Select the file create in step 1 above and click OK in the file section dialog.

4) Click the "Execute" button in the MySQL QB Toolbar.
[4 Jul 2008 17:20] Valeriy Kravchuk
Thank you for a bug report. Verified just as described.
[4 Jun 2009 12:56] Axel Schwenke
Many thanks for writing a bug report. We are on the way to implement full functionality of MySQL Query Browser into MySQL Workbench. We won't fix uncritical bugs in Query Browser anymore.

More information on MySQL Workbench:

http://dev.mysql.com/workbench/