I have scoured the web for the past 4 hours in search of a solution but all i can find is:
You cant. Impossible. Not gonna happen.
I dont like that approach.
We have investigated the issue and found that "DECLARE" doesn't work in the sample above, also the general_log flag should be enabled on the server. Finally we have the following trigger code:
DELIMITER $$
DROP TRIGGER IF EXISTS `our_trigger`$$
CREATE TRIGGER `our_trigger`
BEFORE UPDATE ON `our_table_for_debug`
FOR EACH ROW BEGIN
SELECT argument INTO @tquery FROM mysql.general_log where thread_id = connection_id() and argument like 'update%' order by event_time desc limit 1;
INSERT INTO `our_log_table` (`query`) VALUES (@tquery);
END IF;
END$$
DELIMITER ;
"our_log_table" is table with single mediumtext field named query
.
to enable general log you should run this query: general_log = 1; or enable it
in mysql settings directly.