Debugging Engine

This topic describes the debug mechanism that is used in dbForge Studio.

Debug Engine overview

To debug stored procedures, functions, and triggers, you must deploy the debug engine on the server. The debug engine, which is the server-side component of the debugging infrastructure, consists of stored procedures, functions, and tables stored in the cr_debug database.

If the debug engine is not deployed, you are prompted to deploy it when you compile a stored routine with debug information. You can deploy or redeploy the debug engine at any time by selecting Deploy Debug Engine in the Debug menu.

To remove the debug engine from the server, in Database Explorer, right-click the database and select Compile.

Permissions

Before deploying the debug engine, ensure that the following privileges are granted to your user:

  • PROCESS global privilege
  • Privileges on the cr_debug database (or equivalent global privileges):
    • SELECT
    • CREATE
    • DROP
    • CREATE ROUTINE

Compile stored procedures, functions, and triggers for debugging

To debug a stored procedure, function, or trigger, you must compile it with debug information. To do this, right-click the object in Database Explorer and select Compile for Debugging. This action adds additional statements required for debugging to the stored routine.

Note

These statements don’t change the object logic or behavior.

When you open an object compiled with debug information in a visual editor, dbForge Studio hides the added debug statements. To remove the debug statements, compile the object without debug information. To ensure that there is no debug information in a stored procedure, function, or trigger, execute the SHOW CREATE { PROCEDURE | FUNCTION | TRIGGER } query in a SQL document.

After you finish debugging, right-click the object and select Compile to remove the debug information because it may impact performance.

Note

If a procedure, function, or trigger is not compiled with debug information, you’re prompted to compile it when you run the debugger.

Recommended workflow

1. In Database Explorer, right-click the procedure, function, or trigger and select Compile for Debugging.

2. Start debugging.

3. If you find an issue, stop debugging.

4. In Database Explorer, select Compile.

5. Modify the object.

6. Recompile the object with debugging information. To do this, in Database Explorer, right-click the object and select Compile for Debugging.

7. Debug the procedure again to verify that the issue is fixed.

8. When you’re done, select Compile to remove debug information.

Warning

Keeping objects compiled with debug information in a production environment can affect performance. Always recompile objects without debug information before deployment.