Bug #2080 Option file comment characters not treated consistently
Submitted: 10 Dec 2003 9:40 Modified: 14 Jan 2004 17:59
Reporter: Paul Dubois Email Updates:
Status: Closed Impact on me:
Category:MySQL Server Severity:S3 (Non-critical)
Version: OS:
Assigned to: Peter Gulutzan CPU Architecture:Any

[10 Dec 2003 9:40] Paul Dubois
As of MySQL 4.0.14, you're allowed to quote option
values in option files, and you're allowed to begin
comments in the middle of a line. For example,

password="my#pass"  # my password contains a # character

Semicolon (';') is also allowed as a comment character.
But it's still only recognized as such at the beginning
of a line.

If # is allowed in the middle of a line to begin a comment,
shouldn't ; be allowed as well?

How to repeat:
Put this in ~/.my.cnf:


Then run mysql --print-defaults:

% mysql --print-defaults
mysql would have been started with the following arguments:

Now change ~/.my.cnf to this:


And run mysql-print-defaults again:

mysql would have been started with the following arguments:

Note that ; is not treated as a comment character.

Suggested fix:
This seems to fix the problem?

--- mysys/default.c.orig        Wed Oct  1 13:36:59 2003
+++ mysys/default.c     Wed Dec 10 11:35:57 2003
@@ -460,7 +460,7 @@
       else if (quote == *ptr)
        quote= 0;
-    if (!quote && *ptr == '#') /* We are not inside a comment */
+    if (!quote && (*ptr == '#' || *ptr == ';')) /* We are not inside a comment */
       *ptr= 0;
       return ptr;
[18 Dec 2003 20:57] MySQL Verification Team
Paul I am putting first PeterG in this thread because I have
the impression that ; is only used for comment at the begin
of the lines. I would like to heard his opinion for.
[18 Dec 2003 21:05] Paul Dubois
Okay.  However, this isn't really a question of SQL conformance,
is it? The point I'm making is that comment characters are not
treated equivalently.

Also, I see no *harm* in treating both characters the same way
in all contexts.
[19 Dec 2003 7:52] Peter Gulutzan
For an SQL statement, semicolons are supposed to be for ending statements (not for 
comments) and MySQL supports that. Paul isn't talking about true SQL statements, 
so the standard doesn't matter. I would still say that semicolons should indicate "end" 
rather than comment and I would reject this because it's unnecessary but such opinions 
are non-authoritative.
[19 Dec 2003 8:25] Paul Dubois
Miguel, PeterG:

Why are the two of you even talking about SQL statements?

The issue is comment characters in OPTION FILES, not
in SQL statements.
[19 Dec 2003 8:33] MySQL Verification Team
Paul I didn't make mention to SQL, I meant that until now I didn't see
any configuration file that uses ; at the end as comment.
[14 Jan 2004 17:59] Jani Tolonen
Applied and tested the patch in MySQL 4.1.