PGDebugger
To enable interactive debugging of PL/pgSQL procedures on a Postgres server, you need to use the plugin_debugger. The plugin_debugger is a typical interactive debugger delivered as an extension. It requires a shared library preload in Postgres to operate the shared_preload_libraries parameter in the settings. The debugger is developed and maintained by EDB. Its source code is available for examination and improvement.
The debugger provides the required server API for debugging PL/SQL procedures with:
- Breakpoint management;
- Step-by-step tracing;
- Variable acquisition and management.
If you happen to have a PostgreSQL 12 installed via apt, then the procedure is quite straightforward:
sudo apt install postgresql-12-pldebugger
sudo service postgresql restart
After that, run the following command in the database or databases that you wish to debug functions in:
CREATE EXTENSION pldbgapi;
You can find the source code in this repository. Installation instructions are located in the README file.
Open the source code of the function you want to debug. To toggle breakpoints,
place the caret on the line you want the function to be stopped at and use a shortcut Shift + Control + B
.
Alternatively, you can toggle the breakpoint with your mouse by clicking on a
ruler, as demonstrated in the screenshot below:
NB. You must only toggle the breakpoints when Show header option is not on.
Then you need to set up a debugging configuration. Locate the downward-facing arrow right to the bug icon, click on it, then
Debug As -> Database Debug:
The Edit Configuration dialog opens. Set up input values in the table Function parameters.
Click on OK button, and you are ready to go!
The usual buttons essential for debugging such as Step Over and Continue are located here:
- Installation
- Application Window Overview
- Views
- Database Object Editor
- SQL Editor
- Search
- Schema compare
- Using Liquibase in DBeaver
- Data compare
- MockData generation
- Spelling
- Dashboards, DB monitoring
- Projects
- Managing Master password
- Security in PRO products
- Certificate Management
- Bookmarks
- Shortcuts
- Accessibility
- Sample Database
-
Database Connections
- Edit Connection
- Invalidate/Reconnect to Database
- Disconnect from Database
- Change current user password
- Advanced settings
- Cloud configuration settings
- Local Client Configuration
- Connection Types
- Configure Connection Initialization Settings
- Tableau integration
- Transactions
- Drivers
- Tasks
- Cloud Explorer
- Cloud Storage
- Classic
- Cloud
- Changing interface language
- DBeaver extensions - Office, Debugger, SVG
- Installing extensions - Themes, version control, etc
- User Interface Themes
- Command Line
- Reset UI settings
- Reset workspace
- Troubleshooting system issues
- Posting issues
- Log files
- JDBC trace
- Thread dump
- Managing connections
- Managing variables
- Managing drivers
- Managing preferences
- Managing restrictions
- Windows Silent Install
- Snap installation