mirror of
https://github.com/MariaDB/server.git
synced 2025-12-24 11:21:21 +03:00
Save and clear run context before executing a stored function or trigger and restore it afterwards.
This allows us to use statement replication with functions and triggers The following things are fixed with this patch: - NOW() and automatic timestamps takes the value from the main event for functions and triggers (which allows these to replicate with statement level logging) - No side effects for triggers or functions with auto-increment values(), last_insert_id(), rand() or found_rows() - Triggers can't return result sets Fixes bugs: #12480: NOW() is not constant in a trigger #12481: Using NOW() in a stored function breaks statement based replication #12482: Triggers has side effects with auto_increment values #11587: trigger causes lost connection error
This commit is contained in:
@@ -665,6 +665,7 @@ drop table t1;
|
||||
|
||||
# Test for bug #11973 "SELECT .. INTO var_name; in trigger cause
|
||||
# crash on update"
|
||||
|
||||
create table t1 (id int, data int, username varchar(16));
|
||||
insert into t1 (id, data) values (1, 0);
|
||||
delimiter |;
|
||||
@@ -684,4 +685,47 @@ connection addconroot;
|
||||
update t1 set data = 2;
|
||||
|
||||
connection default;
|
||||
disconnect addconroot;
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# #11587 Trigger causes lost connection error
|
||||
#
|
||||
|
||||
create table t1 (c1 int, c2 datetime);
|
||||
delimiter |;
|
||||
--error ER_SP_NO_RETSET
|
||||
create trigger tr1 before insert on t1 for each row
|
||||
begin
|
||||
set new.c2= '2004-04-01';
|
||||
select 'hello';
|
||||
end|
|
||||
delimiter ;|
|
||||
|
||||
insert into t1 (c1) values (1),(2),(3);
|
||||
select * from t1;
|
||||
|
||||
--disable_warnings
|
||||
drop procedure if exists bug11587;
|
||||
--enable_warnings
|
||||
|
||||
delimiter |;
|
||||
create procedure bug11587(x char(16))
|
||||
begin
|
||||
select "hello";
|
||||
select "hello again";
|
||||
end|
|
||||
|
||||
create trigger tr1 before insert on t1 for each row
|
||||
begin
|
||||
call bug11587();
|
||||
set new.c2= '2004-04-02';
|
||||
end|
|
||||
delimiter ;|
|
||||
|
||||
--error 726
|
||||
insert into t1 (c1) values (4),(5),(6);
|
||||
select * from t1;
|
||||
|
||||
drop procedure bug11587;
|
||||
drop table t1;
|
||||
|
||||
Reference in New Issue
Block a user