Bug #90112 SELECT /*/*/ 1 FROM DUAL;
Submitted: 16 Mar 2018 14:53 Modified: 16 Mar 2018 16:56
Reporter: Peter Laursen (Basic Quality Contributor) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:any OS:Any
Assigned to: CPU Architecture:Any

[16 Mar 2018 14:53] Peter Laursen
Description:
I am totally unsure about the proper categgory here (client/server, docs only or not). 

I came across a script from a customer - very beautifully formatted with comments like

/*////////////////////////////////////
------- this is a comment ----------
/////////////////////////////////////*

The script fails sometimes and sometimes not. The problem with the script can be reduced to the query

SELECT /*/*/ 1; 

-- note the occurrence of slash ("/") as the first character in the comment. If I add SPACES like "SELECT /* / */;" everything is fine everywhere. 

How to repeat:
In both Workbench and SQLyog editors you can sometimes execute "SELECT /*/*/ 1;" with desired result. It depends on what else is in the editor. For instance a syntax error 1064 occurs when adding "FROM DUAL" to the query (in SQLyog - I did not try this with Workbench).

And in both programs executing same (ie. "SELECT /*/*/ 1;") from an external file, also returns server syntax error (1064). 

In 'mysql' CLI it is different and weird:

mysql> select /*/*/;
   /*>
   /*> \c
   /*>

.. and I cannot figure out how to 'get out here' except for killing the terminal. It seems that the client thinks that we are inside a comment, where it should not react to control tokens (such as "\c").

Suggested fix:
Not sure. This may involve both the server and the tokenizer code in the various clients. 

But at least I think that docs at https://dev.mysql.com/doc/refman/5.7/en/comments.html should clarify that for /* this type of comment */ , that the first character inside the comment should not be SLASH (ie. "/"). 

Not sure if also the server and/or the CLI should handle it better.
[16 Mar 2018 14:58] Peter Laursen
small typo:

If I add SPACES like "SELECT /* / */ 1;" , everything is fine always and everywhere.
[16 Mar 2018 15:05] Peter Laursen
One more typo. The simplified script example should read

/*////////////////////////////////////
------- this is a comment ----------
////////////////////////////////////*/
[16 Mar 2018 15:09] Peter Laursen
Also typo in synopsis ...
[16 Mar 2018 16:56] MySQL Verification Team
Thank you for the bug report.

Enter password: ******
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.23-log Source distribution 2018-MAR-08

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql 5.7 > SELECT /*/*/ 1;
   /*> ;
   /*> *
   /*> *
   /*> /c
   /*> /*
   /*>
Not sure about the correct category also.