How do you debug MySQL stored procedures?

后端 未结 16 1275
旧时难觅i
旧时难觅i 2020-11-30 17:44

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. Thi

16条回答
  •  生来不讨喜
    2020-11-30 17:50

    I'm late to the party, but brought more beer:

    http://ocelot.ca/blog/blog/2015/03/02/the-ocelotgui-debugger/ and https://github.com/ocelot-inc/ocelotgui

    I tried, and it seems pretty stable, supporting Breakpoints and Variable inspection.

    It's not a complete suite (just 4,1 Mb) but helped me a lot!

    How it works: It integrates with your mysql client (I'm using Ubuntu 14.04), and after you execute:

    $install
    $setup yourFunctionName
    

    It installs a new database at your server, that control the debugging process. So:

    $debug yourFunctionName('yourParameter')
    

    will give you a chance to step by step walk your code, and "refreshing" your variables you can better view what is going on inside your code.

    Important Tip: while debugging, maybe you will change (re-create the procedure). After a re-creation, execute: $exit and $setup before a new $debug

    This is an alternative to "insert" and "log" methods. Your code remains free of additional "debug" instructions.

    Screenshot:

提交回复
热议问题