MySQL exit handler ignored

The output handler is being ignored by my stored procedure. I am executing the following line:

CALL updateTemplate('MyObject', 'NewTemplate');

      

And get the error:

Error code: 1452. Unable to add or update child row: foreign key failed ( db

. objects

, CONSTRAINT Object: Template Foreign Key

FOREIGN KEY ( TemplateId

) REFERENCES templates

( TemplateId

) ON CASCADE UPDATE)

Indeed, the restriction does not work because "NewTemplate" does not exist in the template table. But why am I not getting a custom error message in the stored procedure exit handler below?

CREATE DEFINER=`root`@`localhost` PROCEDURE `updateTemplate`(in inObjectId varchar(45), in inTemplateId varchar(45))
BEGIN

    declare exit handler for 1452
    begin
        signal sqlstate '45000' set MESSAGE_TEXT = 'The template identifier is invalid.';
    end;

    UPDATE objects SET TemplateId=inTemplateId WHERE ObjectId=inObjectId;

END

      

For information, I am running MySQL 5.6.20.

+3


source to share


1 answer


(Confirmed by GarethD)

This is due to a bug that was fixed in version 5.7.2.



Updated to MySQL 5.7.5 and everything works now.

http://bugs.mysql.com/bug.php?id=68831

+1


source







All Articles