Bug #40730 MySQL changed a behavior for SQL comment(Start with '--' and no white space).
Submitted: 14 Nov 2008 9:05
Reporter: Meiji KIMURA Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:5.0.67, 5.1.29, 6.0.x OS:Any
Assigned to: CPU Architecture:Any
Triage: Triaged: D3 (Medium) / R4 (High) / E4 (High)

[14 Nov 2008 9:05] Meiji KIMURA
Description:
We can use '--' for SQL Comment like this.

-- Create table
CREATE TABLE T1(i1 int);

MySQL 5.0.46 don't need white space immediate after '--' like this.

--Create table
CREATE TABLE T1(i1 int);

But Latest MySQL (5.0.67, 5.1.29 and MySQL 6.0.x) cannot understand '--Create'. There is no white space immediate after '--'.

mysql> --Create table
    -> create table t1(i1 int);
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 '--Cre
ate table
create table t1(i1 int)' at line 1
mysql>

I don't know that SQL standard specification's comment need white space, or not.
But there is some impact at these cases.

(1) Upgrading older MySQL to Latest MySQL.
(2) Migrating from Other databases to Latest MySQL.

How to repeat:
Execute two statements under Latest MySQL.

-- create table
create table t1(i1 int);

--create table
create table t2(i2 int);

Results are here.

mysql> -- create table
mysql> create table t1(i1 int);
Query OK, 0 rows affected (0.08 sec)

mysql> --create table
    -> create table t2(i2 int);
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 '--cre
ate table
create table t2(i2 int)' at line 1

Under MySQL 5.0.46, results are here.
mysql> -- create table
mysql> create table t1(i1 int);
Query OK, 0 rows affected (0.08 sec)

mysql> --create table
mysql> create table t2(i2 int);
Query OK, 0 rows affected (0.06 sec)

That's all.

Suggested fix:
Use '-- create' instead of '--create'.

And if this change is done on purpose, it should be described on 'Incompatible Change:' on release notes.
[17 Dec 2008 17:45] Konstantin Osipov
Looks like a bug in the client, not on the server.
[4 May 2009 17:27] Jim Winstead
This sounds like a side-effect of an earlier bug fix that resulted in all comments being sent to the server, instead of some simply being discarded by the client. And the server requires a space after '--'. Going back to the old behavior would just break something else, so this change in behavior should probably just be documented.