How can I detect into a trigger in my slave that it has been invoked by a replicated statement in MySQL?
I've tried with USER() function, but it returns null when the trigger is activated by a replicated statement. Shouldn't it returns replication user (repl)?
Example:
CREATE TRIGGER `test`.`t1_BEFORE_INSERT` BEFORE INSERT ON `t1` FOR EACH ROW
BEGIN
IF USER() LIKE 'repl@%'
THEN
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'Custom error';
END IF;
END
I want the behaviour of the trigger to be different depending of it's activated by a replicated statement or not. I've configured statement based replication and I've tested that triggers run in my slave.