
CREATE TABLE IF NOT EXISTS bug_test(
    ID INTEGER(11),
    NAME VARCHAR(22)
);

CREATE TABLE IF NOT EXISTS bug_test_child(
    ID INTEGER(11),
    CHILD_TYPE INTEGER(11)
);

DELIMITER ;;
CREATE OR REPLACE PROCEDURE bug_proc_test()
  NOT DETERMINISTIC
  SQL SECURITY INVOKER
  MODIFIES SQL DATA
  COMMENT ''
BEGIN
  
END;;


INSERT INTO bug_test VALUES(1, 'var1');
INSERT INTO bug_test VALUES(2, 'var2');

INSERT INTO bug_test_child VALUES(1, 1);
INSERT INTO bug_test_child VALUES(1, 2);
INSERT INTO bug_test_child VALUES(2, 2);
INSERT INTO bug_test_child VALUES(2, 3);

DROP TRIGGER IF EXISTS `test_bug_test`;;
CREATE TRIGGER `test_bug_test` AFTER UPDATE ON `bug_test`
  FOR EACH ROW
BEGIN 
  IF OLD.NAME <> NEW.NAME THEN
    CALL bug_proc_test();
  END IF;
END;;

DELIMITER ;

-- Uncommend this update and the problem goes away
-- UPDATE bug_test SET NAME = 'var';

-- When this is executed first you get PROCEDURE does not exists
UPDATE bug_test 
 INNER JOIN bug_test_child USING(ID)
   SET NAME = 'var';

