Tuesday, February 27, 2007

Debugging mysql stored procedures

The other day I needed to figure out why the heck my mysql stored procedure wasn't working. I poked around for a way to do the most fundamental debugging possible: print out a log message.

Postgres accomplishes this by using the RAISE keyword, but mysql didn't seem to have a comparable function.

After a bit of Googling around I came across this article where the author recommends a technique for doing just this kind of debugging.

The technique is embarrassingly simple, and I wish I had thought of it: simply create a debug_log table that contains a text field in it. Then write a debug function that inserts into that table.

Duh. Now, why didn't I think of that?

It's a simple and brilliant way to get around the fact that mysql doesn't seem to provide any other debugging facilities.

Get all the details here.

4 comments:

  1. Anonymous9:47 AM

    May be it can help
    http://www.eclipseplugincentral.com/Web_Links-index-req-viewlink-cid-898.html. Illatis StepIn is Eclipse based debugger for stored procedures in MySQL.

    ReplyDelete
  2. Anonymous7:16 AM

    Core Lab MySql Developer Studio 2.0 http://crlab.com/mysqldev/ has an integrated debugger for mysql stored procedures, with stepping facilities, breakpoints and watches.

    ReplyDelete
  3. Anonymous4:35 AM

    I recommend great tool for this - mysql debugger - http://www.mydebugger.com.

    ReplyDelete
  4. Anonymous7:09 AM

    Debugging MySQL Stored Routines is available in dbForge Studio for MySQL, v4.50 as well as debug mysql triggers:

    http://www.devart.com/dbforge/mysql/studio/

    http://www.devart.com/dbforge/mysql/studio/demostutorials/debugging.html

    ReplyDelete