Bug #89099 Possible unintended usage of a macro in file "mysql-server/sql/sp.cc" line 1341
Submitted: 3 Jan 2018 18:10 Modified: 9 Jan 2018 15:37
Reporter: Petru-Florin Mihancea Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Stored Routines Severity:S3 (Non-critical)
Version:github head, 5.7 OS:Any
Assigned to: CPU Architecture:Any

[3 Jan 2018 18:10] Petru-Florin Mihancea
Description:
While experimenting with a CodeSonar plugin we develop, we noticed a potential bug in file "mysql-server/sql/sp.cc" line 1341 function sp_drop_routine:

 if (!(table= open_proc_table_for_update(thd)))
    DBUG_RETURN(SP_OPEN_TABLE_FAILED); //HERE

Shouldn't SP_DELETE_ROW_FAILED be used as it is used in several places in this function (e.g. lines 1338 or 1354)?

Thanks,
Petru Florin Mihancea

How to repeat:
The potential issue has been detected automatically using static analysis.
[5 Jan 2018 7:15] MySQL Verification Team
Hello Petru-Florin Mihancea,

Thank you for the report and feedback.
Discussed internally with the Runtime Dev and confirmed that it is not really a bug. For an end user we report the right error i.e Failed to DROP %s %s. The SP_OPEN_TABLE_FAILED error makes sense here, since we tried to open the proc table and there was a failure and couldn't delete the routine entry from the table.

Closing this as !bg.

Thanks,
Umesh
[9 Jan 2018 15:37] Petru-Florin Mihancea
To be honest, I hesitated to report this exactly due to the same reason: the invocation of the open_proc_table_for_update function :).

On the other hand then, it is not clear to me why SP_DELETE_ROW_FAILED is used to report a problem related to the invocation of lock_object_name (line 1338). In other places, like line 1425 and 1428 (in sp_update_routine) the *same* SP_OPEN_TABLE_FAILED is used for a similar lock_object_name followed by an open_proc_table_for_update invocation. 

Would it be possible to explain to me the difference :) ?