0

I need to create a stored function which disables triggers on demand. At first I have a parameter @disable_triggers which can I set to "all" or to specific trigger name. In the trigger I would have a variable which I assign to procedures return value and if it's true I don't execute trigger code. So in procedure I need to somehow handle the case with specific trigger name.

CREATE PROCEDURE `DisableTriggers`()
BEGIN
IF(@disable_triggers = 'all') THEN
    RETURN 1;
END IF;
IF (@disable_triggers CONTAINS 'Specific trigger name') THEN 
Return true to disable specific trigger. <<-- how to return it here.
END IF;
END

So the question I ask is how to handle the case with specific triggers what to return.

Donatas
  • 71
  • 1
  • 9

1 Answers1

0

In general there is no way to disable triggers in MySQL/MariaDB. You can only delete triggers and re-create them later but be aware of MDL locks if you have high loaded environment.

Still you have an option to do some tricks with session variables like MySQL disable all triggers

Community
  • 1
  • 1
ravnur
  • 2,772
  • 19
  • 28