如何调试MySQL存储过程? [英] How do you debug MySQL stored procedures?
问题描述
我当前调试存储过程的过程非常简单。我创建一个名为debug的表,其中在运行时从存储过程插入变量值。这允许我在脚本中的给定点看到任何变量的值,但是有更好的方法来调试MySQL存储过程吗?
My current process for debugging stored procedures is very simple. I create a table called "debug" where I insert variable values from the stored procedure as it runs. This allows me to see the value of any variable at a given point in the script, but is there a better way to debug MySQL stored procedures?
推荐答案
我做的事情和你很相似。
I do something very similar to you.
我通常会包含一个默认为false的DEBUG参数,我可以在运行时设置为true。然后将调试语句包装到If DEBUG块中。
I'll usually include a DEBUG param that defaults to false and I can set to true at run time. Then wrap the debug statements into an "If DEBUG" block.
我还使用一个记录表与我的许多工作,以便我可以审查过程和时间。我的调试代码也得到输出。我包括调用的参数名称,简要描述,受影响的行计数(如果适用),注释字段和时间戳。
I also use a logging table with many of my jobs so that I can review processes and timing. My Debug code gets output there as well. I include the calling param name, a brief description, row counts affected (if appropriate), a comments field and a time stamp.
好的调试工具是悲伤所有SQL平台的失败。
Good debugging tools is one of the sad failings of all SQL platforms.
这篇关于如何调试MySQL存储过程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!