mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
BUG#21414: SP: Procedure undroppable, to some extent
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.
This commit is contained in:
@ -5394,4 +5394,12 @@ Procedure sql_mode Create Procedure
|
||||
bug21416 CREATE DEFINER=`root`@`localhost` PROCEDURE `bug21416`()
|
||||
show create procedure bug21416
|
||||
drop procedure bug21416|
|
||||
DROP PROCEDURE IF EXISTS bug21414|
|
||||
CREATE PROCEDURE bug21414() SELECT 1|
|
||||
FLUSH TABLES WITH READ LOCK|
|
||||
DROP PROCEDURE bug21414|
|
||||
ERROR HY000: Can't execute the query because you have a conflicting read lock
|
||||
UNLOCK TABLES|
|
||||
The following should succeed.
|
||||
DROP PROCEDURE bug21414|
|
||||
drop table t1,t2;
|
||||
|
@ -1,13 +1,9 @@
|
||||
#
|
||||
# Basic stored PROCEDURE tests
|
||||
#
|
||||
# Please keep this file free of --error cases and other
|
||||
# things that will not run in a single debugged mysqld
|
||||
# process (e.g. master-slave things).
|
||||
#
|
||||
# Test cases for bugs are added at the end. See template there.
|
||||
#
|
||||
# Tests that require --error go into sp-error.test
|
||||
# Some tests that require --error go into sp-error.test
|
||||
# Tests that require inndb go into sp_trans.test
|
||||
# Tests that check privilege and security issues go to sp-security.test.
|
||||
# Tests that require multiple connections, except security/privilege tests,
|
||||
@ -6322,6 +6318,27 @@ create procedure bug21416() show create procedure bug21416|
|
||||
call bug21416()|
|
||||
drop procedure bug21416|
|
||||
|
||||
|
||||
#
|
||||
# BUG#21414: SP: Procedure undroppable, to some extent
|
||||
#
|
||||
--disable_warnings
|
||||
DROP PROCEDURE IF EXISTS bug21414|
|
||||
--enable_warnings
|
||||
|
||||
CREATE PROCEDURE bug21414() SELECT 1|
|
||||
|
||||
FLUSH TABLES WITH READ LOCK|
|
||||
|
||||
--error ER_CANT_UPDATE_WITH_READLOCK
|
||||
DROP PROCEDURE bug21414|
|
||||
|
||||
UNLOCK TABLES|
|
||||
|
||||
--echo The following should succeed.
|
||||
DROP PROCEDURE bug21414|
|
||||
|
||||
|
||||
#
|
||||
# BUG#NNNN: New bug synopsis
|
||||
#
|
||||
|
Reference in New Issue
Block a user