Bug #77493 The /*! */ comment is very strange, suggest to change it.

Submitted: 26 Jun 2015 0:58 Modified: 26 Jun 2015 6:01
Reporter: Fangxin Flou (OCA) Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S3 (Non-critical)
Version:All OS:Any
Assigned to: CPU Architecture:Any
Tags: server, SQL

[26 Jun 2015 0:58] Fangxin Flou
Description:
mysql> select 1 /*! , col1, col2 from t_sum1 */;
+---+------+------+
| 1 | col1 | col2 |
+---+------+------+
| 1 |    1 | 1000 |
| 1 |    2 |  800 |
+---+------+------+
2 rows in set (0.02 sec)

This can be executed, strange syntax.

How to repeat:
run 

select 1 /*! , col1, col2 from t_sum1 */;

in MySQL

Suggested fix:
NA
[26 Jun 2015 4:56] MySQL Verification Team
Hello Fangxin,

Thank you for the report.
Imho this is a documented behavior i.e /*! MySQL-specific code */ MySQL Server parses and executes the code within the comment as it would any other SQL statement. Please see - https://dev.mysql.com/doc/refman/5.6/en/comments.html

[test]> select 1/*!,2,3*/;
+---+---+---+
| 1 | 2 | 3 |
+---+---+---+
| 1 | 2 | 3 |
+---+---+---+
1 row in set (0.00 sec)

root@myhostname [test]> create table t1(id int, col1 int,col2 int);
Query OK, 0 rows affected (0.23 sec)

root@myhostname [test]> insert into t1 values(1,1,1),(2,2,2);
Query OK, 2 rows affected (0.03 sec)
Records: 2  Duplicates: 0  Warnings: 0

root@myhostname [test]> select id,/*! col1,col2 from t1*/;
+------+------+------+
| id   | col1 | col2 |
+------+------+------+
|    1 |    1 |    1 |
|    2 |    2 |    2 |
+------+------+------+
2 rows in set (0.01 sec)

Thanks,
Umesh
[26 Jun 2015 5:56] Fangxin Flou
Hi:

I read the source code, and know that.

One more thing, does the SQL firewall can properly handle these cases.

such as 

select 1 /*! */
select 1 /*!, col2, col3 from tab */

I am designing a SQL firewall for a company now, and found it's hard to process it.
[26 Jun 2015 6:01] Fangxin Flou
It should be in the middle of a SQL statement, but now we can put all the query into it.

the folowing is quite ok.

select /*! ... */ ... 
insert /*! ... */ ... 
update /*! ... */ ... 
delete /*! ... */ ...

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

Page generated in 0.052 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.