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.

2 comments:

Anonymous said...

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.

Anonymous said...

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.

Post a Comment