MySQL and MariaDB only update rows where values are changed. Here is an example in db<>fiddle.
I suspect this is the issue that you are seeing.
If you do:
update t
set value_a = 123
where id = ?;
Then (presumably) both value_a
and value_result
change. The row is updated.
If you do:
update t
set value_result = 123
where id = ?;
Then the trigger resets value_result
to the old value and no rows are changed.
Note: It sounds like you would be better off with a computed column rather than setting a value in a trigger:
alter table t add value_result int as (value_a + value_b);
The database should not even let you try to assign a value to a computed column -- and the value is always correct.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…