• unknown's avatar
    BUG#21414: SP: Procedure undroppable, to some extent · d4933af8
    unknown 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.
    
    
    mysql-test/r/sp.result:
      Add result for bug#21414: SP: Procedure undroppable, to some extent.
    mysql-test/t/sp.test:
      Remove no longer relevant comment.
      Add test case for bug#21414: SP: Procedure undroppable, to some extent.
    sql/mysql_priv.h:
      Remove declaration of mysql_proc_table_exists.
    sql/sp.cc:
      Remove references to mysql_proc_table_exists.
    sql/sql_acl.cc:
      Remove reference to mysql_proc_table_exists.
    d4933af8
sql_acl.cc 175 KB