mirror of
https://github.com/MariaDB/server.git
synced 2026-01-06 05:22:24 +03:00
Fix for bug #11896 "Partial locking in case of recursive trigger definitions".
If we are in stored function or trigger we should ensure that we won't change table that is already used by calling statement (this can damage table or easily cause infinite loops). Particularly this means that recursive triggers should be disallowed.
This commit is contained in:
@@ -409,6 +409,35 @@ lock tables mysql.proc write|
|
||||
unlock tables|
|
||||
|
||||
|
||||
#
|
||||
# Check that in functions we don't allow to update tables which
|
||||
# are used by statements which invoke these functions.
|
||||
#
|
||||
--disable_warnings
|
||||
drop function if exists f1|
|
||||
--enable_warnings
|
||||
create function f1(i int) returns int
|
||||
begin
|
||||
insert into t1 (val) values (i);
|
||||
return 0;
|
||||
end|
|
||||
--error ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG
|
||||
select val, f1(val) from t1|
|
||||
# Table alias should not matter
|
||||
--error ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG
|
||||
select val, f1(val) from t1 as tab|
|
||||
select * from t1|
|
||||
--error ER_CANT_UPDATE_USED_TABLE_IN_SF_OR_TRG
|
||||
update t1 set val= f1(val)|
|
||||
select * from t1|
|
||||
# But this should be OK
|
||||
select f1(17)|
|
||||
select * from t1|
|
||||
# Cleanup
|
||||
delete from t1 where val= 17|
|
||||
drop function f1|
|
||||
|
||||
|
||||
#
|
||||
# BUG#1965
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user