mirror of
https://github.com/MariaDB/server.git
synced 2025-01-17 04:22:27 +01:00
11f9e513d7
of stored routines definitions even if we already have some tables open and locked. To avoid deadlocks in this case we have to put certain restrictions on locking of mysql.proc table. This allows to use stored routines safely under LOCK TABLES without explicitly mentioning mysql.proc in the list of locked tables. It also fixes bug #11554 "Server crashes on statement indirectly using non-cached function". mysql-test/r/sp-error.result: Added test which checks that now we can read stored routines definitions under LOCK TABLES even if we have not locked mysql.proc explicitly. Also added check for restrictions which this ability puts on mysql.proc locking. Updated test for bug #9566 to correspond this new situation. mysql-test/r/sp-threads.result: Added test for bug #11554 "Server crashes on statement indirectly using non-cached function". mysql-test/t/sp-error.test: Added test which checks that now we can read stored routines definitions under LOCK TABLES even if we have not locked mysql.proc explicitly. Also added check for restrictions which this ability puts on mysql.proc locking. Updated test for bug #9566 to correspond this new situation. mysql-test/t/sp-threads.test: Added test for bug #11554 "Server crashes on statement indirectly using non-cached function". sql/lock.cc: get_lock_data(): To be able to open and lock for reading system tables like 'mysql.proc', when we already have some tables opened and locked, and avoid deadlocks we have to disallow write-locking of these tables with any other tables. sql/mysql_priv.h: open_table() has new parameter which allows to open table even if some-one has done a flush or holding namelock on it. sql/share/errmsg.txt: Added error message saying that one cannot write-lock some of system tables with any other tables. sql/sp.cc: open_proc_table_for_read()/close_proc_table(): Added functions to be able open and close mysql.proc table when we already have some tables open and locked. open_proc_table_for_update(): Added function to simplify opening of mysql.proc for updates. db_find_routine_aux()/db_find_routine()/db_update_routine()/... Moved responsibility for opening mysql.proc table from db_find_routine_aux() one level up, since this level knows better which type of table access for reading of for update it needs. sp_function_exists(): Removed unused function. sql/sp.h: sp_function_exists(): Removed unused function. sql/sql_base.cc: open_table(): Added new parameter which allows to open table even if some-one has done a flush or holding namelock on it. open_unireg_entry(): Mark 'mysql.proc' as a system table which has special restrictions on its locking, but thanks to them can be open and locked even if we already have some open and locked. sql/sql_class.cc: Moved THD members holding information about open and locked tables to separate Open_tables_state class to be able to save/restore this state easier. Added THD::push_open_tables_state()/pop_open_tables_state() methods for saving/restoring this state. sql/sql_class.h: Moved THD members holding information about open and locked tables to separate Open_tables_state class to be able to save/restore this state easier. Added THD::push_open_tables_state()/pop_open_tables_state() methods for saving/restoring this state. sql/sql_lex.cc: Removed LEX::proc_table member which was not really used. sql/sql_lex.h: Removed LEX::proc_table member which was not really used. sql/sql_table.cc: open_table() has new parameter which allows to open table even if some-one has done a flush or holding namelock on it. sql/table.h: Added TABLE_SHARE::system_table indicating that this table is system table like 'mysql.proc' and we want to be able to open and read-lock it even when we already have some tables open and locked (and because of this we have to put some restrictions on write locking it).
66 lines
1.5 KiB
Text
66 lines
1.5 KiB
Text
use test;
|
|
drop table if exists t1;
|
|
create table t1 (s1 int, s2 int, s3 int);
|
|
create procedure bug4934()
|
|
begin
|
|
insert into t1 values (1,0,1);
|
|
end//
|
|
use test;
|
|
call bug4934();
|
|
select * from t1;
|
|
s1 s2 s3
|
|
1 0 1
|
|
drop table t1;
|
|
create table t1 (s1 int, s2 int, s3 int);
|
|
drop procedure bug4934;
|
|
create procedure bug4934()
|
|
begin
|
|
end//
|
|
select * from t1;
|
|
s1 s2 s3
|
|
call bug4934();
|
|
select * from t1;
|
|
s1 s2 s3
|
|
drop table t1;
|
|
drop procedure bug4934;
|
|
drop procedure if exists bug9486;
|
|
drop table if exists t1, t2;
|
|
create table t1 (id1 int, val int);
|
|
create table t2 (id2 int);
|
|
create procedure bug9486()
|
|
update t1, t2 set val= 1 where id1=id2;
|
|
call bug9486();
|
|
lock tables t2 write;
|
|
call bug9486();
|
|
show processlist;
|
|
Id User Host db Command Time State Info
|
|
# root localhost test Sleep # NULL
|
|
# root localhost test Query # Locked call bug9486()
|
|
# root localhost test Query # NULL show processlist
|
|
unlock tables;
|
|
drop procedure bug9486;
|
|
drop table t1, t2;
|
|
drop procedure if exists bug11158;
|
|
create procedure bug11158() delete t1 from t1, t2 where t1.id = t2.id;
|
|
create table t1 (id int, j int);
|
|
insert into t1 values (1, 1), (2, 2);
|
|
create table t2 (id int);
|
|
insert into t2 values (1);
|
|
call bug11158();
|
|
select * from t1;
|
|
id j
|
|
2 2
|
|
lock tables t2 read;
|
|
call bug11158();
|
|
unlock tables;
|
|
drop procedure bug11158;
|
|
drop table t1, t2;
|
|
drop function if exists bug11554;
|
|
drop view if exists v1;
|
|
create table t1 (i int);
|
|
create function bug11554 () returns int return 1;
|
|
create view v1 as select bug11554() as f;
|
|
insert into t1 (select f from v1);
|
|
drop function bug11554;
|
|
drop table t1;
|
|
drop view v1;
|