忽略MySQL退出处理程序 [英] MySQL exit handler ignored

查看:115
本文介绍了忽略MySQL退出处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的存储过程忽略了一个退出处理程序。我执行以下行:

An exit handler is being ignored by my stored procedure. I execute the following line:

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

并收到错误:


错误代码:1452.无法添加或更新子行:外键约束失败( db 对象,CONSTRAINT 对象:模板外键 FOREIGN KEY( TemplateId )参考模板 TemplateId )ON UPDATE CASCADE)

Error Code: 1452. Cannot add or update a child row: a foreign key constraint fails (db.objects, CONSTRAINT Object: Template Foreign Key FOREIGN KEY (TemplateId) REFERENCES templates (TemplateId) ON UPDATE CASCADE)

实际上,约束确实失败,因为模板表中不存在NewTemplate。但是为什么在下面的存储过程的退出处理程序中没有收到自定义错误消息?

Indeed, a constraint does fail, because 'NewTemplate' does not exist in the template table. But why do I not receive the custom error message in the exit handler of the stored procedure 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

对于信息,我正在运行MySQL 5.6.20。

For info, I'm running MySQL 5.6.20.

推荐答案

(确认GarethD)

(Acknowledge GarethD)

这是在5.7.2版本中修复的。

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

升级到MySQL 5.7.5,现在全部正在运行。

Upgraded to MySQL 5.7.5, and all is now working.

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

这篇关于忽略MySQL退出处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆