pldbgapi

server-side support for debugging PL/pgSQL functions

Overview

PackageVersionCategoryLicenseLanguage
pldebugger1.9LANGArtisticC
IDExtensionBinLibLoadCreateTrustRelocSchema
3050pldbgapiNoYesNoYesNoYes-
Relatedplpgsql_check plprofiler plpgsql pgtap pg_stat_statements plv8 plperl plpython3u

Version

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

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

Create Extension:

CREATE EXTENSION pldbgapi;

Usage

pldbgapi: server-side support for debugging PL/pgSQL functions

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.


Last Modified 2026-03-12: add pg extension catalog (95749bf)