Skip to content

[Feature Request]: Integrate PL/pgSQL Debugger (pldebugger) with GUI similar to pgAdmin/DBeaver #243

@LSIND

Description

@LSIND

Feature Description

Currently, the vscode-pgsql extension is excellent for query execution, schema browsing, and visualization. However, when it comes to debugging stored procedures and functions written in PL/pgSQL, developers have to switch to external tools like pgAdmin or DBeaver.
The current workflow for debugging in VS Code is non-existent. Debugging server-side logic requires a separate, heavy IDE, which breaks the development flow. Developers want to set breakpoints, step into functions, and inspect variables directly inside VS Code without leaving the editor.

Proposed Capabilities

I propose the integration of the pldebugger extension into the vscode-pgsql workflow, accompanied by a native graphical interface.
The implementation should automate or simplify the following setup steps that are currently manual.

  1. OS-Level Package Installation: First, the pldebugger shared library must be installed on the PostgreSQL server machine. The installation method varies significantly by operating system:
  • Ubuntu/Debian: sudo apt install postgresql-<version>-pldebugger (e.g., postgresql-16-pldebugger)
  • RHEL/Rocky/AlmaLinux: sudo dnf install pldebugger_<version> (e.g., pldebugger_16)
  • Windows: the debugger library (plugin_debugger.dll) is bundled with the EnterpriseDB (EDB) PostgreSQL distribution, typically located in: C:\Program Files\PostgreSQL\<version>\lib\plugin_debugger.dll. If using the EDB installer, no additional OS-level installation is required - the library is present by default.
  1. PostgreSQL Server Configuration (shared_preload_libraries):
    The debugger library must be loaded at server startup. It cannot be added dynamically.
    Required setting in postgresql.conf.
  • Check current setting by executing SHOW shared_preload_libraries;
  • Detect the operating system and suggest the correct library path
  • If plugin_debugger is not present:
    • Show a warning notification with platform-specific instructions
    • Provide the correct postgresql.conf location for the detected OS
    • Include the exact line to add to the configuration file
    • Guide the user to restart PostgreSQL after configuration changes
    • Provide a "Check Again" button after the user confirms the restart
  • Server restart detection: Implement a way to detect if the server has been restarted after config changes (e.g., compare pg_postmaster_start_time before and after)
  1. Database Extension Creation
    After the server restart, the debugger API must be enabled in the target database: CREATE EXTENSION pldbgapi;
    Extension Behavior:
  • Check if the extension already exists: SELECT * FROM pg_extension WHERE extname = 'pldbgapi';
  • If missing, display a prompt: "Debugger API is not installed in this database. Install now?"
  • Provide an "Install" button that executes CREATE EXTENSION pldbgapi; in the current connection.
  • Show a confirmation upon successful installation.

4. GUI Debugger Interface
Once all prerequisites are satisfied, provide a visual debugger within VS Code:

  • Breakpoints: Set/remove breakpoints in .sql or .pgsql files, or directly in the function body editor.
  • Debug Controls: Step Over, Step Into, Step Out, Continue, Stop.
  • Variables Panel: Inspect local variables, parameters, and their values during execution.
  • Call Stack: Show the current execution stack with navigation.
  • Parameter Input: When debugging a function, prompt the user to enter parameter values (types, defaults, etc.).
  • Output Panel: Display debug output, errors, and execution logs.
  • Watch Expressions: Allow users to add custom expressions to monitor

The debugging experience should match the native VS Code Debugger UI (similar to Python, Node.js, or C# extensions), with a dedicated debug view and seamless integration.

Alternatives

  • pgAdmin: While it has a functional debugger, it requires running a separate desktop application and a browser. It lacks the tight integration with the code editor that VS Code provides.
  • DBeaver: Similar to pgAdmin, it is an external tool. It also relies on the same underlying pldebugger extension but offers a less modern UI compared to VS Code's native debugging experience.

Conclusion

Adding PL/pgSQL debugging with a complete cross-platform setup assistant and graphical interface would significantly enhance vscode-pgsql, making it the ultimate PostgreSQL development tool within VS Code. The three-layer setup (OS package → server config → database extension) is non-trivial, but with proper automation and platform-specific guidance, it becomes accessible to all developers, regardless of their operating system or deployment environment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions