Bug #54831 Multi statement SQL does not work
Submitted: 26 Jun 2010 21:43 Modified: 29 Jul 2010 13:08
Reporter: Anders Karlsson Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Workbench: SQL Editor Severity:S3 (Non-critical)
Version:5.2.24 OS:Any
Assigned to: Sergei Tkachenko CPU Architecture:Any

[26 Jun 2010 21:43] Anders Karlsson
Description:
Multi statement syntax does not work as it does in the mysql commandline, or ratrher, it doesn't seem to work at all. For multi-statements, the statement separator is a semicolon, which is the same as the statement separator used by default by both the mysql commandline and MySQL Workbench.
When you set the delimiter cluase to something else than the semicolon though, the mysql commandline tool handles semicolon separated statements as they should be handled, whereas MySQL Workbench does not, it seems that the CLIENT_MULTI_STATEMENTS flag is not set.

How to repeat:
Create a script, say x.sql, and let it contain:
<SCRIPT>
delimter //
select 1; select 2; select 3;
</SCRIPT>

From the commandline then, the results is:
shell> mysql < x.sql
1
1
2
2
3
3
shell>

In MySQL Workbench though, the result is:
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 'select 2; select 3;
LIMIT 0, 1000' at line 1)

Also, the LIMIT statement that is added by Workbench also gets confused here:
select 1; select 2; select 3;
LIMIT 0, 1000
is what is generated, which clearly is an error.
[27 Jun 2010 7:05] Valeriy Kravchuk
Thank you for the bug report.
[16 Jul 2010 10:50] Sergei Tkachenko
Enabled CLIENT_MULTI_STATEMENTS flag for connections.
Though syntax checker still marks second sub-statement as syntax error and hardly it will be fixed in v5.2, required changes are planned for one of future versions.
[27 Jul 2010 13:06] Johannes Taxacher
fix confirmed in repository.
we'll take care of adapting syntax-highlighter in future versions.
[29 Jul 2010 13:08] Tony Bedford
An entry has been added to the 5.2.26 changelog:

Multi-statement syntax did not work in the SQL Editor. If the delimiter was set to a character other than the default semi-colon, then the semi-colon should still have been recognized as a valid delimiter for multi-statements, but in the SQL Editor it was not.