Bug #36244 MySQL CLI doesn't recognize standalone -- as comment

Submitted: 22 Apr 2008 7:27 Modified: 10 Jul 2008 20:28
Reporter: Domas Mituzas Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:5.0-bk OS:Any
Assigned to: Gleb Shchepa CPU Architecture:Any

[22 Apr 2008 7:27] Domas Mituzas
Description:
A comment that is just '--\n' is not recognized by MySQL CLI, and CLI commands like 'SYSTEM' are not detected in further statement, what causes syntax error:

mysql> #
mysql> -- a
mysql> --
    -> select 1;
+---+
| 1 |
+---+
| 1 | 
+---+
1 row in set (0.00 sec)

mysql> --
    -> system echo test
    -> ;
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 'system echo test' at line 2

How to repeat:
( echo --; echo system echo test) | mysql

Suggested fix:
if '--' is not treated as internal comment, at detect statements as SYSTEM in it.
[22 Apr 2008 8:47] Magnus Blåudd
The -- comment is not detected at all by mysql> it is a SQL comment and should thus be sent to the server for evaluation.

To be a valid SQL comment I think it has to have a two double dashes followed by a space. Please double check that.
[22 Apr 2008 8:52] Domas Mituzas
Do note 'such as newline' at http://dev.mysql.com/doc/refman/5.0/en/ansi-diff-comments.html:

Standard SQL uses “--” as a start-comment sequence. MySQL Server uses “#” as the start comment character. MySQL Server 3.23.3 and up also supports a variant of the “--” comment style. That is, the “--” start-comment sequence must be followed by a space (or by a control character such as a newline).
[22 Apr 2008 8:55] Domas Mituzas
Do note:
'-- ' is detected by CLI
'#\n' is detected by CLI
'--\n' is deceted by server, not by CLI

it is inconsistency both with standard and server behavior.
[2 Jun 2008 14:01] Domas Mituzas
removed stale assignment
[23 Jun 2008 12:37] Gleb Shchepa
See below the patch for this bug:

=== modified file 'client/mysql.cc'
--- old/client/mysql.cc	2008-03-28 18:02:27 +0000
+++ new/client/mysql.cc	2008-06-23 12:26:19 +0000
@@ -2156,7 +2156,8 @@
     }
     else if (!*ml_comment && (!*in_string && (inchar == '#' ||
 			      inchar == '-' && pos[1] == '-' &&
-			      my_isspace(charset_info,pos[2]))))
+			      (my_isspace(charset_info,pos[2]) ||
+                               !pos[2]))))
     {
       // Flush previously accepted characters
       if (out != line)
[24 Jun 2008 12:59] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/48388

2641 Gleb Shchepa	2008-06-24
      Bug #36244: MySQL CLI doesn't recognize standalone -- or # 
                  as a commentary
      
      mysql client has been modified to interpret EOL after
      standalone -- and # commentary strings like whitespace 
      character (according to 
      http://dev.mysql.com/doc/refman/5.0/en/ansi-diff-comments.html)
[24 Jun 2008 14:16] Chad MILLER
revno 2641 is good with me.

That part of the code is rather ugly, so a comment would be helpful there.

/* The third byte is either whitespace or is the end of the line -- which would occur only because of the user sending newline -- which is itself whitespace and should also match. */
[24 Jun 2008 14:33] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/48394

2641 Gleb Shchepa	2008-06-24
      Bug #36244: MySQL CLI doesn't recognize standalone -- 
                  as a commentary
      
      mysql client has been modified to interpret EOL after
      standalone -- commentary strings like whitespace
      character (according to
      http://dev.mysql.com/doc/refman/5.0/en/ansi-diff-comments.html)
[24 Jun 2008 16:30] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/48407

2643 Gleb Shchepa	2008-06-24
      back-port from 5.1.
      
      Bug#35480: BOM detection code crashes mysql CLI with zero-sized input
            
      MySQL client crashed if no input was passed to it.
[26 Jun 2008 13:40] Bugs System
Pushed into 5.0.66
[10 Jul 2008 19:59] Paul DuBois
Noted in 5.0.66 changelog.

The mysql client failed to recognize comment lines consisting of --
followed by a newline.

Setting report to Patch queued pending push into 5.1.x/6.0.x.
[10 Jul 2008 20:28] Paul DuBois
Noted in 5.1.27, 6.0.6 changelogs.
[28 Jul 2008 13:47] Bugs System
Pushed into 5.0.68  (revid:kpettersson@mysql.com-20080715152926-s5kgnqhtu93b3c8v) (pib:2)
(Retry automatic marking, to ensure nothing is missed. cm01)
[28 Jul 2008 15:12] Paul DuBois
Fix is pushed to 5.1.28, not 5.1.27.
[28 Jul 2008 16:49] Bugs System
Pushed into 5.1.27  (revid:joerg@mysql.com-20080626161101-h5hsaluwtf05xdr2) (version source revid:joerg@mysql.com-20080626161101-h5hsaluwtf05xdr2) (pib:3)

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.045 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.