Debugging MySQL
Stored Routines

MySQL debugger built into dbForge Studio for MySQL allows debugging stored procedures quickly and easily using traditional debugging operations such as setting breakpoints, viewing variable values, examining the call stack, etc.

As stored procedures get more complex, it becomes harder to spot typos and logical errors, especially if you need to debug code written by someone else. dbForge Studio for MySQL eliminates the need for thoroughly combing out the scripts to locate mistakes and allows you to troubleshoot stored procedures code quickly and effectively.

  • full control over code execution
  • easy-to-use interface
  • faster code processing
  • performance issues prevention
-->

Debugging in dbForge Studio for MySQL

dbForge Studio for MySQL features an advanced MySQL stored procedures debugger allowing you to quickly investigate problematic code and on-the-fly find out why it fails.

The dbForge Studio debugger has all the facilities for debugging stored procedures, including support for stepping through stored procedure code, watches, breakpoints, and a call stack for tracking calls to nested procedures.

dbForge Studio for MySQL - MySQL stored procedure debugger tool

Deploying a Debug Engine

Before starting to debug a MySQL stored procedure, you need to deploy a Debug Engine to the server. Studio for MySQL will create a cr_debug database and fill it with stored routines and tables.

To deploy a Debug Engine, select the Deploy Debug Engine command from the Debug menu. You can deploy or redeploy it at any time. When you need to remove the debug engine from the server, just delete the cr_debug database.

MySQL stored procedure tutorial - Deploying Debug Engine

Compiling a MySQL stored procedure for debugging

To debug MySQL stored procedures, functions, and triggers you must first compile them with debug information. To do this, right-click the procedure, function, or trigger in Database Explorer and select Compile for Debugging.

If you haven't compiled a procedure, function, or trigger for debugging, you will be prompted to compile it right as you run the dbForge Studio debugger tool.

Note:
Compiling doesn't affect MySQL procedure logic, so you can execute MySQL stored procedure after debugging without recompiling.

MySQL debug procedure - Compiling

Breakpoints, Watches, and a Call Stack

The dbForge Studio debugger is a powerful tool that allows you to observe the run-time behavior of the stored procedure and locate logic errors. With the debugger, you can break, or suspend the execution of your program to examine your stored procedure or evaluate and edit variables in your script.

Breakpoints allow you to break running the stored procedure in any place you want. You can manipulate breakpoints from the Editor and Breakpoints window.

The Call Stack window shows a stack of the script calls.

The Watches window allows evaluating MySQL stored procedure variables and parameters.

Execute procedure in MySQL - Breakpoints

Evaluating variables values

To view server and session variables during debugging, you can refer to the Watches window. It also allows editing MySQL stored procedure variables.

Watches are bound to stack frames and let you analyze the contexts of your stored procedures. In this way, the Debugger provides all the functionality necessary for automating the process of debugging stored routine with MySQL.

Note:
The Watches window is available only in the debug mode.

Evaluate MySQL stored procedure variables - example

Conclusion

dbForge Studio for MySQL can boast advanced inbuilt debugging features. With the tool, you can debug MySQL triggers, functions, queries, and stored routines to ensure an effective database development process. This highly useful functionality is provided by default in dbForge Studio for MySQL along with many other database management tools and features.

dbForge Studio for MySQL

The most intelligent MySQL management tool

Availability in the editions of dbForge Studio for MySQL

Feature

Enterprise
Professional
Standard
Express
MySQL Debugger
Yes
Yes
Yes
None