• kroki/tomash@moonlight.intranet's avatar
    BUG#21414: SP: Procedure undroppable, to some extent · ed0cb3e4
    kroki/tomash@moonlight.intranet authored
    The problem was that if after FLUSH TABLES WITH READ LOCK the user
    issued DROP/ALTER PROCEDURE/FUNCTION the operation would fail (as
    expected), but after UNLOCK TABLE any attempt to execute the same
    operation would lead to the error 1305 "PROCEDURE/FUNCTION does not
    exist", and an attempt to execute any stored function will also fail.
    
    This happened because under FLUSH TABLES WITH READ LOCK we couldn't open
    and lock mysql.proc table for update, and this fact was erroneously
    remembered by setting mysql_proc_table_exists to false, so subsequent
    statements believed that mysql.proc doesn't exist, and thus that there
    are no functions and procedures in the database.
    
    As a solution, we remove mysql_proc_table_exists flag completely.  The
    reason is that this optimization didn't work most of the time anyway.
    Even if open of mysql.proc failed for some reason when we were trying to
    call a function or a procedure, we were setting mysql_proc_table_exists
    back to true to force table reopen for the sake of producing the same
    error message (the open can fail for number of reasons).  The solution
    could have been to remember the reason why open failed, but that's a lot
    of code for optimization of a rare case.  Hence we simply remove this
    optimization.
    ed0cb3e4
mysql_priv.h 63.3 KB