Bug #84970 DROP PROCEDURE command is lacking 'database' keyword
Submitted: 13 Feb 2017 20:56 Modified: 22 May 2017 15:41
Reporter: Agustín G Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:5.6 5.7 OS:Any
Assigned to: CPU Architecture:Any

[13 Feb 2017 20:56] Agustín G
Description:
From the online docs, we can see that the command for DROP PROCEDURE is the following:

DROP {PROCEDURE | FUNCTION} [IF EXISTS] sp_name

This is misleading, in the sense that it does not mention that the database name can be used before the table name, like:

DROP {PROCEDURE | FUNCTION} [IF EXISTS] [database_name.]sp_name

when in reality it can (see tests below).

Seen in 5.6 and 5.7:

https://dev.mysql.com/doc/refman/5.6/en/drop-procedure.html
https://dev.mysql.com/doc/refman/5.7/en/drop-procedure.html

How to repeat:
CREATE SCHEMA some_schema;
USE some_schema;

DELIMITER //
CREATE DEFINER=`root`@`localhost` PROCEDURE `select_one`() 
BEGIN 
SELECT 1;
END //
DELIMITER ;

SHOW PROCEDURE STATUS\G

USE test;
DROP PROCEDURE select_one; -- this one will fail, and it's ok

DROP PROCEDURE some_schema.select_one; -- this one will succeed, but the command used shouldn't be parsed, according to the documentation.

SHOW PROCEDURE STATUS\G

Suggested fix:
Fix the documentation pages to show that one can add an explicit database name for the sp_name, like:

DROP {PROCEDURE | FUNCTION} [IF EXISTS] [database_name.]sp_name

And mention that failing to use 'database_name' will mean that the current database used will be implicitly added as 'database_name'

Thanks!
Agustín.
[13 Feb 2017 23:19] MySQL Verification Team
Thank you for the bug report.
[24 Feb 2017 1:27] Paul DuBois
That is how object naming works generally, it's not a property specific to DROP PROCEDURE. For more information, see:

https://dev.mysql.com/doc/refman/5.7/en/identifier-qualifiers.html