Description:
The MySQL CLI is a bit stupid.
Consider two remarks, where one contains a version-conditional MySQL statement:
A:
====================
/*Dinkey-doodle;*/
SELECT VERSION();
====================
vs
B:
====================
/*!30000 SELECT VERSION();*/
SELECT VERSION();
====================
Execute them via the CLI.
While executing A, the CLI disregards the semicolon inside the remark:
mysql> /*Dinkey-doodle;*/
mysql> SELECT VERSION();
+-------------------------+
| VERSION() |
+-------------------------+
| 5.0.37-community-nt-log |
+-------------------------+
1 row in set (0.00 sec)
While executing B on the other hand, the CLI, probably recognizing the conditional sql, stops at the semicolon and executes the sentence on the server. Presumably it snips the /*! part before executing, at least it would seem so, since...
mysql> /*!40000 SELECT VERSION();*/
+-------------------------+
| VERSION() |
+-------------------------+
| 5.0.37-community-nt-log |
+-------------------------+
1 row in set (0.00 sec)
-> SELECT VERSION();
ERROR 1064 (42000): 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 '*/\nSELECT VERSION()' at line 1
...the server barfs at the */ part, thus the CLI must be pretending that it is a part of the next SQL sentence.
One effect of this is that standards-compliant (ANSI) SQL files generated by HeidiSQL cannot be imported by a MySQL Server in ANSI mode using the CLI.
How to repeat:
Execute a conditional comment with a semicolon inside; notice that the CLI stops parsing after the semicolon instead of after the end of the conditional comment.
Suggested fix:
Fix the CLI so it considers:
/*!40000 SELECT VERSION();*/
as one SQL sentence, instead of considering:
/*!40000 SELECT VERSION();
as one SQL sentence.