Bug #57509 Nested (C-style) comments are now suppoted
Submitted: 18 Oct 2010 7:26 Modified: 7 Nov 2010 22:51
Reporter: Peter Laursen (Basic Quality Contributor) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:5.1 OS:Any
Assigned to: Paul DuBois CPU Architecture:Any
Tags: qc

[18 Oct 2010 7:26] Peter Laursen
Description:
http://dev.mysql.com/doc/refman/5.1/en/comments.html

states

.. but after http://bugs.mysql.com/bug.php?id=39559 and http://bugs.mysql.com/bug.php?id=44189 and http://bugs.mysql.com/bug.php?id=30631 Nested (C-style) comments are now supported

How to repeat:
read docs

Suggested fix:
update dics
[18 Oct 2010 7:36] Peter Laursen
I am sorry.  I forgot the quote.  It states that "Nested comments are not supported."
[18 Oct 2010 8:15] Peter Laursen
Ok .. it *sometimes* works - in this dump for instance

-- MySQL dump 10.13  Distrib 5.1.51, for Win64 (unknown)
--
-- Host: localhost    Database: sptest
-- ------------------------------------------------------
-- Server version       5.1.51-community

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0
*/;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2010-10-18 10:05:02

C:\Program Files\MySQL\MySQL Server 5.1\bin>cd \program files\mysql\mysql server
 5.1\bin

C:\Program Files\MySQL\MySQL Server 5.1\bin>cd \program files\mysql\mysql server
 5.1\bin

C:\Program Files\MySQL\MySQL Server 5.1\bin>mysqldump sptest --routines -uroot -
p
Enter password: ********
-- MySQL dump 10.13  Distrib 5.1.51, for Win64 (unknown)
--
-- Host: localhost    Database: sptest
-- ------------------------------------------------------
-- Server version       5.1.51-community

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0
*/;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Dumping routines for database 'sptest'
--
/*!50003 DROP PROCEDURE IF EXISTS `tsp` */;
/*!50003 SET @saved_cs_client      = @@character_set_client */ ;
/*!50003 SET @saved_cs_results     = @@character_set_results */ ;
/*!50003 SET @saved_col_connection = @@collation_connection */ ;
/*!50003 SET character_set_client  = utf8 */ ;
/*!50003 SET character_set_results = utf8 */ ;
/*!50003 SET collation_connection  = utf8_general_ci */ ;
/*!50003 SET @saved_sql_mode       = @@sql_mode */ ;
/*!50003 SET sql_mode              = '' */ ;
DELIMITER ;;
/*!50003 CREATE*/ /*!50020 DEFINER=`root`@`localhost`*/ /*!50003 PROCEDURE `tsp`
()
BEGIN
/* a comment here */
set @test = 'test';
/* a comment here */
    END */;;
DELIMITER ;
/*!50003 SET sql_mode              = @saved_sql_mode */ ;
/*!50003 SET character_set_client  = @saved_cs_client */ ;
/*!50003 SET character_set_results = @saved_cs_results */ ;
/*!50003 SET collation_connection  = @saved_col_connection */ ;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2010-10-18 10:06:35

here:

/*!50003 PROCEDURE `tsp`
()
BEGIN
/* a comment here

there is a 'nested comment - but this does not work: 

select  /* some /* pure */ garbage */ 1;

what are the criteria that the parser uses?  BEGIN?
[5 Nov 2010 15:05] Paul DuBois
Thank you for your bug report. This issue has been addressed in the documentation. The updated documentation will appear on our website shortly, and will be included in the next release of the relevant products.

Added:
"Under some conditions, nested comments might be permitted, but usually are not,
and users should avoid them."

That is as far as we are willing to go.
[5 Nov 2010 15:07] Peter Laursen
Why?

But OK, the code can be studied.
[7 Nov 2010 13:28] Peter Laursen
I had to add to our (public and online) issue tracker this:

"Weird! Why wont they tell details about this?

The status is that when opening a DUMP with a 'stored program' with C-style comments our 'statement folding' feature will fail.  Not a big issue - but completely idiotic reply from MySQL."

Could you please at least reply here what the server logic is?

-- Peter
[7 Nov 2010 22:31] Davi Arnaut
The cases where it works is just a side effect of the flexibility in the implementation. It is not designed with the purpose to parse nested comments. The logic is pure and simple: it is not supported. It might work today, but might not work tomorrow if the implementation is tweaked. If you use nested comments, the behavior is undefined -- anything can happen, maybe nothing at all.
[7 Nov 2010 22:51] Paul DuBois
And with Davi's comment in mind, I am re-closing this report. The manual will not encourage use of nested comments.