When creating or editing a stored function or stored procedure, single-line and multi-line comments are stripped out.
This is not expected behaviour; it should be possible to add comments to stored code to enhance maintenance and readability.
To reproduce:
1) Log into phpMyAdmin, using a database where the user has sufficient rights to create a stored procedure
2) Open the SQL tab of the database
3) Change the delimiter to // or similar and add the following code:
CREATE PROCEDURE myproc()
BEGIN
/* this comment will be stripped */
select now();
-- this comment will also be stripped
END
4) Click the 'Go' button
5) Open the Structure tab of the database
6) Click on Routines, then edit the myproc stored procedure
7) See that the comments are gone
Expected behaviour would be that the comments are stored along with the stored procedure/function code.
Note: The stripping of comments happens when saving a stored procedure/function, not when just viewing it. For instance, it's possible to do the following:
1) Create a stored procedure/function with MySQL Query Browser and use comments
2) View the stored procedure/function with phpMyAdmin and see the comments
why/where should these comments be saved?
comments are comments because its not a executable (sql) code, so why should they be added in any way to database structure with the syntax you have posted?
to add a comment on sql basis to a stored procedure or function you should use a _single_ COMMENT 'comment' syntax like:
CREATE FUNCTION `myFunction`(...) RETURNS ... COMMENT 'this is comment will be saved'
BEGIN
...
END;
you can see these comments using the mysql command
SHOW FUNCTION STATUS;
for stored functions and
SHOW PROCEDURE STATUS;
for stored procedures
which will show you something like
+---------------+---------------------------+----------+----------------+---------------------+---------------------+---------------+------------------------------------+
| Db | Name | Type | Definer | Modified | Created | Security_type | Comment |
+---------------+---------------------------+----------+----------------+---------------------+---------------------+---------------+------------------------------------+
| test | myFunction | FUNCTION | root@localhost | 2009-02-07 18:12:38 | 2009-02-07 18:12:38 | INVOKER | this is comment will be saved |
+---------------+---------------------------+----------+----------------+---------------------+---------------------+---------------+------------------------------------+
1 rows in set (0.00 sec)
THESE comments are not (yet) shown in phpMyAdmin under database->structure->routines which would be an advantage instead executing the "SHOW [FUNCTION|PROCEDURE] STATUS;" manually
multiple comments are not supported and comments which are too long will be truncated by sql parser.
this behavior is also valid for MySQL Query Browser because its a sql behavior...
Stored procedures can be quite complicated so it's very useful to be able to store comments along with code.
The suggestion of the single COMMENT 'comment' syntax is quite useful.
However, inline comments are useful as well. Since uploading code through the mysql command line client will retain comments, I would expect phpMyAdmin to do the same (of course YMMV!)
Fixed in subversion, thanks for reporting.