pldbgapi

server-side support for debugging PL/pgSQL functions

Overview

PackageVersionCategoryLicenseLanguage
pldebugger1.10LANGArtisticC
IDExtensionBinLibLoadCreateTrustRelocSchema
3050pldbgapiNoYesYesYesNoYes-
Relatedplpgsql_check plprofiler plpgsql pgtap pg_stat_statements plv8 plperl plpython3u

Version

TypeRepoVersionPG VerPackageDeps
EXTPGDG1.101817161514pldebugger-
RPMPGDG1.91817161514pldebugger_$v-
DEBPGDG1.101817161514postgresql-$v-pldebugger-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64
el8.aarch64
el9.x86_64
el9.aarch64
el10.x86_64
el10.aarch64
d12.x86_64
d12.aarch64
d13.x86_64
d13.aarch64
u22.x86_64
u22.aarch64
u24.x86_64
u24.aarch64
u26.x86_64
u26.aarch64

Install

You can install pldebugger directly. First, make sure the PGDG repository is added and enabled:

pig repo add pgdg -u          # Add PGDG repo and update cache

Install the extension using pig or apt/yum/dnf:

pig install pldebugger;          # Install for current active PG version
pig ext install -y pldebugger -v 18  # PG 18
pig ext install -y pldebugger -v 17  # PG 17
pig ext install -y pldebugger -v 16  # PG 16
pig ext install -y pldebugger -v 15  # PG 15
pig ext install -y pldebugger -v 14  # PG 14
dnf install -y pldebugger_18       # PG 18
dnf install -y pldebugger_17       # PG 17
dnf install -y pldebugger_16       # PG 16
dnf install -y pldebugger_15       # PG 15
dnf install -y pldebugger_14       # PG 14
apt install -y postgresql-18-pldebugger   # PG 18
apt install -y postgresql-17-pldebugger   # PG 17
apt install -y postgresql-16-pldebugger   # PG 16
apt install -y postgresql-15-pldebugger   # PG 15
apt install -y postgresql-14-pldebugger   # PG 14

Preload:

shared_preload_libraries = 'pldbgapi';

Create Extension:

CREATE EXTENSION pldbgapi;

Usage

Sources: repo README, v1.10 release, extension control

pldbgapi provides a server-side API for interactive debugging of PL/pgSQL functions. It is typically used through a GUI client such as pgAdmin.

CREATE EXTENSION pldbgapi;

Debugging with pgAdmin

The primary way to use the debugger is through pgAdmin’s graphical interface:

  • Direct Debugging: Right-click a function and select “Debug” to execute and step through it immediately
  • Global Breakpoints: Select “Set Global Breakpoint” on a function, then wait for another session (e.g., a web application) to call that function – the debugger will intercept the call and allow in-context debugging

Debugging Capabilities

When connected through a debug client, you can:

  • Set breakpoints on specific lines in PL/pgSQL functions
  • Step through code line by line (step into, step over, step out)
  • Inspect variables and their current values at each step
  • View the call stack for nested function calls
  • Continue execution to the next breakpoint

Architecture

The debugging system has three components:

  1. Client GUI (pgAdmin) – displays source code, variables, and stack
  2. Target Backend – the session executing the PL/pgSQL code being debugged
  3. Debugging Proxy – coordinates between the client and target via a dedicated connection

Supported Languages

The debugger works with PL/pgSQL functions and procedures. It requires the pldbgapi extension to be created in each database where debugging is needed.

Caveats

  • The package name is pldebugger, while the extension created in SQL is pldbgapi; the catalog tracks package version 1.10 for PostgreSQL 14 through 18.
  • The v1.10 upstream release is a PostgreSQL compatibility update and does not document a new user-facing SQL API or debugging workflow.
  • Upstream troubleshooting says shared_preload_libraries = '$libdir/plugin_debugger' must be configured and PostgreSQL restarted. Missing or incorrect preload prevents global breakpoints and can also prevent pldbgapi SQL from loading on some platforms.

Last Modified 2026-05-18: routine extension update (cfff783)