Triggers not executed following foreign key updates/deletes
Description
Environment
Smart Checklist
Activity
Julia Vural March 4, 2025 at 9:01 PM
It appears that this issue is no longer being worked on, so we are closing it for housekeeping purposes. If you believe the issue still exists, please open a new ticket after confirming it's present in the latest release.
Seweryn Ożóg July 18, 2019 at 9:40 PM
https://old.reddit.com/r/PHP/comments/cdgxxu/anyone_made_the_jump_from_mysql_to_postresql_it/?st=jy96zuuz&sh=7272fedc ... If You fix it You should show it on next Percona Live Europe Amsterdam 2019 ... see you
George Lorch July 18, 2019 at 9:35 PM
This can not be properly fixed until foreign key implementation is moved out of the InnoDB layer and up into the server/SQL layer. This is not a simple task and is likely why it has never been dealt with. Oracle has made some movement in this direction in the 8.0 series by moving the constraint parsing and metadata up into the server layer and new Data Dictionary. This is not something that we have on our roadmap to take on ourselves.
Details
Details
Assignee
Reporter
Affects versions
Priority
Smart Checklist
Open Smart Checklist
Smart Checklist

This bug https://bugs.mysql.com/bug.php?id=11472 reported by Omer Barnir in 2005 affects Percona Server as well today! (and vanilla Oracle MySQL as well !!!).
Quotation from his description and test case:
USE test;
DROP TABLE IF EXISTS t1,t2;
CREATE TABLE t1 (id INT NOT NULL, col1 char(50), PRIMARY KEY (id)) ENGINE=INNODB;
CREATE TABLE t2 (id INT PRIMARY KEY, f_id INT, INDEX par_ind (f_id), col1 char(50),
FOREIGN KEY (f_id) REFERENCES t1(id) ON DELETE SET NULL) ENGINE=INNODB;
create trigger tr_t2 after update on t2
for each row set @counter=@counter+1;
insert into t1 values (1,'Department A');
insert into t1 values (2,'Department B');
insert into t1 values (3,'Department C');
insert into t2 values (1,2,'Emp 1');
insert into t2 values (2,2,'Emp 2');
insert into t2 values (3,2,'Emp 3');
insert into t2 values (4,2,'Emp 4');
insert into t2 values (5,2,'Emp 5');
set @counter=0;
select * from t1;
select * from t2;
select @counter;
delete from t1 where id=2;
select * from t1;
select * from t2;
select @counter;
update t2 set col1='Emp 5a' where id=5;
select * from t2;
select @counter;
drop table t2,t1;
Note At this point 5 rows were updated in table t2, the value of
@count is expected to be '5' (each activation of the trigger
increases it by 1, and yet the value remained zero, indicating the
trigger was not executed.
The following shows that the trigger it self is executed when
table 't2' is updated directly: